Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions kubernetes/workloads/multus-cni/create_manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ pushd "${multus_tmpdir}" || exit 1
# This way I don't have to mess w/ installing CNI's to /opt/cni/bin myself
helm repo add rke2-charts https://rke2-charts.rancher.io
helm repo update
helm template rke2-multus rke2-charts/rke2-multus | \
helm template rke2-multus rke2-charts/rke2-multus \
--set manifests.dhcpDaemonSet=true \
--namespace kube-system | \
yq --no-colors --prettyPrint '... comments=""' | \
kubectl-slice -o . --template "{{ .kind | lower }}.yaml"

initContainer=$(yq --no-colors '.spec.template.spec.initContainers[] | del(.env)' daemonset.yaml)
initContainer=$(yq --no-colors 'select(di==0) | .spec.template.spec.initContainers[] | del(.env)' daemonset.yaml)
dhcpDaemonSet=$(yq 'select(di==1)' daemonset.yaml)
popd || exit 1
rm -rf "${multus_tmpdir}"
mkdir -p manifests/base
Expand All @@ -39,27 +42,10 @@ echo -n "${tmpvar}" |
yq --no-colors --prettyPrint | \
kubectl-slice -o . --skip-non-k8s --template "{{ .kind | lower }}.yaml"

# Iterate over each yaml file
files=()
for file in *.yaml; do
if [[ "${file}" == "kustomization.yaml" ]]; then
continue
fi
files+=("${file}")
contents="$(cat "${file}")"
printf -- "---\n# yamllint disable rule:line-length\n%s" "${contents}" > "${file}"
done

yq -i '.spec.template.spec.initContainers += load("'<(echo -n "${initContainer}")'")' daemonset.yaml

echo -e "\n---\n${dhcpDaemonSet}" >> daemonset.yaml
# Create kustomize file
cat <<EOF > kustomization.yaml
---
kind: Kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
resources:
$(printf " - %s\n" "${files[@]}")
EOF
kustomize create --autodetect

# Format YAML
prettier . --write
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---
# yamllint disable rule:line-length
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---
# yamllint disable rule:line-length
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
Expand Down
2 changes: 0 additions & 2 deletions kubernetes/workloads/multus-cni/manifests/base/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---
# yamllint disable rule:line-length
kind: ConfigMap
apiVersion: v1
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---
# yamllint disable rule:line-length
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
Expand Down
72 changes: 70 additions & 2 deletions kubernetes/workloads/multus-cni/manifests/base/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---
# yamllint disable rule:line-length
apiVersion: apps/v1
kind: DaemonSet
metadata:
Expand Down Expand Up @@ -133,3 +131,73 @@ spec:
- name: host-run-netns
hostPath:
path: /run/netns/

---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: rke2-multus-dhcp
namespace: kube-system
labels:
tier: node
app: rke2-multus
spec:
selector:
matchLabels:
app: rke2-multus
updateStrategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
template:
metadata:
labels:
tier: node
app: rke2-multus
spec:
hostNetwork: true
tolerations:
- effect: NoSchedule
operator: Exists
- effect: NoExecute
operator: Exists
nodeSelector:
kubernetes.io/os: linux
initContainers:
- name: kube-rke2-multus-dhcp-cleanup
image: rancher/mirrored-library-busybox:1.36.1
command:
- rm
- -f
- /run/cni/dhcp.sock
securityContext:
privileged: true
volumeMounts:
- name: socketpath
mountPath: /host/run/cni
containers:
- name: kube-rke2-multus-dhcp
image: rancher/mirrored-library-busybox:1.36.1
command:
- /opt/cni/bin/dhcp
- daemon
securityContext:
privileged: true
volumeMounts:
- name: binpath
mountPath: /opt/cni/bin
- name: socketpath
mountPath: /run/cni
- name: netnspath
mountPath: /var/run/netns
mountPropagation: HostToContainer
volumes:
- name: binpath
hostPath:
path: /opt/cni/bin
- name: socketpath
hostPath:
path: /run/cni
- name: netnspath
hostPath:
path: /run/netns
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
kind: Kustomization
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- clusterrole.yaml
- clusterrolebinding.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---
# yamllint disable rule:line-length
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down