<p>I am trying to access Kubernetes cluster deployed Spring Boot microservices and trying to test the REST API. I configured the node port method in my deployment scripts. But when I am trying to access using Postman tool, I am only getting the response that "Could not get any response".</p>

<p>I configured the <strong>service.yaml</strong> script like the following structure,</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: my-service
spec:
  type: NodePort
  ports:
    - port: 7100
      targetPort: 7100
      protocol: TCP
      name: http
      nodePort: 31007
 selector:
      app: my-deployment
</code></pre>

<p>My <strong>deployment.yaml</strong> like the following ,</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-deployment
  labels:
    app: my-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: my-deployment
  template:
    metadata:
      labels:
        app: my-deployment
      annotations: 
        date: "+%H:%M:%S %d/%m/%y"
    spec:
      imagePullSecrets:
        - name: "regcred"
      containers:
       - name: my-deployment-container
         image: spacestudymilletech010/spacestudysecurityauthcontrol:latest
         imagePullPolicy: Always
         ports:
            - name: http
              containerPort: 8065
              protocol: TCP
      tolerations:
      - key: "dedicated-app"
        operator: "Equal"
        value: "my-dedi-app-a"
        effect: "NoSchedule"
</code></pre>

<p>When I am taking <code>kubectl describe service</code>, output is like the following,</p>

<p><a href="https://i.stack.imgur.com/Zwa9A.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Zwa9A.png" alt="enter image description here"></a></p>

<p>And I am trying to access my deployed api Like the following way,</p>

<pre><code>  http://&lt;my-cluster-Worker-NodeIP-Address:31007/&lt;my-deployed-ReST-API-end-point&gt;
</code></pre>

<p><strong>Updates</strong></p>

<p>When I am running the <code>kubectl describe pod</code> command for my deployment I am getting the response like the following,</p>

<pre><code>docker@MILDEVKUB010:~$ kubectl describe pod spacestudycontrolalerts- 
deployment-8644449c58-x4zd6
Name:           spacestudycontrolalerts-deployment-8644449c58-x4zd6
Namespace:      default
Priority:       0
Node:           &lt;none&gt;
Labels:         app=spacestudycontrolalerts-deployment
            pod-template-hash=8644449c58
Annotations:    date: +%H:%M:%S %d/%m/%y
Status:         Pending
IP:
IPs:            &lt;none&gt;
Controlled By:  ReplicaSet/spacestudycontrolalerts-deployment-8644449c58
Containers:
  spacestudycontrolalerts-deployment-container:
    Image:        spacestudymilletech010/spacestudycontrolalerts:latest
    Port:         7102/TCP
    Host Port:    0/TCP
    Environment:  &lt;none&gt;
    Mounts:
  /var/run/secrets/kubernetes.io/serviceaccount from default-token-6s55b (ro)
Conditions:
  Type           Status
  PodScheduled   False
Volumes:
  default-token-6s55b:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-6s55b
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  &lt;none&gt;
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
             node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason            Age        From               Message
  ----     ------            ----       ----               -------
  Warning  FailedScheduling  &lt;unknown&gt;  default-scheduler  0/2 nodes are available: 2 node(s) had taints that the pod didn't tolerate.
</code></pre>

<p>I am getting the event message from describe pod command like <code>0/2 nodes are available: 2 node(s) had taints that the pod didn't tolerate.</code> as shown above.</p>

<p>When I am running <code>kubectl get nodes</code> command , I am getting like the following,</p>

<pre><code>NAME           STATUS   ROLES    AGE   VERSION
mildevkub020   Ready    master   5d    v1.17.0
mildevkub040   Ready    master   5d    v1.17.0
</code></pre>

<p>Where have I gone wrong for service access?</p>

<p>If there is an event message i.e <code>0/2 nodes are available: 2 node(s) had taints that the pod didn't tolerate</code>. This means there is a <strong>Taint</strong> to your nodes.</p>

<p>Step 1:- To verify there is a Taint
<code>kubectl describe node | grep -i taint</code></p>

<p>Step 2:- Remove the Taint, verify it has been removed. </p>

<blockquote>
  <p>Note that the key is used with a minus sign appended to the end.</p>
</blockquote>

<p><code>kubectl taint nodes --all node-role.kubernetes.io/master-</code></p>

<p><code>kubectl taint nodes --all node-role.kubernetes.io/not-ready-</code></p>

<p><code>kubectl taint nodes --all node-role.kubernetes.io/unreachable-</code></p>

<p>Step 3:- Then as per your <strong>deployment.yaml</strong> file, we need to create the Taint.</p>

<p><code>kubectl taint nodes node1 dedicated-app:my-dedi-app-a:NoSchedule</code></p>

<p>Step 4:- To verify there is a Taint
<code>kubectl describe node | grep -i taint</code></p>

<p>Step 5:- Deploy your .yaml file
<code>kubectl apply -f deployment.yaml</code></p>

<p>You specify toleration for a pod in the PodSpec. Both of the following tolerations “match” the taint created by the kubectl taint line above, and thus a pod with either toleration would be able to schedule onto <strong>node1</strong></p>

<blockquote>
  <p><a href="https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/" rel="noreferrer">https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/</a></p>
</blockquote>

<p>Also, your <code>describe pod</code> shows that your deployment name is <code>spacestudycontrolalerts-deployment</code>. which is making us a confusion with your <strong>deployment.yaml file</strong> i.e <strong>metadata.Name:</strong> my-deployment. <code>Make sure you describe pod with respective deployment name</code>.</p>

<p>I hope this will help everyone for future reference on Taints and Tolerations.</p>
