feat: make kube-apiserver endpoint configurable

Add helm values to configure kube-apiserver endpoint when using type: DaemonSet

Signed-off-by: Sander ter Schure <sander.terschure@gmail.com>
This commit is contained in:
Sander ter Schure
2024-10-03 16:12:44 +02:00
parent 41fb283b51
commit 628a7b7fb4
5 changed files with 26 additions and 13 deletions

View File

@@ -122,11 +122,11 @@ docs:
charts/talos-cloud-controller-manager > docs/deploy/cloud-controller-manager-edge.yml charts/talos-cloud-controller-manager > docs/deploy/cloud-controller-manager-edge.yml
helm template -n kube-system talos-cloud-controller-manager \ helm template -n kube-system talos-cloud-controller-manager \
--set-string image.tag=$(TAG) \ --set-string image.tag=$(TAG) \
--set useDaemonSet=true \ --set daemonSet.enabled=true \
charts/talos-cloud-controller-manager > docs/deploy/cloud-controller-manager-daemonset.yml charts/talos-cloud-controller-manager > docs/deploy/cloud-controller-manager-daemonset.yml
helm template -n kube-system talos-cloud-controller-manager \ helm template -n kube-system talos-cloud-controller-manager \
-f charts/talos-cloud-controller-manager/values.edge.yaml \ -f charts/talos-cloud-controller-manager/values.edge.yaml \
--set useDaemonSet=true \ --set daemonSet.enabled=true \
charts/talos-cloud-controller-manager > docs/deploy/cloud-controller-manager-daemonset-edge.yml charts/talos-cloud-controller-manager > docs/deploy/cloud-controller-manager-daemonset-edge.yml
helm-docs charts/talos-cloud-controller-manager helm-docs charts/talos-cloud-controller-manager

View File

@@ -82,6 +82,9 @@ helm upgrade -i --namespace=kube-system -f talos-ccm.yaml \
| Key | Type | Default | Description | | Key | Type | Default | Description |
|-----|------|---------|-------------| |-----|------|---------|-------------|
| affinity | object | `{}` | Affinity for data pods assignment. ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity | | affinity | object | `{}` | Affinity for data pods assignment. ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity |
| daemonSet | object | `{"enabled":false,"k8s":{"serviceHost":"","servicePort":6443}}` | Deploy CCM in Daemonset mode. CCM will use hostNetwork and connect to the Kubernetes API server on the current node by default. Optionally you can specify the Kubernetes API server host and port. You can run it without CNI plugin. |
| daemonSet.k8s.serviceHost | string | `""` | Kubernetes API server host. Default is the current node IP. |
| daemonSet.k8s.servicePort | int | `6443` | Kubernetes API server port. Default is 6443. |
| enabledControllers | list | `["cloud-node","node-csr-approval"]` | List of controllers should be enabled. Use '*' to enable all controllers. Support only `cloud-node, cloud-node-lifecycle, node-csr-approval, node-ipam-controller` controllers. | | enabledControllers | list | `["cloud-node","node-csr-approval"]` | List of controllers should be enabled. Use '*' to enable all controllers. Support only `cloud-node, cloud-node-lifecycle, node-csr-approval, node-ipam-controller` controllers. |
| extraArgs | list | `[]` | Any extra arguments for talos-cloud-controller-manager | | extraArgs | list | `[]` | Any extra arguments for talos-cloud-controller-manager |
| fullnameOverride | string | `""` | String to fully override deployment name. | | fullnameOverride | string | `""` | String to fully override deployment name. |
@@ -108,4 +111,3 @@ helm upgrade -i --namespace=kube-system -f talos-ccm.yaml \
| tolerations | list | `[{"effect":"NoSchedule","key":"node-role.kubernetes.io/control-plane","operator":"Exists"},{"effect":"NoSchedule","key":"node.cloudprovider.kubernetes.io/uninitialized","operator":"Exists"}]` | Tolerations for data pods assignment. ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ | | tolerations | list | `[{"effect":"NoSchedule","key":"node-role.kubernetes.io/control-plane","operator":"Exists"},{"effect":"NoSchedule","key":"node.cloudprovider.kubernetes.io/uninitialized","operator":"Exists"}]` | Tolerations for data pods assignment. ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ |
| transformations | list | `[]` | List of node transformations. Available matchExpressions key values: https://github.com/siderolabs/talos/blob/main/pkg/machinery/resources/runtime/platform_metadata.go#L28 | | transformations | list | `[]` | List of node transformations. Available matchExpressions key values: https://github.com/siderolabs/talos/blob/main/pkg/machinery/resources/runtime/platform_metadata.go#L28 |
| updateStrategy | object | `{"rollingUpdate":{"maxUnavailable":1},"type":"RollingUpdate"}` | Deployment update stategy type. ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment | | updateStrategy | object | `{"rollingUpdate":{"maxUnavailable":1},"type":"RollingUpdate"}` | Deployment update stategy type. ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment |
| useDaemonSet | bool | `false` | Deploy CCM in Daemonset mode. CCM will use hostNetwork and current node to access kubernetes/talos API You can run it without CNI plugin. |

View File

@@ -1,5 +1,5 @@
apiVersion: apps/v1 apiVersion: apps/v1
{{- if .Values.useDaemonSet }} {{- if .Values.daemonSet.enabled }}
kind: DaemonSet kind: DaemonSet
{{- else }} {{- else }}
kind: Deployment kind: Deployment
@@ -10,7 +10,7 @@ metadata:
{{- include "talos-cloud-controller-manager.labels" . | nindent 4 }} {{- include "talos-cloud-controller-manager.labels" . | nindent 4 }}
namespace: {{ .Release.Namespace }} namespace: {{ .Release.Namespace }}
spec: spec:
{{- if not .Values.useDaemonSet }} {{- if not .Values.daemonSet.enabled }}
replicas: {{ .Values.replicaCount }} replicas: {{ .Values.replicaCount }}
strategy: strategy:
type: {{ .Values.updateStrategy.type }} type: {{ .Values.updateStrategy.type }}
@@ -37,7 +37,7 @@ spec:
serviceAccountName: {{ include "talos-cloud-controller-manager.serviceAccountName" . }} serviceAccountName: {{ include "talos-cloud-controller-manager.serviceAccountName" . }}
securityContext: securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }} {{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if .Values.useDaemonSet }} {{- if .Values.daemonSet.enabled }}
dnsPolicy: ClusterFirstWithHostNet dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true hostNetwork: true
{{- end }} {{- end }}
@@ -61,18 +61,22 @@ spec:
{{- with .Values.extraArgs }} {{- with .Values.extraArgs }}
{{- toYaml . | nindent 12 }} {{- toYaml . | nindent 12 }}
{{- end }} {{- end }}
{{- if .Values.useDaemonSet }} {{- if .Values.daemonSet.enabled }}
env: env:
- name: TALOS_ENDPOINTS - name: TALOS_ENDPOINTS
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: status.podIP fieldPath: status.podIP
- name: KUBERNETES_SERVICE_HOST - name: KUBERNETES_SERVICE_HOST
{{- if .Values.daemonSet.k8s.serviceHost }}
value: {{ .Values.daemonSet.k8s.serviceHost }}
{{- else }}
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: status.podIP fieldPath: status.podIP
{{- end }}
- name: KUBERNETES_SERVICE_PORT - name: KUBERNETES_SERVICE_PORT
value: "6443" value: {{ quote .Values.daemonSet.k8s.servicePort }}
{{- end }} {{- end }}
ports: ports:
- name: metrics - name: metrics
@@ -107,7 +111,7 @@ spec:
{{- with .Values.tolerations }} {{- with .Values.tolerations }}
{{- toYaml . | nindent 8 }} {{- toYaml . | nindent 8 }}
{{- end }} {{- end }}
{{- if .Values.useDaemonSet }} {{- if .Values.daemonSet.enabled }}
- effect: NoSchedule - effect: NoSchedule
key: node.kubernetes.io/not-ready key: node.kubernetes.io/not-ready
operator: Exists operator: Exists

View File

@@ -1,4 +1,3 @@
# Use latest Talos image # Use latest Talos image
image: image:
pullPolicy: Always pullPolicy: Always
@@ -53,7 +52,8 @@ transformations:
node-role.kubernetes.io/db: "" node-role.kubernetes.io/db: ""
# Deploy the Talos Cloud Controller Manager as a DaemonSet # Deploy the Talos Cloud Controller Manager as a DaemonSet
useDaemonSet: true daemonSet:
enabled: true
# Tolerate all taints # Tolerate all taints
tolerations: tolerations:

View File

@@ -125,9 +125,16 @@ resources:
memory: 64Mi memory: 64Mi
# -- Deploy CCM in Daemonset mode. # -- Deploy CCM in Daemonset mode.
# CCM will use hostNetwork and current node to access kubernetes/talos API # CCM will use hostNetwork and connect to the Kubernetes API server on the current node by default.
# Optionally you can specify the Kubernetes API server host and port.
# You can run it without CNI plugin. # You can run it without CNI plugin.
useDaemonSet: false daemonSet:
enabled: false
k8s:
# -- Kubernetes API server host. Default is the current node IP.
serviceHost: ""
# -- Kubernetes API server port. Default is 6443.
servicePort: 6443
# -- Deployment update stategy type. # -- Deployment update stategy type.
# ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment # ref: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#updating-a-deployment