Skip to content

Commit d631749

Browse files
committed
Added Opinionated Home-Lab Friendly Clusterclass with a shared ippool
1 parent 4ae6387 commit d631749

34 files changed

+1035
-0
lines changed

examples/home-lab/ipool.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: ipam.cluster.x-k8s.io/v1alpha2
2+
kind: InClusterIPPool
3+
metadata:
4+
name: clusterclass-ipv4
5+
namespace: caprox-kubernetes-engine
6+
spec:
7+
# Change the IP range to match your needs
8+
# These IPs will be used for the cluster nodes
9+
# Also configure your network prefix and gateway accordingly
10+
addresses:
11+
- 192.168.2.150-192.168.2.199
12+
gateway: 192.168.2.1
13+
prefix: 24
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
resources:
4+
- ../../base
5+
- https://github.com/ionos-cloud/cluster-api-provider-proxmox//templates/clusterclass-cilium-with-shared-ippool/base/?ref=main

examples/home-lab/readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# Opinionated Home-Lab Friendly Example
3+
4+
This is an opinionated, Home-Lab friendly example of using CAPMOX in tiny, simple environments.
5+
6+
You can read the full guide [here](https://dev.to/3deep5me/from-zero-to-scale-kubernetes-on-proxmox-the-scaling-autopilot-method-1l64).
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
apiVersion: cluster.x-k8s.io/v1beta1
3+
kind: ClusterClass
4+
metadata:
5+
name: proxmox-clusterclass-cilium-v0.1.0
6+
spec:
7+
controlPlane:
8+
namingStrategy:
9+
template: "{{ .cluster.name }}-control-plane-{{ .random }}"
10+
ref:
11+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
12+
kind: KubeadmControlPlaneTemplate
13+
name: proxmox-clusterclass-v0.1.0-control-plane
14+
machineInfrastructure:
15+
ref:
16+
kind: ProxmoxMachineTemplate
17+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
18+
name: proxmox-clusterclass-v0.1.0-control-plane-template
19+
machineHealthCheck:
20+
maxUnhealthy: 100%
21+
nodeStartupTimeout: 15m
22+
unhealthyConditions:
23+
- type: Ready
24+
status: Unknown
25+
timeout: 300s
26+
- type: Ready
27+
status: "False"
28+
timeout: 300s
29+
infrastructure:
30+
ref:
31+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
32+
kind: ProxmoxClusterTemplate
33+
name: proxmox-clusterclass-cilium-v0.1.0-clustertemplate
34+
workers:
35+
machineDeployments:
36+
- class: proxmox-worker
37+
template:
38+
bootstrap:
39+
ref:
40+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
41+
kind: KubeadmConfigTemplate
42+
name: proxmox-clusterclass-v0.1.0-workertemplate
43+
infrastructure:
44+
ref:
45+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
46+
kind: ProxmoxMachineTemplate
47+
name: proxmox-clusterclass-v0.1.0-workertemplate
48+
metadata:
49+
labels:
50+
node-role.kubernetes.io/node: ""
51+
machineHealthCheck:
52+
maxUnhealthy: 33%
53+
nodeStartupTimeout: 15m
54+
unhealthyConditions:
55+
- type: Ready
56+
status: Unknown
57+
timeout: 300s
58+
- type: Ready
59+
status: "False"
60+
timeout: 300s
61+
namingStrategy:
62+
template: "{{ .cluster.name }}-worker-{{ .random }}"
63+
variables: []
64+
patches: []
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
apiVersion: kustomize.config.k8s.io/v1beta1
2+
kind: Kustomization
3+
namespace: caprox-kubernetes-engine
4+
resources:
5+
- ns.yaml
6+
- cilium-clusterclass.yaml
7+
- templates/helmchartproxy-cilium.yaml
8+
- templates/kubeadm-config-template.yaml
9+
- templates/kubeadm-control-plane-template.yaml
10+
- templates/proxmox-cluster-template.yaml
11+
- templates/proxmox-machine-template-cp.yaml
12+
- templates/proxmox-machine-template-worker.yaml
13+
# - templates/ip-pool.yaml - configure this in your overlay
14+
15+
patches:
16+
# Variables for ClusterClass
17+
- path: variables/allowed-nodes.yaml
18+
target:
19+
kind: ClusterClass
20+
- path: variables/clonespec.yaml
21+
target:
22+
kind: ClusterClass
23+
- path: variables/control-plane-endpoint.yaml
24+
target:
25+
kind: ClusterClass
26+
- path: variables/dns-config.yaml
27+
target:
28+
kind: ClusterClass
29+
- path: variables/ipv4-config.yaml
30+
target:
31+
kind: ClusterClass
32+
- path: variables/ipv6-config.yaml
33+
target:
34+
kind: ClusterClass
35+
- path: variables/kube-proxy.yaml
36+
target:
37+
kind: ClusterClass
38+
# Patches for ClusterClass
39+
- path: patches/KubeadmConfigTemplate/WorkerNodeSetup.yaml
40+
target:
41+
kind: ClusterClass
42+
- path: patches/KubeadmControlPlaneTemplate/ControlPlaneSetup.yaml
43+
target:
44+
kind: ClusterClass
45+
- path: patches/KubeadmControlPlaneTemplate/kube-proxy-setup.yaml
46+
target:
47+
kind: ClusterClass
48+
- path: patches/ProxmoxClusterTemplate/ClusterIPv4Config.yaml
49+
target:
50+
kind: ClusterClass
51+
- path: patches/ProxmoxClusterTemplate/ClusterIPv6Config.yaml
52+
target:
53+
kind: ClusterClass
54+
- path: patches/ProxmoxClusterTemplate/ProxmoxClusterTemplateGeneral.yaml
55+
target:
56+
kind: ClusterClass
57+
- path: patches/ProxmoxMachineTemplate/ControlPlaneCloneDiskFormat.yaml
58+
target:
59+
kind: ClusterClass
60+
- path: patches/ProxmoxMachineTemplate/ControlPlaneDefaultNetwork.yaml
61+
target:
62+
kind: ClusterClass
63+
- path: patches/ProxmoxMachineTemplate/ControlPlaneMem.yaml
64+
target:
65+
kind: ClusterClass
66+
- path: patches/ProxmoxMachineTemplate/ControlPlaneNodeSockets.yaml
67+
target:
68+
kind: ClusterClass
69+
- path: patches/ProxmoxMachineTemplate/WorkerNodeCores.yaml
70+
target:
71+
kind: ClusterClass
72+
- path: patches/ProxmoxMachineTemplate/WorkerNodeDefaultNetwork.yaml
73+
target:
74+
kind: ClusterClass
75+
- path: patches/ProxmoxMachineTemplate/WorkerNodeMem.yaml
76+
target:
77+
kind: ClusterClass
78+
- path: patches/ProxmoxMachineTemplate/WorkerNodeSockets.yaml
79+
target:
80+
kind: ClusterClass
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: caprox-kubernetes-engine
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
- op: add
2+
path: /spec/patches/-
3+
value:
4+
name: WorkerNodeSetup
5+
description: "Configure Worker Node Initialisation"
6+
definitions:
7+
- selector:
8+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
9+
kind: KubeadmConfigTemplate
10+
matchResources:
11+
machineDeploymentClass:
12+
names:
13+
- proxmox-worker
14+
jsonPatches:
15+
- op: add
16+
path: /spec/template/spec/users
17+
valueFrom:
18+
template: |
19+
- name: root
20+
sshAuthorizedKeys: {{ .cloneSpec.sshAuthorizedKeys }}
21+
- selector:
22+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
23+
kind: ProxmoxMachineTemplate
24+
matchResources:
25+
controlPlane: false
26+
machineDeploymentClass:
27+
names:
28+
- proxmox-worker
29+
jsonPatches:
30+
- op: replace
31+
path: /spec/template/spec/sourceNode
32+
valueFrom:
33+
variable: cloneSpec.vmTemplate.sourceNode
34+
- op: replace
35+
path: /spec/template/spec/templateID
36+
valueFrom:
37+
variable: cloneSpec.vmTemplate.templateID
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
- op: add
2+
path: /spec/patches/-
3+
value:
4+
name: ControlPlaneSetup
5+
description: "How to bind the Control Plane and what K8S version"
6+
definitions:
7+
- selector:
8+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
9+
kind: KubeadmControlPlaneTemplate
10+
matchResources:
11+
controlPlane: true
12+
jsonPatches:
13+
- op: add
14+
path: /spec/template/spec/kubeadmConfigSpec/users
15+
valueFrom:
16+
template: |
17+
- name: root
18+
sshAuthorizedKeys: {{ .cloneSpec.sshAuthorizedKeys }}
19+
- op: add
20+
path: /spec/template/spec/kubeadmConfigSpec/files/-
21+
valueFrom:
22+
template: |
23+
owner: root:root
24+
path: /etc/kubernetes/manifests/kube-vip.yaml
25+
content: |
26+
apiVersion: v1
27+
kind: Pod
28+
metadata:
29+
creationTimestamp: null
30+
name: kube-vip
31+
namespace: kube-system
32+
spec:
33+
containers:
34+
- args:
35+
- manager
36+
env:
37+
- name: cp_enable
38+
value: "true"
39+
- name: vip_interface
40+
value: "{{ .cloneSpec.virtualIPNetworkInterface }}"
41+
- name: address
42+
value: "{{ .controlPlaneEndpoint.host }}"
43+
- name: port
44+
value: "6443"
45+
- name: vip_arp
46+
value: "true"
47+
- name: vip_leaderelection
48+
value: "true"
49+
- name: vip_leaseduration
50+
value: "15"
51+
- name: vip_renewdeadline
52+
value: "10"
53+
- name: vip_retryperiod
54+
value: "2"
55+
image: ghcr.io/kube-vip/kube-vip:v0.5.11
56+
imagePullPolicy: IfNotPresent
57+
name: kube-vip
58+
resources: {}
59+
securityContext:
60+
capabilities:
61+
add:
62+
- NET_ADMIN
63+
- NET_RAW
64+
volumeMounts:
65+
- mountPath: /etc/kubernetes/admin.conf
66+
name: kubeconfig
67+
hostAliases:
68+
- hostnames:
69+
- kubernetes
70+
ip: 127.0.0.1
71+
hostNetwork: true
72+
volumes:
73+
- hostPath:
74+
path: /etc/kubernetes/admin.conf
75+
type: FileOrCreate
76+
name: kubeconfig
77+
- selector:
78+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
79+
kind: ProxmoxMachineTemplate
80+
matchResources:
81+
controlPlane: true
82+
jsonPatches:
83+
- op: replace
84+
path: /spec/template/spec/sourceNode
85+
valueFrom:
86+
variable: cloneSpec.vmTemplate.sourceNode
87+
- op: replace
88+
path: /spec/template/spec/templateID
89+
valueFrom:
90+
variable: cloneSpec.vmTemplate.templateID
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
- op: add
2+
path: /spec/patches/-
3+
value:
4+
name: kube-proxy-setup
5+
description: "kube-proxy configuration"
6+
enabledIf: "{{ if eq .kubeProxy.mode \"ipvs\" }}true{{ end }}"
7+
definitions:
8+
- selector:
9+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
10+
kind: KubeadmControlPlaneTemplate
11+
matchResources:
12+
controlPlane: true
13+
jsonPatches:
14+
- op: add
15+
path: /spec/template/spec/kubeadmConfigSpec/files/-
16+
valueFrom:
17+
template: |
18+
content: |
19+
#/bin/sh
20+
cat >> /run/kubeadm/kubeadm.yaml <<EOF
21+
---
22+
apiVersion: kubeproxy.config.k8s.io/v1alpha1
23+
kind: KubeProxyConfiguration
24+
mode: "ipvs"
25+
ipvs:
26+
strictARP: true
27+
EOF
28+
owner: root:root
29+
permissions: "0755"
30+
path: /tmp/kube-proxy.sh
31+
- op: add
32+
path: /spec/template/spec/kubeadmConfigSpec/preKubeadmCommands/-
33+
value: /tmp/kube-proxy.sh
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
- op: add
2+
path: /spec/patches/-
3+
value:
4+
name: ClusterIPv4Config
5+
description: "Configure Cluster IPv4 config"
6+
enabledIf: "{{ if .ipv4Config }}true{{ end }}"
7+
definitions:
8+
- selector:
9+
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
10+
kind: ProxmoxClusterTemplate
11+
matchResources:
12+
infrastructureCluster: true
13+
jsonPatches:
14+
- op: add
15+
path: /spec/template/spec/ipv4Config
16+
valueFrom:
17+
variable: ipv4Config

0 commit comments

Comments
 (0)