diff --git a/.gitignore b/.gitignore index a470e245f5..44444c9d60 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ # build and test outputs -/bin/ /_output/ /_artifacts/ @@ -21,7 +20,10 @@ *.sublime-workspace *~ +/bin/.gimme +/bin/cloud-provisioner* deploy-recorder.lst /hack/go /hack/pkg /hack/*.tar.gz +deploy-recorder.lst \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 63cdbb5722..0b59c51710 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 0.17.0-0.1.0 (2023-03-26) +## 0.17.0-0.1.0 (2023-03-31) * Add clusterAPI capabilities for EKS diff --git a/DEPENDENCIES b/DEPENDENCIES index 60ecda5c38..60757906bf 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,25 +1,26 @@ core: kind: - clusterctl: v1.3.2 - cluster-api: v1.3.2 - capi-kubeadm-bootstrap-system: v1.3.2 - capi-kubeadm-control-plane-system: v1.3.2 + clusterctl: v1.4.1 + cluster-api: v1.4.1 + capi-kubeadm-bootstrap-system: v1.4.1 + capi-kubeadm-control-plane-system: v1.4.1 calico: - calicoctl: v3.22.3 + calicoctl: v3.25.1 tigera-operator: v1.25.9 - cluster-autoscaler: 9.25.0 + cluster-autoscaler: 9.28.0 aws: clusterawsadm: v2.0.2 cluster-api-aws: v2.0.2 cluster-api-aws-templates: v2.0.2 - aws-ebs-csi-driver: v1.14.1-eksbuild.1 - vpc-cni: v1.12.1-eksbuild.1 + aws-ebs-csi-driver: v1.17.0-eksbuild.1 + vpc-cni: v1.12.6-eksbuild.1 gcp: - cluster-api-gcp: v1.2.1 - cluster-api-gcp-templates: v1.2.1 - gcp-compute-persistent-disk-csi-driver: v1.7.1 - csi-node-driver-registrar: v2.5.0 - csi-snapshotter: v4.0.1 - csi-resizer: v1.4.0 - csi-attacher: v3.4.0 - csi-provisioner: v3.1.0 + cluster-api-gcp: v1.3.0 + cluster-api-gcp-templates: v1.3.0 + gcp-compute-persistent-disk-csi-driver: v1.9.2 + csi-node-driver-registrar: v2.6.3 + csi-snapshotter: v6.2.1 + csi-resizer: v1.7.0 + csi-attacher: v4.2.0 + csi-provisioner: v3.4.1 + pause: v3.9 diff --git a/Jenkinsfile b/Jenkinsfile index dbed6c1580..a35ef94540 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,9 +10,10 @@ hose { UPSTREAM_VERSION = '0.17.0' DEPLOYONPRS = true GRYPE_TEST = false + MODULE_LIST = [ "paas.cloud-provisioner:cloud-provisioner:tar.gz"] DEV = { config -> doPackage(conf: config, parameters: "GOCACHE=/tmp") - doDeploy(conf:config) + doDeploy(conf: config) } } \ No newline at end of file diff --git a/Makefile b/Makefile index f2e162dc33..369ae056f4 100644 --- a/Makefile +++ b/Makefile @@ -87,7 +87,7 @@ test: # ================================= Cleanup ==================================== # standard cleanup target clean: - rm -rf "$(OUT_DIR)/" + find $(OUT_DIR)/ -name 'cloud-provisioner*' -delete && rm -rf "$(OUT_DIR)/.gimme" ################################################################################ # ============================== Auto-Update =================================== # update generated code, gofmt, etc. @@ -111,16 +111,14 @@ lint: shellcheck: hack/make-rules/verify/shellcheck.sh - - package: - go build -v -o "$(OUT_DIR)/$(KIND_BINARY_NAME)" $(KIND_BUILD_FLAGS) + make build && bin/package.sh $(version) deploy: - hack/custom/deploy.sh + bin/deploy.sh $(version) change-version: - hack/custom/change-version.sh $(version) + bin/change-version.sh $(version) ################################################################################# .PHONY: all kind build install unit clean update generate gofmt verify lint shellcheck \ No newline at end of file diff --git a/hack/custom/change-version.sh b/bin/change-version.sh similarity index 87% rename from hack/custom/change-version.sh rename to bin/change-version.sh index 041e1e6dc1..ceeb23a468 100755 --- a/hack/custom/change-version.sh +++ b/bin/change-version.sh @@ -1,6 +1,6 @@ #!/bin/bash -e -BASEDIR=`dirname $0`/../.. +BASEDIR=`dirname $0`/.. cd $BASEDIR diff --git a/hack/custom/deploy.sh b/bin/deploy.sh similarity index 57% rename from hack/custom/deploy.sh rename to bin/deploy.sh index 620069f0ea..411385abd5 100755 --- a/hack/custom/deploy.sh +++ b/bin/deploy.sh @@ -2,18 +2,17 @@ DIR=bin BASEDIR=`dirname $0`/../.. -VERSION=`cat $BASEDIR/VERSION` +VERSION=$1 EXTENSION="tar.gz" GROUP_ID="repository.paas.cloud-provisioner" GROUP_ID_NEXUS=${GROUP_ID//.//} +FILE="$DIR"/cloud-provisioner-${VERSION}.${EXTENSION} - -if [ -d "$DIR" ] || [ -r "$DIR"/cloud-provisioner]; then +if [ -d "$DIR" ] || [ -r "$FILE" ]; then echo "Uploading cloud-provisioner-$VERSION..." - tar czf "$DIR"/cloud-provisioner-${VERSION}.${EXTENSION} "$DIR"/cloud-provisioner curl -sS -u stratio:${NEXUSPASS} --upload-file "$DIR"/cloud-provisioner-${VERSION}.${EXTENSION} http://qa.int.stratio.com/${GROUP_ID_NEXUS}/ - echo "$GROUP_ID:cloud-provisioner:$EXTENSION" >> "$BASEDIR/deploy-recorder.lst" - rm -rf $BASEDIR/hack/go + echo "$GROUP_ID:cloud-provisioner:$EXTENSION" >> "$BASEDIR/deploy-recorder.lst" + rm -rf $BASEDIR/hack/go else echo "Run 'make build' first" exit 1 diff --git a/bin/package.sh b/bin/package.sh new file mode 100755 index 0000000000..c7de5e2f52 --- /dev/null +++ b/bin/package.sh @@ -0,0 +1,14 @@ +#!/bin/bash -e + +DIR=bin +BASEDIR=`dirname $0`/../.. +VERSION=$1 +EXTENSION="tar.gz" + +if [ -d "$DIR" ] || [ -r "$DIR"/cloud-provisioner]; then + echo "Packaging cloud-provisioner-$VERSION..." + tar czf "$DIR"/cloud-provisioner-${VERSION}.${EXTENSION} "$DIR"/cloud-provisioner +else + echo "Run 'make build' first" + exit 1 +fi \ No newline at end of file diff --git a/docs/cloud-provisioner/Versiones.md b/docs/cloud-provisioner/Versiones.md new file mode 100644 index 0000000000..dce06544ff --- /dev/null +++ b/docs/cloud-provisioner/Versiones.md @@ -0,0 +1,153 @@ +# Actualización de versiones + +> [kindest/node](https://hub.docker.com/r/kindest/node/tags) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v1.24.7 | 2022-10-26 | v1.27.0 | 2022-04-11 | + +Files: +* pkg/apis/config/defaults/image.go +* pkg/cluster/internal/providers/docker/stratio/Dockerfile + +> [clusterctl](https://github.com/kubernetes-sigs/cluster-api/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v1.3.2 | 2023-01-10 | v1.4.1 | 2023-04-04 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/providers/docker/stratio/Dockerfile +* pkg/cluster/internal/create/actions/createworker/provider.go + +> [clusterawsadm](https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v2.0.2 | 2022-12-01 | v2.0.2 | 2022-12-01 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/providers/docker/stratio/Dockerfile +* pkg/cluster/internal/create/actions/createworker/aws.go + +> [Helm](https://github.com/helm/helm/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v3.11.0 | 2022-01-18 | v3.11.3 | 2023-04-12 | + +Files: +* pkg/cluster/internal/providers/docker/stratio/Dockerfile + +> [cluster_auto_scaler](https://github.com/kubernetes/autoscaler/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v9.25.0 | 2022-02-21 | v9.28.0 | 2023-04-04 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/providers/docker/stratio/Dockerfile + +> [Tigera_operator](https://github.com/projectcalico/calico/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v3.22.3 | 2022-05-21 | v3.25.1 | 2023-03-31 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/providers/docker/stratio/Dockerfile +* pkg/cluster/internal/create/actions/createworker/templates/calico-helm-values.tmpl + +> [aws-ebs-csi-driver](https://github.com/kubernetes-sigs/aws-ebs-csi-driver/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v1.14.1-eksbuild.1 | 2022-01-05 | v1.17.0 | 2023-03-14 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/create/actions/cluster/templates/aws.eks.tmpl + +> [vpc-cni](https://github.com/aws/amazon-vpc-cni-k8s/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v1.12.1-eksbuild.1 | 2023-01-05 | v1.12.6-eksbuild.1 | 2023-03-20 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/create/actions/cluster/templates/aws.eks.tmpl + +> [cluster-api-gcp / cluster-api-gcp-templates](https://github.com/kubernetes-sigs/cluster-api-provider-gcp/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v1.2.1 | 2022-11-28 | v1.3.0 | 2023-03-17 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/create/actions/createworker/gcp.go + +> [gcp-compute-persistent-disk-csi-driver](https://github.com/kubernetes-sigs/gcp-compute-persistent-disk-csi-driver/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v1.7.1 | 2022-01-09 | v1.9.2 | 2022-03-17 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/create/actions/createworker/files/gcp-compute-persistent-disk-csi-driver.yaml + +> [csi-node-driver-registrar](https://github.com/kubernetes-csi/node-driver-registrar/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v2.5.0 | 2022-02-03 | v2.6.3 | 2023-01-24 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/create/actions/createworker/files/gcp-compute-persistent-disk-csi-driver.yaml + +> [csi-snapshotter](https://github.com/kubernetes-csi/external-snapshotter/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v4.0.1 | 2022-02-10 | v6.2.1 | 2023-01-04 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/create/actions/createworker/files/gcp-compute-persistent-disk-csi-driver.yaml + +> [csi-resizer](https://github.com/kubernetes-csi/external-resizer/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v1.4.0 | 2022-01-21 | v1.7.0 | 2022-12-28 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/create/actions/createworker/files/gcp-compute-persistent-disk-csi-driver.yaml + +> [csi-attacher]() + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v3.4.0 | 2021-12-21 | v4.2.0 | 2023-02-01 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/create/actions/createworker/files/gcp-compute-persistent-disk-csi-driver.yaml + +> [csi-provisioner](https://github.com/kubernetes-csi/external-provisioner/releases) + +| Version | Release Date | Latest Version | Latest Release Date | +| ------- | ------------ | -------------- | ------------------- | +| v3.1.0 | 2022-01-12 | v3.4.1 | 2023-04-05 | + +Files: +* DEPENDENCIES +* pkg/cluster/internal/create/actions/createworker/files/gcp-compute-persistent-disk-csi-driver.yaml \ No newline at end of file diff --git a/pkg/apis/config/defaults/image.go b/pkg/apis/config/defaults/image.go index 65bc5edb21..5367245fab 100644 --- a/pkg/apis/config/defaults/image.go +++ b/pkg/apis/config/defaults/image.go @@ -18,7 +18,7 @@ limitations under the License. package defaults // Image is the default for the Config.Image field, aka the default node image. -const Image = "kindest/node:v1.24.7@sha256:5c015142d9b60a0f6c45573f809957076514e38ec973565e2b2fe828b91597f5" +const Image = "kindest/node:v1.27.0@sha256:bac1b0e00322ba0269a5811fb574dab91f93176d9f00cec3b3eb0832beb1ce84" // StratioImage is the extended Image for Stratio KEOS -const StratioImage = "stratio-capi:v1.24.7" +const StratioImage = "stratio-capi:v1.27.0" diff --git a/pkg/cluster/internal/create/actions/cluster/cluster.go b/pkg/cluster/internal/create/actions/cluster/cluster.go index c84d48a778..ed142ebdab 100644 --- a/pkg/cluster/internal/create/actions/cluster/cluster.go +++ b/pkg/cluster/internal/create/actions/cluster/cluster.go @@ -37,7 +37,7 @@ type K8sObject struct { Spec DescriptorFile `yaml:"spec" validate:"required,dive"` } -// DescriptorFile represents the YAML structure in the descriptor file +// DescriptorFile represents the YAML structure in the spec field of the descriptor file type DescriptorFile struct { ClusterID string `yaml:"cluster_id" validate:"required,min=3,max=100"` DeployAutoscaler bool `yaml:"deploy_autoscaler" validate:"boolean"` @@ -48,15 +48,13 @@ type DescriptorFile struct { InfraProvider string `yaml:"infra_provider" validate:"required,oneof='aws' 'gcp' 'azure'"` - K8SVersion string `yaml:"k8s_version" validate:"required,startswith=v,min=7,max=8"` - Region string `yaml:"region" validate:"required"` - SSHKey string `yaml:"ssh_key"` - FullyPrivate bool `yaml:"fully_private" validate:"boolean"` + K8SVersion string `yaml:"k8s_version" validate:"required,startswith=v,min=7,max=8"` + Region string `yaml:"region" validate:"required"` Networks Networks `yaml:"networks"` Dns struct { - HostedZones bool `yaml:"hosted_zones" validate:"boolean"` + ManageZone bool `yaml:"manage_zone" validate:"boolean"` } `yaml:"dns"` DockerRegistries []DockerRegistry `yaml:"docker_registries" validate:"dive"` @@ -64,7 +62,8 @@ type DescriptorFile struct { ExternalDomain string `yaml:"external_domain" validate:"omitempty,hostname"` Keos struct { - Domain string `yaml:"domain" validate:"required,hostname"` + // PR fixing exclude_if behaviour https://github.com/go-playground/validator/pull/939 + Domain string `yaml:"domain" validate:"omitempty,hostname"` Flavour string `yaml:"flavour"` Version string `yaml:"version"` } `yaml:"keos"` @@ -72,10 +71,9 @@ type DescriptorFile struct { ControlPlane struct { Managed bool `yaml:"managed" validate:"boolean"` Name string `yaml:"name"` - AmiID string `yaml:"ami_id"` + NodeImage string `yaml:"node_image" validate:"required_if=InfraProvider gcp"` HighlyAvailable bool `yaml:"highly_available" validate:"boolean"` Size string `yaml:"size" validate:"required_if=Managed false"` - Image string `yaml:"image" validate:"required_if=InfraProvider gcp"` RootVolume struct { Size int `yaml:"size" validate:"numeric"` Type string `yaml:"type"` @@ -121,10 +119,9 @@ type AWS struct { type WorkerNodes []struct { Name string `yaml:"name" validate:"required"` - AmiID string `yaml:"ami_id"` + NodeImage string `yaml:"node_image" validate:"required_if=InfraProvider gcp"` Quantity int `yaml:"quantity" validate:"required,numeric,gt=0"` Size string `yaml:"size" validate:"required"` - Image string `yaml:"image" validate:"required_if=InfraProvider gcp"` ZoneDistribution string `yaml:"zone_distribution" validate:"omitempty,oneof='balanced' 'unbalanced'"` AZ string `yaml:"az"` SSHKey string `yaml:"ssh_key"` @@ -143,9 +140,10 @@ type WorkerNodes []struct { // Bastion represents the bastion VM type Bastion struct { - AmiID string `yaml:"ami_id"` + NodeImage string `yaml:"node_image"` VMSize string `yaml:"vm_size"` AllowedCIDRBlocks []string `yaml:"allowedCIDRBlocks"` + SSHKey string `yaml:"ssh_key"` } type Node struct { @@ -213,7 +211,6 @@ type Taint struct { // Init sets default values for the DescriptorFile func (d DescriptorFile) Init() DescriptorFile { - d.FullyPrivate = false d.ControlPlane.HighlyAvailable = true // Autoscaler @@ -227,8 +224,8 @@ func (d DescriptorFile) Init() DescriptorFile { d.ControlPlane.AWS.Logging.ControllerManager = false d.ControlPlane.AWS.Logging.Scheduler = false - // Hosted zones - d.Dns.HostedZones = true + // Managed zones + d.Dns.ManageZone = true return d } @@ -305,8 +302,7 @@ func GetClusterManifest(flavor string, params TemplateParams, azs []string) (str return !reflect.ValueOf(v).IsZero() }, "lastElement": func(element int, len int) bool { - element += element - return element == len + return element < len }, } diff --git a/pkg/cluster/internal/create/actions/cluster/templates/aws.eks.tmpl b/pkg/cluster/internal/create/actions/cluster/templates/aws.eks.tmpl index 3f1f43cd6c..221d31c501 100644 --- a/pkg/cluster/internal/create/actions/cluster/templates/aws.eks.tmpl +++ b/pkg/cluster/internal/create/actions/cluster/templates/aws.eks.tmpl @@ -32,9 +32,9 @@ metadata: spec: addons: - name: "aws-ebs-csi-driver" - version: "v1.14.1-eksbuild.1" + version: "v1.17.0-eksbuild.1" - name: "vpc-cni" - version: "v1.12.1-eksbuild.1" + version: "v1.12.6-eksbuild.1" conflictResolution: "overwrite" associateOIDCProvider: {{ .Descriptor.ControlPlane.AWS.AssociateOIDCProvider }} eksClusterName: "{{ .Descriptor.ClusterID }}" @@ -88,7 +88,7 @@ spec: {{- end }} {{- end }} region: "{{ .Descriptor.Region }}" - sshKeyName: \"{{ .Descriptor.SSHKey }}\" + sshKeyName: \"{{ .Descriptor.Bastion.SSHKey }}\" version: "{{ .Descriptor.K8SVersion }}" vpcCni: env: @@ -142,9 +142,9 @@ spec: spotMarketOptions: maxPrice: \"\" {{- end }} - {{- if ne $node.AmiID "" }} + {{- if ne $node.NodeImage "" }} ami: - id: {{ $node.AmiID }} + id: {{ $node.NodeImage }} {{- end }} iamInstanceProfile: "nodes.cluster-api-provider-aws.sigs.k8s.io" instanceType: "{{ $node.Size }}" @@ -194,12 +194,14 @@ spec: - {{ $vol.MountPath }} {{- end }} {{- end }} + {{- if or (gt (len $node.Labels) 0) (gt (len $node.Taints) 0) }} kubeletExtraArgs: - {{- if or $node.Labels ( gt (len $node.Taints) 0)}} + {{- if gt (len $node.Labels) 0 }} node-labels: \"{{ range $key, $value := $node.Labels }}{{ $key }}={{ $value }},{{- end }}\" - {{- end }} - {{- if gt (len $node.Taints) 0 }} - register-with-taints: \"{{ range $i, $taint := $node.Taints }}{{$taint.Key}}={{$taint.Value}}:{{$taint.Effect}}{{ $len := len $node.Taints }}{{- if lastElement $i $len }}{{- else }},{{- end }}{{- end }}\" + {{- end }} + {{- if gt (len $node.Taints) 0 }} + register-with-taints: \"{{ range $i, $taint := $node.Taints }}{{ $taint.Key }}={{ $taint.Value }}:{{ $taint.Effect }}{{ $len := len $node.Taints }}{{- if lastElement $i $len }}{{- else }},{{- end }}{{- end }}\" + {{- end }} {{- end }} {{- end }} {{- end }} diff --git a/pkg/cluster/internal/create/actions/cluster/templates/gcp.tmpl b/pkg/cluster/internal/create/actions/cluster/templates/gcp.tmpl index b1fb90aa47..a8b4e508ca 100644 --- a/pkg/cluster/internal/create/actions/cluster/templates/gcp.tmpl +++ b/pkg/cluster/internal/create/actions/cluster/templates/gcp.tmpl @@ -36,7 +36,7 @@ spec: region: "{{ $.Descriptor.Region }}" {{- if ne .CidrBlock "" }} cidrBlock: {{ .CidrBlock }} - {{- end }} + {{- end }} {{- end }} {{- end }} {{- else }} @@ -53,7 +53,7 @@ spec: replicas: {{- if .Descriptor.ControlPlane.HighlyAvailable }} 3 {{- else }} 1 {{- end }} machineTemplate: metadata: - labels: + labels: keos.stratio.com/machine-role: "{{ $.Descriptor.ClusterID }}-control-plane-node" infrastructureRef: kind: GCPMachineTemplate @@ -81,21 +81,31 @@ spec: name: gce-conf pathType: FileOrCreate files: - {{- if .DockerRegistries }} + - content: | + [Global] + multizone=true + path: /etc/kubernetes/gce.conf + {{- if gt (len .DockerRegistries) 0 }} - content: | version = 2 imports = [\"/etc/containerd/conf.d/*.toml\"] [plugins] [plugins.\"io.containerd.grpc.v1.cri\"] - sandbox_image = \"k8s.gcr.io/pause:3.6\" + sandbox_image = \"k8s.gcr.io/pause:3.9\" [plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.runc] runtime_type = \"io.containerd.runc.v2\" - [plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.runc.options] - SystemdCgroup = true + [plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.runc.options] + SystemdCgroup = true [plugins.\"io.containerd.grpc.v1.cri\".registry] [plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors] [plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"docker.io\"] endpoint = [\"https://registry-1.docker.io\"] + {{- range $reg := .DockerRegistries }} + {{- $url := hostname $reg.url }} + [plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"{{ $url }}\"] + endpoint = [\"https://{{ $url }}\"] + {{- end }} + [plugins.\"io.containerd.grpc.v1.cri\".registry.configs] {{- range $reg := .DockerRegistries }} {{- $url := hostname $reg.url }} [plugins.\"io.containerd.grpc.v1.cri\".registry.configs.\"{{ $url }}\".auth] @@ -103,11 +113,9 @@ spec: username = \"{{ $reg.user }}\" {{- end }} path: /etc/containerd/config.toml - {{- end }} - - content: | - [Global] - multizone=true - path: /etc/kubernetes/gce.conf + postKubeadmCommands: + - systemctl restart containerd + {{- end }} {{- if .Descriptor.ControlPlane.ExtraVolumes }} diskSetup: filesystems: @@ -145,7 +153,7 @@ spec: template: spec: instanceType: "{{ .Descriptor.ControlPlane.Size }}" - image: "{{ .Descriptor.ControlPlane.Image }}" + image: "{{ .Descriptor.ControlPlane.NodeImage }}" {{- if .Descriptor.ControlPlane.RootVolume.Size }} rootDeviceSize: {{ .Descriptor.ControlPlane.RootVolume.Size }} {{- end }} @@ -182,7 +190,7 @@ spec: matchLabels: template: metadata: - labels: + labels: keos.stratio.com/machine-role: "{{ $.Descriptor.ClusterID }}-worker-node" spec: clusterName: "{{ $.Descriptor.ClusterID }}" @@ -207,7 +215,7 @@ spec: template: spec: instanceType: "{{ $node.Size }}" - image: "{{ $node.Image }}" + image: "{{ $node.NodeImage }}" {{- if $node.RootVolume.Size }} rootDeviceSize: {{ $node.RootVolume.Size }} {{- end }} @@ -233,22 +241,28 @@ metadata: spec: template: spec: - {{- if $.DockerRegistries }} + {{- if gt (len $.DockerRegistries) 0 }} files: - content: | version = 2 imports = [\"/etc/containerd/conf.d/*.toml\"] [plugins] [plugins.\"io.containerd.grpc.v1.cri\"] - sandbox_image = \"k8s.gcr.io/pause:3.6\" + sandbox_image = \"k8s.gcr.io/pause:3.9\" [plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.runc] runtime_type = \"io.containerd.runc.v2\" - [plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.runc.options] - SystemdCgroup = true + [plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.runc.options] + SystemdCgroup = true [plugins.\"io.containerd.grpc.v1.cri\".registry] [plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors] [plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"docker.io\"] endpoint = [\"https://registry-1.docker.io\"] + {{- range $reg := $.DockerRegistries }} + {{- $url := hostname $reg.url }} + [plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"{{ $url }}\"] + endpoint = [\"https://{{ $url }}\"] + {{- end }} + [plugins.\"io.containerd.grpc.v1.cri\".registry.configs] {{- range $reg := $.DockerRegistries }} {{- $url := hostname $reg.url }} [plugins.\"io.containerd.grpc.v1.cri\".registry.configs.\"{{ $url }}\".auth] @@ -256,7 +270,9 @@ spec: username = \"{{ $reg.user }}\" {{- end }} path: /etc/containerd/config.toml - {{- end }} + postKubeadmCommands: + - systemctl restart containerd + {{- end }} {{- if $node.ExtraVolumes }} diskSetup: filesystems: @@ -283,11 +299,11 @@ spec: name: {{`'{{ ds.meta_data.local_hostname.split(\".\")[0] }}'`}} kubeletExtraArgs: cloud-provider: gce - {{- if $node.Labels }} + {{- if gt (len $node.Labels) 0 }} node-labels: \"{{ range $key, $value := $node.Labels }}{{ $key }}={{ $value }},{{- end }}\" {{- end }} {{- if gt (len $node.Taints) 0 }} - register-with-taints: \"{{ range $i, $taint := $node.Taints }}{{$taint.Key}}={{$taint.Value}}:{{$taint.Effect}}{{ $len := len $node.Taints }}{{- if lastElement $i $len }}{{- else }},{{- end }}{{- end }}\" + register-with-taints: \"{{ range $i, $taint := $node.Taints }}{{ $taint.Key }}={{ $taint.Value }}:{{ $taint.Effect }}{{ $len := len $node.Taints }}{{- if lastElement $i $len }}{{- else }},{{- end }}{{- end }}\" {{- end }} {{- end }} {{- end }} diff --git a/pkg/cluster/internal/create/actions/createworker/aws.go b/pkg/cluster/internal/create/actions/createworker/aws.go index 3758e40e86..188803d3bc 100644 --- a/pkg/cluster/internal/create/actions/createworker/aws.go +++ b/pkg/cluster/internal/create/actions/createworker/aws.go @@ -47,7 +47,7 @@ func newAWSBuilder() *AWSBuilder { func (b *AWSBuilder) setCapx(managed bool) { b.capxProvider = "aws" b.capxVersion = "v2.0.2" - b.capxImageVersion = "2.0.2-0.1.0-abc39a5" + b.capxImageVersion = "2.0.2-0.1.0" b.capxName = "capa" b.stClassName = "gp2" if managed { diff --git a/pkg/cluster/internal/create/actions/createworker/createworker.go b/pkg/cluster/internal/create/actions/createworker/createworker.go index dd9e90433e..7e5498752e 100644 --- a/pkg/cluster/internal/create/actions/createworker/createworker.go +++ b/pkg/cluster/internal/create/actions/createworker/createworker.go @@ -257,19 +257,26 @@ func (a *action) Execute(ctx *actions.ActionContext) error { return errors.Wrap(err, "failed to create the worker Cluster") } - // Get the workload cluster kubeconfig + // Wait for the control plane initialization raw = bytes.Buffer{} - cmd = node.Command("sh", "-c", "clusterctl -n "+capiClustersNamespace+" get kubeconfig "+descriptorFile.ClusterID+" | tee "+kubeconfigPath) + cmd = node.Command("kubectl", "-n", capiClustersNamespace, "wait", "--for=condition=ControlPlaneInitialized", "--timeout", "5m", "cluster", descriptorFile.ClusterID) if err := cmd.SetStdout(&raw).Run(); err != nil { - return errors.Wrap(err, "failed to get workload cluster kubeconfig") + return errors.Wrap(err, "failed to create the worker Cluster") } - kubeconfig := raw.String() ctx.Status.End(true) // End Creating the workload cluster ctx.Status.Start("Saving the workload cluster kubeconfig 📝") defer ctx.Status.End(false) + // Get the workload cluster kubeconfig + raw = bytes.Buffer{} + cmd = node.Command("sh", "-c", "clusterctl -n "+capiClustersNamespace+" get kubeconfig "+descriptorFile.ClusterID+" | tee "+kubeconfigPath) + if err := cmd.SetStdout(&raw).SetStderr(&raw).Run(); err != nil || strings.Contains(raw.String(), "Error:") || raw.String() == "" { + return errors.Wrap(err, "failed to get workload cluster kubeconfig") + } + kubeconfig := raw.String() + workKubeconfigBasePath := strings.Split(workKubeconfigPath, "/")[0] _, err = os.Stat(workKubeconfigBasePath) if err != nil { diff --git a/pkg/cluster/internal/create/actions/createworker/files/gcp-compute-persistent-disk-csi-driver.yaml b/pkg/cluster/internal/create/actions/createworker/files/gcp-compute-persistent-disk-csi-driver.yaml index 884648e693..4911dbe35e 100644 --- a/pkg/cluster/internal/create/actions/createworker/files/gcp-compute-persistent-disk-csi-driver.yaml +++ b/pkg/cluster/internal/create/actions/createworker/files/gcp-compute-persistent-disk-csi-driver.yaml @@ -541,7 +541,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: k8s.gcr.io/sig-storage/csi-provisioner:v3.1.0 + image: k8s.gcr.io/sig-storage/csi-provisioner:v3.4.1 livenessProbe: failureThreshold: 1 httpGet: @@ -570,7 +570,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: k8s.gcr.io/sig-storage/csi-attacher:v3.4.0 + image: k8s.gcr.io/sig-storage/csi-attacher:v4.2.0 livenessProbe: failureThreshold: 1 httpGet: @@ -599,7 +599,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: k8s.gcr.io/sig-storage/csi-resizer:v1.4.0 + image: k8s.gcr.io/sig-storage/csi-resizer:v1.7.0 livenessProbe: failureThreshold: 1 httpGet: @@ -628,7 +628,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - image: k8s.gcr.io/sig-storage/csi-snapshotter:v4.0.1 + image: k8s.gcr.io/sig-storage/csi-snapshotter:v6.2.1 name: csi-snapshotter volumeMounts: - mountPath: /csi @@ -639,7 +639,7 @@ spec: env: - name: GOOGLE_APPLICATION_CREDENTIALS value: /etc/cloud-sa/cloud-sa.json - image: k8s.gcr.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver:v1.7.1 + image: k8s.gcr.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver:v1.9.2 name: gce-pd-driver volumeMounts: - mountPath: /csi @@ -683,7 +683,7 @@ spec: valueFrom: fieldRef: fieldPath: spec.nodeName - image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.5.0 + image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.6.3 name: csi-driver-registrar volumeMounts: - mountPath: /csi @@ -694,7 +694,7 @@ spec: - --v=5 - --endpoint=unix:/csi/csi.sock - --run-controller-service=false - image: k8s.gcr.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver:v1.7.1 + image: k8s.gcr.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver:v1.9.2 name: gce-pd-driver securityContext: privileged: true @@ -779,7 +779,7 @@ spec: valueFrom: fieldRef: fieldPath: spec.nodeName - image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.5.0 + image: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.6.3 name: csi-driver-registrar volumeMounts: - mountPath: /csi @@ -790,7 +790,7 @@ spec: - --v=5 - --endpoint=unix:/csi/csi.sock - --run-controller-service=false - image: k8s.gcr.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver:v1.7.1 + image: k8s.gcr.io/cloud-provider-gcp/gcp-compute-persistent-disk-csi-driver:v1.9.2 name: gce-pd-driver volumeMounts: - mountPath: C:\var\lib\kubelet diff --git a/pkg/cluster/internal/create/actions/createworker/gcp.go b/pkg/cluster/internal/create/actions/createworker/gcp.go index d3c2fad545..22eeea9078 100644 --- a/pkg/cluster/internal/create/actions/createworker/gcp.go +++ b/pkg/cluster/internal/create/actions/createworker/gcp.go @@ -53,8 +53,8 @@ func newGCPBuilder() *GCPBuilder { func (b *GCPBuilder) setCapx(managed bool) { b.capxProvider = "gcp" - b.capxVersion = "v1.2.1" - b.capxImageVersion = "v1.2.1" + b.capxVersion = "v1.3.0" + b.capxImageVersion = "v1.3.0" b.capxName = "capg" b.stClassName = "csi-gcp-pd" if managed { diff --git a/pkg/cluster/internal/create/actions/createworker/keosinstaller.go b/pkg/cluster/internal/create/actions/createworker/keosinstaller.go index cdf2a1e29c..91392eb50c 100644 --- a/pkg/cluster/internal/create/actions/createworker/keosinstaller.go +++ b/pkg/cluster/internal/create/actions/createworker/keosinstaller.go @@ -39,17 +39,18 @@ type KEOSDescriptor struct { } `yaml:"gcp,omitempty"` Keos struct { Calico struct { - Ipip bool `yaml:"ipip"` - Pool string `yaml:"pool"` + Ipip bool `yaml:"ipip,omitempty"` + Pool string `yaml:"pool,omitempty"` DeployTigeraOperator bool `yaml:"deploy_tigera_operator"` - } `yaml:"calico,omitempty"` + } `yaml:"calico"` ClusterID string `yaml:"cluster_id"` Dns struct { ExternalDns struct { Enabled *bool `yaml:"enabled,omitempty"` } `yaml:"external_dns,omitempty"` } `yaml:"dns,omitempty"` - Domain string `yaml:"domain"` + // PR fixing exclude_if behaviour https://github.com/go-playground/validator/pull/939 + Domain string `yaml:"domain,omitempty"` ExternalDomain string `yaml:"external_domain,omitempty"` Flavour string `yaml:"flavour"` K8sInstallation bool `yaml:"k8s_installation"` @@ -88,7 +89,11 @@ func createKEOSDescriptor(descriptorFile cluster.DescriptorFile, storageClass st // Keos keosDescriptor.Keos.ClusterID = descriptorFile.ClusterID - keosDescriptor.Keos.Domain = descriptorFile.Keos.Domain + if descriptorFile.InfraProvider == "aws" { + keosDescriptor.Keos.Domain = "cluster.local" + } else if descriptorFile.Keos.Domain != "" { + keosDescriptor.Keos.Domain = descriptorFile.Keos.Domain + } if descriptorFile.ExternalDomain != "" { keosDescriptor.Keos.ExternalDomain = descriptorFile.ExternalDomain } @@ -106,8 +111,8 @@ func createKEOSDescriptor(descriptorFile cluster.DescriptorFile, storageClass st keosDescriptor.Keos.Storage.Providers = []string{"custom"} // Keos - External dns - if !descriptorFile.Dns.HostedZones { - keosDescriptor.Keos.Dns.ExternalDns.Enabled = &descriptorFile.Dns.HostedZones + if !descriptorFile.Dns.ManageZone { + keosDescriptor.Keos.Dns.ExternalDns.Enabled = &descriptorFile.Dns.ManageZone } keosYAMLData, err := yaml.Marshal(keosDescriptor) diff --git a/pkg/cluster/internal/create/actions/createworker/provider.go b/pkg/cluster/internal/create/actions/createworker/provider.go index 6b0406f46b..2d785d7dd5 100644 --- a/pkg/cluster/internal/create/actions/createworker/provider.go +++ b/pkg/cluster/internal/create/actions/createworker/provider.go @@ -26,9 +26,9 @@ import ( ) const ( - CAPICoreProvider = "cluster-api:v1.3.2" - CAPIBootstrapProvider = "kubeadm:v1.3.2" - CAPIControlPlaneProvider = "kubeadm:v1.3.2" + CAPICoreProvider = "cluster-api:v1.4.1" + CAPIBootstrapProvider = "kubeadm:v1.4.1" + CAPIControlPlaneProvider = "kubeadm:v1.4.1" //CAPILocalRepository = "/root/.cluster-api/local-repository" CalicoName = "calico" diff --git a/pkg/cluster/internal/create/actions/createworker/templates/calico-helm-values.tmpl b/pkg/cluster/internal/create/actions/createworker/templates/calico-helm-values.tmpl index 04201354ca..4f57052286 100644 --- a/pkg/cluster/internal/create/actions/createworker/templates/calico-helm-values.tmpl +++ b/pkg/cluster/internal/create/actions/createworker/templates/calico-helm-values.tmpl @@ -3,7 +3,7 @@ apiServer: enabled: false calicoctl: image: docker.io/calico/ctl - tag: v3.22.3 + tag: v3.25.1 certs: node: cert: diff --git a/pkg/cluster/internal/create/actions/createworker/utils.go b/pkg/cluster/internal/create/actions/createworker/utils.go index 0a1fc645b0..7302450bcf 100644 --- a/pkg/cluster/internal/create/actions/createworker/utils.go +++ b/pkg/cluster/internal/create/actions/createworker/utils.go @@ -331,7 +331,7 @@ func rewriteDescriptorFile(descriptorPath string) error { return err } - yamlNodes := removeKey(data.Content, "credentials") + yamlNodes := removeNodesUnderKey(data.Content, "spec", "credentials") b, err := yaml.Marshal(yamlNodes[0]) @@ -491,3 +491,35 @@ func getEcrAuthToken(p ProviderParams) (string, error) { parts := strings.SplitN(string(data), ":", 2) return parts[1], nil } + +func removeNodesUnderKey(nodes []*yaml.Node, parentKey string, childKey string) []*yaml.Node { + for i, node := range nodes { + if node.Kind == yaml.MappingNode { + for j := 0; j < len(node.Content); j += 2 { + keyNode := node.Content[j] + valueNode := node.Content[j+1] + if keyNode.Value == parentKey { + // Se encontró el nodo padre. + if valueNode.Kind == yaml.MappingNode { + // Eliminar todos los nodos que coincidan con la key debajo del nodo padre. + for k := 0; k < len(valueNode.Content); k += 2 { + childKeyNode := valueNode.Content[k] + if childKeyNode.Value == childKey { + valueNode.Content = append(valueNode.Content[:k], valueNode.Content[k+2:]...) + k -= 2 // Se elimina un par clave-valor, por lo que debemos retroceder el índice. + } + } + } + break // Ya no es necesario continuar buscando. + } else { + removeNodesUnderKey([]*yaml.Node{valueNode}, parentKey, childKey) // Buscar recursivamente en los nodos hijos. + } + } + nodes[i].Content = removeNodesUnderKey(node.Content, parentKey, childKey) + } else if node.Kind == yaml.SequenceNode { + // Buscar recursivamente en los elementos de la secuencia. + nodes[i].Content = removeNodesUnderKey(node.Content, parentKey, childKey) + } + } + return nodes +} diff --git a/pkg/cluster/internal/providers/docker/stratio/Dockerfile b/pkg/cluster/internal/providers/docker/stratio/Dockerfile index 0c18680898..c20ac8a1df 100644 --- a/pkg/cluster/internal/providers/docker/stratio/Dockerfile +++ b/pkg/cluster/internal/providers/docker/stratio/Dockerfile @@ -1,16 +1,16 @@ -FROM kindest/node:v1.24.7 +FROM kindest/node:v1.27.0 # Init feature gates ENV CLUSTER_TOPOLOGY=true # Tools versions -ENV CLUSTERCTL=v1.3.2 +ENV CLUSTERCTL=v1.4.1 ENV CLUSTERAWSADM=v2.0.2 -ENV HELM_VERSION=v3.11.0 +ENV HELM_VERSION=v3.11.3 # Helm charts -ENV CLUSTER_AUTOSCALER=9.25.0 -ENV TIGERA_OPERATOR=v3.22.3 +ENV CLUSTER_AUTOSCALER=9.28.0 +ENV TIGERA_OPERATOR=v3.25.1 # Cluster-api artifacts ENV CAPI_REPO=/root/.cluster-api/local-repository