Tuesday, October 09, 2018

How To Change Kubernetes POD CIDR

Requirement:

  Sometimes default K8S Pod CIDR overlap hosts CIDR in the intranet. So there would be problems when pod to communicate to pod. So we need to update Pod CIDR not to overlap any  CIDR in the host network.

Solution:

   It is based on Oracle K8S v1.10.5+2.0.2.el7 ( from yum.oracle.com). In this case we would like to change Pod CIDR to 192.168.0.0/16 (It is advised to use /16 CIDR )
On the master node:

  • ATTEN: The command below will stop/erase existing K8S cluster and recreate a new one. Thus all configurations of K8S will be lost, Please take a backup. However it won't touch  our own docker images. 
  • as root 
  • # export KUBE_REPO_PREFIX=container-registry.oracle.com/kubernetes_developer
  • # kubeadm-setup.sh up --pod-network-cidr  192.168.0.0/16
  • Follow the instructions to get all other worker node to join the new cluster

[===> PLEASE DO THE FOLLOWING STEPS BELOW: <===]
Your Kubernetes master has initialized successfully!
To start using your cluster, you need to run the following as a regular user:
  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

You can now join any number of machines by running the following on each node
as root:
  export KUBE_REPO_PREFIX=container-registry.oracle.com/kubernetes_developer && kubeadm-setup.sh join 100.106.146.3:6443 --token xxiaxy.132mis6d38xg6y3b --discovery-token-ca-cert-hash sha256:dc958ac229e213ca5f04fd609a44aa09606a459da06800224b01fa

No comments: