From e33a36a890e7ef72839549a7681792ae67820985 Mon Sep 17 00:00:00 2001 From: Ashley Dumaine <5779804+AshleyDumaine@users.noreply.github.com> Date: Wed, 10 Apr 2024 14:54:46 -0400 Subject: [PATCH] [feat] Create new dual-stack flavor (#241) * create new dual-stack flavor * add dual-stack flavor doc, formatting --- docs/src/SUMMARY.md | 1 + .../topics/flavors/clusterclass-kubeadm.md | 13 +++--- docs/src/topics/flavors/default.md | 9 ++-- docs/src/topics/flavors/dual-stack.md | 18 ++++++++ .../src/topics/flavors/etcd-backup-restore.md | 6 +-- docs/src/topics/flavors/k3s.md | 10 +++-- docs/src/topics/flavors/rke2.md | 10 +++-- templates/addons/cilium/cilium-ipv6.yaml | 29 +++++++++++++ templates/addons/cilium/cilium.yaml | 5 ++- templates/addons/cilium/kustomization.yaml | 1 + templates/common-init-files/secret.yaml | 1 + .../flavors/dual-stack/kustomization.yaml | 42 +++++++++++++++++++ 12 files changed, 123 insertions(+), 22 deletions(-) create mode 100644 docs/src/topics/flavors/dual-stack.md create mode 100644 templates/addons/cilium/cilium-ipv6.yaml create mode 100644 templates/flavors/dual-stack/kustomization.yaml diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index 2b61f8304..a671b6574 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -7,6 +7,7 @@ - [Addons](./topics/addons.md) - [Flavors](./topics/flavors/flavors.md) - [Default (kubeadm)](./topics/flavors/default.md) + - [Dual-stack (kubeadm)](./topics/flavors/dual-stack.md) - [ClusterClass kubeadm](./topics/flavors/clusterclass-kubeadm.md) - [k3s](./topics/flavors/k3s.md) - [rke2](./topics/flavors/rke2.md) diff --git a/docs/src/topics/flavors/clusterclass-kubeadm.md b/docs/src/topics/flavors/clusterclass-kubeadm.md index 2b5bd152b..72f63864d 100644 --- a/docs/src/topics/flavors/clusterclass-kubeadm.md +++ b/docs/src/topics/flavors/clusterclass-kubeadm.md @@ -1,15 +1,17 @@ # Kubeadm ClusterClass ## Specification -| Control Plane | CNI | Default OS | Installs ClusterClass | -|---------------|--------|--------------|-----------------------| -| Kubeadm | Cilium | Ubuntu 22.04 | Yes | +| Control Plane | CNI | Default OS | Installs ClusterClass | IPv4 | IPv6 | +|---------------|--------|--------------|-----------------------|------|------| +| Kubeadm | Cilium | Ubuntu 22.04 | Yes | Yes | No | ## Prerequisites [Quickstart](../getting-started.md) completed ## Usage ### Create clusterClass and first cluster 1. Generate the ClusterClass and cluster manifests ```bash - clusterctl generate cluster test-cluster --infrastructure linode:0.0.0 --flavor clusterclass-kubeadm > test-cluster.yaml + clusterctl generate cluster test-cluster \ + --infrastructure linode:0.0.0 \ + --flavor clusterclass-kubeadm > test-cluster.yaml ``` 2. Apply cluster manifests ```bash @@ -18,7 +20,8 @@ ### (Optional) Create a second cluster using the existing ClusterClass 1. Generate cluster manifests ```bash - clusterctl generate cluster test-cluster-2 --flavor clusterclass-kubeadm > test-cluster-2.yaml + clusterctl generate cluster test-cluster-2 \ + --flavor clusterclass-kubeadm > test-cluster-2.yaml ``` ```yaml apiVersion: cluster.x-k8s.io/v1beta1 diff --git a/docs/src/topics/flavors/default.md b/docs/src/topics/flavors/default.md index 97ef5f221..d9278aec8 100644 --- a/docs/src/topics/flavors/default.md +++ b/docs/src/topics/flavors/default.md @@ -1,14 +1,15 @@ # Default ## Specification -| Control Plane | CNI | Default OS | Installs ClusterClass | -|---------------|--------|--------------|-----------------------| -| Kubeadm | Cilium | Ubuntu 22.04 | No | +| Control Plane | CNI | Default OS | Installs ClusterClass | IPv4 | IPv6 | +|---------------|--------|--------------|-----------------------|------|------| +| Kubeadm | Cilium | Ubuntu 22.04 | No | Yes | No | ## Prerequisites [Quickstart](../getting-started.md) completed ## Usage 1. Generate cluster yaml ```bash - clusterctl generate cluster test-cluster --infrastructure linode:0.0.0 > test-cluster.yaml + clusterctl generate cluster test-cluster \ + --infrastructure linode:0.0.0 > test-cluster.yaml ``` 2. Apply cluster yaml ```bash diff --git a/docs/src/topics/flavors/dual-stack.md b/docs/src/topics/flavors/dual-stack.md new file mode 100644 index 000000000..c2e96c95a --- /dev/null +++ b/docs/src/topics/flavors/dual-stack.md @@ -0,0 +1,18 @@ +# Dual-Stack +## Specification +| Control Plane | CNI | Default OS | Installs ClusterClass | IPv4 | IPv6 | +|---------------|--------|--------------|-----------------------|------|------| +| Kubeadm | Cilium | Ubuntu 22.04 | No | Yes | Yes | +## Prerequisites +[Quickstart](../topics/getting-started.md) completed +## Usage +1. Generate cluster yaml + ```bash + clusterctl generate cluster test-cluster \ + --infrastructure linode:0.0.0 \ + --flavor dual-stack > test-cluster.yaml + ``` +2. Apply cluster yaml + ```bash + kubectl apply -f test-cluster.yaml + ``` diff --git a/docs/src/topics/flavors/etcd-backup-restore.md b/docs/src/topics/flavors/etcd-backup-restore.md index 55e96e60b..ad48498c3 100644 --- a/docs/src/topics/flavors/etcd-backup-restore.md +++ b/docs/src/topics/flavors/etcd-backup-restore.md @@ -1,9 +1,9 @@ # etcd-backup-restore ## Specification -| Control Plane | CNI | Default OS | Installs ClusterClass | Installs etcd backup | -|---------------|--------|--------------|-----------------------|----------------------| -| Kubeadm | Cilium | Ubuntu 22.04 | No | Yes | +| Control Plane | CNI | Default OS | Installs ClusterClass | Installs etcd backup | IPv4 | IPv6 | +|---------------|--------|--------------|-----------------------|----------------------|------|------| +| Kubeadm | Cilium | Ubuntu 22.04 | No | Yes | Yes | No | ## Prerequisites [Quickstart](../topics/getting-started.md) completed diff --git a/docs/src/topics/flavors/k3s.md b/docs/src/topics/flavors/k3s.md index bc0f5ecd8..0eef945cb 100644 --- a/docs/src/topics/flavors/k3s.md +++ b/docs/src/topics/flavors/k3s.md @@ -1,8 +1,8 @@ # K3s ## Specification -| Control Plane | CNI | Default OS | Installs ClusterClass | -|-----------------------------|--------|--------------|-----------------------| -| [k3s](https://docs.k3s.io/) | Cilium | Ubuntu 22.04 | No | +| Control Plane | CNI | Default OS | Installs ClusterClass | IPv4 | IPv6 | +|-----------------------------|--------|--------------|-----------------------|------|------| +| [k3s](https://docs.k3s.io/) | Cilium | Ubuntu 22.04 | No | Yes | No | ## Prerequisites * [Quickstart](../getting-started.md) completed * Select a [k3s kubernetes version](https://github.com/k3s-io/k3s/releases) to set for the kubernetes version @@ -28,7 +28,9 @@ ## Usage 1. Generate cluster yaml ```bash - clusterctl generate cluster test-cluster --infrastructure linode:0.0.0 --flavor k3s > test-k3s-cluster.yaml + clusterctl generate cluster test-cluster \ + --infrastructure linode:0.0.0 \ + --flavor k3s > test-k3s-cluster.yaml ``` 2. Apply cluster yaml ```bash diff --git a/docs/src/topics/flavors/rke2.md b/docs/src/topics/flavors/rke2.md index 96bf5ccaa..e42e07597 100644 --- a/docs/src/topics/flavors/rke2.md +++ b/docs/src/topics/flavors/rke2.md @@ -1,8 +1,8 @@ # RKE2 ## Specification -| Control Plane | CNI | Default OS | Installs ClusterClass | -|-----------------------------|--------|--------------|-----------------------| -| [rke2](https://docs.rke2.io/) | Cilium | Ubuntu 22.04 | No | +| Control Plane | CNI | Default OS | Installs ClusterClass | IPv4 | IPv6 | +|-------------------------------|--------|--------------|-----------------------|------|------| +| [rke2](https://docs.rke2.io/) | Cilium | Ubuntu 22.04 | No | Yes | No | ## Prerequisites * [Quickstart](../getting-started.md) completed * Select an [rke2 kubernetes version](https://github.com/rancher/rke2/releases) to set for the kubernetes version @@ -16,7 +16,9 @@ ## Usage 1. Generate cluster yaml ```bash - clusterctl generate cluster test-cluster --infrastructure linode:0.0.0 --flavor rke2 > test-rke2-cluster.yaml + clusterctl generate cluster test-cluster \ + --infrastructure linode:0.0.0 \ + --flavor rke2 > test-rke2-cluster.yaml ``` 2. Apply cluster yaml ```bash diff --git a/templates/addons/cilium/cilium-ipv6.yaml b/templates/addons/cilium/cilium-ipv6.yaml new file mode 100644 index 000000000..807dcd08e --- /dev/null +++ b/templates/addons/cilium/cilium-ipv6.yaml @@ -0,0 +1,29 @@ +apiVersion: addons.cluster.x-k8s.io/v1alpha1 +kind: HelmChartProxy +metadata: + name: cilium-ipv6 +spec: + clusterSelector: + matchLabels: + cni: cilium + ipv6: "true" + repoURL: https://helm.cilium.io/ + chartName: cilium + namespace: kube-system + version: ${CILIUM_VERSION:=1.15.0} + options: + waitForJobs: true + wait: true + timeout: 5m + valuesTemplate: | + ipv6: + enabled: true + ipam: + mode: kubernetes + k8s: + requireIPv4PodCIDR: true + hubble: + relay: + enabled: true + ui: + enabled: true diff --git a/templates/addons/cilium/cilium.yaml b/templates/addons/cilium/cilium.yaml index 5527f3a2c..bd778bfef 100644 --- a/templates/addons/cilium/cilium.yaml +++ b/templates/addons/cilium/cilium.yaml @@ -4,8 +4,9 @@ metadata: name: cilium spec: clusterSelector: - matchLabels: - cni: cilium + matchExpressions: + - {key: ipv6, operator: DoesNotExist} + - {key: cni, operator: In, values: ['cilium']} repoURL: https://helm.cilium.io/ chartName: cilium namespace: kube-system diff --git a/templates/addons/cilium/kustomization.yaml b/templates/addons/cilium/kustomization.yaml index 07edafad1..eafa3a9d3 100644 --- a/templates/addons/cilium/kustomization.yaml +++ b/templates/addons/cilium/kustomization.yaml @@ -2,3 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - cilium.yaml + - cilium-ipv6.yaml diff --git a/templates/common-init-files/secret.yaml b/templates/common-init-files/secret.yaml index d0906c7a1..b3e8246c6 100644 --- a/templates/common-init-files/secret.yaml +++ b/templates/common-init-files/secret.yaml @@ -22,6 +22,7 @@ stringData: net.bridge.bridge-nf-call-iptables = 1 net.bridge.bridge-nf-call-ip6tables = 1 net.ipv4.ip_forward = 1 + net.ipv6.conf.all.forwarding = 1 kubeadm-pre-init.sh: | #!/bin/bash set -euo pipefail diff --git a/templates/flavors/dual-stack/kustomization.yaml b/templates/flavors/dual-stack/kustomization.yaml new file mode 100644 index 000000000..5ba4d119c --- /dev/null +++ b/templates/flavors/dual-stack/kustomization.yaml @@ -0,0 +1,42 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../default + +patches: + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + metadata: + name: ${CLUSTER_NAME} + labels: + ipv6: "true" + spec: + clusterNetwork: + pods: + cidrBlocks: + - 10.192.0.0/10 + - fd02::/80 + services: + cidrBlocks: + - 10.96.0.0/12 + - fd03::/108 + - target: + group: controlplane.cluster.x-k8s.io + version: v1beta1 + kind: KubeadmControlPlane + patch: |- + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KubeadmControlPlane + metadata: + name: ${CLUSTER_NAME}-control-plane + spec: + kubeadmConfigSpec: + clusterConfiguration: + controllerManager: + extraArgs: + node-cidr-mask-size-ipv6: "96"