Network Troubleshooting
Network Troubleshooting
——————–
Kubernetes uses CNI plugins to setup network. The kubelet is responsible for executing
plugins as we mention the following parameters in kubelet configuration.
– network-plugin: The network plugin to use from cni-bin-dir. It must match the name
reported by a plugin probed from the plugin directory.
1. Weave Net:
To install,
kubectl apply -f
https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-
daemonset-k8s.yaml
You can find details about the network plugins in the following documentation :
https://kubernetes.io/docs/concepts/cluster-administration/addons/#networking-and-
network-policy
2. Flannel :
To install,
kubectl apply -f
https://raw.githubusercontent.com/coreos/flannel/2140ac876ef134e0ed5af
15c65e414cf26827915/Documentation/kube-flannel.yml
3. Calico :
To install,
curl https://docs.projectcalico.org/manifests/calico.yaml -O
In CKA and CKAD exam, you won’t be asked to install the cni plugin. But if asked you
will be provided with the exact url to install it.
Note: If there are multiple CNI configuration files in the directory, the kubelet uses the
configuration file that comes first by name in lexicographic order.
DNS in Kubernetes
—————–
Kubernetes uses CoreDNS. CoreDNS is a flexible, extensible DNS server that can
serve as the Kubernetes cluster DNS.
While analyzing the coreDNS deployment you can see that the the Corefile plugin
consists of important configuration which is defined as a configmap.
proxy . /etc/resolv.conf
If you have nodes that are running SELinux with an older version of Docker you might
experience a scenario where the coredns pods are not starting. To solve that you can try
one of the following options:
b)Disable SELinux.
There are many ways to work around this issue, some are listed here:
3. If CoreDNS pods and the kube-dns service is working fine, check the kube-dns
service has valid endpoints.
If there are no endpoints for the service, inspect the service and make sure it uses the
correct selectors and ports.
Kube-Proxy
———
kube-proxy is a network proxy that runs on each node in the cluster. kube-proxy
maintains network rules on nodes. These network rules allow network communication
to the Pods from network sessions inside or outside of the cluster.
kubeproxy is responsible for watching services and endpoint associated with each
service. When the client is going to connect to the service using the virtual IP the
kubeproxy is responsible for sending traffic to actual pods.
If you run a kubectl describe ds kube-proxy -n kube-system you can see that
the kube-proxy binary runs with following command inside the kube-proxy container.
Command:
/usr/local/bin/kube-proxy
--config=/var/lib/kube-proxy/config.conf
--hostname-override=$(NODE_NAME)
In the config file we define the clusterCIDR, kubeproxy mode, ipvs, iptables,
bindaddress, kube-config etc.
3. Check configmap is correctly defined and the config file for running kube-proxy
binary is correct.
References:
https://kubernetes.io/docs/tasks/debug-application-cluster/debug-service/
DNS Troubleshooting:
https://kubernetes.io/docs/tasks/administer-cluster/dns-debugging-resolution/