Skip to content

Commit 41ce348

Browse files
committed
create cluster-stack for rke2
Signed-off-by: Axel Schmidt <[email protected]>
1 parent 2264f9f commit 41ce348

20 files changed

+1487
-0
lines changed

providers/openstack/rke2/README.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Cluster Stacks
2+
3+
## Getting started
4+
5+
At first you need a Ready installed Rancher Management Dashboard (without any existing Downstreamclusters installed via custom-cluster. The cso will breake the management).
6+
7+
For Rancher Version < 2.13 you must install the Rancher Turtles to open the preinstalled capi. https://ranchermanager.docs.rancher.com/integrations-in-rancher/cluster-api/overview
8+
9+
For Rancher Version >= 2.13 the Rancher Turtles is preinstalled and enabled by default. Only the Rancher Turtles UI must be installed sepratly. https://turtles.docs.rancher.com/turtles/v0.24/en/tutorials/quickstart.html#_capi_ui_extension_installation
10+
11+
Now you must install following providers (via GUI Cluster Management > CAPI > Provider > Create)
12+
13+
|Key|Value bootstrap|Value controlplane|Value infrastructure|
14+
|---|---|---|--|
15+
|Namespace|rke2-bootstrap|rke2-controlplane|capo-system|
16+
|Name|rke2-bootstrap|rke2-controlplane|infrastructure-openstack|
17+
|Provider|rke2|rke2|openstack|
18+
|Provider type|bootstrap|controlPlane|infrastructure|
19+
|Features Enable cluster resource set|yes|yes|yes|
20+
|Features Enable cluster topology|yes|yes|yes|
21+
|Features Enable machine pool|yes|yes|yes|
22+
|Variables|EXP_RUNTIME_SDK=true|EXP_RUNTIME_SDK=true|EXP_RUNTIME_SDK=true|
23+
24+
25+
26+
```sh
27+
# Init openstack resource controller
28+
kubectl apply -f https://github.com/k-orc/openstack-resource-controller/releases/latest/download/install.yaml
29+
30+
```
31+
32+
```
33+
# Install CSO and CSPO
34+
helm upgrade -i cso \
35+
-n cso-system \
36+
--create-namespace \
37+
oci://registry.scs.community/cluster-stacks/cso
38+
```
39+
40+
```sh
41+
export CLUSTER_NAMESPACE=cluster
42+
export CLUSTER_NAME=my-cluster
43+
export CLUSTERSTACK_NAMESPACE=cluster
44+
export CLUSTERSTACK_VERSION=v6
45+
export OS_CLIENT_CONFIG_FILE=${PWD}/clouds.yaml
46+
kubectl create namespace $CLUSTER_NAMESPACE --dry-run=client -o yaml | kubectl apply -f -
47+
kubectl label namespace $CLUSTER_NAMESPACE cluster-api.cattle.io/rancher-auto-import=true
48+
```
49+
50+
```sh
51+
# Create secret for CAPO
52+
kubectl create secret -n $CLUSTER_NAMESPACE generic openstack --from-file=clouds.yaml=$OS_CLIENT_CONFIG_FILE --dry-run=client -oyaml | kubectl apply -f -
53+
54+
# Prepare the Secret as it will be deployed in the Workload Cluster
55+
kubectl create secret -n kube-system generic clouds-yaml --from-file=clouds.yaml=$OS_CLIENT_CONFIG_FILE --dry-run=client -oyaml > clouds-yaml-secret
56+
57+
# Add the Secret to the ClusterResourceSet Secret in the Management Cluster
58+
kubectl create -n $CLUSTER_NAMESPACE secret generic clouds-yaml --from-file=clouds-yaml-secret --type=addons.cluster.x-k8s.io/resource-set --dry-run=client -oyaml | kubectl apply -f -
59+
```
60+
61+
```yaml
62+
cat <<EOF | kubectl apply -f -
63+
apiVersion: addons.cluster.x-k8s.io/v1beta1
64+
kind: ClusterResourceSet
65+
metadata:
66+
name: clouds-yaml
67+
namespace: $CLUSTER_NAMESPACE
68+
spec:
69+
strategy: "Reconcile"
70+
clusterSelector:
71+
matchLabels:
72+
managed-secret: clouds-yaml
73+
resources:
74+
- name: clouds-yaml
75+
kind: Secret
76+
EOF
77+
```
78+
79+
```sh
80+
# Apply ClusterStack resource
81+
cat <<EOF | kubectl apply -f -
82+
apiVersion: clusterstack.x-k8s.io/v1alpha1
83+
kind: ClusterStack
84+
metadata:
85+
name: openstack
86+
namespace: $CLUSTERSTACK_NAMESPACE
87+
spec:
88+
provider: openstack
89+
name: rke2
90+
kubernetesVersion: "1.33"
91+
channel: stable
92+
autoSubscribe: false
93+
noProvider: true
94+
versions:
95+
- $CLUSTERSTACK_VERSION
96+
EOF
97+
```
98+
99+
```sh
100+
# Apply Cluster resource
101+
cat <<EOF | kubectl apply -f -
102+
apiVersion: cluster.x-k8s.io/v1beta1
103+
kind: Cluster
104+
metadata:
105+
name: $CLUSTER_NAME
106+
namespace: $CLUSTER_NAMESPACE
107+
108+
labels:
109+
managed-secret: clouds-yaml
110+
spec:
111+
clusterNetwork:
112+
pods:
113+
cidrBlocks:
114+
- "172.16.0.0/16"
115+
serviceDomain: cluster.local
116+
services:
117+
cidrBlocks:
118+
- "10.96.0.0/12"
119+
topology:
120+
variables:
121+
- name: clusterCNI
122+
value: "cilium" # also calicio is posible, but musst be manual patched after install: kubectl patch ippools.crd.projectcalico.org default-ipv4-ippool --type='json' -p '[{"op": "replace", "path": "/spec/ipipMode", "value":"CrossSubnet"}]'
123+
- name: apiServerLoadBalancer
124+
value: "octavia-ovn"
125+
- name: imageAddVersion
126+
value: false
127+
- name: imageName
128+
value: "Ubuntu 24.04"
129+
- name: workerFlavor
130+
value: "SCS-4V-8"
131+
- name: controlPlaneFlavor
132+
value: "SCS-4V-8"
133+
- name: bastionFlavor
134+
value: "SCS-2V-4"
135+
- name: bastionEnabled
136+
value: true
137+
class: openstack-rke2-1-33-$CLUSTERSTACK_VERSION
138+
classNamespace: $CLUSTERSTACK_NAMESPACE
139+
controlPlane:
140+
replicas: 1
141+
version: v1.33.6+rke2r1
142+
workers:
143+
machineDeployments:
144+
- class: default-worker
145+
name: md-0
146+
replicas: 1
147+
EOF
148+
```
149+
150+
```sh
151+
clusterctl get kubeconfig -n $CLUSTER_NAMESPACE $CLUSTER_NAME > /tmp/kubeconfig
152+
kubectl get nodes --kubeconfig /tmp/kubeconfig
153+
# Enable rke2-ingress-loadbalancer
154+
kubectl --kubeconfig /tmp/kubeconfig -n kube-system patch HelmChart.helm.cattle.io rke2-ingress-nginx --type='json' -p '[{"op": "add", "path": "/spec/set/'controller.service.enabled'", "value":"true"}]'
155+
# Set rke2-ingress-loadbalancer-IP
156+
kubectl --kubeconfig /tmp/kubeconfig -n kube-system patch HelmChart.helm.cattle.io rke2-ingress-nginx --type='json' -p '[{"op": "add", "path": "/spec/set/'controller.service.loadBalancerIP'", "value":"xxx.xxx.xxx.xxx"}]'
157+
158+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v2
2+
type: application
3+
description: CCM
4+
name: CCM
5+
version: v1
6+
dependencies:
7+
- alias: openstack-cloud-controller-manager
8+
name: openstack-cloud-controller-manager
9+
repository: https://kubernetes.github.io/cloud-provider-openstack
10+
version: 2.33.1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
values: |
2+
openstack-cloud-controller-manager:
3+
cluster:
4+
name: {{ .Cluster.metadata.name }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
openstack-cloud-controller-manager:
2+
secret:
3+
enabled: true
4+
name: ccm-cloud-config
5+
create: true
6+
nodeSelector:
7+
tolerations:
8+
- key: node.cloudprovider.kubernetes.io/uninitialized
9+
value: "true"
10+
effect: NoSchedule
11+
extraVolumes:
12+
- name: clouds-yaml
13+
secret:
14+
secretName: clouds-yaml
15+
extraVolumeMounts:
16+
- name: clouds-yaml
17+
readOnly: true
18+
mountPath: /etc/openstack
19+
cloudConfig:
20+
global:
21+
use-clouds: true
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: v2
2+
type: application
3+
description: CSI
4+
name: CSI
5+
version: v1
6+
dependencies:
7+
- alias: openstack-cinder-csi
8+
name: openstack-cinder-csi
9+
repository: https://kubernetes.github.io/cloud-provider-openstack
10+
version: 2.33.1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
values: |
2+
openstack-cinder-csi:
3+
clusterID: "{{ .Cluster.metadata.name }}"
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
openstack-cinder-csi:
2+
secret:
3+
enabled: true
4+
name: csi-cloud-config
5+
create: true
6+
filename: cloud.conf
7+
data:
8+
cloud.conf: |-
9+
[Global]
10+
use-clouds = "true"
11+
clouds-file = /etc/openstack/clouds.yaml
12+
storageClass:
13+
delete:
14+
isDefault: true
15+
csi:
16+
plugin:
17+
volumes:
18+
- name: clouds-yaml
19+
secret:
20+
secretName: clouds-yaml
21+
- name: cloud-conf
22+
secret:
23+
secretName: csi-cloud-config
24+
volumeMounts:
25+
- name: clouds-yaml
26+
readOnly: true
27+
mountPath: /etc/openstack
28+
- name: cloud-conf
29+
readOnly: true
30+
mountPath: /etc/kubernetes
31+
- name: cloud-conf
32+
readOnly: true
33+
mountPath: /etc/config
34+
nodeSelector:
35+
node-role.kubernetes.io/control-plane: ""
36+
tolerations:
37+
- key: node.cloudprovider.kubernetes.io/uninitialized
38+
value: "true"
39+
effect: NoSchedule
40+
- key: node-role.kubernetes.io/control-plane
41+
effect: NoSchedule
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: v2
2+
description: "This chart installs and configures:
3+
4+
* Openstack rke2 Cluster Class
5+
6+
"
7+
name: openstack-rke2-1-33-cluster-class
8+
type: application
9+
version: v1
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "cluster-class.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "cluster-class.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "cluster-class.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "cluster-class.labels" -}}
37+
helm.sh/chart: {{ include "cluster-class.chart" . }}
38+
{{ include "cluster-class.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "cluster-class.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "cluster-class.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
{{/*
54+
Create the name of the service account to use
55+
*/}}
56+
{{- define "cluster-class.serviceAccountName" -}}
57+
{{- if .Values.serviceAccount.create }}
58+
{{- default (include "cluster-class.fullname" .) .Values.serviceAccount.name }}
59+
{{- else }}
60+
{{- default "default" .Values.serviceAccount.name }}
61+
{{- end }}
62+
{{- end }}

0 commit comments

Comments
 (0)