diff --git a/CHANGELOG.md b/CHANGELOG.md index fa18198d7..7023a6880 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This patch release enables the etcd corruption checks on every etcd member that ### Bug or Regression +- Regenerate container runtime configurations based on kubeone.yaml during control-plane upgrades on Flatcar Linux nodes, not only on the initial installation. ([#1918](https://github.com/kubermatic/kubeone/pull/1918)) - Approve pending CSRs when upgrading control plane and static worker nodes ([#1888](https://github.com/kubermatic/kubeone/pull/1888)) - Enable the etcd integrity checks (on startup and every 4 hours) for Kubernetes 1.22+ clusters. See [the official etcd announcement for more details](https://groups.google.com/a/kubernetes.io/g/dev/c/B7gJs88XtQc/m/rSgNOzV2BwAJ). ([#1909](https://github.com/kubermatic/kubeone/pull/1909)) - Fix CSR approving issue for existing nodes with already approved and GCed CSRs ([#1897](https://github.com/kubermatic/kubeone/pull/1897)) diff --git a/pkg/scripts/os_flatcar.go b/pkg/scripts/os_flatcar.go index f3d323053..5b75d8433 100644 --- a/pkg/scripts/os_flatcar.go +++ b/pkg/scripts/os_flatcar.go @@ -108,6 +108,14 @@ sudo systemctl daemon-reload source /etc/kubeone/proxy-env +{{ if .INSTALL_DOCKER }} +{{ template "flatcar-docker" . }} +{{ end }} + +{{ if .INSTALL_CONTAINERD }} +{{ template "flatcar-containerd" . }} +{{ end }} + sudo mkdir -p /opt/cni/bin curl -L "https://github.com/containernetworking/plugins/releases/download/v{{ .KUBERNETES_CNI_VERSION }}/cni-plugins-linux-${HOST_ARCH}-v{{ .KUBERNETES_CNI_VERSION }}.tgz" | sudo tar -C /opt/cni/bin -xz @@ -130,6 +138,14 @@ source /etc/kubeone/proxy-env {{ template "detect-host-cpu-architecture" }} +{{ if .INSTALL_DOCKER }} +{{ template "flatcar-docker" . }} +{{ end }} + +{{ if .INSTALL_CONTAINERD }} +{{ template "flatcar-containerd" . }} +{{ end }} + RELEASE="v{{ .KUBERNETES_VERSION }}" sudo mkdir -p /var/tmp/kube-binaries cd /var/tmp/kube-binaries @@ -197,15 +213,31 @@ func RemoveBinariesFlatcar() (string, error) { return Render(removeBinariesFlatcarScriptTemplate, nil) } -func UpgradeKubeadmAndCNIFlatcar(k8sVersion string) (string, error) { - return Render(upgradeKubeadmAndCNIFlatcarScriptTemplate, Data{ - "KUBERNETES_VERSION": k8sVersion, +func UpgradeKubeadmAndCNIFlatcar(cluster *kubeoneapi.KubeOneCluster) (string, error) { + data := Data{ + "KUBERNETES_VERSION": cluster.Versions.Kubernetes, "KUBERNETES_CNI_VERSION": defaultKubernetesCNIVersion, - }) + "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, + "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, + } + + if err := containerruntime.UpdateDataMap(cluster, data); err != nil { + return "", err + } + + return Render(upgradeKubeadmAndCNIFlatcarScriptTemplate, data) } -func UpgradeKubeletAndKubectlFlatcar(k8sVersion string) (string, error) { - return Render(upgradeKubeletAndKubectlFlatcarScriptTemplate, Data{ - "KUBERNETES_VERSION": k8sVersion, - }) +func UpgradeKubeletAndKubectlFlatcar(cluster *kubeoneapi.KubeOneCluster) (string, error) { + data := Data{ + "KUBERNETES_VERSION": cluster.Versions.Kubernetes, + "INSTALL_DOCKER": cluster.ContainerRuntime.Docker, + "INSTALL_CONTAINERD": cluster.ContainerRuntime.Containerd, + } + + if err := containerruntime.UpdateDataMap(cluster, data); err != nil { + return "", err + } + + return Render(upgradeKubeletAndKubectlFlatcarScriptTemplate, data) } diff --git a/pkg/scripts/os_test.go b/pkg/scripts/os_test.go index cba42f97a..40cb1977c 100644 --- a/pkg/scripts/os_test.go +++ b/pkg/scripts/os_test.go @@ -572,7 +572,8 @@ func TestUpgradeKubeadmAndCNIAmazonLinux(t *testing.T) { func TestUpgradeKubeadmAndCNIFlatcar(t *testing.T) { t.Parallel() - got, err := UpgradeKubeadmAndCNIFlatcar("v1.17.4") + cls := genCluster(withDocker) + got, err := UpgradeKubeadmAndCNIFlatcar(&cls) if err != nil { t.Errorf("UpgradeKubeadmAndCNIFlatcar() error = %v", err) @@ -627,7 +628,8 @@ func TestUpgradeKubeletAndKubectlAmazonLinux(t *testing.T) { func TestUpgradeKubeletAndKubectlFlatcar(t *testing.T) { t.Parallel() - got, err := UpgradeKubeletAndKubectlFlatcar("v1.17.4") + cls := genCluster(withDocker) + got, err := UpgradeKubeletAndKubectlFlatcar(&cls) if err != nil { t.Errorf("UpgradeKubeletAndKubectlFlatcar() error = %v", err) diff --git a/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIFlatcar.golden b/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIFlatcar.golden index 75d5e3012..149dd1e90 100644 --- a/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIFlatcar.golden +++ b/pkg/scripts/testdata/TestUpgradeKubeadmAndCNIFlatcar.golden @@ -19,11 +19,41 @@ esac source /etc/kubeone/proxy-env + + +sudo mkdir -p $(dirname /etc/docker/daemon.json) +sudo touch /etc/docker/daemon.json +sudo chmod 600 /etc/docker/daemon.json +cat <