Skip to content

Commit 843fc27

Browse files
authored
[improvement] Add new flavors (#325)
* Add new flavors
1 parent 0d9640b commit 843fc27

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1034
-198
lines changed

hack/generate-flavors.sh

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,35 @@ set -euo pipefail
44

55
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
66
FLAVORS_DIR="${REPO_ROOT}/templates/flavors"
7+
SUPPORTED_DISTROS=(
8+
"rke2"
9+
"k3s"
10+
"kubeadm"
11+
)
12+
SUPPORTED_CLUSTERCLASSES=(
13+
"clusterclass-kubeadm"
14+
)
715

8-
for name in $(find "${FLAVORS_DIR}/"* -maxdepth 0 -type d -print0 | xargs -0 -I {} basename {} | grep -v base | grep -v clusterclass-base ); do
16+
for clusterclass in ${SUPPORTED_CLUSTERCLASSES[@]}; do
917
# clusterctl expects clusterclass not have the "cluster-template" prefix
1018
# except for the actual cluster template using the clusterclass
11-
if [[ "$name" == clusterclass* ]]; then
12-
kustomize build "${FLAVORS_DIR}/${name}" > "${REPO_ROOT}/templates/${name}.yaml"
13-
cp "${FLAVORS_DIR}/${name}/cluster-template.yaml" "${REPO_ROOT}/templates/cluster-template-${name}.yaml"
14-
else
15-
kustomize build "${FLAVORS_DIR}/${name}" > "${REPO_ROOT}/templates/cluster-template-${name}.yaml"
16-
fi
19+
echo "****** Generating clusterclass-${clusterclass} flavor ******"
20+
kustomize build "${FLAVORS_DIR}/${clusterclass}" > "${REPO_ROOT}/templates/${clusterclass}.yaml"
21+
cp "${FLAVORS_DIR}/${clusterclass}/cluster-template.yaml" "${REPO_ROOT}/templates/cluster-template-${clusterclass}.yaml"
22+
done
23+
24+
25+
for distro in ${SUPPORTED_DISTROS[@]}; do
26+
for name in $(find "${FLAVORS_DIR}/${distro}/"* -maxdepth 0 -type d -print0 | xargs -0 -I {} basename {}); do
27+
if [[ ${name} == "default" ]]; then
28+
echo "****** Generating ${distro} flavor ******"
29+
kustomize build "${FLAVORS_DIR}/${distro}/${name}" > "${REPO_ROOT}/templates/cluster-template-${distro}.yaml"
30+
else
31+
echo "****** Generating ${distro}-${name} flavor ******"
32+
kustomize build "${FLAVORS_DIR}/${distro}/${name}" > "${REPO_ROOT}/templates/cluster-template-${distro}-${name}.yaml"
33+
fi
34+
done
1735
done
1836

1937
# move the default template to the default file expected by clusterctl
20-
mv "${REPO_ROOT}/templates/cluster-template-default.yaml" "${REPO_ROOT}/templates/cluster-template.yaml"
38+
mv "${REPO_ROOT}/templates/cluster-template-kubeadm.yaml" "${REPO_ROOT}/templates/cluster-template.yaml"

templates/addons/cilium-network-policies/ciliumNetworkPolicies.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ data:
3535
toPorts:
3636
- ports:
3737
- port: "6443"
38-
- port: "2379"
39-
- port: "2380"
4038
---
4139
apiVersion: addons.cluster.x-k8s.io/v1beta1
4240
kind: ClusterResourceSet

templates/flavors/README.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

templates/flavors/clusterclass-kubeadm/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ resources:
44
- clusterClass.yaml
55
- kubeadmControlPlaneTemplate.yaml
66
- linodeClusterTemplate.yaml
7-
- ../default
7+
- ../kubeadm/default
88

99
transformers:
1010
- replacementTransformer.yaml
@@ -47,4 +47,4 @@ patches:
4747
patch: |-
4848
kind: KubeadmConfigTemplate
4949
metadata:
50-
name: kubeadm-worker
50+
name: kubeadm-worker

templates/flavors/default/kustomization.yaml

Lines changed: 0 additions & 42 deletions
This file was deleted.

templates/flavors/k3s/ciliumNetworkPolicies.yaml

Lines changed: 0 additions & 51 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
3+
34
resources:
45
- ../default
5-
- ../../addons/cluster-autoscaler
6+
- ../../../addons/cluster-autoscaler
7+
68
patches:
7-
- target:
8-
group: cluster.x-k8s.io
9-
version: v1beta1
10-
kind: Cluster
11-
patch: |-
12-
apiVersion: cluster.x-k8s.io/v1beta1
13-
kind: Cluster
14-
metadata:
15-
name: ${CLUSTER_NAME}
16-
labels:
17-
cluster-autoscaler: "true"
189
- target:
1910
group: cluster.x-k8s.io
2011
version: v1beta1
@@ -27,3 +18,14 @@ patches:
2718
annotations:
2819
cluster.x-k8s.io/cluster-api-autoscaler-node-group-min-size: ${WORKER_MACHINE_MIN:-"1"}
2920
cluster.x-k8s.io/cluster-api-autoscaler-node-group-max-size: ${WORKER_MACHINE_MAX:-"10"}
21+
- target:
22+
group: cluster.x-k8s.io
23+
version: v1beta1
24+
kind: Cluster
25+
patch: |-
26+
apiVersion: cluster.x-k8s.io/v1beta1
27+
kind: Cluster
28+
metadata:
29+
name: ${CLUSTER_NAME}
30+
labels:
31+
cluster-autoscaler: "true"

templates/flavors/k3s/k3sControlPlane.yaml renamed to templates/flavors/k3s/default/k3sControlPlane.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ spec:
100100
nodeName: '{{ ds.meta_data.label }}'
101101
preK3sCommands:
102102
- |
103+
mkdir -p /etc/rancher/k3s/config.yaml.d/
103104
echo "node-ip: $(ip a s eth1 |grep 'inet ' |cut -d' ' -f6|cut -d/ -f1)" >> /etc/rancher/k3s/config.yaml.d/capi-config.yaml
104105
- sed -i '/swap/d' /etc/fstab
105106
- swapoff -a

templates/flavors/k3s/kustomization.yaml renamed to templates/flavors/k3s/default/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
33
resources:
4-
- ../base
4+
- ../../../infra
55
- k3sControlPlane.yaml
66
- k3sConfigTemplate.yaml
7-
- ciliumNetworkPolicies.yaml
87
- secret.yaml
8+
- ../../../addons/cilium-network-policies
99
patches:
1010
- target:
1111
group: cluster.x-k8s.io

0 commit comments

Comments
 (0)