forked from openshift-service-mesh/sail-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* upstream/main: Add `RemoteIstio` to API concepts in docs (istio-ecosystem#272) Ensure `make gen-check` works when go mod cache is empty (istio-ecosystem#270) Introduce RemoteIstio (istio-ecosystem#202) api_transformer: use `go env` to detect mod cache dir (istio-ecosystem#269) Add field values.experimental to API (istio-ecosystem#264) Fix errors in tables for api reference documentation (istio-ecosystem#263) Generate CNIGlobalConfig from GlobalConfig automatically (istio-ecosystem#260) Fix errors in api reference doc (istio-ecosystem#262) Rename `addTags` to `addComments` in API transformer (istio-ecosystem#259) Add relatedImages to ClusterServiceVersion (istio-ecosystem#243) Generate API from versions defined in go.mod (istio-ecosystem#258) Fix issues identified during API review (istio-ecosystem#254) # Conflicts: # bundle/manifests/sailoperator.clusterserviceversion.yaml
- Loading branch information
Showing
99 changed files
with
40,019 additions
and
2,665 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
// Copyright Istio Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"time" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const RemoteIstioKind = "RemoteIstio" | ||
|
||
// RemoteIstioSpec defines the desired state of RemoteIstio | ||
// +kubebuilder:validation:XValidation:rule="!has(self.values) || !has(self.values.global) || !has(self.values.global.istioNamespace) || self.values.global.istioNamespace == self.__namespace__",message="spec.values.global.istioNamespace must match spec.namespace" | ||
type RemoteIstioSpec struct { | ||
// +sail:version | ||
// Defines the version of Istio to install. | ||
// Must be one of: v1.22.3, v1.22.2, v1.22.1, v1.22.0, v1.21.5, v1.21.4, v1.21.3, v1.21.2, v1.21.0, latest. | ||
// +operator-sdk:csv:customresourcedefinitions:type=spec,order=1,displayName="Istio Version",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:fieldGroup:General", "urn:alm:descriptor:com.tectonic.ui:select:v1.22.3", "urn:alm:descriptor:com.tectonic.ui:select:v1.22.2", "urn:alm:descriptor:com.tectonic.ui:select:v1.22.1", "urn:alm:descriptor:com.tectonic.ui:select:v1.22.0", "urn:alm:descriptor:com.tectonic.ui:select:v1.21.5", "urn:alm:descriptor:com.tectonic.ui:select:v1.21.4", "urn:alm:descriptor:com.tectonic.ui:select:v1.21.3", "urn:alm:descriptor:com.tectonic.ui:select:v1.21.2", "urn:alm:descriptor:com.tectonic.ui:select:v1.21.0", "urn:alm:descriptor:com.tectonic.ui:select:latest"} | ||
// +kubebuilder:validation:Enum=v1.22.3;v1.22.2;v1.22.1;v1.22.0;v1.21.5;v1.21.4;v1.21.3;v1.21.2;v1.21.0;latest | ||
// +kubebuilder:default=v1.22.3 | ||
Version string `json:"version"` | ||
|
||
// Defines the update strategy to use when the version in the RemoteIstio CR is updated. | ||
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Update Strategy" | ||
// +kubebuilder:default={type: "InPlace"} | ||
UpdateStrategy *IstioUpdateStrategy `json:"updateStrategy,omitempty"` | ||
|
||
// +sail:profile | ||
// The built-in installation configuration profile to use. | ||
// The 'default' profile is always applied. On OpenShift, the 'openshift' profile is also applied on top of 'default'. | ||
// Must be one of: ambient, default, demo, empty, external, minimal, openshift-ambient, openshift, preview, remote, stable. | ||
// +++PROFILES-DROPDOWN-HIDDEN-UNTIL-WE-FULLY-IMPLEMENT-THEM+++operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Profile",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:fieldGroup:General", "urn:alm:descriptor:com.tectonic.ui:select:ambient", "urn:alm:descriptor:com.tectonic.ui:select:default", "urn:alm:descriptor:com.tectonic.ui:select:demo", "urn:alm:descriptor:com.tectonic.ui:select:empty", "urn:alm:descriptor:com.tectonic.ui:select:external", "urn:alm:descriptor:com.tectonic.ui:select:minimal", "urn:alm:descriptor:com.tectonic.ui:select:preview", "urn:alm:descriptor:com.tectonic.ui:select:remote"} | ||
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"} | ||
// +kubebuilder:validation:Enum=ambient;default;demo;empty;external;minimal;openshift-ambient;openshift;preview;remote;stable | ||
Profile string `json:"profile,omitempty"` | ||
|
||
// Namespace to which the Istio components should be installed. | ||
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:io.kubernetes:Namespace"} | ||
// +kubebuilder:default=istio-system | ||
Namespace string `json:"namespace"` | ||
|
||
// Defines the values to be passed to the Helm charts when installing Istio. | ||
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Helm Values" | ||
Values *Values `json:"values,omitempty"` | ||
} | ||
|
||
// RemoteIstioStatus defines the observed state of RemoteIstio | ||
type RemoteIstioStatus struct { | ||
// ObservedGeneration is the most recent generation observed for this | ||
// RemoteIstio object. It corresponds to the object's generation, which is | ||
// updated on mutation by the API Server. The information in the status | ||
// pertains to this particular generation of the object. | ||
ObservedGeneration int64 `json:"observedGeneration,omitempty"` | ||
|
||
// Represents the latest available observations of the object's current state. | ||
Conditions []RemoteIstioCondition `json:"conditions,omitempty"` | ||
|
||
// Reports the current state of the object. | ||
State RemoteIstioConditionReason `json:"state,omitempty"` | ||
|
||
// Reports information about the underlying IstioRevisions. | ||
Revisions RevisionSummary `json:"revisions,omitempty"` | ||
} | ||
|
||
// GetCondition returns the condition of the specified type | ||
func (s *RemoteIstioStatus) GetCondition(conditionType RemoteIstioConditionType) RemoteIstioCondition { | ||
if s != nil { | ||
for i := range s.Conditions { | ||
if s.Conditions[i].Type == conditionType { | ||
return s.Conditions[i] | ||
} | ||
} | ||
} | ||
return RemoteIstioCondition{Type: conditionType, Status: metav1.ConditionUnknown} | ||
} | ||
|
||
// SetCondition sets a specific condition in the list of conditions | ||
func (s *RemoteIstioStatus) SetCondition(condition RemoteIstioCondition) { | ||
var now time.Time | ||
if testTime == nil { | ||
now = time.Now() | ||
} else { | ||
now = *testTime | ||
} | ||
|
||
// The lastTransitionTime only gets serialized out to the second. This can | ||
// break update skipping, as the time in the resource returned from the client | ||
// may not match the time in our cached status during a reconcile. We truncate | ||
// here to save any problems down the line. | ||
lastTransitionTime := metav1.NewTime(now.Truncate(time.Second)) | ||
|
||
for i, prevCondition := range s.Conditions { | ||
if prevCondition.Type == condition.Type { | ||
if prevCondition.Status != condition.Status { | ||
condition.LastTransitionTime = lastTransitionTime | ||
} else { | ||
condition.LastTransitionTime = prevCondition.LastTransitionTime | ||
} | ||
s.Conditions[i] = condition | ||
return | ||
} | ||
} | ||
|
||
// If the condition does not exist, initialize the lastTransitionTime | ||
condition.LastTransitionTime = lastTransitionTime | ||
s.Conditions = append(s.Conditions, condition) | ||
} | ||
|
||
// RemoteIstioCondition represents a specific observation of the RemoteIstioCondition object's state. | ||
type RemoteIstioCondition struct { | ||
// The type of this condition. | ||
Type RemoteIstioConditionType `json:"type,omitempty"` | ||
|
||
// The status of this condition. Can be True, False or Unknown. | ||
Status metav1.ConditionStatus `json:"status,omitempty"` | ||
|
||
// Unique, single-word, CamelCase reason for the condition's last transition. | ||
Reason RemoteIstioConditionReason `json:"reason,omitempty"` | ||
|
||
// Human-readable message indicating details about the last transition. | ||
Message string `json:"message,omitempty"` | ||
|
||
// Last time the condition transitioned from one status to another. | ||
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` | ||
} | ||
|
||
// RemoteIstioConditionType represents the type of the condition. Condition stages are: | ||
// Installed, Reconciled, Ready | ||
type RemoteIstioConditionType string | ||
|
||
// RemoteIstioConditionReason represents a short message indicating how the condition came | ||
// to be in its present state. | ||
type RemoteIstioConditionReason string | ||
|
||
const ( | ||
// RemoteIstioConditionReconciled signifies whether the controller has | ||
// successfully reconciled the resources defined through the CR. | ||
RemoteIstioConditionReconciled RemoteIstioConditionType = "Reconciled" | ||
|
||
// RemoteIstioReasonReconcileError indicates that the reconciliation of the resource has failed, but will be retried. | ||
RemoteIstioReasonReconcileError RemoteIstioConditionReason = "ReconcileError" | ||
) | ||
|
||
const ( | ||
// RemoteIstioConditionReady signifies whether any Deployment, StatefulSet, | ||
// etc. resources are Ready. | ||
RemoteIstioConditionReady RemoteIstioConditionType = "Ready" | ||
|
||
// RemoteIstioReasonRevisionNotFound indicates that the active IstioRevision is not found. | ||
RemoteIstioReasonRevisionNotFound RemoteIstioConditionReason = "ActiveRevisionNotFound" | ||
|
||
// RemoteIstioReasonFailedToGetActiveRevision indicates that a failure occurred when getting the active IstioRevision | ||
RemoteIstioReasonFailedToGetActiveRevision RemoteIstioConditionReason = "FailedToGetActiveRevision" | ||
|
||
// RemoteIstioReasonIstiodNotReady indicates that the control plane is fully reconciled, but istiod is not ready. | ||
RemoteIstioReasonIstiodNotReady RemoteIstioConditionReason = "IstiodNotReady" | ||
|
||
// RemoteIstioReasonReadinessCheckFailed indicates that readiness could not be ascertained. | ||
RemoteIstioReasonReadinessCheckFailed RemoteIstioConditionReason = "ReadinessCheckFailed" | ||
) | ||
|
||
const ( | ||
// RemoteIstioReasonHealthy indicates that the control plane is fully reconciled and that all components are ready. | ||
RemoteIstioReasonHealthy RemoteIstioConditionReason = "Healthy" | ||
) | ||
|
||
// +kubebuilder:object:root=true | ||
// +kubebuilder:resource:scope=Cluster,categories=istio-io | ||
// +kubebuilder:subresource:status | ||
// +kubebuilder:printcolumn:name="Revisions",type="string",JSONPath=".status.revisions.total",description="Total number of IstioRevision objects currently associated with this object." | ||
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.revisions.ready",description="Number of revisions that are ready." | ||
// +kubebuilder:printcolumn:name="In use",type="string",JSONPath=".status.revisions.inUse",description="Number of revisions that are currently being used by workloads." | ||
// +kubebuilder:printcolumn:name="Active Revision",type="string",JSONPath=".status.state",description="The current state of the active revision." | ||
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version",description="The version of the control plane installation." | ||
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="The age of the object" | ||
|
||
// RemoteIstio represents a remote Istio Service Mesh deployment consisting of one or more | ||
// remote control plane instances (represented by one or more IstioRevision objects). | ||
type RemoteIstio struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ObjectMeta `json:"metadata,omitempty"` | ||
|
||
// +kubebuilder:default={version: "v1.22.3", namespace: "istio-system", updateStrategy: {type:"InPlace"}} | ||
Spec RemoteIstioSpec `json:"spec,omitempty"` | ||
|
||
Status RemoteIstioStatus `json:"status,omitempty"` | ||
} | ||
|
||
// +kubebuilder:object:root=true | ||
|
||
// RemoteIstioList contains a list of RemoteIstio | ||
type RemoteIstioList struct { | ||
metav1.TypeMeta `json:",inline"` | ||
metav1.ListMeta `json:"metadata,omitempty"` | ||
Items []RemoteIstio `json:"items"` | ||
} | ||
|
||
func init() { | ||
SchemeBuilder.Register(&RemoteIstio{}, &RemoteIstioList{}) | ||
} |
Oops, something went wrong.