Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rke2 flavor support #144

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
- [Getting Started](./topics/getting-started.md)
- [Troubleshooting](./topics/troubleshooting.md)
- [Addons](./topics/addons.md)
- [Flavors](./topics/flavors/flavors.md)
- [Default (kubeadm)](./topics/flavors/default.md)
- [ClusterClass kubeadm](./topics/flavors/clusterclass-kubeadm.md)
- [k3s](./topics/flavors/k3s.md)
- [rke2](./topics/flavors/rke2.md)
- [Development](./developers/development.md)
- [Releasing](./developers/releasing.md)
- [Reference](./reference/reference.md)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Flavors

This section contains information about supported flavors in Cluster API Provider Linode

In `clusterctl` the infrastructure provider authors can provide different types
of cluster templates referred to as "flavors". You can use the `--flavor` flag
to specify which flavor to use for a cluster, e.g:
Expand All @@ -11,10 +13,3 @@ clusterctl generate cluster test-cluster --flavor clusterclass
To use the default flavor, omit the `--flavor` flag.

See the [`clusterctl` flavors docs](https://cluster-api.sigs.k8s.io/clusterctl/commands/generate-cluster.html#flavors) for more information.


## Supported flavors

- [Default (kubeadm)](default.md)
- [Cluster Class Kubeadm](clusterclass-kubeadm.md)
- [k3s](k3s.md)
File renamed without changes.
24 changes: 24 additions & 0 deletions docs/src/topics/flavors/rke2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# RKE2
## Specification
| Control Plane | CNI | Default OS | Installs ClusterClass |
|-----------------------------|--------|--------------|-----------------------|
| [rke2](https://docs.rke2.io/) | Cilium | Ubuntu 22.04 | No |
## Prerequisites
* [Quickstart](../topics/getting-started.md) completed
* Select an [rke2 kubernetes version](https://github.com/rancher/rke2/releases) to set for the kubernetes version
```bash
export KUBERNETES_VERSION=v1.29.1+rke2r1
```
* Installed [rke2 bootstrap provider](https://github.com/rancher-sandbox/cluster-api-provider-rke2) into your management cluster
```shell
clusterctl init --bootstrap rke2 --control-plane rke2
```
## Usage
1. Generate cluster yaml
```bash
clusterctl generate cluster test-cluster --infrastructure linode:0.0.0 --flavor rke2 > test-rke2-cluster.yaml
```
2. Apply cluster yaml
```bash
kubectl apply -f test-rke2-cluster.yaml
```
22 changes: 22 additions & 0 deletions templates/flavors/rke2/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
resources:
- ../base
- rke2ControlPlane.yaml
- rke2ConfigTemplate.yaml
- secret.yaml
patches:
- target:
group: cluster.x-k8s.io
version: v1beta1
kind: Cluster
patch: |-
- op: replace
path: /spec/controlPlaneRef/kind
value: RKE2ControlPlane
- target:
group: cluster.x-k8s.io
version: v1beta1
kind: MachineDeployment
patch: |-
- op: replace
path: /spec/template/spec/bootstrap/configRef/kind
value: RKE2ConfigTemplate
18 changes: 18 additions & 0 deletions templates/flavors/rke2/rke2ConfigTemplate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha1
kind: RKE2ConfigTemplate
metadata:
name: ${CLUSTER_NAME}-md-0
spec:
template:
spec:
agentConfig:
version: ${KUBERNETES_VERSION}
nodeName: '{{ ds.meta_data.label }}'
kubelet:
extraArgs:
- "provider-id=linode://{{ ds.meta_data.id }}"
preRKE2Commands:
- sed -i '/swap/d' /etc/fstab
- swapoff -a
- hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname
42 changes: 42 additions & 0 deletions templates/flavors/rke2/rke2ControlPlane.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
apiVersion: controlplane.cluster.x-k8s.io/v1alpha1
kind: RKE2ControlPlane
metadata:
name: ${CLUSTER_NAME}-control-plane
spec:
infrastructureRef:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: LinodeMachineTemplate
name: ${CLUSTER_NAME}-control-plane
files:
- contentFrom:
secret:
key: linode-ccm.yaml
name: linode-${CLUSTER_NAME}-crs-0
owner: root:root
path: /var/lib/rancher/rke2/server/manifests/linode-ccm.yaml
- contentFrom:
secret:
key: linode-token-region.yaml
name: linode-${CLUSTER_NAME}-crs-0
owner: root:root
path: /var/lib/rancher/rke2/server/manifests/linode-token-region.yaml
serverConfig:
cni: cilium
cloudProviderName: external
disableComponents:
pluginComponents:
- "rke2-ingress-nginx"
kubernetesComponents:
- "cloudController"
agentConfig:
version: ${KUBERNETES_VERSION}
nodeName: '{{ ds.meta_data.label }}'
kubelet:
extraArgs:
- "provider-id=linode://{{ ds.meta_data.id }}"
preRKE2Commands:
- sed -i '/swap/d' /etc/fstab
- swapoff -a
- hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
32 changes: 32 additions & 0 deletions templates/flavors/rke2/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: v1
kind: Secret
metadata:
name: linode-${CLUSTER_NAME}-crs-0
stringData:
linode-token-region.yaml: |-
kind: Secret
apiVersion: v1
metadata:
name: linode-token-region
namespace: kube-system
stringData:
apiToken: ${LINODE_TOKEN}
region: ${LINODE_REGION}
linode-ccm.yaml: |-
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
namespace: kube-system
name: ccm-linode
spec:
targetNamespace: kube-system
version: ${LINODE_CCM_VERSION:=v0.3.24}
chart: ccm-linode
repo: https://linode.github.io/linode-cloud-controller-manager/
bootstrap: true
valuesContent: |-
secretRef:
name: "linode-token-region"
nodeSelector:
node-role.kubernetes.io/control-plane: "true"