Skip to content

Commit 9ba9ff2

Browse files
committed
feat(chart): add hostAliases and initContainers
It helps to deploy CCM with load blancer as sidecar. Signed-off-by: Serge Logvinov <[email protected]>
1 parent 677e6cc commit 9ba9ff2

File tree

8 files changed

+144
-9
lines changed

8 files changed

+144
-9
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/charts/proxmox-cloud-controller-manager/values-dev.yaml
44
/proxmox-cloud-controller-manager*
55
/kubeconfig
6+
/kubeconfig*
67
/proxmox-config.yaml
78
#
89

charts/proxmox-cloud-controller-manager/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ maintainers:
1414
# This is the chart version. This version number should be incremented each time you make changes
1515
# to the chart and its templates, including the app version.
1616
# Versions are expected to follow Semantic Versioning (https://semver.org/)
17-
version: 0.1.11
17+
version: 0.2.0
1818
# This is the version number of the application being deployed. This version number should be
1919
# incremented each time you make changes to the application. Versions are not expected to
2020
# follow Semantic Versioning. They should reflect the version the application is using.

charts/proxmox-cloud-controller-manager/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# proxmox-cloud-controller-manager
22

3-
![Version: 0.1.11](https://img.shields.io/badge/Version-0.1.11-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.4.0](https://img.shields.io/badge/AppVersion-v0.4.0-informational?style=flat-square)
3+
![Version: 0.2.0](https://img.shields.io/badge/Version-0.2.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.4.0](https://img.shields.io/badge/AppVersion-v0.4.0-informational?style=flat-square)
44

55
A Helm chart for Kubernetes
66

@@ -73,6 +73,8 @@ helm upgrade -i --namespace=kube-system -f proxmox-ccm.yaml \
7373
| config | object | `{"clusters":[]}` | Proxmox cluster config. |
7474
| serviceAccount | object | `{"annotations":{},"create":true,"name":""}` | Pods Service Account. ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/ |
7575
| priorityClassName | string | `"system-cluster-critical"` | CCM pods' priorityClassName. |
76+
| initContainers | list | `[]` | Add additional init containers to the CCM pods. ref: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/ |
77+
| hostAliases | list | `[]` | hostAliases Deployment pod host aliases ref: https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/ |
7678
| podAnnotations | object | `{}` | Annotations for data pods. ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ |
7779
| podSecurityContext | object | `{"fsGroup":10258,"fsGroupChangePolicy":"OnRootMismatch","runAsGroup":10258,"runAsNonRoot":true,"runAsUser":10258}` | Pods Security Context. ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod |
7880
| securityContext | object | `{"allowPrivilegeEscalation":false,"capabilities":{"drop":["ALL"]},"seccompProfile":{"type":"RuntimeDefault"}}` | Container Security Context. ref: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod |

charts/proxmox-cloud-controller-manager/templates/deployment.yaml

+13-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ spec:
3535
serviceAccountName: {{ include "proxmox-cloud-controller-manager.serviceAccountName" . }}
3636
securityContext:
3737
{{- toYaml .Values.podSecurityContext | nindent 8 }}
38+
hostAliases:
39+
{{- toYaml .Values.hostAliases | nindent 8 }}
40+
initContainers: {{- toYaml .Values.initContainers | nindent 8 }}
3841
containers:
3942
- name: {{ .Chart.Name }}
4043
securityContext:
@@ -73,9 +76,18 @@ spec:
7376
nodeSelector:
7477
{{- toYaml . | nindent 8 }}
7578
{{- end }}
76-
{{- with .Values.affinity }}
7779
affinity:
80+
{{- with .Values.affinity }}
7881
{{- toYaml . | nindent 8 }}
82+
{{- else }}
83+
podAntiAffinity:
84+
preferredDuringSchedulingIgnoredDuringExecution:
85+
- podAffinityTerm:
86+
labelSelector:
87+
matchLabels:
88+
{{- include "proxmox-cloud-controller-manager.selectorLabels" . | nindent 20 }}
89+
topologyKey: topology.kubernetes.io/zone
90+
weight: 1
7991
{{- end }}
8092
{{- with .Values.tolerations }}
8193
tolerations:

charts/proxmox-cloud-controller-manager/values.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,36 @@ serviceAccount:
6161
# -- CCM pods' priorityClassName.
6262
priorityClassName: system-cluster-critical
6363

64+
# -- Add additional init containers to the CCM pods.
65+
# ref: https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
66+
initContainers: []
67+
# - name: loadbalancer
68+
# restartPolicy: Always
69+
# image: ghcr.io/sergelogvinov/haproxy:2.8.3-alpine3.18
70+
# imagePullPolicy: IfNotPresent
71+
# env:
72+
# - name: SVC
73+
# value: "proxmox.domain.com"
74+
# - name: PORT
75+
# value: "8006"
76+
# securityContext:
77+
# runAsUser: 99
78+
# runAsGroup: 99
79+
# resources:
80+
# limits:
81+
# cpu: 50m
82+
# memory: 64Mi
83+
# requests:
84+
# cpu: 50m
85+
# memory: 32Mi
86+
87+
# -- hostAliases Deployment pod host aliases
88+
# ref: https://kubernetes.io/docs/tasks/network/customize-hosts-file-for-pods/
89+
hostAliases: []
90+
# - ip: 127.0.0.1
91+
# hostnames:
92+
# - proxmox.domain.com
93+
6494
# -- Annotations for data pods.
6595
# ref: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/
6696
podAnnotations: {}

docs/deploy/cloud-controller-manager-talos.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ kind: ServiceAccount
55
metadata:
66
name: proxmox-cloud-controller-manager
77
labels:
8-
helm.sh/chart: proxmox-cloud-controller-manager-0.1.11
8+
helm.sh/chart: proxmox-cloud-controller-manager-0.2.0
99
app.kubernetes.io/name: proxmox-cloud-controller-manager
1010
app.kubernetes.io/instance: proxmox-cloud-controller-manager
1111
app.kubernetes.io/version: "v0.4.0"
@@ -18,7 +18,7 @@ kind: ClusterRole
1818
metadata:
1919
name: system:proxmox-cloud-controller-manager
2020
labels:
21-
helm.sh/chart: proxmox-cloud-controller-manager-0.1.11
21+
helm.sh/chart: proxmox-cloud-controller-manager-0.2.0
2222
app.kubernetes.io/name: proxmox-cloud-controller-manager
2323
app.kubernetes.io/instance: proxmox-cloud-controller-manager
2424
app.kubernetes.io/version: "v0.4.0"
@@ -106,7 +106,7 @@ kind: Deployment
106106
metadata:
107107
name: proxmox-cloud-controller-manager
108108
labels:
109-
helm.sh/chart: proxmox-cloud-controller-manager-0.1.11
109+
helm.sh/chart: proxmox-cloud-controller-manager-0.2.0
110110
app.kubernetes.io/name: proxmox-cloud-controller-manager
111111
app.kubernetes.io/instance: proxmox-cloud-controller-manager
112112
app.kubernetes.io/version: "v0.4.0"
@@ -137,6 +137,10 @@ spec:
137137
runAsGroup: 10258
138138
runAsNonRoot: true
139139
runAsUser: 10258
140+
hostAliases:
141+
[]
142+
initContainers:
143+
[]
140144
containers:
141145
- name: proxmox-cloud-controller-manager
142146
securityContext:

docs/deploy/cloud-controller-manager.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ kind: ServiceAccount
55
metadata:
66
name: proxmox-cloud-controller-manager
77
labels:
8-
helm.sh/chart: proxmox-cloud-controller-manager-0.1.11
8+
helm.sh/chart: proxmox-cloud-controller-manager-0.2.0
99
app.kubernetes.io/name: proxmox-cloud-controller-manager
1010
app.kubernetes.io/instance: proxmox-cloud-controller-manager
1111
app.kubernetes.io/version: "v0.4.0"
@@ -18,7 +18,7 @@ kind: ClusterRole
1818
metadata:
1919
name: system:proxmox-cloud-controller-manager
2020
labels:
21-
helm.sh/chart: proxmox-cloud-controller-manager-0.1.11
21+
helm.sh/chart: proxmox-cloud-controller-manager-0.2.0
2222
app.kubernetes.io/name: proxmox-cloud-controller-manager
2323
app.kubernetes.io/instance: proxmox-cloud-controller-manager
2424
app.kubernetes.io/version: "v0.4.0"
@@ -106,7 +106,7 @@ kind: Deployment
106106
metadata:
107107
name: proxmox-cloud-controller-manager
108108
labels:
109-
helm.sh/chart: proxmox-cloud-controller-manager-0.1.11
109+
helm.sh/chart: proxmox-cloud-controller-manager-0.2.0
110110
app.kubernetes.io/name: proxmox-cloud-controller-manager
111111
app.kubernetes.io/instance: proxmox-cloud-controller-manager
112112
app.kubernetes.io/version: "v0.4.0"
@@ -137,6 +137,10 @@ spec:
137137
runAsGroup: 10258
138138
runAsNonRoot: true
139139
runAsUser: 10258
140+
hostAliases:
141+
[]
142+
initContainers:
143+
[]
140144
containers:
141145
- name: proxmox-cloud-controller-manager
142146
securityContext:

docs/loadbalancer.md

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Loadbalancer on top of the Proxmox cluster
2+
3+
Set up a load balancer to distribute traffic across multiple proxmox nodes.
4+
We use the [haproxy](https://hub.docker.com/_/haproxy) image to create a simple load balancer on top of the proxmox cluster.
5+
First, we need to create a headless service and set endpoints.
6+
7+
```yaml
8+
# proxmox-service.yaml
9+
---
10+
apiVersion: v1
11+
kind: Service
12+
metadata:
13+
name: proxmox
14+
namespace: kube-system
15+
spec:
16+
clusterIP: None
17+
ports:
18+
- name: https
19+
protocol: TCP
20+
port: 8006
21+
targetPort: 8006
22+
---
23+
apiVersion: v1
24+
kind: Endpoints
25+
metadata:
26+
name: proxmox
27+
namespace: kube-system
28+
subsets:
29+
- addresses:
30+
- ip: 192.168.0.1
31+
- ip: 192.168.0.2
32+
ports:
33+
- port: 8006
34+
```
35+
36+
Apply the configuration to the cluster.
37+
38+
```bash
39+
kubectl apply -f proxmox-service.yaml
40+
```
41+
42+
Second, we need to deploy proxmox CCM with sidecar load balancer.
43+
Haproxy will resolve the `proxmox.kube-system.svc.cluster.local` service and uses IPs from the endpoints to distribute traffic.
44+
Proxmox CCM will use the `proxmox.domain.com` domain to connect to the proxmox cluster wich is resolved to the load balancer IP (127.0.0.1).
45+
46+
```yaml
47+
# Helm Chart values
48+
49+
config:
50+
clusters:
51+
- region: cluster
52+
url: https://proxmox.domain.com:8006/api2/json
53+
insecure: true
54+
token_id: kubernetes@pve!ccm
55+
token_secret: 11111111-1111-1111-1111-111111111111
56+
57+
hostAliases:
58+
- ip: 127.0.0.1
59+
hostnames:
60+
- proxmox.domain.com
61+
62+
initContainers:
63+
- name: loadbalancer
64+
restartPolicy: Always
65+
image: ghcr.io/sergelogvinov/haproxy:2.8.6-alpine3.19
66+
imagePullPolicy: IfNotPresent
67+
env:
68+
- name: SVC
69+
value: proxmox.kube-system.svc.cluster.local
70+
- name: PORT
71+
value: "8006"
72+
securityContext:
73+
runAsUser: 99
74+
runAsGroup: 99
75+
resources:
76+
limits:
77+
cpu: 50m
78+
memory: 64Mi
79+
requests:
80+
cpu: 50m
81+
memory: 32Mi
82+
```

0 commit comments

Comments
 (0)