Skip to content

Commit d74705b

Browse files
committed
add hetzner template
1 parent 099d28f commit d74705b

File tree

2 files changed

+231
-0
lines changed

2 files changed

+231
-0
lines changed

templates/cluster-template-hetzner.rc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Kubernetes cluster configuration
2+
export KUBERNETES_VERSION=1.28.8
3+
export CONTROL_PLANE_MACHINE_COUNT=1
4+
export WORKER_MACHINE_COUNT=1
5+
6+
# Hetzner Cloud configuration
7+
HCLOUD_SECRET_NAME=hetzner
8+
HCLOUD_CONTROL_PLANE_MACHINE_TYPE=cax11
9+
HCLOUD_REGION=fsn1
10+
HCLOUD_SSH_KEY=my-ssh-key
11+
HCLOUD_WORKER_MACHINE_TYPE=cax11
12+
13+
# Snap risk level and confinement
14+
SNAP_CONFINEMENT=classic
15+
SNAP_RISKLEVEL=stable
16+
17+
# Upgrade configuration
18+
export UPGRADE_STRATEGY=SmartUpgrade
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
apiVersion: cluster.x-k8s.io/v1beta1
2+
kind: Cluster
3+
metadata:
4+
name: ${CLUSTER_NAME}
5+
spec:
6+
clusterNetwork:
7+
pods:
8+
cidrBlocks:
9+
- ${CLUSTER_POD_CIDR_BLOCK:=10.0.128.0/17}
10+
services:
11+
cidrBlocks:
12+
- ${CLUSTER_SERVICE_CIDR_BLOCK:=10.0.8.0/21}
13+
controlPlaneRef:
14+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
15+
kind: MicroK8sControlPlane
16+
name: ${CLUSTER_NAME}-control-plane
17+
infrastructureRef:
18+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
19+
kind: HetznerCluster
20+
name: ${CLUSTER_NAME}
21+
---
22+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
23+
kind: HetznerCluster
24+
metadata:
25+
name: ${CLUSTER_NAME}
26+
spec:
27+
controlPlaneEndpoint:
28+
host: ""
29+
port: 443
30+
controlPlaneLoadBalancer:
31+
enabled: true
32+
region: ${HCLOUD_REGION}
33+
controlPlaneRegions:
34+
- ${HCLOUD_REGION}
35+
hcloudNetwork:
36+
enabled: true
37+
cidrBlock: ${HCLOUD_CIDR_BLOCK:=10.0.0.0/16}
38+
subnetCidrBlock: ${HCLOUD_SUBNET_CIDR_BLOCK:=10.0.0.0/24}
39+
hcloudPlacementGroups:
40+
- name: control-plane
41+
type: spread
42+
- name: md-0
43+
type: spread
44+
hetznerSecretRef:
45+
key:
46+
hcloudToken: hcloud
47+
hetznerRobotPassword: robot-password
48+
hetznerRobotUser: robot-user
49+
name: ${HCLOUD_SECRET_NAME:=hetzner}
50+
sshKeys:
51+
hcloud:
52+
- name: ${HCLOUD_SSH_KEY}
53+
---
54+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
55+
kind: MicroK8sControlPlane
56+
metadata:
57+
name: "${CLUSTER_NAME}-control-plane"
58+
spec:
59+
controlPlaneConfig:
60+
initConfiguration:
61+
addons:
62+
- dns
63+
- ingress
64+
- cert-manager
65+
- metrics-server
66+
- cilium
67+
- metallb
68+
riskLevel: "${SNAP_RISKLEVEL:=}"
69+
confinement: "${SNAP_CONFINEMENT:=}"
70+
clusterConfiguration:
71+
portCompatibilityRemap: true
72+
machineTemplate:
73+
infrastructureTemplate:
74+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
75+
kind: HCloudMachineTemplate
76+
name: "${CLUSTER_NAME}-control-plane"
77+
replicas: ${CONTROL_PLANE_MACHINE_COUNT:=1}
78+
version: "v${KUBERNETES_VERSION}"
79+
upgradeStrategy: "${UPGRADE_STRATEGY}"
80+
---
81+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
82+
kind: HCloudMachineTemplate
83+
metadata:
84+
name: ${CLUSTER_NAME}-control-plane
85+
spec:
86+
template:
87+
spec:
88+
imageName: ubuntu-22.04
89+
placementGroupName: control-plane
90+
type: ${HCLOUD_CONTROL_PLANE_MACHINE_TYPE}
91+
---
92+
apiVersion: cluster.x-k8s.io/v1beta1
93+
kind: MachineDeployment
94+
metadata:
95+
labels:
96+
nodepool: ${CLUSTER_NAME}-md-0
97+
name: ${CLUSTER_NAME}-md-0
98+
spec:
99+
clusterName: ${CLUSTER_NAME}
100+
replicas: ${WORKER_MACHINE_COUNT}
101+
selector:
102+
matchLabels: null
103+
template:
104+
metadata:
105+
labels:
106+
nodepool: ${CLUSTER_NAME}-md-0
107+
spec:
108+
bootstrap:
109+
configRef:
110+
name: "${CLUSTER_NAME}-md-0"
111+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
112+
kind: MicroK8sConfigTemplate
113+
clusterName: ${CLUSTER_NAME}
114+
failureDomain: ${HCLOUD_REGION}
115+
infrastructureRef:
116+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
117+
kind: HCloudMachineTemplate
118+
name: ${CLUSTER_NAME}-md-0
119+
version: ${KUBERNETES_VERSION}
120+
---
121+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
122+
kind: HCloudMachineTemplate
123+
metadata:
124+
name: ${CLUSTER_NAME}-md-0
125+
spec:
126+
template:
127+
spec:
128+
imageName: ubuntu-22.04
129+
placementGroupName: md-0
130+
type: ${HCLOUD_WORKER_MACHINE_TYPE}
131+
---
132+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
133+
kind: MicroK8sConfigTemplate
134+
metadata:
135+
name: "${CLUSTER_NAME}-md-0"
136+
spec:
137+
template:
138+
spec:
139+
clusterConfiguration:
140+
portCompatibilityRemap: true
141+
initConfiguration:
142+
riskLevel: "${SNAP_RISKLEVEL:=}"
143+
confinement: "${SNAP_CONFINEMENT:=}"
144+
---
145+
apiVersion: cluster.x-k8s.io/v1beta1
146+
kind: MachineHealthCheck
147+
metadata:
148+
name: ${CLUSTER_NAME}-control-plane-unhealthy-5m
149+
spec:
150+
clusterName: ${CLUSTER_NAME}
151+
maxUnhealthy: 100%
152+
nodeStartupTimeout: 15m
153+
remediationTemplate:
154+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
155+
kind: HCloudRemediationTemplate
156+
name: control-plane-remediation-request
157+
selector:
158+
matchLabels:
159+
cluster.x-k8s.io/control-plane: ""
160+
unhealthyConditions:
161+
- status: Unknown
162+
timeout: 180s
163+
type: Ready
164+
- status: "False"
165+
timeout: 180s
166+
type: Ready
167+
---
168+
apiVersion: cluster.x-k8s.io/v1beta1
169+
kind: MachineHealthCheck
170+
metadata:
171+
name: ${CLUSTER_NAME}-md-0-unhealthy-5m
172+
spec:
173+
clusterName: ${CLUSTER_NAME}
174+
maxUnhealthy: 100%
175+
nodeStartupTimeout: 10m
176+
remediationTemplate:
177+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
178+
kind: HCloudRemediationTemplate
179+
name: worker-remediation-request
180+
selector:
181+
matchLabels:
182+
nodepool: ${CLUSTER_NAME}-md-0
183+
unhealthyConditions:
184+
- status: Unknown
185+
timeout: 180s
186+
type: Ready
187+
- status: "False"
188+
timeout: 180s
189+
type: Ready
190+
---
191+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
192+
kind: HCloudRemediationTemplate
193+
metadata:
194+
name: control-plane-remediation-request
195+
spec:
196+
template:
197+
spec:
198+
strategy:
199+
retryLimit: 1
200+
timeout: 180s
201+
type: Reboot
202+
---
203+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
204+
kind: HCloudRemediationTemplate
205+
metadata:
206+
name: worker-remediation-request
207+
spec:
208+
template:
209+
spec:
210+
strategy:
211+
retryLimit: 1
212+
timeout: 180s
213+
type: Reboot

0 commit comments

Comments
 (0)