From d78d22f95a343df5dbb9ad29cfa9186f9f45837e Mon Sep 17 00:00:00 2001 From: Otto Bittner Date: Wed, 22 Feb 2023 09:52:47 +0100 Subject: [PATCH] cli: add `config kubernetes-versions` subcommand (#1224) Allows users to learn which k8s versions are supported by the current CLI. Extend respective docs section. --- cli/internal/cmd/config.go | 1 + cli/internal/cmd/configkubernetesversions.go | 34 ++++++++++++++++++++ docs/docs/architecture/versions.md | 3 ++ docs/docs/workflows/config.md | 7 +++- internal/versions/versions.go | 14 +++----- 5 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 cli/internal/cmd/configkubernetesversions.go diff --git a/cli/internal/cmd/config.go b/cli/internal/cmd/config.go index b68cb9e67..4fe7153a2 100644 --- a/cli/internal/cmd/config.go +++ b/cli/internal/cmd/config.go @@ -23,6 +23,7 @@ func NewConfigCmd() *cobra.Command { cmd.AddCommand(newConfigGenerateCmd()) cmd.AddCommand(newConfigFetchMeasurementsCmd()) cmd.AddCommand(newConfigInstanceTypesCmd()) + cmd.AddCommand(newConfigKubernetesVersionsCmd()) return cmd } diff --git a/cli/internal/cmd/configkubernetesversions.go b/cli/internal/cmd/configkubernetesversions.go new file mode 100644 index 000000000..412c4421f --- /dev/null +++ b/cli/internal/cmd/configkubernetesversions.go @@ -0,0 +1,34 @@ +/* +Copyright (c) Edgeless Systems GmbH + +SPDX-License-Identifier: AGPL-3.0-only +*/ + +package cmd + +import ( + "strings" + + "github.com/edgelesssys/constellation/v2/internal/versions" + "github.com/spf13/cobra" +) + +func newConfigKubernetesVersionsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "kubernetes-versions", + Short: "Print the Kubernetes versions supported by this CLI", + Long: "Print the Kubernetes versions supported by this CLI.", + Args: cobra.ArbitraryArgs, + Run: printSupportedKubernetesVersions, + } + + return cmd +} + +func printSupportedKubernetesVersions(cmd *cobra.Command, args []string) { + cmd.Printf("Supported Kubernetes Versions:\n\t%s\n", formatKubernetesVersions()) +} + +func formatKubernetesVersions() string { + return strings.Join(versions.SupportedK8sVersions(), "\n\t") +} diff --git a/docs/docs/architecture/versions.md b/docs/docs/architecture/versions.md index 6fa365f6c..a79f66501 100644 --- a/docs/docs/architecture/versions.md +++ b/docs/docs/architecture/versions.md @@ -10,3 +10,6 @@ New releases are published on [GitHub](https://github.com/edgelesssys/constellat ### Kubernetes support policy Constellation is aligned to the [version support policy of Kubernetes](https://kubernetes.io/releases/version-skew-policy/#supported-versions), and therefore supports the most recent three minor versions. +When a new minor version is released upstream, the next Constellation release will include four supported Kubernetes versions. +The fourth version being the newly released Kubernetes version. +Then, the next Constellation release after that will drop the oldest supported Kubernetes version. diff --git a/docs/docs/workflows/config.md b/docs/docs/workflows/config.md index 698afcf93..57b08c0d4 100644 --- a/docs/docs/workflows/config.md +++ b/docs/docs/workflows/config.md @@ -36,7 +36,7 @@ This creates the file `constellation-conf.yaml` in the current directory. You can also automatically generate a configuration file by adding the `--generate-config` flag to the `constellation iam create` command when [creating an IAM configuration](#creating-an-iam-configuration). ::: -## Choosing VM types +## Choosing a VM type Constellation supports the following VM types: @@ -61,6 +61,11 @@ By default, Constellation uses `m6a.xlarge` VMs (4 vCPUs, 16 GB RAM) to create y Fill the desired VM type into the **instanceType** field in the `constellation-conf.yml` file. +## Choosing a Kubernetes version + +To learn which Kubernetes versions can be installed with your current CLI you can run `constellation config kubernetes-versions`. +Our support policy for Kubernetes versions is described in [Kubernetes support policy](../architecture/versions.md#kubernetes-support-policy). + ## Creating an IAM configuration You can create an IAM configuration for your cluster automatically using the `constellation iam create` command. diff --git a/internal/versions/versions.go b/internal/versions/versions.go index 7fe1d8fde..7b73fa2f0 100644 --- a/internal/versions/versions.go +++ b/internal/versions/versions.go @@ -49,16 +49,12 @@ func NewValidK8sVersion(k8sVersion string) (ValidK8sVersion, error) { // IsSupportedK8sVersion checks if a given Kubernetes version is supported by Constellation. func IsSupportedK8sVersion(version string) bool { - switch version { - case string(V1_24): - return true - case string(V1_25): - return true - case string(V1_26): - return true - default: - return false + 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.