Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ resources:
domain: sailoperator.io
kind: ZTunnel
path: github.com/istio-ecosystem/sail-operator/api/v1alpha1
version: v1alpha1
version: v1
version: "3"
195 changes: 195 additions & 0 deletions api/v1/ztunnel_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
// 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 v1

import (
"time"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const (
ZTunnelKind = "ZTunnel"
)

// ZTunnelSpec defines the desired state of ZTunnel
type ZTunnelSpec struct {
// +sail:version
// Defines the version of Istio to install.
// Must be one of: v1.27-latest, v1.27.3, v1.27.2, v1.27.1, v1.27.0, v1.26-latest, v1.26.6, v1.26.5, v1.26.4, v1.26.3, v1.26.2, v1.26.1, v1.26.0, v1.25-latest, v1.25.5, v1.25.4, v1.25.3, v1.25.2, v1.25.1, v1.24-latest, v1.24.6, v1.24.5, v1.24.4, v1.24.3, v1.24.2, v1.24.1, v1.24.0.
// +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.27-latest", "urn:alm:descriptor:com.tectonic.ui:select:v1.27.3", "urn:alm:descriptor:com.tectonic.ui:select:v1.27.2", "urn:alm:descriptor:com.tectonic.ui:select:v1.27.1", "urn:alm:descriptor:com.tectonic.ui:select:v1.27.0", "urn:alm:descriptor:com.tectonic.ui:select:v1.26-latest", "urn:alm:descriptor:com.tectonic.ui:select:v1.26.6", "urn:alm:descriptor:com.tectonic.ui:select:v1.26.5", "urn:alm:descriptor:com.tectonic.ui:select:v1.26.4", "urn:alm:descriptor:com.tectonic.ui:select:v1.26.3", "urn:alm:descriptor:com.tectonic.ui:select:v1.26.2", "urn:alm:descriptor:com.tectonic.ui:select:v1.26.1", "urn:alm:descriptor:com.tectonic.ui:select:v1.26.0", "urn:alm:descriptor:com.tectonic.ui:select:v1.25-latest", "urn:alm:descriptor:com.tectonic.ui:select:v1.25.5", "urn:alm:descriptor:com.tectonic.ui:select:v1.25.4", "urn:alm:descriptor:com.tectonic.ui:select:v1.25.3", "urn:alm:descriptor:com.tectonic.ui:select:v1.25.2", "urn:alm:descriptor:com.tectonic.ui:select:v1.25.1", "urn:alm:descriptor:com.tectonic.ui:select:v1.24-latest", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.6", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.5", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.4", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.3", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.2", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.1", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.0"}
// +kubebuilder:validation:Enum=v1.27-latest;v1.27.3;v1.27.2;v1.27.1;v1.27.0;v1.26-latest;v1.26.6;v1.26.5;v1.26.4;v1.26.3;v1.26.2;v1.26.1;v1.26.0;v1.25-latest;v1.25.5;v1.25.4;v1.25.3;v1.25.2;v1.25.1;v1.24-latest;v1.24.6;v1.24.5;v1.24.4;v1.24.3;v1.24.2;v1.24.1;v1.24.0
// +kubebuilder:default=v1.27.3
Version string `json:"version"`

// Namespace to which the Istio ztunnel component should be installed.
// +operator-sdk:csv:customresourcedefinitions:type=spec,xDescriptors={"urn:alm:descriptor:io.kubernetes:Namespace"}
// +kubebuilder:default=ztunnel
Namespace string `json:"namespace"`

// Defines the values to be passed to the Helm charts when installing Istio ztunnel.
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Helm Values"
Values *ZTunnelValues `json:"values,omitempty"`
}

// ZTunnelStatus defines the observed state of ZTunnel
type ZTunnelStatus struct {
// ObservedGeneration is the most recent generation observed for this
// ZTunnel 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 []ZTunnelCondition `json:"conditions,omitempty"`

// Reports the current state of the object.
State ZTunnelConditionReason `json:"state,omitempty"`
}

// GetCondition returns the condition of the specified type
func (s *ZTunnelStatus) GetCondition(conditionType ZTunnelConditionType) ZTunnelCondition {
if s != nil {
for i := range s.Conditions {
if s.Conditions[i].Type == conditionType {
return s.Conditions[i]
}
}
}
return ZTunnelCondition{Type: conditionType, Status: metav1.ConditionUnknown}
}

// SetCondition sets a specific condition in the list of conditions
func (s *ZTunnelStatus) SetCondition(condition ZTunnelCondition) {
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)
}

// ZTunnelCondition represents a specific observation of the ZTunnel object's state.
type ZTunnelCondition struct {
// The type of this condition.
Type ZTunnelConditionType `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 ZTunnelConditionReason `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.
// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitzero"`
}

// ZTunnelConditionType represents the type of the condition. Condition stages are:
// Installed, Reconciled, Ready
type ZTunnelConditionType string

// ZTunnelConditionReason represents a short message indicating how the condition came
// to be in its present state.
type ZTunnelConditionReason string

const (
// ZTunnelConditionReconciled signifies whether the controller has
// successfully reconciled the resources defined through the CR.
ZTunnelConditionReconciled ZTunnelConditionType = "Reconciled"

// ZTunnelReasonReconcileError indicates that the reconciliation of the resource has failed, but will be retried.
ZTunnelReasonReconcileError ZTunnelConditionReason = "ReconcileError"
)

const (
// ZTunnelConditionReady signifies whether the ztunnel DaemonSet is ready.
ZTunnelConditionReady ZTunnelConditionType = "Ready"

// ZTunnelDaemonSetNotReady indicates that the ztunnel DaemonSet is not ready.
ZTunnelDaemonSetNotReady ZTunnelConditionReason = "DaemonSetNotReady"

// ZTunnelReasonReadinessCheckFailed indicates that the DaemonSet readiness status could not be ascertained.
ZTunnelReasonReadinessCheckFailed ZTunnelConditionReason = "ReadinessCheckFailed"
)

const (
// ZTunnelReasonHealthy indicates that the control plane is fully reconciled and that all components are ready.
ZTunnelReasonHealthy ZTunnelConditionReason = "Healthy"
)

// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster,categories=istio-io
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="Namespace",type="string",JSONPath=".spec.namespace",description="The namespace for the ztunnel component."
// +kubebuilder:printcolumn:name="Profile",type="string",JSONPath=".spec.values.profile",description="The selected profile (collection of value presets)."
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description="Whether the Istio ztunnel installation is ready to handle requests."
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.state",description="The current state of this object."
// +kubebuilder:printcolumn:name="Version",type="string",JSONPath=".spec.version",description="The version of the Istio ztunnel installation."
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="The age of the object"
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default'",message="metadata.name must be 'default'"

// ZTunnel represents a deployment of the Istio ztunnel component.
type ZTunnel struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata"`

// +kubebuilder:default={version: "v1.27.3", namespace: "ztunnel"}
// +optional
Spec ZTunnelSpec `json:"spec"`

// +optional
Status ZTunnelStatus `json:"status"`
}

// +kubebuilder:object:root=true

// ZTunnelList contains a list of ZTunnel
type ZTunnelList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []ZTunnel `json:"items"`
}

func init() {
SchemeBuilder.Register(&ZTunnel{}, &ZTunnelList{})
}
117 changes: 117 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/v1alpha1/ztunnel_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ const (
ZTunnelReasonHealthy ZTunnelConditionReason = "Healthy"
)

// +kubebuilder:deprecatedversion
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster,categories=istio-io
// +kubebuilder:subresource:status
Expand Down
17 changes: 6 additions & 11 deletions bundle/manifests/sailoperator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ metadata:
}
},
{
"apiVersion": "sailoperator.io/v1alpha1",
"apiVersion": "sailoperator.io/v1",
"kind": "ZTunnel",
"metadata": {
"name": "default"
Expand All @@ -45,7 +45,7 @@ metadata:
capabilities: Seamless Upgrades
categories: OpenShift Optional, Integration & Delivery, Networking, Security
containerImage: quay.io/sail-dev/sail-operator:1.27.3
createdAt: "2025-10-21T08:35:53Z"
createdAt: "2025-11-25T10:40:24Z"
description: The Sail Operator manages the lifecycle of your Istio control plane. It provides custom resources for you to deploy and manage your control plane components.
features.operators.openshift.io/cnf: "false"
features.operators.openshift.io/cni: "true"
Expand Down Expand Up @@ -145,6 +145,9 @@ spec:
- kind: WorkloadGroup
name: workloadgroups.networking.istio.io
version: v1beta1
- kind: ZTunnel
name: ztunnels.sailoperator.io
version: v1alpha1
- kind: AuthorizationPolicy
name: authorizationpolicies.security.istio.io
version: v1
Expand Down Expand Up @@ -431,18 +434,10 @@ spec:
path: namespace
x-descriptors:
- urn:alm:descriptor:io.kubernetes:Namespace
- description: |-
The built-in installation configuration profile to use.
The 'default' profile is 'ambient' and it is always applied.
Must be one of: ambient, default, demo, empty, external, preview, remote, stable.
displayName: Profile
path: profile
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:hidden
- description: Defines the values to be passed to the Helm charts when installing Istio ztunnel.
displayName: Helm Values
path: values
version: v1alpha1
version: v1
description: |-
The Sail Operator manages the lifecycle of your Istio control plane. It provides custom resources for you to deploy and manage your control plane components.

Expand Down
Loading