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
4 changes: 3 additions & 1 deletion Makefile.core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ VERSION ?= 1.0.0
MINOR_VERSION := $(shell echo "${VERSION}" | cut -f1,2 -d'.')

OPERATOR_NAME ?= sailoperator
VERSIONS_YAML_DIR ?= pkg/istioversion
VERSIONS_YAML_FILE ?= versions.yaml

# Istio images names
Expand Down Expand Up @@ -53,6 +54,7 @@ LD_EXTRAFLAGS = -X ${GO_MODULE}/pkg/version.buildVersion=${VERSION}
LD_EXTRAFLAGS += -X ${GO_MODULE}/pkg/version.buildGitRevision=${GIT_REVISION}
LD_EXTRAFLAGS += -X ${GO_MODULE}/pkg/version.buildTag=${GIT_TAG}
LD_EXTRAFLAGS += -X ${GO_MODULE}/pkg/version.buildStatus=${GIT_STATUS}
LD_EXTRAFLAGS += -X ${GO_MODULE}/pkg/istioversion.versionsFilename=${VERSIONS_YAML_FILE}

IS_FIPS_COMPLIANT ?= false # set to true for FIPS compliance
ifeq ($(IS_FIPS_COMPLIANT), true)
Expand Down Expand Up @@ -389,7 +391,7 @@ gen-charts: ## Pull charts from istio repository.
@# use yq to generate a list of download-charts.sh commands for each version in versions.yaml; these commands are
@# passed to sh and executed; in a nutshell, the yq command generates commands like:
@# ./hack/download-charts.sh <version> <git repo> <commit> [chart1] [chart2] ...
@yq eval '.versions[] | "./hack/download-charts.sh " + .name + " " + .repo + " " + .commit + " " + ((.charts // []) | join(" "))' < $(VERSIONS_YAML_FILE) | sh
@yq eval '.versions[] | "./hack/download-charts.sh " + .name + " " + .repo + " " + .commit + " " + ((.charts // []) | join(" "))' < $(VERSIONS_YAML_DIR)/$(VERSIONS_YAML_FILE) | sh

@# remove old version directories
@hack/remove-old-versions.sh
Expand Down
6 changes: 3 additions & 3 deletions api/v1/istio_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ const (
type IstioSpec struct {
// +sail:version
// Defines the version of Istio to install.
// Must be one of: v1.24.2, v1.24.1, v1.23.4, v1.23.3, v1.23.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.24.2", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.1", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.4", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.3", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.0"}
// +kubebuilder:validation:Enum=v1.24.2;v1.24.1;v1.23.4;v1.23.3;v1.23.0
// Must be one of: v1.24-latest, v1.24.2, v1.24.1, v1.23-latest, v1.23.4, v1.23.3, v1.23.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.24-latest", "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.23-latest", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.4", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.3", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.0"}
// +kubebuilder:validation:Enum=v1.24-latest;v1.24.2;v1.24.1;v1.23-latest;v1.23.4;v1.23.3;v1.23.0
// +kubebuilder:default=v1.24.2
Version string `json:"version"`

Expand Down
6 changes: 3 additions & 3 deletions api/v1/istiocni_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const (
type IstioCNISpec struct {
// +sail:version
// Defines the version of Istio to install.
// Must be one of: v1.24.2, v1.24.1, v1.23.4, v1.23.3, v1.23.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.24.2", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.1", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.4", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.3", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.0"}
// +kubebuilder:validation:Enum=v1.24.2;v1.24.1;v1.23.4;v1.23.3;v1.23.0
// Must be one of: v1.24-latest, v1.24.2, v1.24.1, v1.23-latest, v1.23.4, v1.23.3, v1.23.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.24-latest", "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.23-latest", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.4", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.3", "urn:alm:descriptor:com.tectonic.ui:select:v1.23.0"}
// +kubebuilder:validation:Enum=v1.24-latest;v1.24.2;v1.24.1;v1.23-latest;v1.23.4;v1.23.3;v1.23.0
// +kubebuilder:default=v1.24.2
Version string `json:"version"`

Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/ztunnel_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const (
type ZTunnelSpec struct {
// +sail:version
// Defines the version of Istio to install.
// Must be one of: v1.24.2, v1.24.1.
// +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.24.2", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.1"}
// +kubebuilder:validation:Enum=v1.24.2;v1.24.1
// Must be one of: v1.24-latest, v1.24.2, v1.24.1.
// +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.24-latest", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.2", "urn:alm:descriptor:com.tectonic.ui:select:v1.24.1"}
// +kubebuilder:validation:Enum=v1.24-latest;v1.24.2;v1.24.1
// +kubebuilder:default=v1.24.2
Version string `json:"version"`

Expand Down
2 changes: 1 addition & 1 deletion bundle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Repeat the process to create a project named `istio-cni`.
The `version` field of the `Istio` and `IstioCNI` resource defines which version
of each component should be deployed. This can be set using the `Istio Version`
drop down menu when creating a new `Istio` with the OpenShift Container Platform
web console. For a list of available versions, see the [versions.yaml](/versions.yaml) file
web console. For a list of available versions, see the [versions.yaml](/pkg/istioversion/versions.yaml) file
or use the command:

```sh
Expand Down
15 changes: 11 additions & 4 deletions bundle/manifests/sailoperator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ metadata:
capabilities: Seamless Upgrades
categories: OpenShift Optional, Integration & Delivery, Networking, Security
containerImage: quay.io/sail-dev/sail-operator:1.0-latest
createdAt: "2025-02-14T13:22:25Z"
createdAt: "2025-02-18T08:19:42Z"
description: Experimental operator for installing Istio service mesh
features.operators.openshift.io/cnf: "false"
features.operators.openshift.io/cni: "true"
Expand Down Expand Up @@ -165,13 +165,15 @@ spec:
specDescriptors:
- description: |-
Defines the version of Istio to install.
Must be one of: v1.24.2, v1.24.1, v1.23.4, v1.23.3, v1.23.0.
Must be one of: v1.24-latest, v1.24.2, v1.24.1, v1.23-latest, v1.23.4, v1.23.3, v1.23.0.
displayName: Istio Version
path: version
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:fieldGroup:General
- urn:alm:descriptor:com.tectonic.ui:select:v1.24-latest
- 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.23-latest
- urn:alm:descriptor:com.tectonic.ui:select:v1.23.4
- urn:alm:descriptor:com.tectonic.ui:select:v1.23.3
- urn:alm:descriptor:com.tectonic.ui:select:v1.23.0
Expand Down Expand Up @@ -259,13 +261,15 @@ spec:
- urn:alm:descriptor:com.tectonic.ui:select:RevisionBased
- description: |-
Defines the version of Istio to install.
Must be one of: v1.24.2, v1.24.1, v1.23.4, v1.23.3, v1.23.0.
Must be one of: v1.24-latest, v1.24.2, v1.24.1, v1.23-latest, v1.23.4, v1.23.3, v1.23.0.
displayName: Istio Version
path: version
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:fieldGroup:General
- urn:alm:descriptor:com.tectonic.ui:select:v1.24-latest
- 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.23-latest
- urn:alm:descriptor:com.tectonic.ui:select:v1.23.4
- urn:alm:descriptor:com.tectonic.ui:select:v1.23.3
- urn:alm:descriptor:com.tectonic.ui:select:v1.23.0
Expand Down Expand Up @@ -318,11 +322,12 @@ spec:
specDescriptors:
- description: |-
Defines the version of Istio to install.
Must be one of: v1.24.2, v1.24.1.
Must be one of: v1.24-latest, v1.24.2, v1.24.1.
displayName: Istio Version
path: version
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:fieldGroup:General
- urn:alm:descriptor:com.tectonic.ui:select:v1.24-latest
- urn:alm:descriptor:com.tectonic.ui:select:v1.24.2
- urn:alm:descriptor:com.tectonic.ui:select:v1.24.1
- description: Namespace to which the Istio ztunnel component should be installed.
Expand All @@ -348,8 +353,10 @@ spec:

This version of the operator supports the following Istio versions:

- v1.24-latest
- v1.24.2
- v1.24.1
- v1.23-latest
- v1.23.4
- v1.23.3
- v1.23.0
Expand Down
4 changes: 3 additions & 1 deletion bundle/manifests/sailoperator.io_istiocnis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1432,10 +1432,12 @@ spec:
default: v1.24.2
description: |-
Defines the version of Istio to install.
Must be one of: v1.24.2, v1.24.1, v1.23.4, v1.23.3, v1.23.0.
Must be one of: v1.24-latest, v1.24.2, v1.24.1, v1.23-latest, v1.23.4, v1.23.3, v1.23.0.
enum:
- v1.24-latest
- v1.24.2
- v1.24.1
- v1.23-latest
- v1.23.4
- v1.23.3
- v1.23.0
Expand Down
4 changes: 3 additions & 1 deletion bundle/manifests/sailoperator.io_istios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9458,10 +9458,12 @@ spec:
default: v1.24.2
description: |-
Defines the version of Istio to install.
Must be one of: v1.24.2, v1.24.1, v1.23.4, v1.23.3, v1.23.0.
Must be one of: v1.24-latest, v1.24.2, v1.24.1, v1.23-latest, v1.23.4, v1.23.3, v1.23.0.
enum:
- v1.24-latest
- v1.24.2
- v1.24.1
- v1.23-latest
- v1.23.4
- v1.23.3
- v1.23.0
Expand Down
3 changes: 2 additions & 1 deletion bundle/manifests/sailoperator.io_ztunnels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5488,8 +5488,9 @@ spec:
default: v1.24.2
description: |-
Defines the version of Istio to install.
Must be one of: v1.24.2, v1.24.1.
Must be one of: v1.24-latest, v1.24.2, v1.24.1.
enum:
- v1.24-latest
- v1.24.2
- v1.24.1
type: string
Expand Down
4 changes: 3 additions & 1 deletion chart/crds/sailoperator.io_istiocnis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1432,10 +1432,12 @@ spec:
default: v1.24.2
description: |-
Defines the version of Istio to install.
Must be one of: v1.24.2, v1.24.1, v1.23.4, v1.23.3, v1.23.0.
Must be one of: v1.24-latest, v1.24.2, v1.24.1, v1.23-latest, v1.23.4, v1.23.3, v1.23.0.
enum:
- v1.24-latest
- v1.24.2
- v1.24.1
- v1.23-latest
- v1.23.4
- v1.23.3
- v1.23.0
Expand Down
4 changes: 3 additions & 1 deletion chart/crds/sailoperator.io_istios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9458,10 +9458,12 @@ spec:
default: v1.24.2
description: |-
Defines the version of Istio to install.
Must be one of: v1.24.2, v1.24.1, v1.23.4, v1.23.3, v1.23.0.
Must be one of: v1.24-latest, v1.24.2, v1.24.1, v1.23-latest, v1.23.4, v1.23.3, v1.23.0.
enum:
- v1.24-latest
- v1.24.2
- v1.24.1
- v1.23-latest
- v1.23.4
- v1.23.3
- v1.23.0
Expand Down
3 changes: 2 additions & 1 deletion chart/crds/sailoperator.io_ztunnels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5488,8 +5488,9 @@ spec:
default: v1.24.2
description: |-
Defines the version of Istio to install.
Must be one of: v1.24.2, v1.24.1.
Must be one of: v1.24-latest, v1.24.2, v1.24.1.
enum:
- v1.24-latest
- v1.24.2
- v1.24.1
type: string
Expand Down
2 changes: 2 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ csv:

This version of the operator supports the following Istio versions:

- v1.24-latest
- v1.24.2
- v1.24.1
- v1.23-latest
- v1.23.4
- v1.23.3
- v1.23.0
Expand Down
9 changes: 7 additions & 2 deletions controllers/istio/istio_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/istio-ecosystem/sail-operator/pkg/config"
"github.com/istio-ecosystem/sail-operator/pkg/enqueuelogger"
"github.com/istio-ecosystem/sail-operator/pkg/errlist"
"github.com/istio-ecosystem/sail-operator/pkg/istioversion"
"github.com/istio-ecosystem/sail-operator/pkg/kube"
"github.com/istio-ecosystem/sail-operator/pkg/reconciler"
"github.com/istio-ecosystem/sail-operator/pkg/revision"
Expand Down Expand Up @@ -120,8 +121,12 @@ func validate(istio *v1.Istio) error {
}

func (r *Reconciler) reconcileActiveRevision(ctx context.Context, istio *v1.Istio) error {
version, err := istioversion.Resolve(istio.Spec.Version)
if err != nil {
return fmt.Errorf("failed to resolve Istio version for %q: %w", istio.Name, err)
}
values, err := revision.ComputeValues(
istio.Spec.Values, istio.Spec.Namespace, istio.Spec.Version,
istio.Spec.Values, istio.Spec.Namespace, version,
r.Config.Platform, r.Config.DefaultProfile, istio.Spec.Profile,
r.Config.ResourceDirectory, getActiveRevisionName(istio))
if err != nil {
Expand All @@ -130,7 +135,7 @@ func (r *Reconciler) reconcileActiveRevision(ctx context.Context, istio *v1.Isti

return revision.CreateOrUpdate(ctx, r.Client,
getActiveRevisionName(istio),
istio.Spec.Version, istio.Spec.Namespace, values,
version, istio.Spec.Namespace, values,
metav1.OwnerReference{
APIVersion: v1.GroupVersion.String(),
Kind: v1.IstioKind,
Expand Down
14 changes: 10 additions & 4 deletions controllers/istio/istio_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@ import (
"context"
"fmt"
"runtime/debug"
"strings"
"testing"
"time"

"github.com/google/go-cmp/cmp"
v1 "github.com/istio-ecosystem/sail-operator/api/v1"
"github.com/istio-ecosystem/sail-operator/pkg/config"
"github.com/istio-ecosystem/sail-operator/pkg/istioversion"
"github.com/istio-ecosystem/sail-operator/pkg/scheme"
"github.com/istio-ecosystem/sail-operator/pkg/test/testtime"
"github.com/istio-ecosystem/sail-operator/pkg/test/util/supportedversion"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -127,7 +128,8 @@ func TestReconcile(t *testing.T) {
istio := &v1.Istio{
ObjectMeta: objectMeta,
Spec: v1.IstioSpec{
Version: "my-version",
Version: "my-version",
Namespace: "istio-system",
},
}

Expand Down Expand Up @@ -157,6 +159,10 @@ func TestReconcile(t *testing.T) {
t.Errorf("Expected Reconciled condition status to be %q, but got %q", metav1.ConditionFalse, reconciledCond.Status)
}

if !strings.Contains(reconciledCond.Message, "version \"my-version\" not found") {
t.Errorf("Expected Reconciled condition message to contain %q, but got %q", "version \"my-version\" not found", reconciledCond.Message)
}

readyCond := istio.Status.GetCondition(v1.IstioConditionReady)
if readyCond.Status != metav1.ConditionUnknown {
t.Errorf("Expected Reconciled condition status to be %q, but got %q", metav1.ConditionUnknown, readyCond.Status)
Expand All @@ -177,7 +183,7 @@ func TestValidate(t *testing.T) {
Name: "default",
},
Spec: v1.IstioSpec{
Version: supportedversion.Default,
Version: istioversion.Default,
Namespace: "istio-system",
},
},
Expand All @@ -202,7 +208,7 @@ func TestValidate(t *testing.T) {
Name: "default",
},
Spec: v1.IstioSpec{
Version: supportedversion.Default,
Version: istioversion.Default,
},
},
expectErr: "spec.namespace not set",
Expand Down
20 changes: 13 additions & 7 deletions controllers/istiocni/istiocni_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/istio-ecosystem/sail-operator/pkg/errlist"
"github.com/istio-ecosystem/sail-operator/pkg/helm"
"github.com/istio-ecosystem/sail-operator/pkg/istiovalues"
"github.com/istio-ecosystem/sail-operator/pkg/istioversion"
"github.com/istio-ecosystem/sail-operator/pkg/kube"
"github.com/istio-ecosystem/sail-operator/pkg/predicate"
"github.com/istio-ecosystem/sail-operator/pkg/reconciler"
Expand Down Expand Up @@ -141,32 +142,37 @@ func (r *Reconciler) installHelmChart(ctx context.Context, cni *v1.IstioCNI) err
BlockOwnerDeletion: ptr.Of(true),
}

version, err := istioversion.Resolve(cni.Spec.Version)
if err != nil {
return fmt.Errorf("failed to resolve IstioCNI version for %q: %w", cni.Name, err)
}

// get userValues from Istio.spec.values
userValues := cni.Spec.Values

// apply image digests from configuration, if not already set by user
userValues = applyImageDigests(cni, userValues, config.Config)
userValues = applyImageDigests(version, userValues, config.Config)

// apply userValues on top of defaultValues from profiles
mergedHelmValues, err := istiovalues.ApplyProfilesAndPlatform(
r.Config.ResourceDirectory, cni.Spec.Version, r.Config.Platform, r.Config.DefaultProfile, cni.Spec.Profile, helm.FromValues(userValues))
r.Config.ResourceDirectory, version, r.Config.Platform, r.Config.DefaultProfile, cni.Spec.Profile, helm.FromValues(userValues))
if err != nil {
return fmt.Errorf("failed to apply profile: %w", err)
}

_, err = r.ChartManager.UpgradeOrInstallChart(ctx, r.getChartDir(cni), mergedHelmValues, cni.Spec.Namespace, cniReleaseName, ownerReference)
_, err = r.ChartManager.UpgradeOrInstallChart(ctx, r.getChartDir(version), mergedHelmValues, cni.Spec.Namespace, cniReleaseName, ownerReference)
if err != nil {
return fmt.Errorf("failed to install/update Helm chart %q: %w", cniChartName, err)
}
return nil
}

func (r *Reconciler) getChartDir(cni *v1.IstioCNI) string {
return path.Join(r.Config.ResourceDirectory, cni.Spec.Version, "charts", cniChartName)
func (r *Reconciler) getChartDir(version string) string {
return path.Join(r.Config.ResourceDirectory, version, "charts", cniChartName)
}

func applyImageDigests(cni *v1.IstioCNI, values *v1.CNIValues, config config.OperatorConfig) *v1.CNIValues {
imageDigests, digestsDefined := config.ImageDigests[cni.Spec.Version]
func applyImageDigests(version string, values *v1.CNIValues, config config.OperatorConfig) *v1.CNIValues {
imageDigests, digestsDefined := config.ImageDigests[version]
// if we don't have default image digests defined for this version, it's a no-op
if !digestsDefined {
return values
Expand Down
Loading