Why are my Kubernetes services running on different subnets?
Asked Answered
E

1

6

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
Eight answered 22/2, 2019 at 13:17 Comment(5)
having the same issue..Homespun
What do you mean by "different subnet"? Different as in not a 192.168 address, or the 10.* addresses are not on the same subnet? If the latter, how do you know, given the usual subnet mask for a 10.* address is /8?Jerricajerrie
@Jerricajerrie 10.* is on different subnetEight
@c4f4t0r any idea ?Eight
are your worker nodes spread out in different subnets? if so, this is expectedSeasickness
T
1

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

Tenne answered 22/2, 2019 at 14:11 Comment(5)
annotations: "cni.projectcalico.org/ipv4pools": "[\"192.168.0.0/16\"]"Eight
check my response aboveTenne
Servcie Endpoint not getting generated.. is it cause the issue ? because my spring boot application not able to communicate with postgres. its say unknown host.. please check my update questionEight
i believe, the pod might not be running and hence you dont see the endpoints. one important point to be noted is that the pod-network-cidr range and service-cluster-ip-range should be unique across the cluster. same holds true for node ip. there shouldnt be overlap of ip addressesTenne
postgres pods running properly but its endpoint remain <none>. see update output in questionEight

© 2022 - 2024 — McMap. All rights reserved.