Skip to content

Commit

Permalink
add k3s flavor support
Browse files Browse the repository at this point in the history
  • Loading branch information
eljohnson92 committed Feb 26, 2024
1 parent 37dd717 commit 1f86d01
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
18 changes: 18 additions & 0 deletions templates/flavors/k3s/k3sConfigTemplate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
kind: KThreesConfigTemplate
metadata:
name: ${CLUSTER_NAME}-md-0
spec:
template:
spec:
agentConfig:
nodeName: '{{ ds.meta_data.label }}'
kubeletArgs:
- "provider-id=linode://{{ ds.meta_data.id }}"
preK3sCommands:
- |
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
50 changes: 50 additions & 0 deletions templates/flavors/k3s/k3sControlPlane.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
kind: KThreesControlPlane
metadata:
name: ${CLUSTER_NAME}-control-plane
spec:
infrastructureTemplate:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1
kind: LinodeMachineTemplate
name: ${CLUSTER_NAME}-control-plane
kthreesConfigSpec:
files:
- content: |
flannel-backend: none
disable-network-policy: true
owner: root:root
path: /etc/rancher/k3s/config.yaml.d/capi-config.yaml
- contentFrom:
secret:
key: cilium.yaml
name: linode-${CLUSTER_NAME}-crs-0
owner: root:root
path: /var/lib/rancher/k3s/server/manifests/cilium.yaml
- contentFrom:
secret:
key: linode-ccm.yaml
name: linode-${CLUSTER_NAME}-crs-0
owner: root:root
path: /var/lib/rancher/k3s/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/k3s/server/manifests/linode-token-region.yaml
serverConfig:
disableComponents:
- servicelb
- traefik
agentConfig:
nodeName: '{{ ds.meta_data.label }}'
kubeletArgs:
- "provider-id=linode://{{ ds.meta_data.id }}"
preK3sCommands:
- |
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
replicas: ${CONTROL_PLANE_MACHINE_COUNT}
version: ${KUBERNETES_VERSION}
22 changes: 22 additions & 0 deletions templates/flavors/k3s/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
resources:
- ../base
- k3sControlPlane.yaml
- k3sConfigTemplate.yaml
- secret.yaml
patches:
- target:
group: cluster.x-k8s.io
version: v1beta1
kind: Cluster
patch: |-
- op: replace
path: /spec/controlPlaneRef/kind
value: KThreesControlPlane
- target:
group: cluster.x-k8s.io
version: v1beta1
kind: MachineDeployment
patch: |-
- op: replace
path: /spec/template/spec/bootstrap/configRef/kind
value: KThreesConfigTemplate
50 changes: 50 additions & 0 deletions templates/flavors/k3s/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
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}
cilium.yaml: |-
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
namespace: kube-system
name: cilium
spec:
targetNamespace: kube-system
version: v1.15.0
chart: cilium
repo: https://helm.cilium.io/
bootstrap: true
valuesContent: |-
hubble:
relay:
enabled: true
ui:
enabled: true
linode-ccm.yaml: |-
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
namespace: kube-system
name: ccm-linode
spec:
targetNamespace: kube-system
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"

0 comments on commit 1f86d01

Please sign in to comment.