From 843fc27a37aa95a5c6ed7a017ef7a33ef157a1f5 Mon Sep 17 00:00:00 2001 From: amold1 Date: Thu, 23 May 2024 14:18:06 -0400 Subject: [PATCH] [improvement] Add new flavors (#325) * Add new flavors --- hack/generate-flavors.sh | 34 +++-- .../ciliumNetworkPolicies.yaml | 2 - templates/flavors/README.md | 12 -- .../clusterclass-kubeadm/kustomization.yaml | 4 +- templates/flavors/default/kustomization.yaml | 42 ------ .../flavors/k3s/ciliumNetworkPolicies.yaml | 51 ------- .../cluster-autoscaler/kustomization.yaml | 26 ++-- .../k3s/{ => default}/k3sConfigTemplate.yaml | 0 .../k3s/{ => default}/k3sControlPlane.yaml | 1 + .../k3s/{ => default}/kustomization.yaml | 4 +- .../flavors/k3s/{ => default}/secret.yaml | 0 .../flavors/k3s/dual-stack/kustomization.yaml | 77 +++++++++++ .../etcd-backup-restore/kustomization.yaml | 2 +- .../k3s/full-vpcless/kustomization.yaml | 120 +++++++++++++++++ templates/flavors/k3s/full/kustomization.yaml | 8 ++ .../k3s/self-healing/kustomization.yaml | 5 + .../flavors/k3s/vpcless/kustomization.yaml | 117 ++++++++++++++++ .../cluster-autoscaler/kustomization.yaml | 31 +++++ .../default/kubeadmConfigTemplate.yaml | 0 .../default/kubeadmControlPlane.yaml | 0 .../kubeadm/default/kustomization.yaml | 86 ++++++++++++ .../dual-stack/kustomization.yaml | 10 +- .../etcd-backup-restore/kustomization.yaml | 17 +++ .../etcd-disk/kustomization.yaml | 1 + .../kubeadm/full-vpcless/kustomization.yaml | 127 ++++++++++++++++++ .../flavors/kubeadm/full/kustomization.yaml | 46 +++++++ .../self-healing/kustomization.yaml | 2 +- .../{ => kubeadm}/vpcless/kustomization.yaml | 1 - .../flavors/rke2/ciliumNetworkPolicies.yaml | 50 ------- .../cluster-autoscaler/kustomization.yaml | 31 +++++ .../rke2/{ => default}/kustomization.yaml | 17 ++- .../{ => default}/rke2ConfigTemplate.yaml | 0 .../rke2/{ => default}/rke2ControlPlane.yaml | 0 .../flavors/rke2/{ => default}/secret.yaml | 0 .../etcd-backup-restore/kustomization.yaml | 17 +++ .../flavors/rke2/etcd-disk/kustomization.yaml | 46 +++++++ .../rke2/full-vpcless/kustomization.yaml | 63 +++++++++ .../flavors/rke2/full/kustomization.yaml | 49 +++++++ .../rke2/self-healing/kustomization.yaml | 5 + .../flavors/rke2/vpcless/kustomization.yaml | 124 +++++++++++++++++ .../{flavors/base => infra}/cluster.yaml | 0 .../base => infra}/kustomization.yaml | 0 .../base => infra}/linodeCluster.yaml | 0 .../base => infra}/linodeMachineTemplate.yaml | 4 +- .../{flavors/base => infra}/linodeVPC.yaml | 0 .../base => infra}/machineDeployment.yaml | 0 templates/{flavors/base => infra}/secret.yaml | 0 47 files changed, 1034 insertions(+), 198 deletions(-) delete mode 100644 templates/flavors/README.md delete mode 100644 templates/flavors/default/kustomization.yaml delete mode 100644 templates/flavors/k3s/ciliumNetworkPolicies.yaml rename templates/flavors/{ => k3s}/cluster-autoscaler/kustomization.yaml (95%) rename templates/flavors/k3s/{ => default}/k3sConfigTemplate.yaml (100%) rename templates/flavors/k3s/{ => default}/k3sControlPlane.yaml (98%) rename templates/flavors/k3s/{ => default}/kustomization.yaml (90%) rename templates/flavors/k3s/{ => default}/secret.yaml (100%) create mode 100644 templates/flavors/k3s/dual-stack/kustomization.yaml rename templates/flavors/{ => k3s}/etcd-backup-restore/kustomization.yaml (89%) create mode 100644 templates/flavors/k3s/full-vpcless/kustomization.yaml create mode 100644 templates/flavors/k3s/full/kustomization.yaml create mode 100644 templates/flavors/k3s/self-healing/kustomization.yaml create mode 100644 templates/flavors/k3s/vpcless/kustomization.yaml create mode 100644 templates/flavors/kubeadm/cluster-autoscaler/kustomization.yaml rename templates/flavors/{ => kubeadm}/default/kubeadmConfigTemplate.yaml (100%) rename templates/flavors/{ => kubeadm}/default/kubeadmControlPlane.yaml (100%) create mode 100644 templates/flavors/kubeadm/default/kustomization.yaml rename templates/flavors/{ => kubeadm}/dual-stack/kustomization.yaml (84%) create mode 100644 templates/flavors/kubeadm/etcd-backup-restore/kustomization.yaml rename templates/flavors/{ => kubeadm}/etcd-disk/kustomization.yaml (99%) create mode 100644 templates/flavors/kubeadm/full-vpcless/kustomization.yaml create mode 100644 templates/flavors/kubeadm/full/kustomization.yaml rename templates/flavors/{ => kubeadm}/self-healing/kustomization.yaml (92%) rename templates/flavors/{ => kubeadm}/vpcless/kustomization.yaml (98%) delete mode 100644 templates/flavors/rke2/ciliumNetworkPolicies.yaml create mode 100644 templates/flavors/rke2/cluster-autoscaler/kustomization.yaml rename templates/flavors/rke2/{ => default}/kustomization.yaml (70%) rename templates/flavors/rke2/{ => default}/rke2ConfigTemplate.yaml (100%) rename templates/flavors/rke2/{ => default}/rke2ControlPlane.yaml (100%) rename templates/flavors/rke2/{ => default}/secret.yaml (100%) create mode 100644 templates/flavors/rke2/etcd-backup-restore/kustomization.yaml create mode 100644 templates/flavors/rke2/etcd-disk/kustomization.yaml create mode 100644 templates/flavors/rke2/full-vpcless/kustomization.yaml create mode 100644 templates/flavors/rke2/full/kustomization.yaml create mode 100644 templates/flavors/rke2/self-healing/kustomization.yaml create mode 100644 templates/flavors/rke2/vpcless/kustomization.yaml rename templates/{flavors/base => infra}/cluster.yaml (100%) rename templates/{flavors/base => infra}/kustomization.yaml (100%) rename templates/{flavors/base => infra}/linodeCluster.yaml (100%) rename templates/{flavors/base => infra}/linodeMachineTemplate.yaml (92%) rename templates/{flavors/base => infra}/linodeVPC.yaml (100%) rename templates/{flavors/base => infra}/machineDeployment.yaml (100%) rename templates/{flavors/base => infra}/secret.yaml (100%) diff --git a/hack/generate-flavors.sh b/hack/generate-flavors.sh index fb7be707c..9124445f2 100755 --- a/hack/generate-flavors.sh +++ b/hack/generate-flavors.sh @@ -4,17 +4,35 @@ set -euo pipefail REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. FLAVORS_DIR="${REPO_ROOT}/templates/flavors" +SUPPORTED_DISTROS=( + "rke2" + "k3s" + "kubeadm" +) +SUPPORTED_CLUSTERCLASSES=( + "clusterclass-kubeadm" +) -for name in $(find "${FLAVORS_DIR}/"* -maxdepth 0 -type d -print0 | xargs -0 -I {} basename {} | grep -v base | grep -v clusterclass-base ); do +for clusterclass in ${SUPPORTED_CLUSTERCLASSES[@]}; do # clusterctl expects clusterclass not have the "cluster-template" prefix # except for the actual cluster template using the clusterclass - if [[ "$name" == clusterclass* ]]; then - kustomize build "${FLAVORS_DIR}/${name}" > "${REPO_ROOT}/templates/${name}.yaml" - cp "${FLAVORS_DIR}/${name}/cluster-template.yaml" "${REPO_ROOT}/templates/cluster-template-${name}.yaml" - else - kustomize build "${FLAVORS_DIR}/${name}" > "${REPO_ROOT}/templates/cluster-template-${name}.yaml" - fi + echo "****** Generating clusterclass-${clusterclass} flavor ******" + kustomize build "${FLAVORS_DIR}/${clusterclass}" > "${REPO_ROOT}/templates/${clusterclass}.yaml" + cp "${FLAVORS_DIR}/${clusterclass}/cluster-template.yaml" "${REPO_ROOT}/templates/cluster-template-${clusterclass}.yaml" +done + + +for distro in ${SUPPORTED_DISTROS[@]}; do + for name in $(find "${FLAVORS_DIR}/${distro}/"* -maxdepth 0 -type d -print0 | xargs -0 -I {} basename {}); do + if [[ ${name} == "default" ]]; then + echo "****** Generating ${distro} flavor ******" + kustomize build "${FLAVORS_DIR}/${distro}/${name}" > "${REPO_ROOT}/templates/cluster-template-${distro}.yaml" + else + echo "****** Generating ${distro}-${name} flavor ******" + kustomize build "${FLAVORS_DIR}/${distro}/${name}" > "${REPO_ROOT}/templates/cluster-template-${distro}-${name}.yaml" + fi + done done # move the default template to the default file expected by clusterctl -mv "${REPO_ROOT}/templates/cluster-template-default.yaml" "${REPO_ROOT}/templates/cluster-template.yaml" +mv "${REPO_ROOT}/templates/cluster-template-kubeadm.yaml" "${REPO_ROOT}/templates/cluster-template.yaml" diff --git a/templates/addons/cilium-network-policies/ciliumNetworkPolicies.yaml b/templates/addons/cilium-network-policies/ciliumNetworkPolicies.yaml index 1400a242c..17ba7778e 100644 --- a/templates/addons/cilium-network-policies/ciliumNetworkPolicies.yaml +++ b/templates/addons/cilium-network-policies/ciliumNetworkPolicies.yaml @@ -35,8 +35,6 @@ data: toPorts: - ports: - port: "6443" - - port: "2379" - - port: "2380" --- apiVersion: addons.cluster.x-k8s.io/v1beta1 kind: ClusterResourceSet diff --git a/templates/flavors/README.md b/templates/flavors/README.md deleted file mode 100644 index b19ada708..000000000 --- a/templates/flavors/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Flavors - -## [Flavor usage documentation](https://linode.github.io/cluster-api-provider-linode/topics/flavors/flavors.html) - -## Development - -This directory contains each of the flavors for CAPL. Each directory besides `base` will be used to -create a flavor by running `kustomize build` on the directory. The name of the directory will be -appended to the end of the cluster-template.yaml, e.g cluster-template-{directory-name}.yaml. That -flavor can be used by specifying `--flavor {directory-name}`. - -To generate all CAPL flavors, run `make generate-flavors`. diff --git a/templates/flavors/clusterclass-kubeadm/kustomization.yaml b/templates/flavors/clusterclass-kubeadm/kustomization.yaml index 5e157df22..fc13c216e 100644 --- a/templates/flavors/clusterclass-kubeadm/kustomization.yaml +++ b/templates/flavors/clusterclass-kubeadm/kustomization.yaml @@ -4,7 +4,7 @@ resources: - clusterClass.yaml - kubeadmControlPlaneTemplate.yaml - linodeClusterTemplate.yaml - - ../default + - ../kubeadm/default transformers: - replacementTransformer.yaml @@ -47,4 +47,4 @@ patches: patch: |- kind: KubeadmConfigTemplate metadata: - name: kubeadm-worker \ No newline at end of file + name: kubeadm-worker diff --git a/templates/flavors/default/kustomization.yaml b/templates/flavors/default/kustomization.yaml deleted file mode 100644 index 9bfc48821..000000000 --- a/templates/flavors/default/kustomization.yaml +++ /dev/null @@ -1,42 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization -resources: - - ../base - - kubeadmConfigTemplate.yaml - - kubeadmControlPlane.yaml - - ../../addons/cilium - - ../../addons/cilium-network-policies - - ../../addons/csi-driver-linode - - ../../addons/ccm-linode - - ../../addons/cluster-resource-set -patches: - - target: - group: cluster.x-k8s.io - version: v1beta1 - kind: Cluster - patch: |- - - op: replace - path: /spec/controlPlaneRef/kind - value: KubeadmControlPlane - - target: - group: cluster.x-k8s.io - version: v1beta1 - kind: Cluster - patch: |- - apiVersion: cluster.x-k8s.io/v1beta1 - kind: Cluster - metadata: - name: ${CLUSTER_NAME} - labels: - cni: ${CLUSTER_NAME}-cilium - ccm: ${CLUSTER_NAME}-linode - csi: ${CLUSTER_NAME}-linode - crs: ${CLUSTER_NAME}-crs - - target: - group: cluster.x-k8s.io - version: v1beta1 - kind: MachineDeployment - patch: |- - - op: replace - path: /spec/template/spec/bootstrap/configRef/kind - value: KubeadmConfigTemplate diff --git a/templates/flavors/k3s/ciliumNetworkPolicies.yaml b/templates/flavors/k3s/ciliumNetworkPolicies.yaml deleted file mode 100644 index c0591b7b3..000000000 --- a/templates/flavors/k3s/ciliumNetworkPolicies.yaml +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: ${CLUSTER_NAME}-cilium-policy -data: - cilium-policy.yaml: |- - apiVersion: "cilium.io/v2" - kind: CiliumClusterwideNetworkPolicy - metadata: - name: "default-cluster-policy" - spec: - description: "allow cluster intra cluster traffic" - endpointSelector: {} - ingress: - - fromEntities: - - cluster - - fromCIDR: - - 10.0.0.0/8 - - 192.168.128.0/17 - --- - apiVersion: "cilium.io/v2" - kind: CiliumClusterwideNetworkPolicy - metadata: - name: "default-external-policy" - spec: - description: "allow etcd & api server traffic" - nodeSelector: {} - ingress: - - fromEntities: - - cluster - - fromCIDR: - - 10.0.0.0/8 - - fromEntities: - - world - toPorts: - - ports: - - port: "6443" ---- -apiVersion: addons.cluster.x-k8s.io/v1beta1 -kind: ClusterResourceSet -metadata: - name: ${CLUSTER_NAME}-cilium-policy -spec: - clusterSelector: - matchLabels: - cluster: ${CLUSTER_NAME} - resources: - - kind: ConfigMap - name: ${CLUSTER_NAME}-cilium-policy - strategy: Reconcile - diff --git a/templates/flavors/cluster-autoscaler/kustomization.yaml b/templates/flavors/k3s/cluster-autoscaler/kustomization.yaml similarity index 95% rename from templates/flavors/cluster-autoscaler/kustomization.yaml rename to templates/flavors/k3s/cluster-autoscaler/kustomization.yaml index 4a2f43968..8f2b0cc22 100644 --- a/templates/flavors/cluster-autoscaler/kustomization.yaml +++ b/templates/flavors/k3s/cluster-autoscaler/kustomization.yaml @@ -1,20 +1,11 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization + resources: - ../default - - ../../addons/cluster-autoscaler + - ../../../addons/cluster-autoscaler + 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: - cluster-autoscaler: "true" - target: group: cluster.x-k8s.io version: v1beta1 @@ -27,3 +18,14 @@ patches: annotations: cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: ${WORKER_MACHINE_MIN:-"1"} cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: ${WORKER_MACHINE_MAX:-"10"} + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + metadata: + name: ${CLUSTER_NAME} + labels: + cluster-autoscaler: "true" diff --git a/templates/flavors/k3s/k3sConfigTemplate.yaml b/templates/flavors/k3s/default/k3sConfigTemplate.yaml similarity index 100% rename from templates/flavors/k3s/k3sConfigTemplate.yaml rename to templates/flavors/k3s/default/k3sConfigTemplate.yaml diff --git a/templates/flavors/k3s/k3sControlPlane.yaml b/templates/flavors/k3s/default/k3sControlPlane.yaml similarity index 98% rename from templates/flavors/k3s/k3sControlPlane.yaml rename to templates/flavors/k3s/default/k3sControlPlane.yaml index a7badd8c8..5347065c8 100644 --- a/templates/flavors/k3s/k3sControlPlane.yaml +++ b/templates/flavors/k3s/default/k3sControlPlane.yaml @@ -100,6 +100,7 @@ spec: nodeName: '{{ ds.meta_data.label }}' preK3sCommands: - | + mkdir -p /etc/rancher/k3s/config.yaml.d/ echo "node-ip: $(ip a s eth1 |grep 'inet ' |cut -d' ' -f6|cut -d/ -f1)" >> /etc/rancher/k3s/config.yaml.d/capi-config.yaml - sed -i '/swap/d' /etc/fstab - swapoff -a diff --git a/templates/flavors/k3s/kustomization.yaml b/templates/flavors/k3s/default/kustomization.yaml similarity index 90% rename from templates/flavors/k3s/kustomization.yaml rename to templates/flavors/k3s/default/kustomization.yaml index c542350e3..c1b734a18 100644 --- a/templates/flavors/k3s/kustomization.yaml +++ b/templates/flavors/k3s/default/kustomization.yaml @@ -1,11 +1,11 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - ../base + - ../../../infra - k3sControlPlane.yaml - k3sConfigTemplate.yaml - - ciliumNetworkPolicies.yaml - secret.yaml + - ../../../addons/cilium-network-policies patches: - target: group: cluster.x-k8s.io diff --git a/templates/flavors/k3s/secret.yaml b/templates/flavors/k3s/default/secret.yaml similarity index 100% rename from templates/flavors/k3s/secret.yaml rename to templates/flavors/k3s/default/secret.yaml diff --git a/templates/flavors/k3s/dual-stack/kustomization.yaml b/templates/flavors/k3s/dual-stack/kustomization.yaml new file mode 100644 index 000000000..d75ebf177 --- /dev/null +++ b/templates/flavors/k3s/dual-stack/kustomization.yaml @@ -0,0 +1,77 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../vpcless + +patches: + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + metadata: + name: ${CLUSTER_NAME} + 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: KThreesControlPlane + patch: |- + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KThreesControlPlane + metadata: + name: ${CLUSTER_NAME}-control-plane + spec: + kthreesConfigSpec: + serverConfig: + kubeControllerManagerArgs: + - "node-cidr-mask-size-ipv6=96" + clusterCidr: "10.192.0.0/10,fd02::/80" + serviceCidr: "10.96.0.0/12,fd03::/108" + - target: + kind: HelmChartProxy + name: .*-cilium + patch: |- + - op: replace + path: /spec/valuesTemplate + value: | + bgpControlPlane: + enabled: true + ipv6: + enabled: true + ipam: + mode: kubernetes + k8s: + requireIPv4PodCIDR: true + hubble: + relay: + enabled: true + ui: + enabled: true + - target: + group: controlplane.cluster.x-k8s.io + version: v1beta1 + kind: KThreesControlPlane + patch: |- + - op: replace + path: /spec/kthreesConfigSpec/preK3sCommands + value: + - | + mkdir -p /etc/rancher/k3s/config.yaml.d/ + echo -n "kubelet-arg: \"--node-ip=" >> /etc/rancher/k3s/config.yaml.d/capi-config.yaml + echo -n "$(ip a s eth0 |grep -E 'inet ' |cut -d' ' -f6|cut -d/ -f1 | grep -E '192.168')" >> /etc/rancher/k3s/config.yaml.d/capi-config.yaml + echo ",$(ip a s eth0 |grep -E 'inet6 ' |cut -d' ' -f6|cut -d/ -f1 | grep -vE 'fe80')\"" >> /etc/rancher/k3s/config.yaml.d/capi-config.yaml + - sed -i '/swap/d' /etc/fstab + - swapoff -a + - hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname diff --git a/templates/flavors/etcd-backup-restore/kustomization.yaml b/templates/flavors/k3s/etcd-backup-restore/kustomization.yaml similarity index 89% rename from templates/flavors/etcd-backup-restore/kustomization.yaml rename to templates/flavors/k3s/etcd-backup-restore/kustomization.yaml index 3696694c1..f866b1951 100644 --- a/templates/flavors/etcd-backup-restore/kustomization.yaml +++ b/templates/flavors/k3s/etcd-backup-restore/kustomization.yaml @@ -2,7 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - ../default - - ../../addons/etcd-backup-restore + - ../../../addons/etcd-backup-restore patches: - target: group: cluster.x-k8s.io diff --git a/templates/flavors/k3s/full-vpcless/kustomization.yaml b/templates/flavors/k3s/full-vpcless/kustomization.yaml new file mode 100644 index 000000000..ca1fa4705 --- /dev/null +++ b/templates/flavors/k3s/full-vpcless/kustomization.yaml @@ -0,0 +1,120 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../default + - ../../../addons/cluster-autoscaler + - ../../../addons/etcd-backup-restore + - ../../../addons/machine-health-check + +patches: + - target: + kind: HelmChartProxy + name: .*-cilium + patch: |- + - op: replace + path: /spec/valuesTemplate + value: | + bgpControlPlane: + enabled: true + ipam: + mode: kubernetes + k8s: + requireIPv4PodCIDR: true + hubble: + relay: + enabled: true + ui: + enabled: true + - target: + kind: HelmChartProxy + name: .*-linode-cloud-controller-manager + patch: |- + - op: replace + path: /spec/valuesTemplate + value: | + secretRef: + name: "linode-token-region" + image: + pullPolicy: IfNotPresent + - target: + kind: LinodeVPC + patch: |- + $patch: delete + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeVPC + metadata: + name: ${VPC_NAME:=${CLUSTER_NAME}} + - target: + group: infrastructure.cluster.x-k8s.io + version: v1alpha1 + kind: LinodeCluster + patch: |- + - op: remove + path: /spec/vpcRef + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + metadata: + name: ${CLUSTER_NAME} + 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: KThreesControlPlane + patch: |- + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KThreesControlPlane + metadata: + name: ${CLUSTER_NAME}-control-plane + spec: + kthreesConfigSpec: + clusterConfiguration: + controllerManager: + extraArgs: + node-cidr-mask-size-ipv6: "96" + - target: + kind: HelmChartProxy + name: .*-cilium + patch: |- + - op: replace + path: /spec/valuesTemplate + value: | + bgpControlPlane: + enabled: true + ipv6: + enabled: true + ipam: + mode: kubernetes + k8s: + requireIPv4PodCIDR: true + hubble: + relay: + enabled: true + ui: + enabled: true + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: MachineDeployment + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: MachineDeployment + metadata: + name: ${CLUSTER_NAME}-md-0 + annotations: + cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: ${WORKER_MACHINE_MIN:-"1"} + cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: ${WORKER_MACHINE_MAX:-"10"} diff --git a/templates/flavors/k3s/full/kustomization.yaml b/templates/flavors/k3s/full/kustomization.yaml new file mode 100644 index 000000000..49e1baedf --- /dev/null +++ b/templates/flavors/k3s/full/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../default + - ../../../addons/cluster-autoscaler + - ../../../addons/etcd-backup-restore + - ../../../addons/machine-health-check diff --git a/templates/flavors/k3s/self-healing/kustomization.yaml b/templates/flavors/k3s/self-healing/kustomization.yaml new file mode 100644 index 000000000..d26f30bbd --- /dev/null +++ b/templates/flavors/k3s/self-healing/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../default + - ../../../addons/machine-health-check diff --git a/templates/flavors/k3s/vpcless/kustomization.yaml b/templates/flavors/k3s/vpcless/kustomization.yaml new file mode 100644 index 000000000..972dde10a --- /dev/null +++ b/templates/flavors/k3s/vpcless/kustomization.yaml @@ -0,0 +1,117 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../default + +patches: + - target: + kind: HelmChartProxy + name: .*-cilium + patch: |- + - op: replace + path: /spec/valuesTemplate + value: | + bgpControlPlane: + enabled: true + ipam: + mode: kubernetes + k8s: + requireIPv4PodCIDR: true + hubble: + relay: + enabled: true + ui: + enabled: true + - target: + kind: HelmChartProxy + name: .*-linode-cloud-controller-manager + patch: |- + - op: replace + path: /spec/valuesTemplate + value: | + secretRef: + name: "linode-token-region" + image: + pullPolicy: IfNotPresent + - target: + kind: LinodeVPC + patch: |- + $patch: delete + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeVPC + metadata: + name: ${VPC_NAME:=${CLUSTER_NAME}} + - target: + group: infrastructure.cluster.x-k8s.io + version: v1alpha1 + kind: LinodeCluster + patch: |- + - op: remove + path: /spec/vpcRef + - target: + group: bootstrap.cluster.x-k8s.io + version: v1beta1 + kind: KThreesConfigTemplate + patch: |- + - op: replace + path: /spec/template/spec/preK3sCommands + value: + - | + mkdir -p /etc/rancher/k3s/config.yaml.d/ + echo "node-ip: $(hostname -I | grep -oE 192\.168\.[0-9]+\.[0-9]+)" >> /etc/rancher/k3s/config.yaml.d/capi-config.yaml + - sed -i '/swap/d' /etc/fstab + - swapoff -a + - hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname + - target: + group: controlplane.cluster.x-k8s.io + version: v1beta1 + kind: KThreesControlPlane + patch: |- + - op: replace + path: /spec/kthreesConfigSpec/preK3sCommands + value: + - | + mkdir -p /etc/rancher/k3s/config.yaml.d/ + echo "node-ip: $(hostname -I | grep -oE 192\.168\.[0-9]+\.[0-9]+)" >> /etc/rancher/k3s/config.yaml.d/capi-config.yaml + - sed -i '/swap/d' /etc/fstab + - swapoff -a + - hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname + - op: replace + path: /spec/kthreesConfigSpec/files + value: + - path: /var/lib/rancher/k3s/server/manifests/ccm-linode.yaml + owner: root:root + content: |- + apiVersion: helm.cattle.io/v1 + kind: HelmChart + metadata: + namespace: kube-system + name: ccm-linode + spec: + targetNamespace: kube-system + version: ${LINODE_CCM_VERSION:=v0.4.4} + 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" + - contentFrom: + secret: + key: linode-token-region.yaml + name: linode-${CLUSTER_NAME}-crs-0 + owner: root:root + path: /var/lib/rancher/k3s/server/manifests/linode-token-region.yaml + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + metadata: + name: ${CLUSTER_NAME} + labels: + vpcless: "true" diff --git a/templates/flavors/kubeadm/cluster-autoscaler/kustomization.yaml b/templates/flavors/kubeadm/cluster-autoscaler/kustomization.yaml new file mode 100644 index 000000000..8f2b0cc22 --- /dev/null +++ b/templates/flavors/kubeadm/cluster-autoscaler/kustomization.yaml @@ -0,0 +1,31 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../default + - ../../../addons/cluster-autoscaler + +patches: + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: MachineDeployment + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: MachineDeployment + metadata: + name: ${CLUSTER_NAME}-md-0 + annotations: + cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: ${WORKER_MACHINE_MIN:-"1"} + cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: ${WORKER_MACHINE_MAX:-"10"} + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + metadata: + name: ${CLUSTER_NAME} + labels: + cluster-autoscaler: "true" diff --git a/templates/flavors/default/kubeadmConfigTemplate.yaml b/templates/flavors/kubeadm/default/kubeadmConfigTemplate.yaml similarity index 100% rename from templates/flavors/default/kubeadmConfigTemplate.yaml rename to templates/flavors/kubeadm/default/kubeadmConfigTemplate.yaml diff --git a/templates/flavors/default/kubeadmControlPlane.yaml b/templates/flavors/kubeadm/default/kubeadmControlPlane.yaml similarity index 100% rename from templates/flavors/default/kubeadmControlPlane.yaml rename to templates/flavors/kubeadm/default/kubeadmControlPlane.yaml diff --git a/templates/flavors/kubeadm/default/kustomization.yaml b/templates/flavors/kubeadm/default/kustomization.yaml new file mode 100644 index 000000000..2acdee3b4 --- /dev/null +++ b/templates/flavors/kubeadm/default/kustomization.yaml @@ -0,0 +1,86 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../../../infra + - kubeadmConfigTemplate.yaml + - kubeadmControlPlane.yaml + - ../../../addons/cilium + - ../../../addons/cilium-network-policies + - ../../../addons/csi-driver-linode + - ../../../addons/ccm-linode + - ../../../addons/cluster-resource-set +patches: + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + - op: replace + path: /spec/controlPlaneRef/kind + value: KubeadmControlPlane + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: MachineDeployment + patch: |- + - op: replace + path: /spec/template/spec/bootstrap/configRef/kind + value: KubeadmConfigTemplate + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + metadata: + name: ${CLUSTER_NAME} + labels: + cni: ${CLUSTER_NAME}-cilium + ccm: ${CLUSTER_NAME}-linode + csi: ${CLUSTER_NAME}-linode + crs: ${CLUSTER_NAME}-crs + - target: + version: v1 + kind: ConfigMap + name: ${CLUSTER_NAME}-cilium-policy + patch: |- + apiVersion: v1 + kind: ConfigMap + metadata: + name: ${CLUSTER_NAME}-cilium-policy + data: + cilium-policy.yaml: |- + apiVersion: "cilium.io/v2" + kind: CiliumClusterwideNetworkPolicy + metadata: + name: "default-cluster-policy" + spec: + description: "allow cluster intra cluster traffic" + endpointSelector: {} + ingress: + - fromEntities: + - cluster + - fromCIDR: + - 10.0.0.0/8 + - 192.168.128.0/17 + --- + apiVersion: "cilium.io/v2" + kind: CiliumClusterwideNetworkPolicy + metadata: + name: "default-external-policy" + spec: + description: "allow etcd & api server traffic" + nodeSelector: {} + ingress: + - fromEntities: + - cluster + - fromCIDR: + - 10.0.0.0/8 + - fromEntities: + - world + toPorts: + - ports: + - port: "6443" + - port: "2379" + - port: "2380" diff --git a/templates/flavors/dual-stack/kustomization.yaml b/templates/flavors/kubeadm/dual-stack/kustomization.yaml similarity index 84% rename from templates/flavors/dual-stack/kustomization.yaml rename to templates/flavors/kubeadm/dual-stack/kustomization.yaml index 729b06c9a..2c2550472 100644 --- a/templates/flavors/dual-stack/kustomization.yaml +++ b/templates/flavors/kubeadm/dual-stack/kustomization.yaml @@ -1,7 +1,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - # VPCs don't support ipv6. Hence using vpcless flavor to run outside of VPC - ../vpcless patches: @@ -24,13 +23,6 @@ patches: cidrBlocks: - 10.96.0.0/12 - fd03::/108 - - target: - group: cluster.x-k8s.io - version: v1beta1 - kind: Cluster - patch: |- - - op: remove - path: /metadata/labels/vxlan - target: group: controlplane.cluster.x-k8s.io version: v1beta1 @@ -65,4 +57,4 @@ patches: relay: enabled: true ui: - enabled: true \ No newline at end of file + enabled: true diff --git a/templates/flavors/kubeadm/etcd-backup-restore/kustomization.yaml b/templates/flavors/kubeadm/etcd-backup-restore/kustomization.yaml new file mode 100644 index 000000000..f866b1951 --- /dev/null +++ b/templates/flavors/kubeadm/etcd-backup-restore/kustomization.yaml @@ -0,0 +1,17 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../default + - ../../../addons/etcd-backup-restore +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: + etcd-backup: "true" diff --git a/templates/flavors/etcd-disk/kustomization.yaml b/templates/flavors/kubeadm/etcd-disk/kustomization.yaml similarity index 99% rename from templates/flavors/etcd-disk/kustomization.yaml rename to templates/flavors/kubeadm/etcd-disk/kustomization.yaml index dde808eb3..d9dc6b976 100644 --- a/templates/flavors/etcd-disk/kustomization.yaml +++ b/templates/flavors/kubeadm/etcd-disk/kustomization.yaml @@ -1,5 +1,6 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization + resources: - ../default diff --git a/templates/flavors/kubeadm/full-vpcless/kustomization.yaml b/templates/flavors/kubeadm/full-vpcless/kustomization.yaml new file mode 100644 index 000000000..bee63730d --- /dev/null +++ b/templates/flavors/kubeadm/full-vpcless/kustomization.yaml @@ -0,0 +1,127 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../vpcless + - ../../../addons/cluster-autoscaler + - ../../../addons/etcd-backup-restore + - ../../../addons/machine-health-check + + +patches: + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + metadata: + name: ${CLUSTER_NAME} + 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" + - target: + kind: HelmChartProxy + name: .*-cilium + patch: |- + - op: replace + path: /spec/valuesTemplate + value: | + bgpControlPlane: + enabled: true + ipv6: + enabled: true + ipam: + mode: kubernetes + k8s: + requireIPv4PodCIDR: true + hubble: + relay: + enabled: true + ui: + enabled: true + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: MachineDeployment + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: MachineDeployment + metadata: + name: ${CLUSTER_NAME}-md-0 + annotations: + cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: ${WORKER_MACHINE_MIN:-"1"} + cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: ${WORKER_MACHINE_MAX:-"10"} + - target: + group: infrastructure.cluster.x-k8s.io + version: v1alpha1 + kind: LinodeMachineTemplate + name: .*-control-plane + patch: |- + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachineTemplate + metadata: + name: ${CLUSTER_NAME}-control-plane + spec: + template: + spec: + dataDisks: + sdc: + label: etcd_disk + size: 10Gi + - 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: + diskSetup: + filesystems: + - label: etcd_data + filesystem: ext4 + device: /dev/sdc + mounts: + - - LABEL=etcd_data + - /var/lib/etcd_data + - 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: + remediationStrategy: + maxRetry: 5 + retryPeriod: 2m + minHealthyPeriod: 2h diff --git a/templates/flavors/kubeadm/full/kustomization.yaml b/templates/flavors/kubeadm/full/kustomization.yaml new file mode 100644 index 000000000..339238499 --- /dev/null +++ b/templates/flavors/kubeadm/full/kustomization.yaml @@ -0,0 +1,46 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../default + - ../../../addons/cluster-autoscaler + - ../../../addons/etcd-backup-restore + - ../../../addons/machine-health-check + +patches: + - target: + group: infrastructure.cluster.x-k8s.io + version: v1alpha1 + kind: LinodeMachineTemplate + name: .*-control-plane + patch: |- + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachineTemplate + metadata: + name: ${CLUSTER_NAME}-control-plane + spec: + template: + spec: + dataDisks: + sdc: + label: etcd_disk + size: 10Gi + - 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: + diskSetup: + filesystems: + - label: etcd_data + filesystem: ext4 + device: /dev/sdc + mounts: + - - LABEL=etcd_data + - /var/lib/etcd_data diff --git a/templates/flavors/self-healing/kustomization.yaml b/templates/flavors/kubeadm/self-healing/kustomization.yaml similarity index 92% rename from templates/flavors/self-healing/kustomization.yaml rename to templates/flavors/kubeadm/self-healing/kustomization.yaml index 1235a1028..1f524685a 100644 --- a/templates/flavors/self-healing/kustomization.yaml +++ b/templates/flavors/kubeadm/self-healing/kustomization.yaml @@ -2,7 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - ../default - - ../../addons/machine-health-check + - ../../../addons/machine-health-check patches: - target: group: controlplane.cluster.x-k8s.io diff --git a/templates/flavors/vpcless/kustomization.yaml b/templates/flavors/kubeadm/vpcless/kustomization.yaml similarity index 98% rename from templates/flavors/vpcless/kustomization.yaml rename to templates/flavors/kubeadm/vpcless/kustomization.yaml index e6a680279..102d5984c 100644 --- a/templates/flavors/vpcless/kustomization.yaml +++ b/templates/flavors/kubeadm/vpcless/kustomization.yaml @@ -68,5 +68,4 @@ patches: metadata: name: ${CLUSTER_NAME} labels: - vxlan: "true" vpcless: "true" diff --git a/templates/flavors/rke2/ciliumNetworkPolicies.yaml b/templates/flavors/rke2/ciliumNetworkPolicies.yaml deleted file mode 100644 index 17ba7778e..000000000 --- a/templates/flavors/rke2/ciliumNetworkPolicies.yaml +++ /dev/null @@ -1,50 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: ${CLUSTER_NAME}-cilium-policy -data: - cilium-policy.yaml: |- - apiVersion: "cilium.io/v2" - kind: CiliumClusterwideNetworkPolicy - metadata: - name: "default-cluster-policy" - spec: - description: "allow cluster intra cluster traffic" - endpointSelector: {} - ingress: - - fromEntities: - - cluster - - fromCIDR: - - 10.0.0.0/8 - - 192.168.128.0/17 - --- - apiVersion: "cilium.io/v2" - kind: CiliumClusterwideNetworkPolicy - metadata: - name: "default-external-policy" - spec: - description: "allow etcd & api server traffic" - nodeSelector: {} - ingress: - - fromEntities: - - cluster - - fromCIDR: - - 10.0.0.0/8 - - fromEntities: - - world - toPorts: - - ports: - - port: "6443" ---- -apiVersion: addons.cluster.x-k8s.io/v1beta1 -kind: ClusterResourceSet -metadata: - name: ${CLUSTER_NAME}-cilium-policy -spec: - clusterSelector: - matchLabels: - cluster: ${CLUSTER_NAME} - resources: - - kind: ConfigMap - name: ${CLUSTER_NAME}-cilium-policy - strategy: Reconcile diff --git a/templates/flavors/rke2/cluster-autoscaler/kustomization.yaml b/templates/flavors/rke2/cluster-autoscaler/kustomization.yaml new file mode 100644 index 000000000..8f2b0cc22 --- /dev/null +++ b/templates/flavors/rke2/cluster-autoscaler/kustomization.yaml @@ -0,0 +1,31 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../default + - ../../../addons/cluster-autoscaler + +patches: + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: MachineDeployment + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: MachineDeployment + metadata: + name: ${CLUSTER_NAME}-md-0 + annotations: + cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: ${WORKER_MACHINE_MIN:-"1"} + cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: ${WORKER_MACHINE_MAX:-"10"} + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + metadata: + name: ${CLUSTER_NAME} + labels: + cluster-autoscaler: "true" diff --git a/templates/flavors/rke2/kustomization.yaml b/templates/flavors/rke2/default/kustomization.yaml similarity index 70% rename from templates/flavors/rke2/kustomization.yaml rename to templates/flavors/rke2/default/kustomization.yaml index 212b243d5..1f8448567 100644 --- a/templates/flavors/rke2/kustomization.yaml +++ b/templates/flavors/rke2/default/kustomization.yaml @@ -1,12 +1,12 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - - ../base - - ../../addons/cilium - - ciliumNetworkPolicies.yaml + - ../../../infra - rke2ControlPlane.yaml - rke2ConfigTemplate.yaml - secret.yaml + - ../../../addons/cilium + - ../../../addons/cilium-network-policies patches: - target: group: cluster.x-k8s.io @@ -35,3 +35,14 @@ patches: - op: replace path: /spec/template/spec/bootstrap/configRef/kind value: RKE2ConfigTemplate + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + metadata: + name: ${CLUSTER_NAME} + labels: + cni: ${CLUSTER_NAME}-cilium diff --git a/templates/flavors/rke2/rke2ConfigTemplate.yaml b/templates/flavors/rke2/default/rke2ConfigTemplate.yaml similarity index 100% rename from templates/flavors/rke2/rke2ConfigTemplate.yaml rename to templates/flavors/rke2/default/rke2ConfigTemplate.yaml diff --git a/templates/flavors/rke2/rke2ControlPlane.yaml b/templates/flavors/rke2/default/rke2ControlPlane.yaml similarity index 100% rename from templates/flavors/rke2/rke2ControlPlane.yaml rename to templates/flavors/rke2/default/rke2ControlPlane.yaml diff --git a/templates/flavors/rke2/secret.yaml b/templates/flavors/rke2/default/secret.yaml similarity index 100% rename from templates/flavors/rke2/secret.yaml rename to templates/flavors/rke2/default/secret.yaml diff --git a/templates/flavors/rke2/etcd-backup-restore/kustomization.yaml b/templates/flavors/rke2/etcd-backup-restore/kustomization.yaml new file mode 100644 index 000000000..f866b1951 --- /dev/null +++ b/templates/flavors/rke2/etcd-backup-restore/kustomization.yaml @@ -0,0 +1,17 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../default + - ../../../addons/etcd-backup-restore +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: + etcd-backup: "true" diff --git a/templates/flavors/rke2/etcd-disk/kustomization.yaml b/templates/flavors/rke2/etcd-disk/kustomization.yaml new file mode 100644 index 000000000..bc04d68ee --- /dev/null +++ b/templates/flavors/rke2/etcd-disk/kustomization.yaml @@ -0,0 +1,46 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../default + +patches: + - target: + group: infrastructure.cluster.x-k8s.io + version: v1alpha1 + kind: LinodeMachineTemplate + name: .*-control-plane + patch: |- + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachineTemplate + metadata: + name: ${CLUSTER_NAME}-control-plane + spec: + template: + spec: + dataDisks: + sdc: + label: etcd_disk + size: 10Gi + - target: + group: controlplane.cluster.x-k8s.io + version: v1alpha1 + kind: RKE2ControlPlane + patch: |- + apiVersion: controlplane.cluster.x-k8s.io/v1alpha1 + kind: RKE2ControlPlane + metadata: + name: ${CLUSTER_NAME}-control-plane + spec: + agentConfig: + additionalUserData: + config: |- + diskSetup: + /dev/sdc: + layout: true + fs_setup: + - label: /dev/sdc + filesystem: ext4 + device: /dev/sdc + mounts: + - ["/dev/sdc", "/var/lib/etcd_data"] diff --git a/templates/flavors/rke2/full-vpcless/kustomization.yaml b/templates/flavors/rke2/full-vpcless/kustomization.yaml new file mode 100644 index 000000000..92ff7db40 --- /dev/null +++ b/templates/flavors/rke2/full-vpcless/kustomization.yaml @@ -0,0 +1,63 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../vpcless + - ../../../addons/cluster-autoscaler + - ../../../addons/etcd-backup-restore + - ../../../addons/machine-health-check + +patches: + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: MachineDeployment + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: MachineDeployment + metadata: + name: ${CLUSTER_NAME}-md-0 + annotations: + cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: ${WORKER_MACHINE_MIN:-"1"} + cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: ${WORKER_MACHINE_MAX:-"10"} + - target: + group: infrastructure.cluster.x-k8s.io + version: v1alpha1 + kind: LinodeMachineTemplate + name: .*-control-plane + patch: |- + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachineTemplate + metadata: + name: ${CLUSTER_NAME}-control-plane + spec: + template: + spec: + dataDisks: + sdc: + label: etcd_disk + size: 10Gi + - target: + group: controlplane.cluster.x-k8s.io + version: v1alpha1 + kind: RKE2ControlPlane + patch: |- + apiVersion: controlplane.cluster.x-k8s.io/v1alpha1 + kind: RKE2ControlPlane + metadata: + name: ${CLUSTER_NAME}-control-plane + spec: + agentConfig: + additionalUserData: + config: |- + diskSetup: + /dev/sdc: + layout: true + fs_setup: + - label: /dev/sdc + filesystem: ext4 + device: /dev/sdc + mounts: + - ["/dev/sdc", "/var/lib/etcd_data"] + + - /var/lib/etcd_data diff --git a/templates/flavors/rke2/full/kustomization.yaml b/templates/flavors/rke2/full/kustomization.yaml new file mode 100644 index 000000000..0a62c601d --- /dev/null +++ b/templates/flavors/rke2/full/kustomization.yaml @@ -0,0 +1,49 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ../default + - ../../../addons/cluster-autoscaler + - ../../../addons/etcd-backup-restore + - ../../../addons/machine-health-check + +patches: + - target: + group: infrastructure.cluster.x-k8s.io + version: v1alpha1 + kind: LinodeMachineTemplate + name: .*-control-plane + patch: |- + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachineTemplate + metadata: + name: ${CLUSTER_NAME}-control-plane + spec: + template: + spec: + dataDisks: + sdc: + label: etcd_disk + size: 10Gi + - target: + group: controlplane.cluster.x-k8s.io + version: v1alpha1 + kind: RKE2ControlPlane + patch: |- + apiVersion: controlplane.cluster.x-k8s.io/v1alpha1 + kind: RKE2ControlPlane + metadata: + name: ${CLUSTER_NAME}-control-plane + spec: + agentConfig: + additionalUserData: + config: |- + diskSetup: + /dev/sdc: + layout: true + fs_setup: + - label: /dev/sdc + filesystem: ext4 + device: /dev/sdc + mounts: + - ["/dev/sdc", "/var/lib/etcd_data"] diff --git a/templates/flavors/rke2/self-healing/kustomization.yaml b/templates/flavors/rke2/self-healing/kustomization.yaml new file mode 100644 index 000000000..d26f30bbd --- /dev/null +++ b/templates/flavors/rke2/self-healing/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../default + - ../../../addons/machine-health-check diff --git a/templates/flavors/rke2/vpcless/kustomization.yaml b/templates/flavors/rke2/vpcless/kustomization.yaml new file mode 100644 index 000000000..03c2df75b --- /dev/null +++ b/templates/flavors/rke2/vpcless/kustomization.yaml @@ -0,0 +1,124 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - ../default + +patches: + - target: + kind: HelmChartProxy + name: .*-cilium + patch: |- + - op: replace + path: /spec/valuesTemplate + value: | + bgpControlPlane: + enabled: true + ipam: + mode: kubernetes + k8s: + requireIPv4PodCIDR: true + hubble: + relay: + enabled: true + ui: + enabled: true + - target: + kind: HelmChartProxy + name: .*-linode-cloud-controller-manager + patch: |- + - op: replace + path: /spec/valuesTemplate + value: | + secretRef: + name: "linode-token-region" + image: + pullPolicy: IfNotPresent + - target: + kind: LinodeVPC + patch: |- + $patch: delete + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeVPC + metadata: + name: ${VPC_NAME:=${CLUSTER_NAME}} + - target: + group: infrastructure.cluster.x-k8s.io + version: v1alpha1 + kind: LinodeCluster + patch: |- + - op: remove + path: /spec/vpcRef + - target: + group: controlplane.cluster.x-k8s.io + version: v1alpha1 + kind: RKE2ControlPlane + patch: |- + - op: remove + path: /spec/serverConfig/disableComponents/kubernetesComponents/1 + - target: + group: bootstrap.cluster.x-k8s.io + version: v1alpha1 + kind: RKE2ConfigTemplate + patch: |- + - op: replace + path: /spec/template/spec/preRKE2Commands + value: + - | + mkdir -p /etc/rancher/rke2/config.yaml.d/ + echo "node-ip: $(hostname -I | grep -oE 192\.168\.[0-9]+\.[0-9]+)" >> /etc/rancher/rke2/config.yaml.d/capi-config.yaml + - sed -i '/swap/d' /etc/fstab + - swapoff -a + - hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname + - target: + group: controlplane.cluster.x-k8s.io + version: v1alpha1 + kind: RKE2ControlPlane + patch: |- + - op: replace + path: /spec/preRKE2Commands + value: + - | + mkdir -p /etc/rancher/rke2/config.yaml.d/ + echo "node-ip: $(hostname -I | grep -oE 192\.168\.[0-9]+\.[0-9]+)" >> /etc/rancher/rke2/config.yaml.d/capi-config.yaml + - sed -i '/swap/d' /etc/fstab + - swapoff -a + - hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname + - op: replace + path: /spec/files + value: + - path: /var/lib/rancher/rke2/server/manifests/ccm-linode.yaml + owner: root:root + content: |- + apiVersion: helm.cattle.io/v1 + kind: HelmChart + metadata: + namespace: kube-system + name: ccm-linode + spec: + targetNamespace: kube-system + version: ${LINODE_CCM_VERSION:=v0.4.4} + 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" + - 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 + - target: + group: cluster.x-k8s.io + version: v1beta1 + kind: Cluster + patch: |- + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + metadata: + name: ${CLUSTER_NAME} + labels: + vpcless: "true" diff --git a/templates/flavors/base/cluster.yaml b/templates/infra/cluster.yaml similarity index 100% rename from templates/flavors/base/cluster.yaml rename to templates/infra/cluster.yaml diff --git a/templates/flavors/base/kustomization.yaml b/templates/infra/kustomization.yaml similarity index 100% rename from templates/flavors/base/kustomization.yaml rename to templates/infra/kustomization.yaml diff --git a/templates/flavors/base/linodeCluster.yaml b/templates/infra/linodeCluster.yaml similarity index 100% rename from templates/flavors/base/linodeCluster.yaml rename to templates/infra/linodeCluster.yaml diff --git a/templates/flavors/base/linodeMachineTemplate.yaml b/templates/infra/linodeMachineTemplate.yaml similarity index 92% rename from templates/flavors/base/linodeMachineTemplate.yaml rename to templates/infra/linodeMachineTemplate.yaml index dd4c74610..f8332052e 100644 --- a/templates/flavors/base/linodeMachineTemplate.yaml +++ b/templates/infra/linodeMachineTemplate.yaml @@ -14,7 +14,7 @@ spec: primary: true authorizedKeys: # uncomment to include your ssh key in linode provisioning - # - ${LINODE_SSH_PUBKEY:=""} + # - $LINODE_SSH_PUBKEY --- apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 kind: LinodeMachineTemplate @@ -31,4 +31,4 @@ spec: primary: true authorizedKeys: # uncomment to include your ssh key in linode provisioning - # - ${LINODE_SSH_PUBKEY:=""} + # - $LINODE_SSH_PUBKEY diff --git a/templates/flavors/base/linodeVPC.yaml b/templates/infra/linodeVPC.yaml similarity index 100% rename from templates/flavors/base/linodeVPC.yaml rename to templates/infra/linodeVPC.yaml diff --git a/templates/flavors/base/machineDeployment.yaml b/templates/infra/machineDeployment.yaml similarity index 100% rename from templates/flavors/base/machineDeployment.yaml rename to templates/infra/machineDeployment.yaml diff --git a/templates/flavors/base/secret.yaml b/templates/infra/secret.yaml similarity index 100% rename from templates/flavors/base/secret.yaml rename to templates/infra/secret.yaml