2022-02-17 14:10:55 +00:00
|
|
|
|
{{/*
|
2022-03-01 09:43:14 +00:00
|
|
|
|
Produces the kubeadm config spec for a controlplane object, with support for the skipPhases
|
|
|
|
|
option of InitConfiguration and specifying a KubeProxyConfiguration.
|
2022-02-17 14:10:55 +00:00
|
|
|
|
*/}}
|
|
|
|
|
{{- define "openstack-cluster.controlplane.kubeadmConfigSpec" -}}
|
2022-03-01 09:43:14 +00:00
|
|
|
|
{{- $ctx := index . 0 }}
|
|
|
|
|
{{- $kubeadmConfigSpec := omit
|
|
|
|
|
(index . 1)
|
|
|
|
|
"initConfiguration"
|
|
|
|
|
"kubeProxyConfiguration"
|
|
|
|
|
"files"
|
|
|
|
|
"preKubeadmCommands"
|
|
|
|
|
}}
|
|
|
|
|
{{- $initConfiguration := omit (index . 1 | dig "initConfiguration" dict) "skipPhases" }}
|
|
|
|
|
{{- $skipPhases := index . 1 | dig "initConfiguration" "skipPhases" list }}
|
|
|
|
|
{{- $kubeProxyConfiguration := index . 1 | dig "kubeProxyConfiguration" dict }}
|
|
|
|
|
{{- $files := index . 1 | dig "files" list }}
|
|
|
|
|
{{- $preKubeadmCommands := index . 1 | dig "preKubeadmCommands" list }}
|
|
|
|
|
|
|
|
|
|
{{- if and $skipPhases (semverCompare "<1.22.0" $ctx.Values.global.kubernetesVersion) }}
|
|
|
|
|
{{- fail "skipPhases is only supported for Kubernetes 1.22 and higher" }}
|
|
|
|
|
{{- end }}
|
|
|
|
|
|
2022-02-17 14:10:55 +00:00
|
|
|
|
{{- with $kubeadmConfigSpec }}
|
|
|
|
|
{{- toYaml . }}
|
|
|
|
|
{{- end }}
|
2022-02-18 15:05:17 +00:00
|
|
|
|
{{- with $initConfiguration }}
|
|
|
|
|
initConfiguration: {{ toYaml $initConfiguration | nindent 2 }}
|
|
|
|
|
{{- end }}
|
|
|
|
|
{{- if or $files $skipPhases $kubeProxyConfiguration }}
|
2022-02-17 14:10:55 +00:00
|
|
|
|
files:
|
|
|
|
|
{{- range $files }}
|
|
|
|
|
- {{ toYaml . | nindent 4 }}
|
|
|
|
|
{{- end }}
|
2022-02-18 15:05:17 +00:00
|
|
|
|
{{- if $skipPhases }}
|
|
|
|
|
- path: /run/kubeadm/skip-phases.yaml
|
|
|
|
|
content: |
|
|
|
|
|
skipPhases: {{ toYaml $skipPhases | nindent 8 }}
|
|
|
|
|
owner: root:root
|
|
|
|
|
permissions: "0644"
|
|
|
|
|
{{- end }}
|
2022-02-17 14:10:55 +00:00
|
|
|
|
{{- with $kubeProxyConfiguration }}
|
|
|
|
|
- path: /run/kubeadm/kube-proxy-configuration.yaml
|
|
|
|
|
content: |
|
|
|
|
|
---
|
|
|
|
|
apiVersion: kubeproxy.config.k8s.io/v1alpha1
|
|
|
|
|
kind: KubeProxyConfiguration
|
|
|
|
|
{{- toYaml . | nindent 6 }}
|
|
|
|
|
owner: root:root
|
|
|
|
|
permissions: "0644"
|
|
|
|
|
{{- end }}
|
2022-02-18 15:05:17 +00:00
|
|
|
|
{{- end }}
|
|
|
|
|
{{- if or $preKubeadmCommands $skipPhases $kubeProxyConfiguration }}
|
2022-02-17 14:10:55 +00:00
|
|
|
|
preKubeadmCommands:
|
|
|
|
|
{{- range $preKubeadmCommands }}
|
|
|
|
|
- {{ . }}
|
|
|
|
|
{{- end }}
|
2022-02-18 15:05:17 +00:00
|
|
|
|
{{- if $skipPhases }}
|
|
|
|
|
- cat /run/kubeadm/skip-phases.yaml >> /run/kubeadm/kubeadm.yaml
|
|
|
|
|
{{- end }}
|
2022-02-17 14:10:55 +00:00
|
|
|
|
{{- if $kubeProxyConfiguration }}
|
|
|
|
|
- cat /run/kubeadm/kube-proxy-configuration.yaml >> /run/kubeadm/kubeadm.yaml
|
|
|
|
|
{{- end }}
|
|
|
|
|
{{- end }}
|
2022-02-18 15:05:17 +00:00
|
|
|
|
{{- end }}
|
|
|
|
|
|
2021-08-26 10:40:10 +01:00
|
|
|
|
---
|
2021-11-17 10:02:06 +00:00
|
|
|
|
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
|
2021-08-26 10:40:10 +01:00
|
|
|
|
kind: KubeadmControlPlane
|
|
|
|
|
metadata:
|
|
|
|
|
name: {{ include "openstack-cluster.componentName" (list . "control-plane") }}
|
|
|
|
|
labels: {{ include "openstack-cluster.componentLabels" (list . "control-plane") | nindent 4 }}
|
2022-08-01 16:48:13 +01:00
|
|
|
|
annotations:
|
|
|
|
|
# We let Cluster API clean up the cluster resources
|
|
|
|
|
# Deleting them ourselves, which CAPI is not expecting, can cause some nasty race conditions
|
|
|
|
|
helm.sh/resource-policy: keep
|
2021-08-26 10:40:10 +01:00
|
|
|
|
spec:
|
2022-01-19 15:34:54 +00:00
|
|
|
|
version: {{ .Values.global.kubernetesVersion | required ".Values.global.kubernetesVersion is required" }}
|
2021-08-26 10:40:10 +01:00
|
|
|
|
replicas: {{ .Values.controlPlane.machineCount }}
|
2022-01-11 17:09:34 +00:00
|
|
|
|
rolloutStrategy: {{ toYaml .Values.controlPlane.rolloutStrategy | nindent 4 }}
|
2021-08-26 10:40:10 +01:00
|
|
|
|
machineTemplate:
|
2021-09-06 10:23:43 +01:00
|
|
|
|
metadata:
|
2022-09-22 11:23:14 +01:00
|
|
|
|
labels: {{ include "openstack-cluster.componentSelectorLabels" (list . "control-plane") | nindent 8 }}
|
2021-08-26 10:40:10 +01:00
|
|
|
|
infrastructureRef:
|
|
|
|
|
kind: OpenStackMachineTemplate
|
2022-08-01 17:50:23 +01:00
|
|
|
|
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha6
|
2021-09-01 11:20:23 +01:00
|
|
|
|
name: {{ include "openstack-cluster.controlplane.mt.name" . }}
|
2022-01-11 17:09:34 +00:00
|
|
|
|
{{- with .Values.controlPlane.nodeDrainTimeout }}
|
|
|
|
|
nodeDrainTimeout: {{ . }}
|
|
|
|
|
{{- end }}
|
2022-03-01 09:43:14 +00:00
|
|
|
|
kubeadmConfigSpec: {{
|
|
|
|
|
include
|
|
|
|
|
"openstack-cluster.controlplane.kubeadmConfigSpec"
|
|
|
|
|
(list . .Values.controlPlane.kubeadmConfigSpec) |
|
|
|
|
|
fromYaml |
|
|
|
|
|
list . |
|
|
|
|
|
include "openstack-cluster.kubeadmConfigSpec" |
|
|
|
|
|
nindent 4
|
|
|
|
|
}}
|