Skip to content

Commit

Permalink
use kustomize transformers
Browse files Browse the repository at this point in the history
  • Loading branch information
AshleyDumaine committed May 24, 2024
1 parent 56a081f commit c572de1
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 84 deletions.
3 changes: 1 addition & 2 deletions docs/src/topics/flavors/cilium-bgp-lb.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ Linode networking and API limitations:

## Usage

1. (Optional) Set up environment variables
1. (Optional) Set up environment variable
```sh
# Optional
export LINODE_BGP_PEER_MACHINE_TYPE=g6-standard-2
export BGP_PEER_MACHINE_COUNT=2
```

Expand Down
57 changes: 0 additions & 57 deletions templates/flavors/cilium-bgp-lb/kubeadmConfigTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,3 @@ apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
metadata:
name: ${CLUSTER_NAME}-md-bgp
spec:
template:
spec:
files:
- path: /etc/containerd/config.toml
content: |
version = 2
imports = ["/etc/containerd/conf.d/*.toml"]
[plugins]
[plugins."io.containerd.grpc.v1.cri"]
sandbox_image = "registry.k8s.io/pause:3.9"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
runtime_type = "io.containerd.runc.v2"
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
- path: /etc/modules-load.d/k8s.conf
content: |
overlay
br_netfilter
- path: /etc/sysctl.d/k8s.conf
content: |
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
- path: /kubeadm-pre-init.sh
content: |
#!/bin/bash
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
mkdir -p -m 755 /etc/apt/keyrings
PATCH_VERSION=$${1#[v]}
VERSION=$${PATCH_VERSION%.*}
curl -fsSL "https://pkgs.k8s.io/core:/stable:/v$VERSION/deb/Release.key" | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v$VERSION/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
apt-get update -y
apt-get install -y kubelet=$PATCH_VERSION* kubeadm=$PATCH_VERSION* kubectl=$PATCH_VERSION* containerd
apt-mark hold kubelet kubeadm kubectl containerd
modprobe overlay
modprobe br_netfilter
sysctl --system
if [ -d "/sys/class/net/eth1" ]; then
IPADDR=$(ip a s eth1 |grep 'inet ' |cut -d' ' -f6|cut -d/ -f1)
sed -i "s/kubeletExtraArgs:/kubeletExtraArgs:\n node-ip: $IPADDR/g" /run/kubeadm/kubeadm.yaml
fi
permissions: "0500"
preKubeadmCommands:
- /kubeadm-pre-init.sh ${KUBERNETES_VERSION}
- sed -i '/swap/d' /etc/fstab
- swapoff -a
- hostnamectl set-hostname '{{ ds.meta_data.label }}' && hostname -F /etc/hostname
joinConfiguration:
nodeRegistration:
kubeletExtraArgs:
cloud-provider: external
node-labels: cilium-bgp-peering="true"
name: '{{ ds.meta_data.label }}'
70 changes: 70 additions & 0 deletions templates/flavors/cilium-bgp-lb/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,73 @@ patches:
env:
- name: LINODE_URL
value: https://api.linode.com/v4beta
transformers:
- |

Check failure on line 31 in templates/flavors/cilium-bgp-lb/kustomization.yaml

View workflow job for this annotation

GitHub Actions / yamllint

31:1 [indentation] wrong indentation: expected 2 but found 0
apiVersion: builtin
kind: ReplacementTransformer
metadata:
name: clone-bgp
replacements:
- source:
kind: KubeadmConfigTemplate
name: ${CLUSTER_NAME}-md-0
fieldPath: .spec
targets:
- select:
kind: KubeadmConfigTemplate
name: ${CLUSTER_NAME}-md-bgp
fieldPaths:
- .spec
options:
create: true
- source:
kind: LinodeMachineTemplate
name: ${CLUSTER_NAME}-md-0
fieldPath: .spec
targets:
- select:
kind: LinodeMachineTemplate
name: ${CLUSTER_NAME}-md-bgp
fieldPaths:
- .spec
options:
create: true
- source:
kind: MachineDeployment
name: ${CLUSTER_NAME}-md-0
fieldPath: .spec.template
targets:
- select:
kind: MachineDeployment
name: ${CLUSTER_NAME}-md-bgp
fieldPaths:
- .spec.template
options:
create: true
- |-
apiVersion: builtin
kind: PatchTransformer
metadata:
name: patch-kubeadmconfig
patch: |-
- op: add
path: /spec/template/spec/joinConfiguration/nodeRegistration/kubeletExtraArgs/node-labels
value: cilium-bgp-peering="true"
target:
kind: KubeadmConfigTemplate
name: .*-md-bgp
- |-
apiVersion: builtin
kind: PatchTransformer
metadata:
name: patch-machinedeployment
patch: |-
- op: replace
path: /spec/template/spec/bootstrap/configRef/name
value: ${CLUSTER_NAME}-md-bgp
- op: replace
path: /spec/template/spec/infrastructureRef/name
value: ${CLUSTER_NAME}-md-bgp
target:
kind: MachineDeployment
name: .*-md-bgp
12 changes: 0 additions & 12 deletions templates/flavors/cilium-bgp-lb/linodeMachineTemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,3 @@ apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: LinodeMachineTemplate
metadata:
name: ${CLUSTER_NAME}-md-bgp
spec:
template:
spec:
image: ${LINODE_OS:="linode/ubuntu22.04"}
type: ${LINODE_BGP_PEER_MACHINE_TYPE:=${LINODE_MACHINE_TYPE}}
region: ${LINODE_REGION}
interfaces:
- purpose: public
primary: true
authorizedKeys:
# uncomment to include your ssh key in linode provisioning
# - ${LINODE_SSH_PUBKEY:=""}
13 changes: 0 additions & 13 deletions templates/flavors/cilium-bgp-lb/machineDeployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,3 @@ metadata:
spec:
clusterName: ${CLUSTER_NAME}
replicas: ${BGP_PEER_MACHINE_COUNT:=2}
template:
spec:
clusterName: ${CLUSTER_NAME}
version: "${KUBERNETES_VERSION}"
bootstrap:
configRef:
name: ${CLUSTER_NAME}-md-bgp
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KubeadmConfigTemplate
infrastructureRef:
name: ${CLUSTER_NAME}-md-bgp
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: LinodeMachineTemplate

0 comments on commit c572de1

Please sign in to comment.