<p>I have a Spring Boot and PostgreSQL communication issue using service name.</p>

<p>I have created a cluster using Calico for networking, as follows:</p>

<pre><code>sudo kubeadm init --pod-network-cidr=192.168.0.0/16  --apiserver-advertise-address=178.12.1.10
</code></pre>

<p>and joined to the worker node using the output produced from the above command.</p>

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

<pre><code>kubectl get svc
</code></pre>

<pre><code>NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
backend-service     ClusterIP      10.110.149.43   &lt;none&gt;        8091/TCP      12s
postgres            ClusterIP      10.108.1.52     &lt;none&gt;        5432/TCP      14m
</code></pre>

<p>The service endpoint is not getting generated.</p>

<pre><code>kubectl get endpoints
</code></pre>

<pre><code>NAME                   ENDPOINTS             AGE

backend-service                              20m
postgres               &lt;none&gt;                21m
</code></pre>

<pre><code>kubectl get pods --all-namespaces
</code></pre>

<pre><code>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
</code></pre>

<p>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.</p>

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

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

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