diff --git a/templates/azure-hosted-cp/.helmignore b/templates/azure-hosted-cp/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/templates/azure-hosted-cp/.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/azure-hosted-cp/Chart.yaml b/templates/azure-hosted-cp/Chart.yaml new file mode 100644 index 000000000..eb951555b --- /dev/null +++ b/templates/azure-hosted-cp/Chart.yaml @@ -0,0 +1,20 @@ +apiVersion: v2 +name: azure-hosted-cp +description: | + An HMC template to deploy a k8s cluster on Azure with control plane components + within the management cluster. +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.1 +# 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.2+k0s.0" +annotations: + hmc.mirantis.com/type: deployment + hmc.mirantis.com/infrastructure-providers: azure + hmc.mirantis.com/controlplane-providers: k0s + hmc.mirantis.com/bootstrap-providers: k0s diff --git a/templates/azure-hosted-cp/templates/_helpers.tpl b/templates/azure-hosted-cp/templates/_helpers.tpl new file mode 100644 index 000000000..06dc0b9f7 --- /dev/null +++ b/templates/azure-hosted-cp/templates/_helpers.tpl @@ -0,0 +1,19 @@ +{{- define "cluster.name" -}} + {{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{- define "azuremachinetemplate.name" -}} + {{- include "cluster.name" . }}-mt +{{- end }} + +{{- define "k0smotroncontrolplane.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/azure-hosted-cp/templates/azurecluster.yaml b/templates/azure-hosted-cp/templates/azurecluster.yaml new file mode 100644 index 000000000..fa329e34b --- /dev/null +++ b/templates/azure-hosted-cp/templates/azurecluster.yaml @@ -0,0 +1,19 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: AzureCluster +metadata: + name: {{ include "cluster.name" . }} + # annotations: + # cluster.x-k8s.io/managed-by: k0smotron +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/azure-hosted-cp/templates/azuremachinetemplate.yaml b/templates/azure-hosted-cp/templates/azuremachinetemplate.yaml new file mode 100644 index 000000000..973c603fe --- /dev/null +++ b/templates/azure-hosted-cp/templates/azuremachinetemplate.yaml @@ -0,0 +1,14 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 +kind: AzureMachineTemplate +metadata: + name: {{ include "azuremachinetemplate.name" . }} +spec: + template: + spec: + osDisk: + diskSizeGB: {{ .Values.rootVolumeSize }} + osType: Linux + {{- if not (quote .Values.sshPublicKey | empty) }} + sshPublicKey: {{ .Values.sshPublicKey }} + {{- end }} + vmSize: {{ .Values.vmSize }} diff --git a/templates/azure-hosted-cp/templates/cluster.yaml b/templates/azure-hosted-cp/templates/cluster.yaml new file mode 100644 index 000000000..74bd07a54 --- /dev/null +++ b/templates/azure-hosted-cp/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: K0smotronControlPlane + name: {{ include "k0smotroncontrolplane.name" . }} + infrastructureRef: + apiVersion: infrastructure.cluster.x-k8s.io/v1beta1 + kind: AzureCluster + name: {{ include "cluster.name" . }} diff --git a/templates/azure-hosted-cp/templates/k0smotroncontrolplane.yaml b/templates/azure-hosted-cp/templates/k0smotroncontrolplane.yaml new file mode 100644 index 000000000..664d451b8 --- /dev/null +++ b/templates/azure-hosted-cp/templates/k0smotroncontrolplane.yaml @@ -0,0 +1,47 @@ +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +kind: K0smotronControlPlane +metadata: + name: {{ include "k0smotroncontrolplane.name" . }} +spec: + replicas: {{ .Values.controlPlaneNumber }} + version: {{ .Values.k0s.version | replace "+" "-" }} + {{- with .Values.k0smotron.service }} + service: + {{- toYaml . | nindent 4 }} + {{- end }} + controllerPlaneFlags: + - "--enable-cloud-provider=true" + - "--debug=true" + k0sConfig: + apiVersion: k0s.k0sproject.io/v1beta1 + kind: ClusterConfig + metadata: + name: k0s + spec: + 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 + values: | + cloudControllerManager: + nodeSelector: + node-role.kubernetes.io/control-plane: null + - name: azuredisk-csi-driver + namespace: kube-system + chartname: azuredisk-csi-driver/azuredisk-csi-driver + version: 1.30.3 + values: | + linux: + kubelet: "/var/lib/k0s/kubelet" diff --git a/templates/azure-hosted-cp/templates/k0sworkerconfigtemplate.yaml b/templates/azure-hosted-cp/templates/k0sworkerconfigtemplate.yaml new file mode 100644 index 000000000..562e4fdeb --- /dev/null +++ b/templates/azure-hosted-cp/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/azure-hosted-cp/templates/machinedeployment.yaml b/templates/azure-hosted-cp/templates/machinedeployment.yaml new file mode 100644 index 000000000..e5995a1fb --- /dev/null +++ b/templates/azure-hosted-cp/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.name" . }} diff --git a/templates/azure-hosted-cp/values.schema.json b/templates/azure-hosted-cp/values.schema.json new file mode 100644 index 000000000..a959b35ab --- /dev/null +++ b/templates/azure-hosted-cp/values.schema.json @@ -0,0 +1,125 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "An HMC template to deploy a K8s cluster on Azure with control plane components within the management cluster.", + "type": "object", + "required": [ + "controlPlaneNumber", + "workersNumber", + "location", + "vmSize" + ], + "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" + }, + "bastion": { + "type": "object", + "description": "The configuration of the bastion host", + "required": [], + "properties": { + "enabled": { + "type": "boolean" + } + } + }, + "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" + }, + "k0smotron": { + "description": "K0smotron parameters", + "type": "object", + "properties": { + "service": { + "description": "The configuration of a K0smotron service", + "properties": { + "type": { + "description": "Ingress methods for a k0smotron service", + "enum": [ + "ClusterIP", + "NodePort", + "LoadBalancer" + ], + "type": "string" + }, + "apiPort": { + "description": "The kubernetes API port for a k0smotron service", + "type": "number", + "minimum": 1, + "maximum": 65535 + }, + "konnectivityPort": { + "description": "The konnectivity port", + "type": "number", + "minimum": 1, + "maximum": 65535 + } + } + } + } + }, + "k0s": { + "description": "K0s parameters", + "type": "object", + "required": [ + "version" + ], + "properties": { + "version":{ + "description": "K0s version to use", + "type": "string" + } + } + } + } +} diff --git a/templates/azure-hosted-cp/values.yaml b/templates/azure-hosted-cp/values.yaml new file mode 100644 index 000000000..f92a95a5d --- /dev/null +++ b/templates/azure-hosted-cp/values.yaml @@ -0,0 +1,38 @@ +# Cluster parameters +controlPlaneNumber: 3 +workersNumber: 2 + +clusterNetwork: + pods: + cidrBlocks: + - "10.244.0.0/16" + services: + cidrBlocks: + - "10.96.0.0/12" + +# AWS cluster parameters +location: "" +subscriptionID: "" +bastion: + enabled: false + bastionSpec: + azureBastion: {} +clusterIdentity: + name: "" + namespace: hmc-system +# AWS machines parameters + +sshPublicKey: "" +vmSize: "" +rootVolumeSize: 30 + +# K0smotron parameters +k0smotron: + service: + type: LoadBalancer + apiPort: 6443 + konnectivityPort: 8132 + +# K0s parameters +k0s: + version: v1.30.2+k0s.0 diff --git a/templates/hmc-templates/files/templates/azure-hosted-cp.yaml b/templates/hmc-templates/files/templates/azure-hosted-cp.yaml new file mode 100644 index 000000000..67daba869 --- /dev/null +++ b/templates/hmc-templates/files/templates/azure-hosted-cp.yaml @@ -0,0 +1,8 @@ +apiVersion: hmc.mirantis.com/v1alpha1 +kind: Template +metadata: + name: azure-hosted-cp +spec: + helm: + chartName: azure-hosted-cp + chartVersion: 0.0.1