diff --git a/ansible/k8s/components/cilium/README.md b/ansible/k8s/components/cilium/README.md new file mode 100644 index 0000000000000000000000000000000000000000..1cdad60a97b458615a2a2835e53846c2765bf833 --- /dev/null +++ b/ansible/k8s/components/cilium/README.md @@ -0,0 +1,28 @@ +# Cilium + +## BGP + +Cilium has an integration with Metallb. +https://docs.cilium.io/en/v1.10/gettingstarted/bgp/ + +We just need to provide a configmap to it. +`kubectl create -f bgp-configmap.yaml` + +## Chart + +```bash +helm repo add cilium https://helm.cilium.io/ +helm repo update +helm install cilium cilium/cilium \ + --version 1.10.5 \ + --namespace kube-system \ + --values values.yaml +``` + +## Upgrade + +Review the changelog and if everything is fine just change the version tag and upgrade helm. + +## Test it + +There is an example deployment and loadbalancer in the `example` folder. diff --git a/ansible/k8s/components/cilium/bgp-configmap.yaml b/ansible/k8s/components/cilium/bgp-configmap.yaml new file mode 100644 index 0000000000000000000000000000000000000000..d140b10d811169c1cdcbeede3bf50309a6c070e7 --- /dev/null +++ b/ansible/k8s/components/cilium/bgp-configmap.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: bgp-config + namespace: kube-system +data: + config.yaml: | + peers: + - peer-address: 192.168.99.254 + peer-asn: 64512 + my-asn: 64512 + address-pools: + - name: default + protocol: bgp + addresses: + - 192.168.44.0/24 diff --git a/ansible/k8s/components/cilium/example/example-nginx.yaml b/ansible/k8s/components/cilium/example/example-nginx.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0b60ff5e95fde2a908d9d55c78ce9f70a8b54a8e --- /dev/null +++ b/ansible/k8s/components/cilium/example/example-nginx.yaml @@ -0,0 +1,43 @@ +apiVersion: v1 +kind: Service +metadata: + name: test-lb +spec: + type: LoadBalancer + loadBalancerIP: 152.66.192.34 + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: http + selector: + svc: test-lb +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx +spec: + selector: + matchLabels: + svc: test-lb + template: + metadata: + labels: + svc: test-lb + spec: + containers: + - name: web + image: nginx + imagePullPolicy: IfNotPresent + ports: + - containerPort: 80 + readinessProbe: + httpGet: + path: / + port: 80 + resources: + requests: {} + limits: + cpu: '50m' + memory: '100M' diff --git a/ansible/k8s/components/cilium/values.yaml b/ansible/k8s/components/cilium/values.yaml new file mode 100644 index 0000000000000000000000000000000000000000..18ce7e0bd4c247b1ab19e7e5540c9fdbb02b3f9b --- /dev/null +++ b/ansible/k8s/components/cilium/values.yaml @@ -0,0 +1,11 @@ +kubeProxyReplacement: strict +k8sServiceHost: 127.0.0.1 +k8sServicePort: 6443 +# devices: Don't specify it because cilium will use eth0 and eth1 +bgp: + enabled: true + announce: + loadbalancerIP: true +ipam: + mode: "kubernetes" +