diff --git a/templates/cluster/aws-standalone-cp-0-0-2/.helmignore b/templates/cluster/aws-standalone-cp-0-0-2/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/templates/cluster/aws-standalone-cp-0-0-2/Chart.yaml b/templates/cluster/aws-standalone-cp-0-0-2/Chart.yaml new file mode 100644 index 000000000..7da0bf4ec --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/Chart.yaml @@ -0,0 +1,23 @@ +apiVersion: v2 +name: aws-standalone-cp +description: | + An HMC template to deploy a k0s cluster on AWS with bootstrapped control plane nodes. + Upgrade sequences: + * 0.0.1 -> 0.0.2 + Diff: + * aws-ebs-csi-driver: bumped 2.33.0 -> 2.35.1 + * aws-cloud-controller-manager: enabled more verbose logging (v=2 -> v=10) +type: application +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.2 +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.31.1+k0s.0" +annotations: + hmc.mirantis.com/infrastructure-providers: aws + hmc.mirantis.com/control-plane-providers: k0s + hmc.mirantis.com/bootstrap-providers: k0s diff --git a/templates/cluster/aws-standalone-cp-0-0-2/README.md b/templates/cluster/aws-standalone-cp-0-0-2/README.md new file mode 100644 index 000000000..268e26297 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/README.md @@ -0,0 +1,11 @@ +## Install applications into Target Cluster + +To install applications into the target cluster created using Cluster API (CAPI) upon creation, a Flux `HelmRelease` object is to be made such that its `.spec.KubeConfig` references the kubeconfig of the target cluster. + +**Reference:** https://fluxcd.io/flux/components/helm/helmreleases/#remote-clusters--cluster-api + +This chart/template already defines the following applications under `templates/beachheadservices` which can be be installed into the target cluster by setting `.Values.installBeachHeadServices=true`: +1. cert-manager +2. nginx-ingress + +**Important:** The Flux objects added to `templates/beachheadservices` to install custom applications must have the `hmc.mirantis.com/managed: "true"` label to be reconciled by HMC. diff --git a/templates/cluster/aws-standalone-cp-0-0-2/templates/_helpers.tpl b/templates/cluster/aws-standalone-cp-0-0-2/templates/_helpers.tpl new file mode 100644 index 000000000..b78d81324 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/templates/_helpers.tpl @@ -0,0 +1,23 @@ +{{- define "cluster.name" -}} + {{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "awsmachinetemplate.controlplane.name" -}} + {{- include "cluster.name" . }}-cp-mt +{{- end }} + +{{- define "awsmachinetemplate.worker.name" -}} + {{- include "cluster.name" . }}-worker-mt +{{- end }} + +{{- define "k0scontrolplane.name" -}} + {{- include "cluster.name" . }}-cp +{{- end }} + +{{- define "k0sworkerconfigtemplate.name" -}} + {{- include "cluster.name" . }}-machine-config +{{- end }} + +{{- define "machinedeployment.name" -}} + {{- include "cluster.name" . }}-md +{{- end }} diff --git a/templates/cluster/aws-standalone-cp-0-0-2/templates/awscluster.yaml b/templates/cluster/aws-standalone-cp-0-0-2/templates/awscluster.yaml new file mode 100644 index 000000000..7b098d678 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/templates/awscluster.yaml @@ -0,0 +1,26 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: AWSCluster +metadata: + name: {{ include "cluster.name" . }} + annotations: + aws.cluster.x-k8s.io/external-resource-gc: "true" +spec: + region: {{ .Values.region }} + identityRef: + kind: {{ .Values.clusterIdentity.kind }} + name: {{ .Values.clusterIdentity.name }} + controlPlaneLoadBalancer: + healthCheckProtocol: TCP + network: + additionalControlPlaneIngressRules: + - description: "k0s controller join API" + protocol: tcp + fromPort: 9443 + toPort: 9443 + {{- if not (quote .Values.sshKeyName | empty) }} + sshKeyName: {{ .Values.sshKeyName | quote }} + {{- end }} + {{- with .Values.bastion }} + bastion: + {{- toYaml . | nindent 4 }} + {{- end }} diff --git a/templates/cluster/aws-standalone-cp-0-0-2/templates/awsmachinetemplate-controlplane.yaml b/templates/cluster/aws-standalone-cp-0-0-2/templates/awsmachinetemplate-controlplane.yaml new file mode 100644 index 000000000..3e66e382d --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/templates/awsmachinetemplate-controlplane.yaml @@ -0,0 +1,24 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: AWSMachineTemplate +metadata: + name: {{ include "awsmachinetemplate.controlplane.name" . }} +spec: + template: + spec: + {{- if not (quote .Values.controlPlane.amiID | empty) }} + ami: + id: {{ .Values.controlPlane.amiID }} + {{- end }} + imageLookupFormat: {{ .Values.controlPlane.imageLookup.format }} + imageLookupOrg: "{{ .Values.controlPlane.imageLookup.org }}" + imageLookupBaseOS: {{ .Values.controlPlane.imageLookup.baseOS }} + instanceType: {{ .Values.controlPlane.instanceType }} + # Instance Profile created by `clusterawsadm bootstrap iam create-cloudformation-stack` + iamInstanceProfile: {{ .Values.controlPlane.iamInstanceProfile }} + cloudInit: + # Makes CAPA use k0s bootstrap cloud-init directly and not via SSM + # Simplifies the VPC setup as we do not need custom SSM endpoints etc. + insecureSkipSecretsManager: true + publicIP: {{ .Values.publicIP }} + rootVolume: + size: {{ .Values.controlPlane.rootVolumeSize }} diff --git a/templates/cluster/aws-standalone-cp-0-0-2/templates/awsmachinetemplate-worker.yaml b/templates/cluster/aws-standalone-cp-0-0-2/templates/awsmachinetemplate-worker.yaml new file mode 100644 index 000000000..5651f30b0 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/templates/awsmachinetemplate-worker.yaml @@ -0,0 +1,24 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: AWSMachineTemplate +metadata: + name: {{ include "awsmachinetemplate.worker.name" . }} +spec: + template: + spec: + {{- if not (quote .Values.worker.amiID | empty) }} + ami: + id: {{ .Values.worker.amiID }} + {{- end }} + imageLookupFormat: {{ .Values.worker.imageLookup.format }} + imageLookupOrg: "{{ .Values.worker.imageLookup.org }}" + imageLookupBaseOS: {{ .Values.worker.imageLookup.baseOS }} + instanceType: {{ .Values.worker.instanceType }} + # Instance Profile created by `clusterawsadm bootstrap iam create-cloudformation-stack` + iamInstanceProfile: {{ .Values.worker.iamInstanceProfile }} + cloudInit: + # Makes CAPA use k0s bootstrap cloud-init directly and not via SSM + # Simplifies the VPC setup as we do not need custom SSM endpoints etc. + insecureSkipSecretsManager: true + publicIP: {{ .Values.publicIP }} + rootVolume: + size: {{ .Values.worker.rootVolumeSize }} diff --git a/templates/cluster/aws-standalone-cp-0-0-2/templates/beachheadservices/cert-manager.yaml b/templates/cluster/aws-standalone-cp-0-0-2/templates/beachheadservices/cert-manager.yaml new file mode 100644 index 000000000..36c6b8f33 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/templates/beachheadservices/cert-manager.yaml @@ -0,0 +1,42 @@ +{{- if .Values.installBeachHeadServices }} +apiVersion: source.toolkit.fluxcd.io/v1 +kind: HelmRepository +metadata: + name: cert-manager + labels: + hmc.mirantis.com/managed: "true" +spec: + interval: 24h + url: https://charts.jetstack.io +--- +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: {{ include "cluster.name" . }}-cert-manager + labels: + hmc.mirantis.com/managed: "true" +spec: + chart: + metadata: + labels: + hmc.mirantis.com/managed: "true" + spec: + chart: cert-manager + version: "v1.12.3" + sourceRef: + kind: HelmRepository + name: cert-manager + install: + createNamespace: true + remediation: + retries: -1 + interval: 10m + kubeConfig: + secretRef: + name: {{ include "cluster.name" . }}-kubeconfig + releaseName: cert-manager + targetNamespace: cert-manager + storageNamespace: cert-manager + values: + installCRDs: true +{{- end }} diff --git a/templates/cluster/aws-standalone-cp-0-0-2/templates/beachheadservices/nginx-ingress.yaml b/templates/cluster/aws-standalone-cp-0-0-2/templates/beachheadservices/nginx-ingress.yaml new file mode 100644 index 000000000..73c329159 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/templates/beachheadservices/nginx-ingress.yaml @@ -0,0 +1,36 @@ +{{- if .Values.installBeachHeadServices }} +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: OCIRepository +metadata: + name: nginx-ingress + labels: + hmc.mirantis.com/managed: "true" +spec: + interval: 24h + url: oci://ghcr.io/nginxinc/charts/nginx-ingress + ref: + semver: "1.3.2" +--- +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: {{ include "cluster.name" . }}-nginx-ingress + labels: + hmc.mirantis.com/managed: "true" +spec: + targetNamespace: nginx-ingress + storageNamespace: nginx-ingress + kubeConfig: + secretRef: + name: {{ include "cluster.name" . }}-kubeconfig + interval: 10m + chartRef: + kind: OCIRepository + name: nginx-ingress + install: + createNamespace: true + remediation: + retries: -1 + values: + fullnameOverride: nginx-ingress +{{- end }} diff --git a/templates/cluster/aws-standalone-cp-0-0-2/templates/cluster.yaml b/templates/cluster/aws-standalone-cp-0-0-2/templates/cluster.yaml new file mode 100644 index 000000000..cb3425af5 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/templates/cluster.yaml @@ -0,0 +1,17 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + name: {{ include "cluster.name" . }} +spec: + {{- with .Values.clusterNetwork }} + clusterNetwork: + {{- toYaml . | nindent 4 }} + {{- end }} + controlPlaneRef: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: K0sControlPlane + name: {{ include "k0scontrolplane.name" . }} + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: AWSCluster + name: {{ include "cluster.name" . }} \ No newline at end of file diff --git a/templates/cluster/aws-standalone-cp-0-0-2/templates/k0scontrolplane.yaml b/templates/cluster/aws-standalone-cp-0-0-2/templates/k0scontrolplane.yaml new file mode 100644 index 000000000..900f2102c --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/templates/k0scontrolplane.yaml @@ -0,0 +1,65 @@ +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +kind: K0sControlPlane +metadata: + name: {{ include "k0scontrolplane.name" . }} +spec: + replicas: {{ .Values.controlPlaneNumber }} + version: {{ .Values.k0s.version }} + updateStrategy: {{ .Values.k0s.updateStrategy }} + k0sConfigSpec: + args: + - --enable-worker + - --enable-cloud-provider + - --kubelet-extra-args="--cloud-provider=external" + - --disable-components=konnectivity-server + k0s: + apiVersion: k0s.k0sproject.io/v1beta1 + kind: ClusterConfig + metadata: + name: k0s + spec: + api: + extraArgs: + anonymous-auth: "true" + network: + provider: calico + calico: + mode: ipip + extensions: + helm: + repositories: + - name: aws-cloud-controller-manager + url: https://kubernetes.github.io/cloud-provider-aws + - name: aws-ebs-csi-driver + url: https://kubernetes-sigs.github.io/aws-ebs-csi-driver + charts: + - name: aws-cloud-controller-manager + namespace: kube-system + chartname: aws-cloud-controller-manager/aws-cloud-controller-manager + version: "0.0.8" + values: | + nodeSelector: + node-role.kubernetes.io/control-plane: "true" + image: + tag: v1.30.3 + args: + - --v=10 + - --cloud-provider=aws + - --cluster-cidr={{ first .Values.clusterNetwork.pods.cidrBlocks }} + - --allocate-node-cidrs=true + - --cluster-name={{ include "cluster.name" . }} + - name: aws-ebs-csi-driver + namespace: kube-system + chartname: aws-ebs-csi-driver/aws-ebs-csi-driver + version: 2.35.1 + values: | + defaultStorageClass: + enabled: true + node: + kubeletPath: /var/lib/k0s/kubelet + machineTemplate: + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: AWSMachineTemplate + name: {{ include "awsmachinetemplate.controlplane.name" . }} + namespace: {{ .Release.Namespace }} diff --git a/templates/cluster/aws-standalone-cp-0-0-2/templates/k0sworkerconfigtemplate.yaml b/templates/cluster/aws-standalone-cp-0-0-2/templates/k0sworkerconfigtemplate.yaml new file mode 100644 index 000000000..562e4fdeb --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/templates/k0sworkerconfigtemplate.yaml @@ -0,0 +1,11 @@ +apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +kind: K0sWorkerConfigTemplate +metadata: + name: {{ include "k0sworkerconfigtemplate.name" . }} +spec: + template: + spec: + version: {{ .Values.k0s.version }} + args: + - --enable-cloud-provider + - --kubelet-extra-args="--cloud-provider=external" diff --git a/templates/cluster/aws-standalone-cp-0-0-2/templates/machinedeployment.yaml b/templates/cluster/aws-standalone-cp-0-0-2/templates/machinedeployment.yaml new file mode 100644 index 000000000..5c51c1045 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/templates/machinedeployment.yaml @@ -0,0 +1,26 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: {{ include "machinedeployment.name" . }} +spec: + clusterName: {{ include "cluster.name" . }} + replicas: {{ .Values.workersNumber }} + selector: + matchLabels: + cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }} + template: + metadata: + labels: + cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }} + spec: + version: {{ regexReplaceAll "\\+k0s.+$" .Values.k0s.version "" }} + clusterName: {{ include "cluster.name" . }} + bootstrap: + configRef: + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: K0sWorkerConfigTemplate + name: {{ include "k0sworkerconfigtemplate.name" . }} + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: AWSMachineTemplate + name: {{ include "awsmachinetemplate.worker.name" . }} diff --git a/templates/cluster/aws-standalone-cp-0-0-2/values.schema.json b/templates/cluster/aws-standalone-cp-0-0-2/values.schema.json new file mode 100644 index 000000000..7b39a7d0c --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/values.schema.json @@ -0,0 +1,228 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "An HMC template to deploy a k0s cluster on AWS with bootstrapped control plane nodes.", + "type": "object", + "required": [ + "controlPlaneNumber", + "workersNumber", + "region", + "clusterIdentity" + ], + "properties": { + "controlPlaneNumber": { + "description": "The number of the control plane machines", + "type": "number", + "minimum": 1 + }, + "workersNumber": { + "description": "The number of the worker machines", + "type": "number", + "minimum": 1 + }, + "clusterNetwork": { + "type": "object", + "properties": { + "pods": { + "type": "object", + "properties": { + "cidrBlocks": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1, + "uniqueItems": true + } + } + }, + "services": { + "type": "object", + "properties": { + "cidrBlocks": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1, + "uniqueItems": true + } + } + } + } + }, + "region": { + "description": "AWS region to deploy the cluster in", + "type": "string" + }, + "sshKeyName": { + "description": "The name of the key pair to securely connect to your instances. Valid values are empty string (do not use SSH keys), a valid SSH key name, or omitted (use the default SSH key name)", + "type": ["string", "null"] + }, + "publicIP": { + "description": "Specifies whether the instance should get a public IP", + "type": "boolean" + }, + "bastion": { + "type": "object", + "description": "The configuration of the bastion host", + "required": [], + "properties": { + "enabled": { + "type": "boolean" + }, + "disableIngressRules": { + "type": "boolean" + }, + "allowedCIDRBlocks": { + "type": "array", + "items": {}, + "uniqueItems": true + }, + "instanceType": { + "type": "string" + }, + "ami": { + "type": "string" + } + } + }, + "clusterIdentity": { + "type": "object", + "description": "AWS Cluster Identity object reference", + "required": [ + "name", + "kind" + ], + "properties": { + "name": { + "description": "AWS ClusterIdentity object name", + "type": "string" + }, + "kind": { + "description": "AWS ClusterIdentity object kind", + "type": "string" + } + } + }, + "controlPlane": { + "description": "The configuration of the control plane machines", + "type": "object", + "required": [ + "iamInstanceProfile", + "instanceType" + ], + "properties": { + "amiID": { + "description": "The ID of Amazon Machine Image", + "type": "string" + }, + "iamInstanceProfile": { + "description": "The name of an IAM instance profile to assign to the instance", + "type": "string" + }, + "instanceType": { + "description": "The type of instance to create", + "type": "string" + }, + "additionalSecurityGroupIDs": { + "description": "An array of references to security groups that should be applied to the instance", + "type": "array", + "items": { + "type": "string" + } + }, + "rootVolumeSize": { + "description": "The size of the root volume of the instance (GB)", + "type": "integer" + }, + "imageLookup": { + "description": "AMI lookup parameters", + "type": "object", + "required": [ + "format", + "org" + ], + "properties": { + "format": { + "description": "Format string which will be used for image lookup", + "type": "string" + }, + "org": { + "description": "AWS org ID which owns the AMI", + "type": "string" + }, + "baseOS": { + "description": "OS name which can be used in format string", + "type": "string" + } + } + } + } + }, + "worker": { + "description": "The configuration of the worker machines", + "type": "object", + "required": [ + "iamInstanceProfile", + "instanceType" + ], + "properties": { + "amiID": { + "description": "The ID of Amazon Machine Image", + "type": "string" + }, + "iamInstanceProfile": { + "description": "The name of an IAM instance profile to assign to the instance", + "type": "string" + }, + "instanceType": { + "description": "The type of instance to create", + "type": "string" + }, + "additionalSecurityGroupIDs": { + "description": "An array of references to security groups that should be applied to the instance", + "type": "array" + }, + "rootVolumeSize": { + "description": "The size of the root volume of the instance (GB)", + "type": "integer" + }, + "imageLookup": { + "description": "AMI lookup parameters", + "type": "object", + "required": [ + "format", + "org" + ], + "properties": { + "format": { + "description": "Format string which will be used for image lookup", + "type": "string" + }, + "org": { + "description": "AWS org ID which owns the AMI", + "type": "string" + }, + "baseOS": { + "description": "OS name which can be used in format string", + "type": "string" + } + } + } + } + }, + "k0s": { + "description": "K0s parameters", + "type": "object", + "required": [ + "version" + ], + "properties": { + "version":{ + "description": "K0s version to use", + "type": "string" + } + } + } + } +} diff --git a/templates/cluster/aws-standalone-cp-0-0-2/values.yaml b/templates/cluster/aws-standalone-cp-0-0-2/values.yaml new file mode 100644 index 000000000..1979ba3c1 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-2/values.yaml @@ -0,0 +1,54 @@ +# Cluster parameters +controlPlaneNumber: 3 +workersNumber: 2 + +clusterNetwork: + pods: + cidrBlocks: + - "10.244.0.0/16" + services: + cidrBlocks: + - "10.96.0.0/12" + +# AWS cluster parameters +region: "" +sshKeyName: "" +publicIP: false +bastion: + enabled: false + disableIngressRules: false + allowedCIDRBlocks: [] + instanceType: t2.micro + ami: "" +clusterIdentity: + name: "" + kind: "AWSClusterStaticIdentity" +# AWS machines parameters +controlPlane: + amiID: "" + iamInstanceProfile: control-plane.cluster-api-provider-aws.sigs.k8s.io + instanceType: "" + rootVolumeSize: 8 + imageLookup: + format: "amzn2-ami-hvm*-gp2" + org: "137112412989" + baseOS: "" + +worker: + amiID: "" + iamInstanceProfile: control-plane.cluster-api-provider-aws.sigs.k8s.io + instanceType: "" + rootVolumeSize: 8 + imageLookup: + format: "amzn2-ami-hvm*-gp2" + org: "137112412989" + baseOS: "" + +# K0s parameters +k0s: + version: v1.30.4+k0s.0 + updateStrategy: InPlace + +# Optionally install applications defined under +# templates/beachheadservices into target cluster +installBeachHeadServices: false diff --git a/templates/cluster/aws-standalone-cp-0-0-3/.helmignore b/templates/cluster/aws-standalone-cp-0-0-3/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/templates/cluster/aws-standalone-cp-0-0-3/Chart.yaml b/templates/cluster/aws-standalone-cp-0-0-3/Chart.yaml new file mode 100644 index 000000000..792d95029 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/Chart.yaml @@ -0,0 +1,22 @@ +apiVersion: v2 +name: aws-standalone-cp +description: | + An HMC template to deploy a k0s cluster on AWS with bootstrapped control plane nodes. + Upgrade sequences: + * 0.0.1 -> 0.0.3 + Diff: + * k0s version update: v1.30.4+k0s.0 -> v1.31.1+k0s.0 +type: application +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.3 +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.31.1+k0s.0" +annotations: + hmc.mirantis.com/infrastructure-providers: aws + hmc.mirantis.com/control-plane-providers: k0s + hmc.mirantis.com/bootstrap-providers: k0s diff --git a/templates/cluster/aws-standalone-cp-0-0-3/README.md b/templates/cluster/aws-standalone-cp-0-0-3/README.md new file mode 100644 index 000000000..268e26297 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/README.md @@ -0,0 +1,11 @@ +## Install applications into Target Cluster + +To install applications into the target cluster created using Cluster API (CAPI) upon creation, a Flux `HelmRelease` object is to be made such that its `.spec.KubeConfig` references the kubeconfig of the target cluster. + +**Reference:** https://fluxcd.io/flux/components/helm/helmreleases/#remote-clusters--cluster-api + +This chart/template already defines the following applications under `templates/beachheadservices` which can be be installed into the target cluster by setting `.Values.installBeachHeadServices=true`: +1. cert-manager +2. nginx-ingress + +**Important:** The Flux objects added to `templates/beachheadservices` to install custom applications must have the `hmc.mirantis.com/managed: "true"` label to be reconciled by HMC. diff --git a/templates/cluster/aws-standalone-cp-0-0-3/templates/_helpers.tpl b/templates/cluster/aws-standalone-cp-0-0-3/templates/_helpers.tpl new file mode 100644 index 000000000..b78d81324 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/templates/_helpers.tpl @@ -0,0 +1,23 @@ +{{- define "cluster.name" -}} + {{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "awsmachinetemplate.controlplane.name" -}} + {{- include "cluster.name" . }}-cp-mt +{{- end }} + +{{- define "awsmachinetemplate.worker.name" -}} + {{- include "cluster.name" . }}-worker-mt +{{- end }} + +{{- define "k0scontrolplane.name" -}} + {{- include "cluster.name" . }}-cp +{{- end }} + +{{- define "k0sworkerconfigtemplate.name" -}} + {{- include "cluster.name" . }}-machine-config +{{- end }} + +{{- define "machinedeployment.name" -}} + {{- include "cluster.name" . }}-md +{{- end }} diff --git a/templates/cluster/aws-standalone-cp-0-0-3/templates/awscluster.yaml b/templates/cluster/aws-standalone-cp-0-0-3/templates/awscluster.yaml new file mode 100644 index 000000000..7b098d678 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/templates/awscluster.yaml @@ -0,0 +1,26 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: AWSCluster +metadata: + name: {{ include "cluster.name" . }} + annotations: + aws.cluster.x-k8s.io/external-resource-gc: "true" +spec: + region: {{ .Values.region }} + identityRef: + kind: {{ .Values.clusterIdentity.kind }} + name: {{ .Values.clusterIdentity.name }} + controlPlaneLoadBalancer: + healthCheckProtocol: TCP + network: + additionalControlPlaneIngressRules: + - description: "k0s controller join API" + protocol: tcp + fromPort: 9443 + toPort: 9443 + {{- if not (quote .Values.sshKeyName | empty) }} + sshKeyName: {{ .Values.sshKeyName | quote }} + {{- end }} + {{- with .Values.bastion }} + bastion: + {{- toYaml . | nindent 4 }} + {{- end }} diff --git a/templates/cluster/aws-standalone-cp-0-0-3/templates/awsmachinetemplate-controlplane.yaml b/templates/cluster/aws-standalone-cp-0-0-3/templates/awsmachinetemplate-controlplane.yaml new file mode 100644 index 000000000..3e66e382d --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/templates/awsmachinetemplate-controlplane.yaml @@ -0,0 +1,24 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: AWSMachineTemplate +metadata: + name: {{ include "awsmachinetemplate.controlplane.name" . }} +spec: + template: + spec: + {{- if not (quote .Values.controlPlane.amiID | empty) }} + ami: + id: {{ .Values.controlPlane.amiID }} + {{- end }} + imageLookupFormat: {{ .Values.controlPlane.imageLookup.format }} + imageLookupOrg: "{{ .Values.controlPlane.imageLookup.org }}" + imageLookupBaseOS: {{ .Values.controlPlane.imageLookup.baseOS }} + instanceType: {{ .Values.controlPlane.instanceType }} + # Instance Profile created by `clusterawsadm bootstrap iam create-cloudformation-stack` + iamInstanceProfile: {{ .Values.controlPlane.iamInstanceProfile }} + cloudInit: + # Makes CAPA use k0s bootstrap cloud-init directly and not via SSM + # Simplifies the VPC setup as we do not need custom SSM endpoints etc. + insecureSkipSecretsManager: true + publicIP: {{ .Values.publicIP }} + rootVolume: + size: {{ .Values.controlPlane.rootVolumeSize }} diff --git a/templates/cluster/aws-standalone-cp-0-0-3/templates/awsmachinetemplate-worker.yaml b/templates/cluster/aws-standalone-cp-0-0-3/templates/awsmachinetemplate-worker.yaml new file mode 100644 index 000000000..5651f30b0 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/templates/awsmachinetemplate-worker.yaml @@ -0,0 +1,24 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: AWSMachineTemplate +metadata: + name: {{ include "awsmachinetemplate.worker.name" . }} +spec: + template: + spec: + {{- if not (quote .Values.worker.amiID | empty) }} + ami: + id: {{ .Values.worker.amiID }} + {{- end }} + imageLookupFormat: {{ .Values.worker.imageLookup.format }} + imageLookupOrg: "{{ .Values.worker.imageLookup.org }}" + imageLookupBaseOS: {{ .Values.worker.imageLookup.baseOS }} + instanceType: {{ .Values.worker.instanceType }} + # Instance Profile created by `clusterawsadm bootstrap iam create-cloudformation-stack` + iamInstanceProfile: {{ .Values.worker.iamInstanceProfile }} + cloudInit: + # Makes CAPA use k0s bootstrap cloud-init directly and not via SSM + # Simplifies the VPC setup as we do not need custom SSM endpoints etc. + insecureSkipSecretsManager: true + publicIP: {{ .Values.publicIP }} + rootVolume: + size: {{ .Values.worker.rootVolumeSize }} diff --git a/templates/cluster/aws-standalone-cp-0-0-3/templates/beachheadservices/cert-manager.yaml b/templates/cluster/aws-standalone-cp-0-0-3/templates/beachheadservices/cert-manager.yaml new file mode 100644 index 000000000..36c6b8f33 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/templates/beachheadservices/cert-manager.yaml @@ -0,0 +1,42 @@ +{{- if .Values.installBeachHeadServices }} +apiVersion: source.toolkit.fluxcd.io/v1 +kind: HelmRepository +metadata: + name: cert-manager + labels: + hmc.mirantis.com/managed: "true" +spec: + interval: 24h + url: https://charts.jetstack.io +--- +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: {{ include "cluster.name" . }}-cert-manager + labels: + hmc.mirantis.com/managed: "true" +spec: + chart: + metadata: + labels: + hmc.mirantis.com/managed: "true" + spec: + chart: cert-manager + version: "v1.12.3" + sourceRef: + kind: HelmRepository + name: cert-manager + install: + createNamespace: true + remediation: + retries: -1 + interval: 10m + kubeConfig: + secretRef: + name: {{ include "cluster.name" . }}-kubeconfig + releaseName: cert-manager + targetNamespace: cert-manager + storageNamespace: cert-manager + values: + installCRDs: true +{{- end }} diff --git a/templates/cluster/aws-standalone-cp-0-0-3/templates/beachheadservices/nginx-ingress.yaml b/templates/cluster/aws-standalone-cp-0-0-3/templates/beachheadservices/nginx-ingress.yaml new file mode 100644 index 000000000..73c329159 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/templates/beachheadservices/nginx-ingress.yaml @@ -0,0 +1,36 @@ +{{- if .Values.installBeachHeadServices }} +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: OCIRepository +metadata: + name: nginx-ingress + labels: + hmc.mirantis.com/managed: "true" +spec: + interval: 24h + url: oci://ghcr.io/nginxinc/charts/nginx-ingress + ref: + semver: "1.3.2" +--- +apiVersion: helm.toolkit.fluxcd.io/v2 +kind: HelmRelease +metadata: + name: {{ include "cluster.name" . }}-nginx-ingress + labels: + hmc.mirantis.com/managed: "true" +spec: + targetNamespace: nginx-ingress + storageNamespace: nginx-ingress + kubeConfig: + secretRef: + name: {{ include "cluster.name" . }}-kubeconfig + interval: 10m + chartRef: + kind: OCIRepository + name: nginx-ingress + install: + createNamespace: true + remediation: + retries: -1 + values: + fullnameOverride: nginx-ingress +{{- end }} diff --git a/templates/cluster/aws-standalone-cp-0-0-3/templates/cluster.yaml b/templates/cluster/aws-standalone-cp-0-0-3/templates/cluster.yaml new file mode 100644 index 000000000..cb3425af5 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/templates/cluster.yaml @@ -0,0 +1,17 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + name: {{ include "cluster.name" . }} +spec: + {{- with .Values.clusterNetwork }} + clusterNetwork: + {{- toYaml . | nindent 4 }} + {{- end }} + controlPlaneRef: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: K0sControlPlane + name: {{ include "k0scontrolplane.name" . }} + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: AWSCluster + name: {{ include "cluster.name" . }} \ No newline at end of file diff --git a/templates/cluster/aws-standalone-cp-0-0-3/templates/k0scontrolplane.yaml b/templates/cluster/aws-standalone-cp-0-0-3/templates/k0scontrolplane.yaml new file mode 100644 index 000000000..0cc76fe81 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/templates/k0scontrolplane.yaml @@ -0,0 +1,65 @@ +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +kind: K0sControlPlane +metadata: + name: {{ include "k0scontrolplane.name" . }} +spec: + replicas: {{ .Values.controlPlaneNumber }} + version: {{ .Values.k0s.version }} + updateStrategy: {{ .Values.k0s.updateStrategy }} + k0sConfigSpec: + args: + - --enable-worker + - --enable-cloud-provider + - --kubelet-extra-args="--cloud-provider=external" + - --disable-components=konnectivity-server + k0s: + apiVersion: k0s.k0sproject.io/v1beta1 + kind: ClusterConfig + metadata: + name: k0s + spec: + api: + extraArgs: + anonymous-auth: "true" + network: + provider: calico + calico: + mode: ipip + extensions: + helm: + repositories: + - name: aws-cloud-controller-manager + url: https://kubernetes.github.io/cloud-provider-aws + - name: aws-ebs-csi-driver + url: https://kubernetes-sigs.github.io/aws-ebs-csi-driver + charts: + - name: aws-cloud-controller-manager + namespace: kube-system + chartname: aws-cloud-controller-manager/aws-cloud-controller-manager + version: "0.0.8" + values: | + nodeSelector: + node-role.kubernetes.io/control-plane: "true" + image: + tag: v1.30.3 + args: + - --v=2 + - --cloud-provider=aws + - --cluster-cidr={{ first .Values.clusterNetwork.pods.cidrBlocks }} + - --allocate-node-cidrs=true + - --cluster-name={{ include "cluster.name" . }} + - name: aws-ebs-csi-driver + namespace: kube-system + chartname: aws-ebs-csi-driver/aws-ebs-csi-driver + version: 2.33.0 + values: | + defaultStorageClass: + enabled: true + node: + kubeletPath: /var/lib/k0s/kubelet + machineTemplate: + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: AWSMachineTemplate + name: {{ include "awsmachinetemplate.controlplane.name" . }} + namespace: {{ .Release.Namespace }} diff --git a/templates/cluster/aws-standalone-cp-0-0-3/templates/k0sworkerconfigtemplate.yaml b/templates/cluster/aws-standalone-cp-0-0-3/templates/k0sworkerconfigtemplate.yaml new file mode 100644 index 000000000..562e4fdeb --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/templates/k0sworkerconfigtemplate.yaml @@ -0,0 +1,11 @@ +apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +kind: K0sWorkerConfigTemplate +metadata: + name: {{ include "k0sworkerconfigtemplate.name" . }} +spec: + template: + spec: + version: {{ .Values.k0s.version }} + args: + - --enable-cloud-provider + - --kubelet-extra-args="--cloud-provider=external" diff --git a/templates/cluster/aws-standalone-cp-0-0-3/templates/machinedeployment.yaml b/templates/cluster/aws-standalone-cp-0-0-3/templates/machinedeployment.yaml new file mode 100644 index 000000000..5c51c1045 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/templates/machinedeployment.yaml @@ -0,0 +1,26 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: {{ include "machinedeployment.name" . }} +spec: + clusterName: {{ include "cluster.name" . }} + replicas: {{ .Values.workersNumber }} + selector: + matchLabels: + cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }} + template: + metadata: + labels: + cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }} + spec: + version: {{ regexReplaceAll "\\+k0s.+$" .Values.k0s.version "" }} + clusterName: {{ include "cluster.name" . }} + bootstrap: + configRef: + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: K0sWorkerConfigTemplate + name: {{ include "k0sworkerconfigtemplate.name" . }} + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 + kind: AWSMachineTemplate + name: {{ include "awsmachinetemplate.worker.name" . }} diff --git a/templates/cluster/aws-standalone-cp-0-0-3/values.schema.json b/templates/cluster/aws-standalone-cp-0-0-3/values.schema.json new file mode 100644 index 000000000..7b39a7d0c --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/values.schema.json @@ -0,0 +1,228 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "An HMC template to deploy a k0s cluster on AWS with bootstrapped control plane nodes.", + "type": "object", + "required": [ + "controlPlaneNumber", + "workersNumber", + "region", + "clusterIdentity" + ], + "properties": { + "controlPlaneNumber": { + "description": "The number of the control plane machines", + "type": "number", + "minimum": 1 + }, + "workersNumber": { + "description": "The number of the worker machines", + "type": "number", + "minimum": 1 + }, + "clusterNetwork": { + "type": "object", + "properties": { + "pods": { + "type": "object", + "properties": { + "cidrBlocks": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1, + "uniqueItems": true + } + } + }, + "services": { + "type": "object", + "properties": { + "cidrBlocks": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1, + "uniqueItems": true + } + } + } + } + }, + "region": { + "description": "AWS region to deploy the cluster in", + "type": "string" + }, + "sshKeyName": { + "description": "The name of the key pair to securely connect to your instances. Valid values are empty string (do not use SSH keys), a valid SSH key name, or omitted (use the default SSH key name)", + "type": ["string", "null"] + }, + "publicIP": { + "description": "Specifies whether the instance should get a public IP", + "type": "boolean" + }, + "bastion": { + "type": "object", + "description": "The configuration of the bastion host", + "required": [], + "properties": { + "enabled": { + "type": "boolean" + }, + "disableIngressRules": { + "type": "boolean" + }, + "allowedCIDRBlocks": { + "type": "array", + "items": {}, + "uniqueItems": true + }, + "instanceType": { + "type": "string" + }, + "ami": { + "type": "string" + } + } + }, + "clusterIdentity": { + "type": "object", + "description": "AWS Cluster Identity object reference", + "required": [ + "name", + "kind" + ], + "properties": { + "name": { + "description": "AWS ClusterIdentity object name", + "type": "string" + }, + "kind": { + "description": "AWS ClusterIdentity object kind", + "type": "string" + } + } + }, + "controlPlane": { + "description": "The configuration of the control plane machines", + "type": "object", + "required": [ + "iamInstanceProfile", + "instanceType" + ], + "properties": { + "amiID": { + "description": "The ID of Amazon Machine Image", + "type": "string" + }, + "iamInstanceProfile": { + "description": "The name of an IAM instance profile to assign to the instance", + "type": "string" + }, + "instanceType": { + "description": "The type of instance to create", + "type": "string" + }, + "additionalSecurityGroupIDs": { + "description": "An array of references to security groups that should be applied to the instance", + "type": "array", + "items": { + "type": "string" + } + }, + "rootVolumeSize": { + "description": "The size of the root volume of the instance (GB)", + "type": "integer" + }, + "imageLookup": { + "description": "AMI lookup parameters", + "type": "object", + "required": [ + "format", + "org" + ], + "properties": { + "format": { + "description": "Format string which will be used for image lookup", + "type": "string" + }, + "org": { + "description": "AWS org ID which owns the AMI", + "type": "string" + }, + "baseOS": { + "description": "OS name which can be used in format string", + "type": "string" + } + } + } + } + }, + "worker": { + "description": "The configuration of the worker machines", + "type": "object", + "required": [ + "iamInstanceProfile", + "instanceType" + ], + "properties": { + "amiID": { + "description": "The ID of Amazon Machine Image", + "type": "string" + }, + "iamInstanceProfile": { + "description": "The name of an IAM instance profile to assign to the instance", + "type": "string" + }, + "instanceType": { + "description": "The type of instance to create", + "type": "string" + }, + "additionalSecurityGroupIDs": { + "description": "An array of references to security groups that should be applied to the instance", + "type": "array" + }, + "rootVolumeSize": { + "description": "The size of the root volume of the instance (GB)", + "type": "integer" + }, + "imageLookup": { + "description": "AMI lookup parameters", + "type": "object", + "required": [ + "format", + "org" + ], + "properties": { + "format": { + "description": "Format string which will be used for image lookup", + "type": "string" + }, + "org": { + "description": "AWS org ID which owns the AMI", + "type": "string" + }, + "baseOS": { + "description": "OS name which can be used in format string", + "type": "string" + } + } + } + } + }, + "k0s": { + "description": "K0s parameters", + "type": "object", + "required": [ + "version" + ], + "properties": { + "version":{ + "description": "K0s version to use", + "type": "string" + } + } + } + } +} diff --git a/templates/cluster/aws-standalone-cp-0-0-3/values.yaml b/templates/cluster/aws-standalone-cp-0-0-3/values.yaml new file mode 100644 index 000000000..7d0f59039 --- /dev/null +++ b/templates/cluster/aws-standalone-cp-0-0-3/values.yaml @@ -0,0 +1,54 @@ +# Cluster parameters +controlPlaneNumber: 3 +workersNumber: 2 + +clusterNetwork: + pods: + cidrBlocks: + - "10.244.0.0/16" + services: + cidrBlocks: + - "10.96.0.0/12" + +# AWS cluster parameters +region: "" +sshKeyName: "" +publicIP: false +bastion: + enabled: false + disableIngressRules: false + allowedCIDRBlocks: [] + instanceType: t2.micro + ami: "" +clusterIdentity: + name: "" + kind: "AWSClusterStaticIdentity" +# AWS machines parameters +controlPlane: + amiID: "" + iamInstanceProfile: control-plane.cluster-api-provider-aws.sigs.k8s.io + instanceType: "" + rootVolumeSize: 8 + imageLookup: + format: "amzn2-ami-hvm*-gp2" + org: "137112412989" + baseOS: "" + +worker: + amiID: "" + iamInstanceProfile: control-plane.cluster-api-provider-aws.sigs.k8s.io + instanceType: "" + rootVolumeSize: 8 + imageLookup: + format: "amzn2-ami-hvm*-gp2" + org: "137112412989" + baseOS: "" + +# K0s parameters +k0s: + version: v1.31.1+k0s.0 + updateStrategy: InPlace + +# Optionally install applications defined under +# templates/beachheadservices into target cluster +installBeachHeadServices: false diff --git a/templates/cluster/aws-standalone-cp/templates/k0scontrolplane.yaml b/templates/cluster/aws-standalone-cp/templates/k0scontrolplane.yaml index 8d17a3497..0cc76fe81 100644 --- a/templates/cluster/aws-standalone-cp/templates/k0scontrolplane.yaml +++ b/templates/cluster/aws-standalone-cp/templates/k0scontrolplane.yaml @@ -5,6 +5,7 @@ metadata: spec: replicas: {{ .Values.controlPlaneNumber }} version: {{ .Values.k0s.version }} + updateStrategy: {{ .Values.k0s.updateStrategy }} k0sConfigSpec: args: - --enable-worker diff --git a/templates/cluster/aws-standalone-cp/values.yaml b/templates/cluster/aws-standalone-cp/values.yaml index 2d09cf5c8..1979ba3c1 100644 --- a/templates/cluster/aws-standalone-cp/values.yaml +++ b/templates/cluster/aws-standalone-cp/values.yaml @@ -47,6 +47,7 @@ worker: # K0s parameters k0s: version: v1.30.4+k0s.0 + updateStrategy: InPlace # Optionally install applications defined under # templates/beachheadservices into target cluster diff --git a/templates/cluster/azure-standalone-cp-0-0-2/.helmignore b/templates/cluster/azure-standalone-cp-0-0-2/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/templates/cluster/azure-standalone-cp-0-0-2/Chart.yaml b/templates/cluster/azure-standalone-cp-0-0-2/Chart.yaml new file mode 100644 index 000000000..fba4c4159 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/Chart.yaml @@ -0,0 +1,22 @@ +apiVersion: v2 +name: azure-standalone-cp +description: | + An HMC template to deploy a k0s cluster on Azure with bootstrapped control plane nodes. + Upgrade sequences: + * 0.0.1 -> 0.0.2 + Diff: + * Added new test label on the control plane nodes +type: application +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.2 +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.30.4+k0s.0" +annotations: + hmc.mirantis.com/infrastructure-providers: azure + hmc.mirantis.com/control-plane-providers: k0s + hmc.mirantis.com/bootstrap-providers: k0s diff --git a/templates/cluster/azure-standalone-cp-0-0-2/templates/_helpers.tpl b/templates/cluster/azure-standalone-cp-0-0-2/templates/_helpers.tpl new file mode 100644 index 000000000..dfd4b9b8b --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/templates/_helpers.tpl @@ -0,0 +1,23 @@ +{{- define "cluster.name" -}} + {{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "azuremachinetemplate.controlplane.name" -}} + {{- include "cluster.name" . }}-cp-mt +{{- end }} + +{{- define "azuremachinetemplate.worker.name" -}} + {{- include "cluster.name" . }}-worker-mt +{{- end }} + +{{- define "k0scontrolplane.name" -}} + {{- include "cluster.name" . }}-cp +{{- end }} + +{{- define "k0sworkerconfigtemplate.name" -}} + {{- include "cluster.name" . }}-machine-config +{{- end }} + +{{- define "machinedeployment.name" -}} + {{- include "cluster.name" . }}-md +{{- end }} diff --git a/templates/cluster/azure-standalone-cp-0-0-2/templates/azurecluster.yaml b/templates/cluster/azure-standalone-cp-0-0-2/templates/azurecluster.yaml new file mode 100644 index 000000000..75769b590 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/templates/azurecluster.yaml @@ -0,0 +1,17 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: AzureCluster +metadata: + name: {{ include "cluster.name" . }} +spec: + identityRef: + kind: AzureClusterIdentity + name: {{ .Values.clusterIdentity.name }} + namespace: {{ .Values.clusterIdentity.namespace }} + location: {{ .Values.location }} + {{- if .Values.bastion.enabled }} + {{- with .Values.bastion.bastionSpec }} + bastionSpec: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} + subscriptionID: {{ .Values.subscriptionID }} diff --git a/templates/cluster/azure-standalone-cp-0-0-2/templates/azuremachinetemplate-controlplane.yaml b/templates/cluster/azure-standalone-cp-0-0-2/templates/azuremachinetemplate-controlplane.yaml new file mode 100644 index 000000000..2e499dd56 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/templates/azuremachinetemplate-controlplane.yaml @@ -0,0 +1,20 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: AzureMachineTemplate +metadata: + name: {{ include "azuremachinetemplate.controlplane.name" . }} +spec: + template: + spec: + osDisk: + diskSizeGB: {{ .Values.controlPlane.rootVolumeSize }} + osType: Linux + {{- if not (quote .Values.controlPlane.sshPublicKey | empty) }} + sshPublicKey: {{ .Values.controlPlane.sshPublicKey }} + {{- end }} + vmSize: {{ .Values.controlPlane.vmSize }} + {{- if not (quote .Values.controlPlane.image | empty) }} + {{- with .Values.controlPlane.image }} + image: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} diff --git a/templates/cluster/azure-standalone-cp-0-0-2/templates/azuremachinetemplate-worker.yaml b/templates/cluster/azure-standalone-cp-0-0-2/templates/azuremachinetemplate-worker.yaml new file mode 100644 index 000000000..365214730 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/templates/azuremachinetemplate-worker.yaml @@ -0,0 +1,20 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: AzureMachineTemplate +metadata: + name: {{ include "azuremachinetemplate.worker.name" . }} +spec: + template: + spec: + osDisk: + diskSizeGB: {{ .Values.worker.rootVolumeSize }} + osType: Linux + {{- if not (quote .Values.worker.sshPublicKey | empty) }} + sshPublicKey: {{ .Values.worker.sshPublicKey }} + {{- end }} + vmSize: {{ .Values.worker.vmSize }} + {{- if not (quote .Values.worker.image | empty) }} + {{- with .Values.worker.image }} + image: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} diff --git a/templates/cluster/azure-standalone-cp-0-0-2/templates/cluster.yaml b/templates/cluster/azure-standalone-cp-0-0-2/templates/cluster.yaml new file mode 100644 index 000000000..2ce7581f7 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/templates/cluster.yaml @@ -0,0 +1,17 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + name: {{ include "cluster.name" . }} +spec: + {{- with .Values.clusterNetwork }} + clusterNetwork: + {{- toYaml . | nindent 4 }} + {{- end }} + controlPlaneRef: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: K0sControlPlane + name: {{ include "k0scontrolplane.name" . }} + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: AzureCluster + name: {{ include "cluster.name" . }} diff --git a/templates/cluster/azure-standalone-cp-0-0-2/templates/k0scontrolplane.yaml b/templates/cluster/azure-standalone-cp-0-0-2/templates/k0scontrolplane.yaml new file mode 100644 index 000000000..53481e3cf --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/templates/k0scontrolplane.yaml @@ -0,0 +1,65 @@ +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +kind: K0sControlPlane +metadata: + name: {{ include "k0scontrolplane.name" . }} +spec: + replicas: {{ .Values.controlPlaneNumber }} + version: {{ .Values.k0s.version }} + k0sConfigSpec: + args: + - --enable-worker + - --enable-cloud-provider + - --kubelet-extra-args="--cloud-provider=external" + - --disable-components=konnectivity-server + - --labels="foo=bar" + files: + - path: "/etc/kubernetes/azure.json" + permissions: "0644" + contentFrom: + secretRef: + key: control-plane-azure.json + name: {{ include "k0scontrolplane.name" . }}-0-azure-json + k0s: + apiVersion: k0s.k0sproject.io/v1beta1 + kind: ClusterConfig + metadata: + name: k0s + spec: + api: + extraArgs: + anonymous-auth: "true" + network: + provider: calico + calico: + mode: vxlan + extensions: + helm: + repositories: + - name: cloud-provider-azure + url: https://raw.githubusercontent.com/kubernetes-sigs/cloud-provider-azure/master/helm/repo + - name: azuredisk-csi-driver + url: https://raw.githubusercontent.com/kubernetes-sigs/azuredisk-csi-driver/master/charts + charts: + - name: cloud-provider-azure + namespace: kube-system + chartname: cloud-provider-azure/cloud-provider-azure + version: 1.30.4 + order: 1 + values: | + cloudControllerManager: + nodeSelector: + node-role.kubernetes.io/control-plane: "true" + - name: azuredisk-csi-driver + namespace: kube-system + chartname: azuredisk-csi-driver/azuredisk-csi-driver + version: 1.30.3 + order: 2 + values: | + linux: + kubelet: "/var/lib/k0s/kubelet" + machineTemplate: + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: AzureMachineTemplate + name: {{ include "azuremachinetemplate.controlplane.name" . }} + namespace: {{ .Release.Namespace }} diff --git a/templates/cluster/azure-standalone-cp-0-0-2/templates/k0sworkerconfigtemplate.yaml b/templates/cluster/azure-standalone-cp-0-0-2/templates/k0sworkerconfigtemplate.yaml new file mode 100644 index 000000000..9072c62e3 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/templates/k0sworkerconfigtemplate.yaml @@ -0,0 +1,18 @@ +apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +kind: K0sWorkerConfigTemplate +metadata: + name: {{ include "k0sworkerconfigtemplate.name" . }} +spec: + template: + spec: + version: {{ .Values.k0s.version }} + args: + - --enable-cloud-provider + - --kubelet-extra-args="--cloud-provider=external" + files: + - path: "/etc/kubernetes/azure.json" + permissions: "0644" + contentFrom: + secretRef: + key: worker-node-azure.json + name: {{ include "azuremachinetemplate.worker.name" . }}-azure-json diff --git a/templates/cluster/azure-standalone-cp-0-0-2/templates/machinedeployment.yaml b/templates/cluster/azure-standalone-cp-0-0-2/templates/machinedeployment.yaml new file mode 100644 index 000000000..464ae0ceb --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/templates/machinedeployment.yaml @@ -0,0 +1,26 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: {{ include "machinedeployment.name" . }} +spec: + clusterName: {{ include "cluster.name" . }} + replicas: {{ .Values.workersNumber }} + selector: + matchLabels: + cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }} + template: + metadata: + labels: + cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }} + spec: + version: {{ regexReplaceAll "\\+k0s.+$" .Values.k0s.version "" }} + clusterName: {{ include "cluster.name" . }} + bootstrap: + configRef: + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: K0sWorkerConfigTemplate + name: {{ include "k0sworkerconfigtemplate.name" . }} + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: AzureMachineTemplate + name: {{ include "azuremachinetemplate.worker.name" . }} diff --git a/templates/cluster/azure-standalone-cp-0-0-2/values.schema.json b/templates/cluster/azure-standalone-cp-0-0-2/values.schema.json new file mode 100644 index 000000000..50e55def5 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/values.schema.json @@ -0,0 +1,206 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "An HMC template to deploy a k0s cluster on Azure with bootstrapped control plane nodes.", + "type": "object", + "required": [ + "controlPlaneNumber", + "workersNumber", + "location", + "subscriptionID", + "clusterIdentity" + ], + "properties": { + "controlPlaneNumber": { + "description": "The number of the control plane machines", + "type": "number", + "minimum": 1 + }, + "workersNumber": { + "description": "The number of the worker machines", + "type": "number", + "minimum": 1 + }, + "clusterNetwork": { + "type": "object", + "properties": { + "pods": { + "type": "object", + "properties": { + "cidrBlocks": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1, + "uniqueItems": true + } + } + }, + "services": { + "type": "object", + "properties": { + "cidrBlocks": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1, + "uniqueItems": true + } + } + } + } + }, + "location": { + "description": "Azure location to deploy the cluster in", + "type": "string" + }, + "subscriptionID": { + "description": "Azure subscription ID which will be used for all resources", + "type": "string" + }, + "bastion": { + "type": "object", + "description": "The configuration of the bastion host", + "required": [], + "properties": { + "enabled": { + "type": "boolean" + } + } + }, + "clusterIdentity": { + "type": "object", + "description": "AzureClusterIdentity object reference", + "required": [ + "name", + "namespace" + ], + "properties": { + "name": { + "description": "AzureClusterIdentity object name", + "type": "string" + }, + "namespace": { + "description": "AzureClusterIdentity object namespace", + "type": "string" + } + } + }, + "controlPlane": { + "description": "The configuration of the control plane machines", + "type": "object", + "required": [ + "vmSize" + ], + "properties": { + "sshPublicKey": { + "description": "SSH public key in base64 format, which will be used on the machine.", + "type": "string" + }, + "vmSize": { + "description": "The size of instance to create", + "type": "string" + }, + "rootVolumeSize": { + "description": "The size of the root volume of the instance (GB)", + "type": "integer" + }, + "image": { + "type": "object", + "description": "Azure VM image configuration", + "properties": { + "marketplace": { + "description": "Azure Marketplace image reference", + "type": "object", + "required": [ + "publisher", + "offer", + "sku", + "version" + ], + "properties": { + "publisher": { + "type": "string" + }, + "offer": { + "type": "string" + }, + "sku": { + "type": "string" + }, + "version": { + "type": "string" + } + } + } + } + } + } + }, + "worker": { + "description": "The configuration of the worker machines", + "type": "object", + "required": [ + "vmSize" + ], + "properties": { + "sshPublicKey": { + "description": "SSH public key in base64 format, which will be used on the machine.", + "type": "string" + }, + "vmSize": { + "description": "The size of instance to create", + "type": "string" + }, + "rootVolumeSize": { + "description": "The size of the root volume of the instance (GB)", + "type": "integer" + }, + "image": { + "type": "object", + "description": "Azure VM image configuration", + "properties": { + "marketplace": { + "description": "Azure Marketplace image reference", + "type": "object", + "required": [ + "publisher", + "offer", + "sku", + "version" + ], + "properties": { + "publisher": { + "type": "string" + }, + "offer": { + "type": "string" + }, + "sku": { + "type": "string" + }, + "version": { + "type": "string" + } + } + } + } + } + } + }, + "k0s": { + "description": "K0s parameters", + "type": "object", + "required": [ + "version" + ], + "properties": { + "version":{ + "description": "K0s version to use", + "type": "string" + } + } + } + } +} diff --git a/templates/cluster/azure-standalone-cp-0-0-2/values.yaml b/templates/cluster/azure-standalone-cp-0-0-2/values.yaml new file mode 100644 index 000000000..9b9bb0520 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-2/values.yaml @@ -0,0 +1,48 @@ +# Cluster parameters +controlPlaneNumber: 3 +workersNumber: 2 + +clusterNetwork: + pods: + cidrBlocks: + - "10.244.0.0/16" + services: + cidrBlocks: + - "10.96.0.0/12" + +# Azure cluster parameters +location: "" +subscriptionID: "" +bastion: + enabled: false + bastionSpec: + azureBastion: {} +clusterIdentity: + name: "" + namespace: hmc-system +# Azure machines parameters +controlPlane: + sshPublicKey: "" + vmSize: "" + rootVolumeSize: 30 + image: + marketplace: + publisher: "cncf-upstream" + offer: "capi" + sku: "ubuntu-2204-gen1" + version: "130.3.20240717" + +worker: + sshPublicKey: "" + vmSize: "" + rootVolumeSize: 30 + image: + marketplace: + publisher: "cncf-upstream" + offer: "capi" + sku: "ubuntu-2204-gen1" + version: "130.3.20240717" + +# K0s parameters +k0s: + version: v1.30.4+k0s.0 diff --git a/templates/cluster/azure-standalone-cp-0-0-3/.helmignore b/templates/cluster/azure-standalone-cp-0-0-3/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/templates/cluster/azure-standalone-cp-0-0-3/Chart.yaml b/templates/cluster/azure-standalone-cp-0-0-3/Chart.yaml new file mode 100644 index 000000000..2af41e30c --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/Chart.yaml @@ -0,0 +1,22 @@ +apiVersion: v2 +name: azure-standalone-cp +description: | + An HMC template to deploy a k0s cluster on Azure with bootstrapped control plane nodes. + Upgrade sequences: + * 0.0.1 -> 0.0.3 + Diff: + * k0s version update: v1.30.4+k0s.0 -> v1.31.1+k0s.0 +type: application +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.0.3 +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.30.4+k0s.0" +annotations: + hmc.mirantis.com/infrastructure-providers: azure + hmc.mirantis.com/control-plane-providers: k0s + hmc.mirantis.com/bootstrap-providers: k0s diff --git a/templates/cluster/azure-standalone-cp-0-0-3/templates/_helpers.tpl b/templates/cluster/azure-standalone-cp-0-0-3/templates/_helpers.tpl new file mode 100644 index 000000000..dfd4b9b8b --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/templates/_helpers.tpl @@ -0,0 +1,23 @@ +{{- define "cluster.name" -}} + {{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "azuremachinetemplate.controlplane.name" -}} + {{- include "cluster.name" . }}-cp-mt +{{- end }} + +{{- define "azuremachinetemplate.worker.name" -}} + {{- include "cluster.name" . }}-worker-mt +{{- end }} + +{{- define "k0scontrolplane.name" -}} + {{- include "cluster.name" . }}-cp +{{- end }} + +{{- define "k0sworkerconfigtemplate.name" -}} + {{- include "cluster.name" . }}-machine-config +{{- end }} + +{{- define "machinedeployment.name" -}} + {{- include "cluster.name" . }}-md +{{- end }} diff --git a/templates/cluster/azure-standalone-cp-0-0-3/templates/azurecluster.yaml b/templates/cluster/azure-standalone-cp-0-0-3/templates/azurecluster.yaml new file mode 100644 index 000000000..75769b590 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/templates/azurecluster.yaml @@ -0,0 +1,17 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: AzureCluster +metadata: + name: {{ include "cluster.name" . }} +spec: + identityRef: + kind: AzureClusterIdentity + name: {{ .Values.clusterIdentity.name }} + namespace: {{ .Values.clusterIdentity.namespace }} + location: {{ .Values.location }} + {{- if .Values.bastion.enabled }} + {{- with .Values.bastion.bastionSpec }} + bastionSpec: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} + subscriptionID: {{ .Values.subscriptionID }} diff --git a/templates/cluster/azure-standalone-cp-0-0-3/templates/azuremachinetemplate-controlplane.yaml b/templates/cluster/azure-standalone-cp-0-0-3/templates/azuremachinetemplate-controlplane.yaml new file mode 100644 index 000000000..2e499dd56 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/templates/azuremachinetemplate-controlplane.yaml @@ -0,0 +1,20 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: AzureMachineTemplate +metadata: + name: {{ include "azuremachinetemplate.controlplane.name" . }} +spec: + template: + spec: + osDisk: + diskSizeGB: {{ .Values.controlPlane.rootVolumeSize }} + osType: Linux + {{- if not (quote .Values.controlPlane.sshPublicKey | empty) }} + sshPublicKey: {{ .Values.controlPlane.sshPublicKey }} + {{- end }} + vmSize: {{ .Values.controlPlane.vmSize }} + {{- if not (quote .Values.controlPlane.image | empty) }} + {{- with .Values.controlPlane.image }} + image: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} diff --git a/templates/cluster/azure-standalone-cp-0-0-3/templates/azuremachinetemplate-worker.yaml b/templates/cluster/azure-standalone-cp-0-0-3/templates/azuremachinetemplate-worker.yaml new file mode 100644 index 000000000..365214730 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/templates/azuremachinetemplate-worker.yaml @@ -0,0 +1,20 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: AzureMachineTemplate +metadata: + name: {{ include "azuremachinetemplate.worker.name" . }} +spec: + template: + spec: + osDisk: + diskSizeGB: {{ .Values.worker.rootVolumeSize }} + osType: Linux + {{- if not (quote .Values.worker.sshPublicKey | empty) }} + sshPublicKey: {{ .Values.worker.sshPublicKey }} + {{- end }} + vmSize: {{ .Values.worker.vmSize }} + {{- if not (quote .Values.worker.image | empty) }} + {{- with .Values.worker.image }} + image: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- end }} diff --git a/templates/cluster/azure-standalone-cp-0-0-3/templates/cluster.yaml b/templates/cluster/azure-standalone-cp-0-0-3/templates/cluster.yaml new file mode 100644 index 000000000..2ce7581f7 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/templates/cluster.yaml @@ -0,0 +1,17 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + name: {{ include "cluster.name" . }} +spec: + {{- with .Values.clusterNetwork }} + clusterNetwork: + {{- toYaml . | nindent 4 }} + {{- end }} + controlPlaneRef: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: K0sControlPlane + name: {{ include "k0scontrolplane.name" . }} + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: AzureCluster + name: {{ include "cluster.name" . }} diff --git a/templates/cluster/azure-standalone-cp-0-0-3/templates/k0scontrolplane.yaml b/templates/cluster/azure-standalone-cp-0-0-3/templates/k0scontrolplane.yaml new file mode 100644 index 000000000..95294cf93 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/templates/k0scontrolplane.yaml @@ -0,0 +1,64 @@ +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +kind: K0sControlPlane +metadata: + name: {{ include "k0scontrolplane.name" . }} +spec: + replicas: {{ .Values.controlPlaneNumber }} + version: {{ .Values.k0s.version }} + k0sConfigSpec: + args: + - --enable-worker + - --enable-cloud-provider + - --kubelet-extra-args="--cloud-provider=external" + - --disable-components=konnectivity-server + files: + - path: "/etc/kubernetes/azure.json" + permissions: "0644" + contentFrom: + secretRef: + key: control-plane-azure.json + name: {{ include "k0scontrolplane.name" . }}-0-azure-json + k0s: + apiVersion: k0s.k0sproject.io/v1beta1 + kind: ClusterConfig + metadata: + name: k0s + spec: + api: + extraArgs: + anonymous-auth: "true" + network: + provider: calico + calico: + mode: vxlan + extensions: + helm: + repositories: + - name: cloud-provider-azure + url: https://raw.githubusercontent.com/kubernetes-sigs/cloud-provider-azure/master/helm/repo + - name: azuredisk-csi-driver + url: https://raw.githubusercontent.com/kubernetes-sigs/azuredisk-csi-driver/master/charts + charts: + - name: cloud-provider-azure + namespace: kube-system + chartname: cloud-provider-azure/cloud-provider-azure + version: 1.30.4 + order: 1 + values: | + cloudControllerManager: + nodeSelector: + node-role.kubernetes.io/control-plane: "true" + - name: azuredisk-csi-driver + namespace: kube-system + chartname: azuredisk-csi-driver/azuredisk-csi-driver + version: 1.30.3 + order: 2 + values: | + linux: + kubelet: "/var/lib/k0s/kubelet" + machineTemplate: + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: AzureMachineTemplate + name: {{ include "azuremachinetemplate.controlplane.name" . }} + namespace: {{ .Release.Namespace }} diff --git a/templates/cluster/azure-standalone-cp-0-0-3/templates/k0sworkerconfigtemplate.yaml b/templates/cluster/azure-standalone-cp-0-0-3/templates/k0sworkerconfigtemplate.yaml new file mode 100644 index 000000000..9072c62e3 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/templates/k0sworkerconfigtemplate.yaml @@ -0,0 +1,18 @@ +apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 +kind: K0sWorkerConfigTemplate +metadata: + name: {{ include "k0sworkerconfigtemplate.name" . }} +spec: + template: + spec: + version: {{ .Values.k0s.version }} + args: + - --enable-cloud-provider + - --kubelet-extra-args="--cloud-provider=external" + files: + - path: "/etc/kubernetes/azure.json" + permissions: "0644" + contentFrom: + secretRef: + key: worker-node-azure.json + name: {{ include "azuremachinetemplate.worker.name" . }}-azure-json diff --git a/templates/cluster/azure-standalone-cp-0-0-3/templates/machinedeployment.yaml b/templates/cluster/azure-standalone-cp-0-0-3/templates/machinedeployment.yaml new file mode 100644 index 000000000..464ae0ceb --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/templates/machinedeployment.yaml @@ -0,0 +1,26 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + name: {{ include "machinedeployment.name" . }} +spec: + clusterName: {{ include "cluster.name" . }} + replicas: {{ .Values.workersNumber }} + selector: + matchLabels: + cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }} + template: + metadata: + labels: + cluster.x-k8s.io/cluster-name: {{ include "cluster.name" . }} + spec: + version: {{ regexReplaceAll "\\+k0s.+$" .Values.k0s.version "" }} + clusterName: {{ include "cluster.name" . }} + bootstrap: + configRef: + apiVersion: bootstrap.cluster.x-k8s.io/v1beta1 + kind: K0sWorkerConfigTemplate + name: {{ include "k0sworkerconfigtemplate.name" . }} + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: AzureMachineTemplate + name: {{ include "azuremachinetemplate.worker.name" . }} diff --git a/templates/cluster/azure-standalone-cp-0-0-3/values.schema.json b/templates/cluster/azure-standalone-cp-0-0-3/values.schema.json new file mode 100644 index 000000000..50e55def5 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/values.schema.json @@ -0,0 +1,206 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "An HMC template to deploy a k0s cluster on Azure with bootstrapped control plane nodes.", + "type": "object", + "required": [ + "controlPlaneNumber", + "workersNumber", + "location", + "subscriptionID", + "clusterIdentity" + ], + "properties": { + "controlPlaneNumber": { + "description": "The number of the control plane machines", + "type": "number", + "minimum": 1 + }, + "workersNumber": { + "description": "The number of the worker machines", + "type": "number", + "minimum": 1 + }, + "clusterNetwork": { + "type": "object", + "properties": { + "pods": { + "type": "object", + "properties": { + "cidrBlocks": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1, + "uniqueItems": true + } + } + }, + "services": { + "type": "object", + "properties": { + "cidrBlocks": { + "type": "array", + "items": { + "type": "string" + }, + "minItems": 1, + "uniqueItems": true + } + } + } + } + }, + "location": { + "description": "Azure location to deploy the cluster in", + "type": "string" + }, + "subscriptionID": { + "description": "Azure subscription ID which will be used for all resources", + "type": "string" + }, + "bastion": { + "type": "object", + "description": "The configuration of the bastion host", + "required": [], + "properties": { + "enabled": { + "type": "boolean" + } + } + }, + "clusterIdentity": { + "type": "object", + "description": "AzureClusterIdentity object reference", + "required": [ + "name", + "namespace" + ], + "properties": { + "name": { + "description": "AzureClusterIdentity object name", + "type": "string" + }, + "namespace": { + "description": "AzureClusterIdentity object namespace", + "type": "string" + } + } + }, + "controlPlane": { + "description": "The configuration of the control plane machines", + "type": "object", + "required": [ + "vmSize" + ], + "properties": { + "sshPublicKey": { + "description": "SSH public key in base64 format, which will be used on the machine.", + "type": "string" + }, + "vmSize": { + "description": "The size of instance to create", + "type": "string" + }, + "rootVolumeSize": { + "description": "The size of the root volume of the instance (GB)", + "type": "integer" + }, + "image": { + "type": "object", + "description": "Azure VM image configuration", + "properties": { + "marketplace": { + "description": "Azure Marketplace image reference", + "type": "object", + "required": [ + "publisher", + "offer", + "sku", + "version" + ], + "properties": { + "publisher": { + "type": "string" + }, + "offer": { + "type": "string" + }, + "sku": { + "type": "string" + }, + "version": { + "type": "string" + } + } + } + } + } + } + }, + "worker": { + "description": "The configuration of the worker machines", + "type": "object", + "required": [ + "vmSize" + ], + "properties": { + "sshPublicKey": { + "description": "SSH public key in base64 format, which will be used on the machine.", + "type": "string" + }, + "vmSize": { + "description": "The size of instance to create", + "type": "string" + }, + "rootVolumeSize": { + "description": "The size of the root volume of the instance (GB)", + "type": "integer" + }, + "image": { + "type": "object", + "description": "Azure VM image configuration", + "properties": { + "marketplace": { + "description": "Azure Marketplace image reference", + "type": "object", + "required": [ + "publisher", + "offer", + "sku", + "version" + ], + "properties": { + "publisher": { + "type": "string" + }, + "offer": { + "type": "string" + }, + "sku": { + "type": "string" + }, + "version": { + "type": "string" + } + } + } + } + } + } + }, + "k0s": { + "description": "K0s parameters", + "type": "object", + "required": [ + "version" + ], + "properties": { + "version":{ + "description": "K0s version to use", + "type": "string" + } + } + } + } +} diff --git a/templates/cluster/azure-standalone-cp-0-0-3/values.yaml b/templates/cluster/azure-standalone-cp-0-0-3/values.yaml new file mode 100644 index 000000000..b632a3455 --- /dev/null +++ b/templates/cluster/azure-standalone-cp-0-0-3/values.yaml @@ -0,0 +1,48 @@ +# Cluster parameters +controlPlaneNumber: 3 +workersNumber: 2 + +clusterNetwork: + pods: + cidrBlocks: + - "10.244.0.0/16" + services: + cidrBlocks: + - "10.96.0.0/12" + +# Azure cluster parameters +location: "" +subscriptionID: "" +bastion: + enabled: false + bastionSpec: + azureBastion: {} +clusterIdentity: + name: "" + namespace: hmc-system +# Azure machines parameters +controlPlane: + sshPublicKey: "" + vmSize: "" + rootVolumeSize: 30 + image: + marketplace: + publisher: "cncf-upstream" + offer: "capi" + sku: "ubuntu-2204-gen1" + version: "130.3.20240717" + +worker: + sshPublicKey: "" + vmSize: "" + rootVolumeSize: 30 + image: + marketplace: + publisher: "cncf-upstream" + offer: "capi" + sku: "ubuntu-2204-gen1" + version: "130.3.20240717" + +# K0s parameters +k0s: + version: v1.31.1+k0s.0 diff --git a/templates/provider/hmc-templates/files/templates/aws-standalone-cp-0-0-2.yaml b/templates/provider/hmc-templates/files/templates/aws-standalone-cp-0-0-2.yaml new file mode 100644 index 000000000..116b2f4eb --- /dev/null +++ b/templates/provider/hmc-templates/files/templates/aws-standalone-cp-0-0-2.yaml @@ -0,0 +1,10 @@ +apiVersion: hmc.mirantis.com/v1alpha1 +kind: ClusterTemplate +metadata: + name: aws-standalone-cp-0-0-2 + annotations: + helm.sh/resource-policy: keep +spec: + helm: + chartName: aws-standalone-cp + chartVersion: 0.0.2 diff --git a/templates/provider/hmc-templates/files/templates/aws-standalone-cp-0-0-3.yaml b/templates/provider/hmc-templates/files/templates/aws-standalone-cp-0-0-3.yaml new file mode 100644 index 000000000..9b1f98f2f --- /dev/null +++ b/templates/provider/hmc-templates/files/templates/aws-standalone-cp-0-0-3.yaml @@ -0,0 +1,10 @@ +apiVersion: hmc.mirantis.com/v1alpha1 +kind: ClusterTemplate +metadata: + name: aws-standalone-cp-0-0-3 + annotations: + helm.sh/resource-policy: keep +spec: + helm: + chartName: aws-standalone-cp + chartVersion: 0.0.3 diff --git a/templates/provider/hmc-templates/files/templates/azure-standalone-cp-0-0-2.yaml b/templates/provider/hmc-templates/files/templates/azure-standalone-cp-0-0-2.yaml new file mode 100644 index 000000000..d07a5d866 --- /dev/null +++ b/templates/provider/hmc-templates/files/templates/azure-standalone-cp-0-0-2.yaml @@ -0,0 +1,10 @@ +apiVersion: hmc.mirantis.com/v1alpha1 +kind: ClusterTemplate +metadata: + name: azure-standalone-cp-0-0-2 + annotations: + helm.sh/resource-policy: keep +spec: + helm: + chartName: azure-standalone-cp + chartVersion: 0.0.2 diff --git a/templates/provider/hmc-templates/files/templates/azure-standalone-cp-0-0-3.yaml b/templates/provider/hmc-templates/files/templates/azure-standalone-cp-0-0-3.yaml new file mode 100644 index 000000000..8b867c342 --- /dev/null +++ b/templates/provider/hmc-templates/files/templates/azure-standalone-cp-0-0-3.yaml @@ -0,0 +1,10 @@ +apiVersion: hmc.mirantis.com/v1alpha1 +kind: ClusterTemplate +metadata: + name: azure-standalone-cp-0-0-3 + annotations: + helm.sh/resource-policy: keep +spec: + helm: + chartName: azure-standalone-cp + chartVersion: 0.0.3