From c90c27f4807d2c9eb64a8167d38f586319e36632 Mon Sep 17 00:00:00 2001 From: Peter Balogh Date: Wed, 5 Oct 2022 17:27:15 +0200 Subject: [PATCH] update cri and containerd and add node-name flag to init (#155) Signed-off-by: Peter Balogh --- cmd/pke/app/constants/constants.go | 3 +++ .../certificate_auto_approver.yaml.go | 2 +- .../kubeadm/controlplane/controlplane.go | 21 +++++++++++++++---- .../kubeadm/controlplane/controlplane_test.go | 3 ++- cmd/pke/app/phases/kubeadm/node/kubeadm.go | 3 ++- cmd/pke/app/phases/pipeline/ready/ready.go | 5 +++-- .../runtime/container/containerd_linux.go | 9 ++++---- cmd/pke/app/util/linux/apt.go | 3 ++- cmd/pke/app/util/linux/rpm.go | 3 ++- cmd/pke/app/util/pipeline/status.go | 3 ++- 10 files changed, 39 insertions(+), 16 deletions(-) diff --git a/cmd/pke/app/constants/constants.go b/cmd/pke/app/constants/constants.go index e1f71e9e..504b142d 100644 --- a/cmd/pke/app/constants/constants.go +++ b/cmd/pke/app/constants/constants.go @@ -103,6 +103,9 @@ const ( // FlagClusterName cluster name FlagClusterName = "kubernetes-cluster-name" + // FlagNodeName nodename for init + FlagNodeName = "kubernetes-node-name" + // FlagOIDCIssuerURL OIDC issuer URL FlagOIDCIssuerURL = "kubernetes-oidc-issuer-url" // FlagOIDCClientID OIDC client ID diff --git a/cmd/pke/app/phases/kubeadm/controlplane/certificate_auto_approver.yaml.go b/cmd/pke/app/phases/kubeadm/controlplane/certificate_auto_approver.yaml.go index f3670a55..fff4d5ab 100644 --- a/cmd/pke/app/phases/kubeadm/controlplane/certificate_auto_approver.yaml.go +++ b/cmd/pke/app/phases/kubeadm/controlplane/certificate_auto_approver.yaml.go @@ -107,6 +107,6 @@ func certificateAutoApproverTemplate() string { " fieldRef:\n" + " fieldPath: metadata.name\n" + " - name: OPERATOR_NAME\n" + - " value: \"auto-approver\"\n" + " value: \"auto-approver\"" return tmpl } diff --git a/cmd/pke/app/phases/kubeadm/controlplane/controlplane.go b/cmd/pke/app/phases/kubeadm/controlplane/controlplane.go index 57835be4..e318d958 100644 --- a/cmd/pke/app/phases/kubeadm/controlplane/controlplane.go +++ b/cmd/pke/app/phases/kubeadm/controlplane/controlplane.go @@ -33,6 +33,10 @@ import ( "emperror.dev/errors" "github.com/Masterminds/semver" + "github.com/lestrrat-go/backoff" + "github.com/spf13/cobra" + "github.com/spf13/pflag" + "github.com/banzaicloud/pke/.gen/pipeline" "github.com/banzaicloud/pke/cmd/pke/app/config" "github.com/banzaicloud/pke/cmd/pke/app/constants" @@ -47,9 +51,6 @@ import ( "github.com/banzaicloud/pke/cmd/pke/app/util/runner" "github.com/banzaicloud/pke/cmd/pke/app/util/transport" "github.com/banzaicloud/pke/cmd/pke/app/util/validator" - "github.com/lestrrat-go/backoff" - "github.com/spf13/cobra" - "github.com/spf13/pflag" ) const ( @@ -92,6 +93,7 @@ type ControlPlane struct { advertiseAddress string apiServerHostPort string clusterName string + nodeName string serviceCIDR string podNetworkCIDR string mtu uint @@ -179,6 +181,8 @@ func (c *ControlPlane) RegisterFlags(flags *pflag.FlagSet) { flags.Uint(constants.FlagMTU, 0, "maximum transmission unit. 0 means default value of the Kubernetes network provider is used") // Kubernetes cluster name flags.String(constants.FlagClusterName, "pke", "Kubernetes cluster name") + // Kubernetes kubadm init node name + flags.String(constants.FlagNodeName, "", "Kubernetes kubeadm node name for init") // Kubernetes certificates flags.StringSlice(constants.FlagAPIServerCertSANs, []string{}, "sets extra Subject Alternative Names for the API Server signing cert") flags.String(constants.FlagControllerManagerSigningCA, "", "Kubernetes Controller Manager signing cert") @@ -504,7 +508,7 @@ func (c *ControlPlane) Run(out io.Writer) error { single = true } // TODO get cilium version from flag - version := "v1.9.1" + version := "v1.11.1" if err := installCilium(out, kubeConfig, c.podNetworkCIDR, c.imageRepository, version, c.mtu, single); err != nil { return err } @@ -627,6 +631,10 @@ func (c *ControlPlane) masterBootstrapParameters(cmd *cobra.Command) (err error) if err != nil { return } + c.nodeName, err = cmd.Flags().GetString(constants.FlagNodeName) + if err != nil { + return + } c.oidcIssuerURL, err = cmd.Flags().GetString(constants.FlagOIDCIssuerURL) if err != nil { return @@ -858,6 +866,11 @@ func (c *ControlPlane) installMaster(out io.Writer) error { "init", "--config=" + kubeadmConfig, } + + if c.cloudProvider == constants.CloudProviderAmazon && c.nodeName != "" { + args = append(args, "--node-name="+c.nodeName) + } + _, err = runner.Cmd(out, cmdKubeadm, args...).CombinedOutputAsync() if err != nil { return err diff --git a/cmd/pke/app/phases/kubeadm/controlplane/controlplane_test.go b/cmd/pke/app/phases/kubeadm/controlplane/controlplane_test.go index 240c2dbb..b595a3ca 100644 --- a/cmd/pke/app/phases/kubeadm/controlplane/controlplane_test.go +++ b/cmd/pke/app/phases/kubeadm/controlplane/controlplane_test.go @@ -21,8 +21,9 @@ import ( "testing" "time" - "github.com/banzaicloud/pke/cmd/pke/app/constants" "github.com/stretchr/testify/require" + + "github.com/banzaicloud/pke/cmd/pke/app/constants" ) func TestWriteKubeadmConfig(t *testing.T) { diff --git a/cmd/pke/app/phases/kubeadm/node/kubeadm.go b/cmd/pke/app/phases/kubeadm/node/kubeadm.go index 8c37efc1..5e507cf2 100644 --- a/cmd/pke/app/phases/kubeadm/node/kubeadm.go +++ b/cmd/pke/app/phases/kubeadm/node/kubeadm.go @@ -22,11 +22,12 @@ import ( "emperror.dev/errors" "github.com/Masterminds/semver" + "github.com/pbnjay/memory" + "github.com/banzaicloud/pke/cmd/pke/app/phases/kubeadm" "github.com/banzaicloud/pke/cmd/pke/app/util/cri" "github.com/banzaicloud/pke/cmd/pke/app/util/file" "github.com/banzaicloud/pke/cmd/pke/app/util/kubernetes" - "github.com/pbnjay/memory" ) //go:generate templify -t ${GOTMPL} -p node -f kubeadmConfigV1Beta2 kubeadm_v1beta2.yaml.tmpl diff --git a/cmd/pke/app/phases/pipeline/ready/ready.go b/cmd/pke/app/phases/pipeline/ready/ready.go index 256bb4ab..84b7e114 100644 --- a/cmd/pke/app/phases/pipeline/ready/ready.go +++ b/cmd/pke/app/phases/pipeline/ready/ready.go @@ -23,14 +23,15 @@ import ( "os" "emperror.dev/errors" + "github.com/spf13/cobra" + "github.com/spf13/pflag" + "github.com/banzaicloud/pke/.gen/pipeline" "github.com/banzaicloud/pke/cmd/pke/app/constants" "github.com/banzaicloud/pke/cmd/pke/app/phases" "github.com/banzaicloud/pke/cmd/pke/app/util/network" pipelineutil "github.com/banzaicloud/pke/cmd/pke/app/util/pipeline" "github.com/banzaicloud/pke/cmd/pke/app/util/validator" - "github.com/spf13/cobra" - "github.com/spf13/pflag" ) const ( diff --git a/cmd/pke/app/phases/runtime/container/containerd_linux.go b/cmd/pke/app/phases/runtime/container/containerd_linux.go index b5591d2b..8c04e72b 100644 --- a/cmd/pke/app/phases/runtime/container/containerd_linux.go +++ b/cmd/pke/app/phases/runtime/container/containerd_linux.go @@ -23,13 +23,14 @@ import ( "text/template" "emperror.dev/errors" + "github.com/banzaicloud/pke/cmd/pke/app/util/file" "github.com/banzaicloud/pke/cmd/pke/app/util/linux" ) const ( - containerdVersion = "1.5.9" - containerdSHA256 = "f64c8e3b736b370c963b08c33ac70f030fc311bc48fcfd00461465af2fff3488" + containerdVersion = "1.6.8" + containerdSHA256 = "8e227caa318faa136e4387ffd6f96baeaad5582d176202fe9da69cde87036033" containerdURL = "https://github.com/containerd/containerd/releases/download/v%s/cri-containerd-cni-%s-linux-amd64.tar.gz" containerdVersionPath = "/opt/containerd/cluster/version" containerdConf = "/etc/containerd/config.toml" @@ -108,8 +109,8 @@ func installContainerd(out io.Writer, imageRepository string) error { return errors.Wrapf(err, "unable to create temporary file: %q", f.Name()) } defer func() { _ = f.Close() }() - // export CONTAINERD_VERSION="1.5.9" - // export CONTAINERD_SHA256="f64c8e3b736b370c963b08c33ac70f030fc311bc48fcfd00461465af2fff3488" + // export CONTAINERD_VERSION="1.6.8" + // export CONTAINERD_SHA256="8e227caa318faa136e4387ffd6f96baeaad5582d176202fe9da69cde87036033" // wget https://github.com/containerd/containerd/releases/download/v${CONTAINERD_VERSION}/cri-containerd-cni-${CONTAINERD_VERSION}-linux-amd64.tar.gz dl := fmt.Sprintf(containerdURL, containerdVersion, containerdVersion) u, err := url.Parse(dl) diff --git a/cmd/pke/app/util/linux/apt.go b/cmd/pke/app/util/linux/apt.go index 22f87020..467cd1c7 100644 --- a/cmd/pke/app/util/linux/apt.go +++ b/cmd/pke/app/util/linux/apt.go @@ -22,6 +22,7 @@ import ( "strings" "emperror.dev/errors" + "github.com/banzaicloud/pke/cmd/pke/app/util/file" "github.com/banzaicloud/pke/cmd/pke/app/util/runner" ) @@ -140,7 +141,7 @@ func mapAptPackageVersion(pkg, kubernetesVersion string) string { return "kubelet=" + getAptPackageVersion(kubernetesVersion) case kubernetescni: - return "kubernetes-cni=0.8.7-00" + return "kubernetes-cni=1.1.1-00" default: return "" diff --git a/cmd/pke/app/util/linux/rpm.go b/cmd/pke/app/util/linux/rpm.go index 99eb5ab7..0ba4f890 100644 --- a/cmd/pke/app/util/linux/rpm.go +++ b/cmd/pke/app/util/linux/rpm.go @@ -19,6 +19,7 @@ import ( "strings" "emperror.dev/errors" + "github.com/banzaicloud/pke/cmd/pke/app/util/runner" ) @@ -28,7 +29,7 @@ const ( kubectl = "kubectl" kubelet = "kubelet" kubernetescni = "kubernetes-cni" - kubernetesCNIVersion = "0.8.7" + kubernetesCNIVersion = "1.1.1" disableExcludesKubernetes = "--disableexcludes=kubernetes" selinuxConfig = "/etc/selinux/config" ) diff --git a/cmd/pke/app/util/pipeline/status.go b/cmd/pke/app/util/pipeline/status.go index aa6b4f9e..7fa5581c 100644 --- a/cmd/pke/app/util/pipeline/status.go +++ b/cmd/pke/app/util/pipeline/status.go @@ -21,9 +21,10 @@ import ( "os" "time" + "github.com/spf13/cobra" + "github.com/banzaicloud/pke/.gen/pipeline" "github.com/banzaicloud/pke/cmd/pke/app/constants" - "github.com/spf13/cobra" ) type pipelineStatusReporter struct {