/* Copyright (c) Edgeless Systems GmbH SPDX-License-Identifier: AGPL-3.0-only */ /* Package versions defines the supported versions of Constellation components. Binaries and container image versions are pinned by their hashes, the generate tool can be found in the hash-generator subpackage. */ package versions import ( "fmt" "sort" "strings" "github.com/edgelesssys/constellation/v2/internal/compatibility" "github.com/edgelesssys/constellation/v2/internal/constants" "github.com/edgelesssys/constellation/v2/internal/versions/components" "golang.org/x/mod/semver" ) // SupportedK8sVersions returns a list (sorted) of supported Kubernetes versions. func SupportedK8sVersions() []string { validVersions := make([]string, len(VersionConfigs)) i := 0 for _, conf := range VersionConfigs { validVersions[i] = compatibility.EnsurePrefixV(conf.ClusterVersion) i++ } validVersionsSorted := semver.ByVersion(validVersions) sort.Sort(validVersionsSorted) return validVersionsSorted } // ValidK8sVersion represents any of the three currently supported k8s versions. type ValidK8sVersion string // NewValidK8sVersion validates the given string and produces a new ValidK8sVersion object. func NewValidK8sVersion(k8sVersion string) (ValidK8sVersion, error) { if IsSupportedK8sVersion(k8sVersion) { return ValidK8sVersion(k8sVersion), nil } return "", fmt.Errorf("invalid k8sVersion supplied: %s", k8sVersion) } // IsSupportedK8sVersion checks if a given Kubernetes version is supported by Constellation. func IsSupportedK8sVersion(version string) bool { for _, valid := range SupportedK8sVersions() { if valid == version { return true } } return false } // IsPreviewK8sVersion checks if a given Kubernetes version is still in preview and not fully supported. func IsPreviewK8sVersion(_ ValidK8sVersion) bool { return false } const ( // // Constellation images. // These images are built in a way that they support all versions currently listed in VersionConfigs. // // KonnectivityAgentImage agent image for konnectivity service. KonnectivityAgentImage = "registry.k8s.io/kas-network-proxy/proxy-agent:v0.1.2@sha256:cd3046d253d26ffb5907c625e0d0c2be05c5693c90e12116980851739fc0ead8" // renovate:container // KonnectivityServerImage server image for konnectivity service. KonnectivityServerImage = "registry.k8s.io/kas-network-proxy/proxy-server:v0.1.2@sha256:79933c3779bc30e33bb7509dff913e70f6ba78ad441f4827f0f3e840ce5f3ddb" // renovate:container // GcpGuestImage image for GCP guest agent. // Check for new versions at https://github.com/GoogleCloudPlatform/guest-agent/releases and update in /.github/workflows/build-gcp-guest-agent.yml. GcpGuestImage = "ghcr.io/edgelesssys/gcp-guest-agent:20230221.0@sha256:8be328a5d8d601170b82481d413cf326b20c5219c016633f1651e35d95f1d6f1" // renovate:container // NodeMaintenanceOperatorImage is the image for the node maintenance operator. NodeMaintenanceOperatorImage = "quay.io/medik8s/node-maintenance-operator:v0.14.0@sha256:2dffb6ffdbbe997d317799fc709baf030d678bde0be0264931ff6b3e94fd89ab" // renovate:container // LogstashImage is the container image of logstash, used for log collection by debugd. LogstashImage = "ghcr.io/edgelesssys/constellation/logstash-debugd:v2.7.0-pre.0.20230405123345-6bf3c63115a5@sha256:1e2c396538be7571138272f8a54e3412d4ff91ee370880f89894501a2555706a" // renovate:container // FilebeatImage is the container image of filebeat, used for log collection by debugd. FilebeatImage = "ghcr.io/edgelesssys/constellation/filebeat-debugd:v2.7.0-pre.0.20230405123345-6bf3c63115a5@sha256:abd739853af4981c3a4b338bb3a27433284525d7ebdb84adfc77f1873c41de93" // renovate:container // currently supported versions. //nolint:revive V1_24 ValidK8sVersion = "v1.24.13" // renovate:kubernetes-release //nolint:revive V1_25 ValidK8sVersion = "v1.25.9" // renovate:kubernetes-release //nolint:revive V1_26 ValidK8sVersion = "v1.26.4" // renovate:kubernetes-release // Default k8s version deployed by Constellation. Default ValidK8sVersion = V1_25 ) // Regenerate the hashes by running go generate. // To add another Kubernetes version, add a new entry to the VersionConfigs map below and fill the Hash field with an empty string. //go:generate hash-generator // VersionConfigs holds download URLs for all required kubernetes components for every supported version. var VersionConfigs = map[ValidK8sVersion]KubernetesVersion{ V1_24: { ClusterVersion: "v1.24.13", // renovate:kubernetes-release KubernetesComponents: components.Components{ { URL: "https://github.com/containernetworking/plugins/releases/download/v1.2.0/cni-plugins-linux-amd64-v1.2.0.tgz", // renovate:cni-plugins-release Hash: "sha256:f3a841324845ca6bf0d4091b4fc7f97e18a623172158b72fc3fdcdb9d42d2d37", InstallPath: constants.CniPluginsDir, Extract: true, }, { URL: "https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.26.1/crictl-v1.26.1-linux-amd64.tar.gz", // renovate:crictl-release Hash: "sha256:0c1a0f9900c15ee7a55e757bcdc220faca5dd2e1cfc120459ad1f04f08598127", InstallPath: constants.BinDir, Extract: true, }, { URL: "https://storage.googleapis.com/kubernetes-release/release/v1.24.13/bin/linux/amd64/kubelet", // renovate:kubernetes-release Hash: "sha256:78cdc9b460c997babc5c8d4f45fc93c7c037df94b7004ecacaa856500ed616a6", InstallPath: constants.KubeletPath, Extract: false, }, { URL: "https://storage.googleapis.com/kubernetes-release/release/v1.24.13/bin/linux/amd64/kubeadm", // renovate:kubernetes-release Hash: "sha256:91a65b7415a1a7e3dbdb23683eff9e2ace5a725a1bcd52b10695dd49adb6787e", InstallPath: constants.KubeadmPath, Extract: false, }, { URL: "https://storage.googleapis.com/kubernetes-release/release/v1.24.13/bin/linux/amd64/kubectl", // renovate:kubernetes-release Hash: "sha256:52455fe485fa11c650ab07fea2e4856b5ea5a3e6ef8a1b3b6121e6361437fff9", InstallPath: constants.KubectlPath, Extract: false, }, }, // CloudControllerManagerImageAWS is the CCM image used on AWS. CloudControllerManagerImageAWS: "registry.k8s.io/provider-aws/cloud-controller-manager:v1.24.4@sha256:56f1e111977989a403ae2bb53a2b4d1565d1ce132016efe47cfbe45b635ec9cd", // renovate:container // CloudControllerManagerImageAzure is the CCM image used on Azure. CloudControllerManagerImageAzure: "mcr.microsoft.com/oss/kubernetes/azure-cloud-controller-manager:v1.24.17@sha256:dc5a74fe39722890adecb56efd0a70f62540c0d86aa91a2f65ff87565aaf3309", // renovate:container // CloudNodeManagerImageAzure is the cloud-node-manager image used on Azure. CloudNodeManagerImageAzure: "mcr.microsoft.com/oss/kubernetes/azure-cloud-node-manager:v1.24.17@sha256:e670919ed7943ec87d61f4adf7aae449be841b98cf262e2a0f7d724326a2bf47", // renovate:container // CloudControllerManagerImageGCP is the CCM image used on GCP. // TODO: use newer "cloud-provider-gcp" from https://github.com/kubernetes/cloud-provider-gcp when newer releases are available. CloudControllerManagerImageGCP: "ghcr.io/edgelesssys/cloud-provider-gcp:v24.0.0@sha256:80e2910509ccb4d99b2e08182c2101fbed64f0663194adae08fc1cf878ecc58b", // renovate:container // CloudControllerManagerImageOpenStack is the CCM image used on OpenStack. CloudControllerManagerImageOpenStack: "docker.io/k8scloudprovider/openstack-cloud-controller-manager:v1.24.6", // renovate:container // External service image. Depends on k8s version. ClusterAutoscalerImage: "registry.k8s.io/autoscaling/cluster-autoscaler:v1.24.0@sha256:5bd22353ae7f30c9abfaa08189281367ef47ea1b3d09eb13eb26bd13de241e72", // renovate:container }, V1_25: { ClusterVersion: "v1.25.9", // renovate:kubernetes-release KubernetesComponents: components.Components{ { URL: "https://github.com/containernetworking/plugins/releases/download/v1.2.0/cni-plugins-linux-amd64-v1.2.0.tgz", // renovate:cni-plugins-release Hash: "sha256:f3a841324845ca6bf0d4091b4fc7f97e18a623172158b72fc3fdcdb9d42d2d37", InstallPath: constants.CniPluginsDir, Extract: true, }, { URL: "https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.26.1/crictl-v1.26.1-linux-amd64.tar.gz", // renovate:crictl-release Hash: "sha256:0c1a0f9900c15ee7a55e757bcdc220faca5dd2e1cfc120459ad1f04f08598127", InstallPath: constants.BinDir, Extract: true, }, { URL: "https://storage.googleapis.com/kubernetes-release/release/v1.25.9/bin/linux/amd64/kubelet", // renovate:kubernetes-release Hash: "sha256:0eb951237379ef023aa52deedb0df5eae54fa71caeb52bdb30a4660806bed23e", InstallPath: constants.KubeletPath, Extract: false, }, { URL: "https://storage.googleapis.com/kubernetes-release/release/v1.25.9/bin/linux/amd64/kubeadm", // renovate:kubernetes-release Hash: "sha256:157be24d998111a51d52db016f9010cd6418506a028f87b5a712f518b392a3f3", InstallPath: constants.KubeadmPath, Extract: false, }, { URL: "https://storage.googleapis.com/kubernetes-release/release/v1.25.9/bin/linux/amd64/kubectl", // renovate:kubernetes-release Hash: "sha256:aaa5ea3b3630730d2b8a8ef3cccb14b47754602c7207c7b0717158ae83c7cb10", InstallPath: constants.KubectlPath, Extract: false, }, }, // CloudControllerManagerImageAWS is the CCM image used on AWS. CloudControllerManagerImageAWS: "registry.k8s.io/provider-aws/cloud-controller-manager:v1.25.3@sha256:47eb1c1e6a3bd6d0fb44ac4992885b6218f1448ea339de778d8b703df463c06f", // renovate:container // CloudControllerManagerImageAzure is the CCM image used on Azure. // Check for newer versions at https://github.com/kubernetes-sigs/cloud-provider-azure/blob/master/README.md. CloudControllerManagerImageAzure: "mcr.microsoft.com/oss/kubernetes/azure-cloud-controller-manager:v1.25.11@sha256:f287ec68bda1aea9dbb85fea23a133bf384137c23f464ad411fc6b6f25477a93", // renovate:container // CloudNodeManagerImageAzure is the cloud-node-manager image used on Azure. // Check for newer versions at https://github.com/kubernetes-sigs/cloud-provider-azure/blob/master/README.md. CloudNodeManagerImageAzure: "mcr.microsoft.com/oss/kubernetes/azure-cloud-node-manager:v1.25.11@sha256:ad54f4e9a357e5b0c2d23e139889da1eb3b1b24194a7ea0d1e1061f27e35b05f", // renovate:container // CloudControllerManagerImageGCP is the CCM image used on GCP. // TODO: use newer "cloud-provider-gcp" from https://github.com/kubernetes/cloud-provider-gcp when newer releases are available. CloudControllerManagerImageGCP: "ghcr.io/edgelesssys/cloud-provider-gcp:v25.2.0@sha256:86fa9d31ed0b3d0d8806f13d6e7debd3471028b2cb7cca3a876d8a31612a7ba5", // renovate:container // CloudControllerManagerImageOpenStack is the CCM image used on OpenStack. CloudControllerManagerImageOpenStack: "docker.io/k8scloudprovider/openstack-cloud-controller-manager:v1.25.5", // renovate:container // External service image. Depends on k8s version. // Check for new versions at https://github.com/kubernetes/autoscaler/releases. ClusterAutoscalerImage: "registry.k8s.io/autoscaling/cluster-autoscaler:v1.25.0@sha256:f509ffab618dbd07d129b69ec56963aac7f61aaa792851206b54a2f0bbe046df", // renovate:container }, V1_26: { ClusterVersion: "v1.26.4", // renovate:kubernetes-release KubernetesComponents: components.Components{ { URL: "https://github.com/containernetworking/plugins/releases/download/v1.2.0/cni-plugins-linux-amd64-v1.2.0.tgz", // renovate:cni-plugins-release Hash: "sha256:f3a841324845ca6bf0d4091b4fc7f97e18a623172158b72fc3fdcdb9d42d2d37", InstallPath: constants.CniPluginsDir, Extract: true, }, { URL: "https://github.com/kubernetes-sigs/cri-tools/releases/download/v1.26.1/crictl-v1.26.1-linux-amd64.tar.gz", // renovate:crictl-release Hash: "sha256:0c1a0f9900c15ee7a55e757bcdc220faca5dd2e1cfc120459ad1f04f08598127", InstallPath: constants.BinDir, Extract: true, }, { URL: "https://storage.googleapis.com/kubernetes-release/release/v1.26.4/bin/linux/amd64/kubelet", // renovate:kubernetes-release Hash: "sha256:1e29fe7a097066cfbc1c1d2ab37f8b883c8f3fec414bafe8f2c7b960b0fb60fe", InstallPath: constants.KubeletPath, Extract: false, }, { URL: "https://storage.googleapis.com/kubernetes-release/release/v1.26.4/bin/linux/amd64/kubeadm", // renovate:kubernetes-release Hash: "sha256:aa1a137aa2c3427f199ff652c96b11d6b124358296996eb7b8cbde220607b2fe", InstallPath: constants.KubeadmPath, Extract: false, }, { URL: "https://storage.googleapis.com/kubernetes-release/release/v1.26.4/bin/linux/amd64/kubectl", // renovate:kubernetes-release Hash: "sha256:636ac0eaa467dbceda4b2c4e33662adc9709f5ce40341c9fc1a687fc276ac02d", InstallPath: constants.KubectlPath, Extract: false, }, }, // CloudControllerManagerImageAWS is the CCM image used on AWS. CloudControllerManagerImageAWS: "registry.k8s.io/provider-aws/cloud-controller-manager:v1.26.1@sha256:2a43d2d5611ba920c49e23127cfd474fb7932fcade1671dddbef757921fcdb40", // renovate:container // CloudControllerManagerImageAzure is the CCM image used on Azure. // Check for newer versions at https://github.com/kubernetes-sigs/cloud-provider-azure/blob/master/README.md. CloudControllerManagerImageAzure: "mcr.microsoft.com/oss/kubernetes/azure-cloud-controller-manager:v1.26.7@sha256:c23ce2231f91c7af3bb4204a7b9c04ae12e63e32581bd41d26a382f959363633", // renovate:container // CloudNodeManagerImageAzure is the cloud-node-manager image used on Azure. // Check for newer versions at https://github.com/kubernetes-sigs/cloud-provider-azure/blob/master/README.md. CloudNodeManagerImageAzure: "mcr.microsoft.com/oss/kubernetes/azure-cloud-node-manager:v1.26.7@sha256:258f2bf85fdeee7a6ffbeb618109da7dd50925c40c3b8a74f358f0c46a03019b", // renovate:container // CloudControllerManagerImageGCP is the CCM image used on GCP. // TODO: use newer "cloud-provider-gcp" from https://github.com/kubernetes/cloud-provider-gcp when newer releases are available. CloudControllerManagerImageGCP: "ghcr.io/edgelesssys/cloud-provider-gcp:v26.0.1@sha256:db2b15a20ad690784a6015bfad55c4dff15826be8cf9f6ac77d70abd11b1f70c", // renovate:container // CloudControllerManagerImageOpenStack is the CCM image used on OpenStack. CloudControllerManagerImageOpenStack: "docker.io/k8scloudprovider/openstack-cloud-controller-manager:v1.26.2", // renovate:container // External service image. Depends on k8s version. // Check for new versions at https://github.com/kubernetes/autoscaler/releases. ClusterAutoscalerImage: "registry.k8s.io/autoscaling/cluster-autoscaler:v1.26.1@sha256:c0b4ef409e23a79b28e2e9710d7317dbddeab141f4021895ebe90422eba1055c", // renovate:container }, } // KubernetesVersion bundles download URLs to all version-releated binaries necessary for installing/deploying a particular Kubernetes version. type KubernetesVersion struct { ClusterVersion string KubernetesComponents components.Components CloudControllerManagerImageAWS string // k8s version dependency. CloudControllerManagerImageAzure string // k8s version dependency. CloudControllerManagerImageGCP string // Using self-built image until resolved: https://github.com/kubernetes/cloud-provider-gcp/issues/289 CloudControllerManagerImageOpenStack string // k8s version dependency. CloudNodeManagerImageAzure string // k8s version dependency. Same version as above. ClusterAutoscalerImage string // Matches k8s versioning scheme. } // versionFromDockerImage returns the version tag from the image name, e.g. "v1.22.2" from "foocr.io/org/repo:v1.22.2@sha256:3009fj0...". func versionFromDockerImage(imageName string) string { beforeAt, _, _ := strings.Cut(imageName, "@") _, version, ok := strings.Cut(beforeAt, ":") if !ok { panic(fmt.Errorf("failed to extract version from image name, no ':' found in %s", imageName)) } return version }