diff --git a/charts/hmc-templates/aws/hmc-template-hosted-control-planes/.helmignore b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/.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/charts/hmc-templates/aws/hmc-template-hosted-control-planes/Chart.yaml b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/Chart.yaml new file mode 100644 index 000000000..37f3881d8 --- /dev/null +++ b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/Chart.yaml @@ -0,0 +1,15 @@ +apiVersion: v2 +name: hmc-template-hosted-control-planes +description: | + The HMC template to deploy kubernetes cluster 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.1.0 +# 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: "0.1.0" diff --git a/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/_helpers.tpl b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/_helpers.tpl new file mode 100644 index 000000000..5246e1a97 --- /dev/null +++ b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/_helpers.tpl @@ -0,0 +1,23 @@ +{{- define "cluster.name" -}} + {{- .Values.clusterName | trunc 63 }} +{{- end }} + +{{- define "awsmachinetemplate.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 }} + +{{- define "k0sconfig.name" -}} + {{- include "cluster.name" . }}-k0sconfig +{{- end }} \ No newline at end of file diff --git a/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/awscluster.yaml b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/awscluster.yaml new file mode 100644 index 000000000..d9063699e --- /dev/null +++ b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/awscluster.yaml @@ -0,0 +1,18 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: AWSCluster +metadata: + name: {{ include "cluster.name" . }} + annotations: + cluster.x-k8s.io/managed-by: k0smotron +spec: + region: {{ .Values.region }} + # identityRef: + # kind: AWSClusterStaticIdentity + # name: aws-identity-name + network: + vpc: + id: {{ .Values.vpcID }} + {{- with .Values.subnets }} + subnets: + {{- toYaml . | nindent 6 }} + {{- end }} \ No newline at end of file diff --git a/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/awsmachinetemplate.yaml b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/awsmachinetemplate.yaml new file mode 100644 index 000000000..608eda2ad --- /dev/null +++ b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/awsmachinetemplate.yaml @@ -0,0 +1,21 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1beta2 +kind: AWSMachineTemplate +metadata: + name: {{ include "awsmachinetemplate.name" . }} +spec: + template: + spec: + ami: + id: {{ .Values.amiID }} + instanceType: {{ .Values.instanceType }} + # Instance Profile created by `clusterawsadm bootstrap iam create-cloudformation-stack` + iamInstanceProfile: {{ .Values.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 + additionalSecurityGroups: + - id: {{ .Values.securityGroupID }} + {{- if .Values.sshKeyName }} + sshKeyName: {{ .Values.sshKeyName }} + {{- end }} diff --git a/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/cluster.yaml b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/cluster.yaml new file mode 100644 index 000000000..eaef59c58 --- /dev/null +++ b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/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/v1beta2 + kind: AWSCluster + name: {{ include "cluster.name" . }} \ No newline at end of file diff --git a/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/k0smotroncontrolplane.yaml b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/k0smotroncontrolplane.yaml new file mode 100644 index 000000000..97dc5cac0 --- /dev/null +++ b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/k0smotroncontrolplane.yaml @@ -0,0 +1,42 @@ +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +kind: K0smotronControlPlane +metadata: + name: {{ include "k0smotroncontrolplane.name" . }} +spec: + replicas: 3 + # dirty hack + 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: {{ include "k0sconfig.name" . }} + namespace: {{ .Release.Namespace }} + spec: + extensions: + helm: + repositories: + - name: aws-cloud-controller-manager + url: https://kubernetes.github.io/cloud-provider-aws + charts: + - name: aws-cloud-controller-manager + namespace: kube-system + chartname: aws-cloud-controller-manager/aws-cloud-controller-manager + version: "0.0.8" + values: | + args: + - --v=2 + - --cloud-provider=aws + - --cluster-cidr={{ first .Values.clusterNetwork.pods.cidrBlocks }} + - --allocate-node-cidrs=true + - --cluster-name={{ include "cluster.name" . }} + # Removing the default `node-role.kubernetes.io/control-plane` node selector + # TODO: it does not work + # nodeSelector: "" \ No newline at end of file diff --git a/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/k0sworkerconfigtemplate.yaml b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/k0sworkerconfigtemplate.yaml new file mode 100644 index 000000000..90b654cb2 --- /dev/null +++ b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/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 --hostname-override=$(hostname --fqdn)" \ No newline at end of file diff --git a/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/machinedeployment.yaml b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/machinedeployment.yaml new file mode 100644 index 000000000..12c9d62ef --- /dev/null +++ b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/templates/machinedeployment.yaml @@ -0,0 +1,25 @@ +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: + 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.name" . }} \ No newline at end of file diff --git a/charts/hmc-templates/aws/hmc-template-hosted-control-planes/values.yaml b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/values.yaml new file mode 100644 index 000000000..b43299755 --- /dev/null +++ b/charts/hmc-templates/aws/hmc-template-hosted-control-planes/values.yaml @@ -0,0 +1,34 @@ +# Cluster parameters +clusterName: k0s-aws +workersNumber: 2 + +clusterNetwork: + pods: + cidrBlocks: + - "10.244.0.0/16" + services: + cidrBlocks: + - "10.96.0.0/12" + +# AWS cluster parameters +vpcID: "" +region: "" +sshKeyName: "" +subnets: [] + +# AWS machines parameters +amiID: "" +iamInstanceProfile: nodes.cluster-api-provider-aws.sigs.k8s.io +instanceType: "" +securityGroupID: "" + +# K0smotron parameters +k0smotron: + service: + type: LoadBalancer + apiPort: 6443 + konnectivityPort: 8132 + +# K0s parameters +k0s: + version: v1.27.2+k0s.0