<p>I am in the phase of learning Kubernetes, trying to create a service and reach it via ping / curl.</p>
<p>Step1: Created a deployment <code>mytomcat</code> in default namespace</p>
<pre><code>alias k='kubectl'
k create deployment mytomcat --image=tomcat
</code></pre>
<p>Step2: Created a deployment busybox with curl in default namespace</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: mybusybox
  namespace: default
spec:
  containers:
  - image: yauritux/busybox-curl
    command:
      - sleep
      - &quot;3600&quot;
    imagePullPolicy: IfNotPresent
    name: busybox
  restartPolicy: Always

k apply -f busybox.yaml
k exec mybusybox -t -i -- sh
</code></pre>
<p>Step3: Ping the mytomcat pods and it works</p>
<pre><code>ping 10.1.1.11
PING 10.1.1.11 (10.1.1.11): 56 data bytes
64 bytes from 10.1.1.11: seq=0 ttl=64 time=0.207 ms
</code></pre>
<p>Step4: Create a service to expose port 8080 on tomcat</p>
<pre><code>k expose deployment mytomcat --port=8080 
</code></pre>
<p>Step5: Get stats of all resources</p>
<pre><code>k get all -o wide
NAME                            READY   STATUS    RESTARTS   AGE   IP          NODE             NOMINATED NODE   READINESS GATES
pod/mybusybox                   1/1     Running   0          10m   10.1.1.14   docker-desktop   &lt;none&gt;           &lt;none&gt;
pod/mytomcat-6bfbf4c889-xqkg9   1/1     Running   0          39m   10.1.1.11   docker-desktop   &lt;none&gt;           &lt;none&gt;

NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE     SELECTOR
service/kubernetes   ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP    42m     &lt;none&gt;
service/mytomcat     ClusterIP   10.102.120.90   &lt;none&gt;        8080/TCP   6m40s   app=mytomcat

NAME                       READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS   IMAGES   SELECTOR
deployment.apps/mytomcat   1/1     1            1           39m   tomcat       tomcat   app=mytomcat

NAME                                  DESIRED   CURRENT   READY   AGE   CONTAINERS   IMAGES   SELECTOR
replicaset.apps/mytomcat-6bfbf4c889   1         1         1       39m   tomcat       tomcat   app=mytomcat,pod-template-hash=6bfbf4c889
</code></pre>
<p>Step7: curl the service to reach tomcat pod failed.
Is this the expected output ? Cos it says Err code 404. I have no working idea of a tomcat server.</p>
<pre><code>    curl http://mytomcat:8080
&lt;!doctype html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;&lt;title&gt;HTTP Status 404 – Not Found&lt;/title&gt;&lt;style type=&quot;text/css&quot;&gt;body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 404 – Not Found&lt;/h1&gt;&lt;hr class=&quot;line&quot; /&gt;&lt;p&gt;&lt;b&gt;Type&lt;/b&gt; Status Report&lt;/p&gt;&lt;p&gt;&lt;b&gt;Description&lt;/b&gt; The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.&lt;/p&gt;&lt;hr class=&quot;line&quot; /&gt;&lt;h3&gt;Apache Tomcat/9.0.37&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;/home
</code></pre>
<p>Can anyone advise where am I doing it wrong or suggest good resources to learn in simple to begin with.</p>
<p>Thank you.</p>

Piyush
<p>This not a <code>DNS Unreachable</code> issue or DNS issue at all. This is expected since you have not deployed a war file on the tomcat hence <code>HTTP Status 404 – Not Found</code></p>
<p>Please refer to this question on how to deploy a war file on tomcat running in kubernetes. <a href="https://stackoverflow.com/questions/54341432/deploy-war-in-tomcat-on-kubernetes">Deploy WAR in Tomcat on Kubernetes</a></p>
