Home

networking

Network Namespace

//ip netns add red //ip netns add blue // list network namespace //ip netns

//Execute a network command //ip netns exec red ip link //ip -n red link

//arp //ip netns exec red arp

//adding connectivity between two namespaces //ip link add veth-red type veth peer name veth-blue //ip link set veth-red netns red //ip link set veth-blue netns blue //assigning ip //ip -n red addr add 192.168.15.1 dev veth-red //ip -n blue addr add 192.168.15.2 dev veth-blue

//ip in red link ser veth-red up //ip in blue link ser veth-blue up

//ip netns exec red ping 192.168.15.2 //ip netns exec red arp

//creating a bridge inside a container //Linux Bridge

//ip link add v-net-0 type bridge //ip link set dev v-net-0 up // removing the old connection between two pods //ip -n red link del veth-red

//creating new connections //ip link add veth-red type veth peer name veth-red-br //ip link add veth-blue type veth peer name veth-blue-br

//connecting one end of the connection top the pod //ip link set veth-red netns red //ip link set veth-blue netns blue

//connecting the other ends with the bridge connection //ip link set veth-red-br master v-net-0 //ip link set veth-blue-br master v-net-0

//assigning ip addresses to the pods //ip -n red addr add 192.168.15.1 dev veth-red //ip -n blue addr add 192.168.15.2 dev veth-blue

//up network //ip -n red link set veth-red up //ip -n blue link set veth-blue up

//connection between host and bridge network //ip addr add 192.168.15.5/24 dev v-net-0 //ping to container from local host now

//connecting two hosts //Add rout to the first host //ip netns exec blue ip route add 192.168.1.0/24 via 192.168.15.5

//In order to communicate with the second host, NAT connection needs to be added //iptables -t nat -A POSTROUTING -s 192.168.15.0/24 -j MASQUERADE

//connecting to the internet //checking routing tables //ip netns exec blue route

//ip netns exec blue ip route add default via 192.168.15.5

//ip netns exec blue ping 8.8.8.8

//adding ip table to allow second host to communicate with the first host //iptables -t nat -A PREROUTING –dport 80 –to-destination 192.168.15.2:80 -j DNAT

Docker Networking //None network: the container cannot communicated and neither it can be communicated from aoutside //docker run –network none nginx

//Host-network: There is no isolation between the network oh host and the conatiner //docker run –network host nginx

//Bridge: Internal private network is created to which the docker container and host is attached to. //docker run nginx

//see docker network //docker network ls

//view the network namespace created by the docker //ip netns

//Important commands //ip link //ip addr //ip addr add 192.168.1.10/24 dev eth0 //ip route //ip route add 192.168.1.0/24 via 192.168.2.1 //cat /proc/sys/net/ipv4/ip_forward //arp //netstat -plnt

https://kubernetes.io/docs/concepts/cluster-administration/addons/

https://kubernetes.io/docs/concepts/cluster-administration/networking/#how-to-implement-the-kubernetes-networking-model

In the CKA exam, for a question that requires you to deploy a network addon, unless specifically directed, you may use any of the solutions described in the link above.

However, the documentation currently does not contain a direct reference to the exact command to be used to deploy a third party network addon.

The links above redirect to third party/ vendor sites or GitHub repositories which cannot be used in the exam. This has been intentionally done to keep the content in the Kubernetes documentation vendor-neutral.

//to check the interface of a cluster //ip d | grep -B2 ipaddress-of-the-cluster

//check ip and mac address //ip link show eth0

//check interface/bridge created //ip link //look for the default gateway //ip route show default //check port which is listening to a node //netstat -nplt // number of client listening to etcd //netstat -anp | grep etcd | grep 2380 | wc -l

CNI plugin //ps -aux | grep kubelet //ps -aux | grep kubelet | grep –color container-runtime-endpoint //check if –network plugin=cni

The CNI binaries are located under /opt/cni/bin by default.

//Run ls /etc/cni/net.d/ and identify the name of the plugin.

//Type of binary executable file created after conatiner and namespace are created: type in /etc/cni/net.d/10-flannel.conflist.

//networking solution : config file located at /etc/cni/net.d/

Before going to the CNI weave lecture, we have an update for the Weave Net installation link. They have announced the end of service for Weave Cloud.

To know more about this, read the blog from the link below: –

https://www.weave.works/blog/weave-cloud-end-of-service

As an impact, the old weave net installation link won’t work anymore: –

kubectl apply -f “https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d ‘\n’)”

Instead of that, use the below latest link to install the weave net: –

kubectl apply -f https://github.com/weaveworks/weave/releases/download/v2.8.1/weave-daemonset-k8s.yaml

Reference links: –

https://www.weave.works/docs/net/latest/kubernetes/kube-addon/#-installation
https://github.com/weaveworks/weave/releases

//Deploy Weave //Deploy as pod

Ingress

  • deploy Ingress controller
    • GCE(GCP load balancer)
    • nginx
    • istio
    • trafik
// deployment, service, configmap, service account are required
  • configure ingress resources

//set of rules

//ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
    name:ingress-wear
spec:
    backend:
        serviceName: wear-service
        SericePort: 80
//k get ingress

https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-ingress-em-

References:-

https://kubernetes.io/docs/concepts/services-networking/ingress

https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types