Skip to content

Commit 6fd78e7

Browse files
committed
add hetzner template
1 parent 099d28f commit 6fd78e7

File tree

2 files changed

+230
-0
lines changed

2 files changed

+230
-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: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
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+
- metallb
67+
riskLevel: "${SNAP_RISKLEVEL:=}"
68+
confinement: "${SNAP_CONFINEMENT:=}"
69+
clusterConfiguration:
70+
portCompatibilityRemap: true
71+
machineTemplate:
72+
infrastructureTemplate:
73+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
74+
kind: HCloudMachineTemplate
75+
name: "${CLUSTER_NAME}-control-plane"
76+
replicas: ${CONTROL_PLANE_MACHINE_COUNT:=1}
77+
version: "v${KUBERNETES_VERSION}"
78+
upgradeStrategy: "${UPGRADE_STRATEGY}"
79+
---
80+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
81+
kind: HCloudMachineTemplate
82+
metadata:
83+
name: ${CLUSTER_NAME}-control-plane
84+
spec:
85+
template:
86+
spec:
87+
imageName: ubuntu-22.04
88+
placementGroupName: control-plane
89+
type: ${HCLOUD_CONTROL_PLANE_MACHINE_TYPE}
90+
---
91+
apiVersion: cluster.x-k8s.io/v1beta1
92+
kind: MachineDeployment
93+
metadata:
94+
labels:
95+
nodepool: ${CLUSTER_NAME}-md-0
96+
name: ${CLUSTER_NAME}-md-0
97+
spec:
98+
clusterName: ${CLUSTER_NAME}
99+
replicas: ${WORKER_MACHINE_COUNT}
100+
selector:
101+
matchLabels: null
102+
template:
103+
metadata:
104+
labels:
105+
nodepool: ${CLUSTER_NAME}-md-0
106+
spec:
107+
bootstrap:
108+
configRef:
109+
name: "${CLUSTER_NAME}-md-0"
110+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
111+
kind: MicroK8sConfigTemplate
112+
clusterName: ${CLUSTER_NAME}
113+
failureDomain: ${HCLOUD_REGION}
114+
infrastructureRef:
115+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
116+
kind: HCloudMachineTemplate
117+
name: ${CLUSTER_NAME}-md-0
118+
version: ${KUBERNETES_VERSION}
119+
---
120+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
121+
kind: HCloudMachineTemplate
122+
metadata:
123+
name: ${CLUSTER_NAME}-md-0
124+
spec:
125+
template:
126+
spec:
127+
imageName: ubuntu-22.04
128+
placementGroupName: md-0
129+
type: ${HCLOUD_WORKER_MACHINE_TYPE}
130+
---
131+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
132+
kind: MicroK8sConfigTemplate
133+
metadata:
134+
name: "${CLUSTER_NAME}-md-0"
135+
spec:
136+
template:
137+
spec:
138+
clusterConfiguration:
139+
portCompatibilityRemap: true
140+
initConfiguration:
141+
riskLevel: "${SNAP_RISKLEVEL:=}"
142+
confinement: "${SNAP_CONFINEMENT:=}"
143+
---
144+
apiVersion: cluster.x-k8s.io/v1beta1
145+
kind: MachineHealthCheck
146+
metadata:
147+
name: ${CLUSTER_NAME}-control-plane-unhealthy-5m
148+
spec:
149+
clusterName: ${CLUSTER_NAME}
150+
maxUnhealthy: 100%
151+
nodeStartupTimeout: 15m
152+
remediationTemplate:
153+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
154+
kind: HCloudRemediationTemplate
155+
name: control-plane-remediation-request
156+
selector:
157+
matchLabels:
158+
cluster.x-k8s.io/control-plane: ""
159+
unhealthyConditions:
160+
- status: Unknown
161+
timeout: 180s
162+
type: Ready
163+
- status: "False"
164+
timeout: 180s
165+
type: Ready
166+
---
167+
apiVersion: cluster.x-k8s.io/v1beta1
168+
kind: MachineHealthCheck
169+
metadata:
170+
name: ${CLUSTER_NAME}-md-0-unhealthy-5m
171+
spec:
172+
clusterName: ${CLUSTER_NAME}
173+
maxUnhealthy: 100%
174+
nodeStartupTimeout: 10m
175+
remediationTemplate:
176+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
177+
kind: HCloudRemediationTemplate
178+
name: worker-remediation-request
179+
selector:
180+
matchLabels:
181+
nodepool: ${CLUSTER_NAME}-md-0
182+
unhealthyConditions:
183+
- status: Unknown
184+
timeout: 180s
185+
type: Ready
186+
- status: "False"
187+
timeout: 180s
188+
type: Ready
189+
---
190+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
191+
kind: HCloudRemediationTemplate
192+
metadata:
193+
name: control-plane-remediation-request
194+
spec:
195+
template:
196+
spec:
197+
strategy:
198+
retryLimit: 1
199+
timeout: 180s
200+
type: Reboot
201+
---
202+
apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
203+
kind: HCloudRemediationTemplate
204+
metadata:
205+
name: worker-remediation-request
206+
spec:
207+
template:
208+
spec:
209+
strategy:
210+
retryLimit: 1
211+
timeout: 180s
212+
type: Reboot

0 commit comments

Comments
 (0)