Last active
December 28, 2020 16:08
-
-
Save ams0/7b454fe68599473fea2759ba1e2003bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Kubenet vs AzureCNI for Cilium investigation | |
az aks create -k 1.19.3 --enable-managed-identity -g k8s --network-plugin kubenet -s Standard_B4ms -c 2 -n kubenet --no-wait | |
az aks create -k 1.19.3 --enable-managed-identity -g k8s --network-plugin azure -s Standard_B4ms -c 2 -n cilium --no-wait | |
AzureCNI | |
# cat /etc/systemd/system/kubelet.service | |
[Unit] | |
Description=Kubelet | |
ConditionPathExists=/usr/local/bin/kubelet | |
[Service] | |
Restart=always | |
EnvironmentFile=/etc/default/kubelet | |
SuccessExitStatus=143 | |
ExecStartPre=/bin/bash /opt/azure/containers/kubelet.sh | |
ExecStartPre=/bin/mkdir -p /var/lib/kubelet | |
ExecStartPre=/bin/mkdir -p /var/lib/cni | |
ExecStartPre=/bin/bash -c "if [ $(mount | grep \"/var/lib/kubelet\" | wc -l) -le 0 ] ; then /bin/mount --bind /var/lib/kubelet /var/lib/kubelet ; fi" | |
ExecStartPre=/bin/mount --make-shared /var/lib/kubelet | |
ExecStartPre=-/sbin/ebtables -t nat --list | |
ExecStartPre=-/sbin/iptables -t nat --numeric --list | |
ExecStartPre=/usr/local/bin/configure_azure0.sh | |
ExecStart=/usr/local/bin/kubelet \ | |
--enable-server \ | |
--node-labels="${KUBELET_NODE_LABELS}" \ | |
--v=2 --container-runtime=remote --runtime-request-timeout=15m --container-runtime-endpoint=unix:///run/containerd/containerd.sock \ | |
--volume-plugin-dir=/etc/kubernetes/volumeplugins \ | |
$KUBELET_FLAGS \ | |
$KUBELET_REGISTER_NODE $KUBELET_REGISTER_WITH_TAINTS | |
[Install] | |
WantedBy=multi-user.target | |
# cat /etc/default/kubelet | |
KUBELET_FLAGS=--address=0.0.0.0 --anonymous-auth=false --authentication-token-webhook=true --authorization-mode=Webhook --azure-container-registry-config=/etc/kubernetes/azure.json --cgroups-per-qos=true --client-ca-file=/etc/kubernetes/certs/ca.crt --cloud-config=/etc/kubernetes/azure.json --cloud-provider=azure --cluster-dns=10.0.0.10 --cluster-domain=cluster.local --dynamic-config-dir=/var/lib/kubelet --enforce-node-allocatable=pods --event-qps=0 --eviction-hard=memory.available<750Mi,nodefs.available<10%,nodefs.inodesFree<5% --feature-gates=RotateKubeletServerCertificate=true --image-gc-high-threshold=85 --image-gc-low-threshold=80 --image-pull-progress-deadline=30m --keep-terminated-pod-volumes=false --kube-reserved=cpu=140m,memory=2662Mi --kubeconfig=/var/lib/kubelet/kubeconfig --max-pods=30 --network-plugin=cni --node-status-update-frequency=10s --non-masquerade-cidr=0.0.0.0/0 --pod-infra-container-image=mcr.microsoft.com/oss/kubernetes/pause:1.3.1 --pod-manifest-path=/etc/kubernetes/manifests --pod-max-pids=-1 --read-only-port=0 --resolv-conf=/run/systemd/resolve/resolv.conf --rotate-certificates=false --streaming-connection-idle-timeout=4h --tls-cert-file=/etc/kubernetes/certs/kubeletserver.crt --tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256 --tls-private-key-file=/etc/kubernetes/certs/kubeletserver.key | |
KUBELET_REGISTER_SCHEDULABLE=true | |
NETWORK_POLICY= | |
KUBELET_NODE_LABELS=kubernetes.azure.com/role=agent,agentpool=nodepool1,storageprofile=managed,storagetier=Premium_LRS,kubernetes.azure.com/cluster=MC_k8s_cilium_westeurope,kubernetes.azure.com/mode=system,kubernetes.azure.com/node-image-version=AKSUbuntu-1804containerd-2020.12.15 | |
# cat /opt/azure/containers/kubelet.sh | |
#!/bin/bash | |
# Disallow container from reaching out to the special IP address 168.63.129.16 | |
# for TCP protocol (which http uses) | |
# | |
# 168.63.129.16 contains protected settings that have priviledged info. | |
# | |
# The host can still reach 168.63.129.16 because it goes through the OUTPUT chain, not FORWARD. | |
# | |
# Note: we should not block all traffic to 168.63.129.16. For example UDP traffic is still needed | |
# for DNS. | |
iptables -I FORWARD -d 168.63.129.16 -p tcp --dport 80 -j DROP | |
# cat /etc/cni/net.d/10-azure.conflist | |
{ | |
"cniVersion":"0.3.0", | |
"name":"azure", | |
"plugins":[ | |
{ | |
"type":"azure-vnet", | |
"mode":"transparent", | |
"ipsToRouteViaHost":["169.254.20.10"], | |
"ipam":{ | |
"type":"azure-vnet-ipam" | |
} | |
}, | |
{ | |
"type":"portmap", | |
"capabilities":{ | |
"portMappings":true | |
}, | |
"snat":true | |
} | |
] | |
} | |
# ls /opt/cni/bin/ | |
azure-vnet azure-vnet-ipamv6 azure-vnet-telemetry.config dhcp host-device ipvlan macvlan ptp tuning | |
azure-vnet-ipam azure-vnet-telemetry bridge flannel host-local loopback portmap sample vlan | |
# Kubenet | |
# cat /etc/systemd/system/kubelet.service | |
[Unit] | |
Description=Kubelet | |
ConditionPathExists=/usr/local/bin/kubelet | |
[Service] | |
Restart=always | |
EnvironmentFile=/etc/default/kubelet | |
SuccessExitStatus=143 | |
ExecStartPre=/bin/bash /opt/azure/containers/kubelet.sh | |
ExecStartPre=/bin/mkdir -p /var/lib/kubelet | |
ExecStartPre=/bin/mkdir -p /var/lib/cni | |
ExecStartPre=/bin/bash -c "if [ $(mount | grep \"/var/lib/kubelet\" | wc -l) -le 0 ] ; then /bin/mount --bind /var/lib/kubelet /var/lib/kubelet ; fi" | |
ExecStartPre=/bin/mount --make-shared /var/lib/kubelet | |
ExecStartPre=-/sbin/ebtables -t nat --list | |
ExecStartPre=-/sbin/iptables -t nat --numeric --list | |
ExecStartPre=/usr/local/bin/configure_azure0.sh | |
ExecStart=/usr/local/bin/kubelet \ | |
--enable-server \ | |
--node-labels="${KUBELET_NODE_LABELS}" \ | |
--v=2 --container-runtime=remote --runtime-request-timeout=15m --container-runtime-endpoint=unix:///run/containerd/containerd.sock \ | |
--volume-plugin-dir=/etc/kubernetes/volumeplugins \ | |
$KUBELET_FLAGS \ | |
$KUBELET_REGISTER_NODE $KUBELET_REGISTER_WITH_TAINTS | |
[Install] | |
WantedBy=multi-user.target | |
# cat /etc/default/kubelet | |
KUBELET_FLAGS=--address=0.0.0.0 --anonymous-auth=false --authentication-token-webhook=true --authorization-mode=Webhook --azure-container-registry-config=/etc/kubernetes/azure.json --cgroups-per-qos=true --client-ca-file=/etc/kubernetes/certs/ca.crt --cloud-config=/etc/kubernetes/azure.json --cloud-provider=azure --cluster-dns=10.0.0.10 --cluster-domain=cluster.local --dynamic-config-dir=/var/lib/kubelet --enforce-node-allocatable=pods --event-qps=0 --eviction-hard=memory.available<750Mi,nodefs.available<10%,nodefs.inodesFree<5% --feature-gates=RotateKubeletServerCertificate=true --image-gc-high-threshold=85 --image-gc-low-threshold=80 --image-pull-progress-deadline=30m --keep-terminated-pod-volumes=false --kube-reserved=cpu=140m,memory=2662Mi --kubeconfig=/var/lib/kubelet/kubeconfig --max-pods=110 --network-plugin=kubenet --node-status-update-frequency=10s --non-masquerade-cidr=10.244.0.0/16 --pod-infra-container-image=mcr.microsoft.com/oss/kubernetes/pause:1.3.1 --pod-manifest-path=/etc/kubernetes/manifests --pod-max-pids=-1 --read-only-port=0 --resolv-conf=/run/systemd/resolve/resolv.conf --rotate-certificates=false --streaming-connection-idle-timeout=4h --tls-cert-file=/etc/kubernetes/certs/kubeletserver.crt --tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256 --tls-private-key-file=/etc/kubernetes/certs/kubeletserver.key | |
KUBELET_REGISTER_SCHEDULABLE=true | |
NETWORK_POLICY= | |
KUBELET_NODE_LABELS=kubernetes.azure.com/role=agent,agentpool=nodepool1,storageprofile=managed,storagetier=Premium_LRS,kubernetes.azure.com/cluster=MC_k8s_kubenet_westeurope,kubernetes.azure.com/mode=system,kubernetes.azure.com/node-image-version=AKSUbuntu-1804containerd-2020.12.15 | |
{ | |
"cniVersion": "0.3.1", | |
"name": "kubenet", | |
"plugins": [{ | |
"type": "bridge", | |
"bridge": "cbr0", | |
"mtu": 1500, | |
"addIf": "eth0", | |
"isGateway": true, | |
"ipMasq": true, | |
"promisMode": true, | |
"hairpinMode": false, | |
"ipam": { | |
"type": "host-local", | |
"subnet": "10.244.0.0/24", | |
"routes": [{ "dst": "0.0.0.0/0" }] | |
} | |
}] | |
} | |
# ls /opt/cni/bin/ | |
bridge dhcp flannel host-device host-local ipvlan loopback macvlan portmap ptp sample tuning vlan | |
DigitalOcean (w/ Cilium) | |
/# cat /etc/systemd/system/kubelet.service | |
[Unit] | |
Description=Kubernetes Kubelet Server | |
Documentation=https://kubernetes.io/docs/concepts/overview/components/#kubelet | |
[Service] | |
OOMScoreAdjust=-999 | |
ExecStart=/usr/bin/kubelet \ | |
--config=/etc/kubernetes/kubelet.conf \ | |
--feature-gates="RuntimeClass=false" \ | |
--logtostderr=true \ | |
--image-pull-progress-deadline=5m \ | |
--kubeconfig=/etc/kubernetes/kubelet.kubeconfig \ | |
--bootstrap-kubeconfig=/etc/kubernetes/bootstrap.kubeconfig \ | |
--rotate-certificates \ | |
--register-node=true \ | |
--node-labels="doks.digitalocean.com/node-id=bb7e6bf3-faba-4b3d-a3bc-b9b55e961be8,doks.digitalocean.com/node-pool-id=505dab09-d820-4161-8298-29c53ec23580,doks.digitalocean.com/node-pool=pool-4gbvqa3av,doks.digitalocean.com/version=1.19.3-do.2" \ | |
--root-dir=/var/lib/kubelet \ | |
--v=2 \ | |
--cloud-provider=external \ | |
--network-plugin=cni \ | |
--provider-id="digitalocean://223671363" \ | |
--node-ip="10.110.0.3" | |
Restart=on-failure | |
RestartSec=5 | |
[Install] | |
WantedBy=multi-user.target | |
# cat /etc/cni/net.d/05-cilium.conflist | |
{ | |
"cniVersion": "0.3.1", | |
"name": "portmap", | |
"plugins": [ | |
{ | |
"name": "cilium", | |
"type": "cilium-cni", | |
"enable-debug": false | |
}, | |
{ | |
"type": "portmap", | |
"capabilities": {"portMappings": true} | |
} | |
] | |
} | |
ls /opt/cni/bin/ | |
bandwidth bridge cilium-cni dhcp firewall flannel host-device host-local ipvlan loopback macvlan portmap ptp sbr static tuning vlan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment