Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my Kubernetes services running on different subnets?

I have a Spring Boot and PostgreSQL communication issue using service name.

I have created a cluster using Calico for networking, as follows:

sudo kubeadm init --pod-network-cidr=192.168.0.0/16  --apiserver-advertise-address=178.12.1.10

and joined to the worker node using the output produced from the above command.

When I am deploying the pod and service both are running on different subnets. Am I missing something?

kubectl get svc
NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
backend-service     ClusterIP      10.110.149.43   <none>        8091/TCP      12s
postgres            ClusterIP      10.108.1.52     <none>        5432/TCP      14m

The service endpoint is not getting generated.

kubectl get endpoints
NAME                   ENDPOINTS             AGE

backend-service                              20m
postgres               <none>                21m
kubectl get pods --all-namespaces
default       backend-service-6dbd64ff4d-gqkq8           0/1     CrashLoopBackOff   12         57m
default       postgres-7564bcc778-578fx                  1/1     Running            0          57m
kube-system   calico-etcd-b7wqf                          1/1     Running            1          2d3h
kube-system   calico-kube-controllers-74887d7bdf-wxhkd   1/1     Running            1          2d3h
kube-system   calico-node-689b5                          0/1     Running            0          47h
kube-system   calico-node-smkq5                          0/1     Running            1          47h
kube-system   coredns-86c58d9df4-7ncdk                   1/1     Running            1          2d3h
kube-system   coredns-86c58d9df4-g4jcp                   1/1     Running            1          2d3h
kube-system   etcd-kmaster                               1/1     Running            1          2d3h
kube-system   kube-apiserver-kmaster                     1/1     Running            1          2d3h
kube-system   kube-controller-manager-kmaster            1/1     Running            3          2d3h
kube-system   kube-proxy-njx5c                           1/1     Running            1          2d3h
kube-system   kube-proxy-pkxx5                           1/1     Running            1          2d3h
kube-system   kube-scheduler-kmaster                     1/1     Running            3          2d3h
kube-system   kubernetes-dashboard-57df4db6b-zcvcc       1/1     Running            1          2d3h
like image 258
Bhargav Patel Avatar asked Feb 22 '19 13:02

Bhargav Patel


1 Answers

You need to check service-cluster-ip-range CIDR that is specified by flag to the API server. service clusterIP is assigned from service-cluster-ip-range.

you have initialized the cluster with --pod-network-cidr=192.168.0.0/16

note that pod-network-cidr range is used for assigning the ip address to pods. it is different from service clusterIP

you should be checking service-cluster-ip-range that is defined in api server startup parameters

like image 169
P Ekambaram Avatar answered Nov 15 '22 06:11

P Ekambaram