Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable cilium CNI option #72

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
c0e11b6
enable cilium CNI option
carpenike Oct 5, 2020
c129195
fix some variables
carpenike Oct 5, 2020
f4c42be
change variable name
carpenike Oct 5, 2020
22ba04b
set permissions on manifests folder and ignore curl warning
carpenike Oct 5, 2020
64bd30b
should have been inside args
carpenike Oct 5, 2020
6e428e0
add some creates pieces to commands
carpenike Nov 17, 2020
c0002dc
add some creates pieces to commands
carpenike Nov 17, 2020
7d10fb0
Merge branch 'add-cilium-cni-with-kube-proxy-option' of https://githu…
carpenike Nov 17, 2020
a620425
args needed to nest creates
carpenike Nov 17, 2020
7ed428e
add another pipefail option
carpenike Nov 17, 2020
415ed8b
Updating variable role prefix and addressing some feedback
xunholy Nov 28, 2020
14dd29c
fix ansible lint issues
xunholy Nov 28, 2020
645377e
update helm values to be from a j2 template
xunholy Nov 29, 2020
c3c2e1a
Merge branch 'main' into add-cilium-cni-with-kube-proxy-option
xunholy Dec 6, 2020
d436a25
Testing cilium on Kubic
anthr76 Dec 19, 2020
9ffc4fd
Add multi-arch envoyproxy/envoy
anthr76 Dec 22, 2020
781cffc
Add quotes for endpoint routes
anthr76 Dec 30, 2020
5879358
Type check on inventory side
anthr76 Dec 30, 2020
ef3e74c
Revised Values
anthr76 Dec 31, 2020
1f8fab3
Disable tunnel
anthr76 Dec 31, 2020
db0be02
Begin adding helm ansible galaxy module
anthr76 Jan 23, 2021
17946e0
Revise cilium role to further use k8s modules
anthr76 Jan 23, 2021
528e59a
Set hostname to inventory hostname if not already set.
anthr76 Jan 23, 2021
940d1c9
Add default pod subnet
anthr76 Jan 23, 2021
e0bfb05
Try adding quotes on version.
anthr76 Jan 23, 2021
e13c365
CNI Role Improvements
anthr76 Jan 23, 2021
f12b19e
Change back to a include task
anthr76 Jan 24, 2021
210c10f
Began adding automating to some of cilium values.
anthr76 Jan 24, 2021
5659a81
Use regex from `cluster_controlplane_endpoint`
anthr76 Jan 24, 2021
99a36c8
Bump tag values and template enovy version.
anthr76 Jan 24, 2021
46f471b
Drop cri_plugin for now
anthr76 Jan 24, 2021
ed97639
Install helm as a kubernete dependency
anthr76 Jan 24, 2021
0c527dc
Add openshift module as a dependency
anthr76 Jan 25, 2021
b6508ee
Merge remote-tracking branch 'upstream/main' into add-cilium-cni-with…
anthr76 Jan 25, 2021
4594501
Remove hostname
anthr76 Jan 25, 2021
a05abcd
Add community.general.modprobe as a requirement
anthr76 Jan 25, 2021
5cfcf04
Drop FQCN, and test kubelt j2 logic
anthr76 Jan 25, 2021
2bf94ae
Enable automatic node CIDR allocation
anthr76 Jan 25, 2021
a97395a
allocate-node-cidrs is enabled by default
anthr76 Jan 25, 2021
4040826
Disable envoy version check
anthr76 Jan 25, 2021
a8ebde2
Template out some variable values and disable BPF by default
anthr76 Jan 25, 2021
904cbae
Remove old packages from Kubernetes role
anthr76 Jan 25, 2021
a439b8c
Kube-Proxy revisions
anthr76 Jan 27, 2021
80f2054
Revise eBPF mount
anthr76 Jan 27, 2021
3f5f9ee
Change default variables
anthr76 Jan 27, 2021
791621c
fix docker restart handler
anthr76 Jan 27, 2021
51a5b1f
Begin adding sysctl fix and enable hubble by default
anthr76 Jan 27, 2021
c3fca22
Some polishes
anthr76 Jan 27, 2021
c95d72e
Scope out cilium variables to examples.
anthr76 Jan 27, 2021
fa4005f
Small cleanups
anthr76 Jan 30, 2021
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
1 change: 1 addition & 0 deletions ansible/roles/cluster/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ cluster_pod_subnet: ""
# Default etcd values, change these if you experience "leader changed" issues when running on a SD card
cluster_etcd_heartbeat_interval: 100
cluster_etcd_election_timeout: 1000
kube_proxy: enabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to have a comment in here for users to roughly know why you'd have this disabled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm unfamiliar with the requirements for cilium, so i am under the assumption that this is a requirement for it. if that is the case, then this var should be scoped as such. explicitly setting this var for later use could be misleading to some users. having this var set based on what CNI you're hoping to deploy would be the ideal situation, likely from a conditional import vars based on CNI selection from the user.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a requirement, but it would modify the installation options for cilium if you're not using kube-proxy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still prefer that the variable be scoped, or at the very least some comments be added to detail what you're enabling/disabling.

11 changes: 10 additions & 1 deletion ansible/roles/cluster/tasks/initialize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,19 @@
src: kubeadm-init.yml.j2
dest: /etc/kubernetes/kubeadm-init.yml

- name: initialize cluster
- name: initialize cluster (with kube-proxy)
command:
cmd: kubeadm init --config /etc/kubernetes/kubeadm-init.yml --upload-certs
creates: /etc/kubernetes/admin.conf
when:
- kube_proxy == "enabled"

- name: initialize cluster (without kube-proxy)
command:
cmd: kubeadm init --skip-phases=addon/kube-proxy --config /etc/kubernetes/kubeadm-init.yml --upload-certs
crutonjohn marked this conversation as resolved.
Show resolved Hide resolved
creates: /etc/kubernetes/admin.conf
when:
- kube_proxy == "disabled"

- name: get sha256 of ca certificate
openssl_certificate_info:
Expand Down
6 changes: 6 additions & 0 deletions ansible/roles/cni/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
---
cni_plugin: calico
bgp_peer_address: 192.168.0.1
bgp_peer_asn: 64512
cilium_helm_version: 1.8.3
cilium_image_version: v1.8.3
k8s_service_host: "{{ hostvars[groups['masters'][0]]['ansible_host'] }}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RobReus -- This really should be VIP IP if it's presented, I'm at the edge of my Ansible skills.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when using keepalived this is associated with keepalived_vip, but i don't know how running cilium affects running keepalived?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theoretically it should be outside of Cilium as it's a host level config, right?

However, this would need to be an either or I think; if VIP present use that, otherwise use the master IP?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i think you're right. it should be an either/or situation. i'm not sure if something could be achieved with jinja logic, but my assumption is that it would be possible by using some jinja operators on the template, in addition to some sanity checking for each var.

k8s_service_port: 6443
61 changes: 61 additions & 0 deletions ansible/roles/cni/tasks/cilium.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
- name: Install Helm v3
shell: |
crutonjohn marked this conversation as resolved.
Show resolved Hide resolved
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
args:
warn: false

- name: Add Cilium Repo
command:
cmd: helm repo add cilium https://helm.cilium.io/

- name: Deploy Cilium
shell: |
helm upgrade -i cilium cilium/cilium --version {{ cilium_helm_version }} \
--set global.registry="docker.io/cilium" \
--set global.tag="{{ cilium_image_version }}" \
--set global.tunnel="disabled" \
--set global.externalIPs.enabled="true" \
--set global.ipam.operator.clusterPoolIPv4PodCIDR="{{ cluster_pod_subnet }}" \
--set global.ipam.operator.clusterPoolIPv4MaskSize="24" \
--set global.endpointRoutes.enabled="true" \
--set global.hostServices.enabled="true" \
--set global.autoDirectNodeRoutes="true" \
--set global.nodePort.enabled="true" \
--set global.nodePort.mode="dsr" \
--set global.masquerade="false" \
--set global.hubble.enabled="true" \
--set global.hubble.ui.enabled="true" \
--set global.hubble.relay.enabled="true" \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is an easier way to store these values to allow them to be easier to configure for users, for example, a user using arm might not be able to enable hubble right now. Would it make sense if we stored these in a values.yaml under files/ and we copy that and just --values=values.yaml on the host, this is just a thought?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah we could template out a cilium-values.yaml file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, if we can template out a file that users can use to edit helm values that would be perfect!

--set global.hubble.metrics.enabled="{dns,drop,tcp,flow,port-distribution,icmp,http}" \
--set global.kubeProxyReplacement=strict \
--set global.k8sServiceHost={{ k8s_service_host }} \
--set global.k8sServicePort={{ k8s_service_port }} \
--set config.bpfMasquerade="false" \
--namespace kube-system

- name: Create Manifests Directory
file:
path: /root/manifests
state: directory
mode: 0700

- name: "Deploy manifests"
become: true
template:
src: "{{ item }}"
dest: "/root/manifests/{{ item | basename | replace('.j2','') }}"
mode: 0600
with_items:
- "generic-kuberouter-only-advertise-routes.yaml.j2"

- name: Applying manifests
command:
cmd: "kubectl apply -f /root/manifests/{{ item }}"
with_items:
- "generic-kuberouter-only-advertise-routes.yaml"

- name: Remove Manifests Directory
file:
path: /root/manifests
state: absent
8 changes: 8 additions & 0 deletions ansible/roles/cni/tasks/pre_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@
fail_msg:
- "Plugin 'flannel' requires pod subnet to be configured."
when: cni_plugin == 'flannel'

- name: 'validate pod subnet is used when using cilium'
assert:
that:
- cluster_pod_subnet | ipaddr
fail_msg:
- "Plugin 'cilium' requires pod subnet to be configured."
when: cni_plugin == 'cilium'
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
k8s-app: kube-router
tier: node
name: kube-router
namespace: kube-system
spec:
selector:
matchLabels:
k8s-app: kube-router
tier: node
template:
metadata:
labels:
k8s-app: kube-router
tier: node
spec:
priorityClassName: system-node-critical
serviceAccountName: kube-router
containers:
- name: kube-router
image: "{{ kube_router_image }}"
imagePullPolicy: Always
args:
- "--run-router=true"
- "--run-firewall=false"
- "--run-service-proxy=false"
- "--bgp-graceful-restart=true"
- "--enable-cni=false"
- "--enable-pod-egress=false"
- "--enable-ibgp=true"
- "--enable-overlay=false"
- "--peer-router-ips={{ bgp_peer_address }}"
- "--peer-router-asns={{ bgp_peer_asn }}"
- "--cluster-asn={{ bgp_cluster_asn }}"
- "--advertise-cluster-ip=true"
- "--advertise-external-ip=true"
- "--advertise-loadbalancer-ip=true"
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
livenessProbe:
httpGet:
path: /healthz
port: 20244
initialDelaySeconds: 10
periodSeconds: 3
resources:
requests:
cpu: 250m
memory: 250Mi
securityContext:
privileged: true
volumeMounts:
- name: xtables-lock
mountPath: /run/xtables.lock
readOnly: false
hostNetwork: true
tolerations:
- effect: NoSchedule
operator: Exists
- key: CriticalAddonsOnly
operator: Exists
- effect: NoExecute
operator: Exists
volumes:
- name: xtables-lock
hostPath:
path: /run/xtables.lock
type: FileOrCreate
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: kube-router
namespace: kube-system
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: kube-router
namespace: kube-system
rules:
- apiGroups:
- ""
resources:
- namespaces
- pods
- services
- nodes
- endpoints
verbs:
- list
- get
- watch
- apiGroups:
- "networking.k8s.io"
resources:
- networkpolicies
verbs:
- list
- get
- watch
- apiGroups:
- extensions
resources:
- networkpolicies
verbs:
- get
- list
- watch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: kube-router
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kube-router
subjects:
- kind: ServiceAccount
name: kube-router
namespace: kube-system
1 change: 1 addition & 0 deletions ansible/roles/cni/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ cni_supported_plugins:
- calico
- flannel
- weave
- cilium