<p>I created one node and I'm running microk8s. I created one Pod and 3 replicasets. I can access trought Cluster IP. But I don't know how to access through the name... Please help me. I'm new in Kubenetes.</p>
<ol>
<li>I create</li>
</ol>
<pre class="lang-text prettyprint-override"><code>microk8s kubectl create deployment httpenv --image bretfisher/httpenv
</code></pre>
<ol start="2">
<li>Scale</li>
</ol>
<pre class="lang-text prettyprint-override"><code>microk8s kubectl scale deployment/httpenv --replicas=3
</code></pre>
<ol start="3">
<li>Expose</li>
</ol>
<pre class="lang-text prettyprint-override"><code>microk8s kubectl expose deployment/httpenv --port 8888
</code></pre>
<ol start="4">
<li>Show Info</li>
</ol>
<pre class="lang-text prettyprint-override"><code>microk8s kubectl get all
</code></pre>
<pre class="lang-text prettyprint-override"><code>NAME                          READY   STATUS    RESTARTS   AGE
pod/httpenv-bd844d85f-9xk9l   1/1     Running   0          18m
pod/httpenv-bd844d85f-jf85j   1/1     Running   0          18m
pod/httpenv-bd844d85f-p5kzg   1/1     Running   0          18m

NAME                 TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
service/httpenv      ClusterIP   10.152.183.91   &lt;none&gt;        8888/TCP   13m
service/kubernetes   ClusterIP   10.152.183.1    &lt;none&gt;        443/TCP    24h

NAME                      READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/httpenv   3/3     3            3           18m

NAME                                DESIRED   CURRENT   READY   AGE
replicaset.apps/httpenv-bd844d85f   3         3         3       18m
</code></pre>
<ol start="5">
<li>Try to access</li>
</ol>
<p>From node :</p>
<pre class="lang-text prettyprint-override"><code>curl -i 10.152.183.91:8888

   HTTP/1.1 200 OK
</code></pre>
<pre class="lang-text prettyprint-override"><code>curl -i httpenv:8888

   curl: (6) Could not resolve host: httpenv
</code></pre>

pomer
<p>You can access the service in 3 ways, i just ran your example in my own microk8s cluster.</p>
<ul>
<li>Port forward traffic from 8888 to you localhost on any port(ex: i have forwarded to 8888).</li>
<li>If you want to access the service from within the cluster, you can access the service from any pod running in your cluster(security issue though, can be handled using policies etc).</li>
<li>You can conver the service from type: ClusterIP to NodePort</li>
</ul>
<p>According to the deployment you have given above, which i ran on my local,  below are the pods running. In the port-forward command below, we are routing all the traffic from microk8s cluster on port 8888 to your localhost 8888. You can then use your browser and navigate to http://localhost:8888, you will see the output there.</p>
<pre><code>k get po 
httpenv-6fdc8554fb-j9q65   1/1     Running   0          14m
httpenv-6fdc8554fb-4fzr8   1/1     Running   0          14m
httpenv-6fdc8554fb-bsxgw   1/1     Running   0          14m

k port-forward httpenv-6fdc8554fb-j9q65 8888:8888 &amp;

curl localhost:8888
Handling connection for 8888
{&quot;HOME&quot;:&quot;/root&quot;,&quot;HOSTNAME&quot;:&quot;httpenv-6fdc8554fb-j9q65&quot;,&quot;KUBERNETES_PORT&quot;:&quot;tcp://10.152.183.1:443&quot;,&quot;KUBERNETES_PORT_443_TCP&quot;:&quot;tcp://10.152.183.1:443&quot;,&quot;KUBERNETES_PORT_443_TCP_ADDR&quot;:&quot;10.152.183.1&quot;,&quot;KUBERNETES_PORT_443_TCP_PORT&quot;:&quot;443&quot;,&quot;KUBERNETES_PORT_443_TCP_PROTO&quot;:&quot;tcp&quot;,&quot;KUBERNETES_SERVICE_HOST&quot;:&quot;10.152.183.1&quot;,&quot;KUBERNETES_SERVICE_PORT&quot;:&quot;443&quot;,&quot;KUBERNETES_SERVICE_PORT_HTTPS&quot;:&quot;443&quot;,&quot;PATH&quot;:&quot;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;}%  
</code></pre>
<ul>
<li>To access the service within your microk8s cluster, we will run a simple busybox container.</li>
</ul>
<pre><code>k run -i --tty bb7 --image=busybox -- sh 
# curl  http://httpenv:8888
{&quot;HOME&quot;:&quot;/root&quot;,&quot;HOSTNAME&quot;:&quot;httpenv-6fdc8554fb-bsxgw&quot;,&quot;KUBERNETES_PORT&quot;:&quot;tcp://10.152.183.1:443&quot;,&quot;KUBERNETES_PORT_443_TCP&quot;:&quot;tcp://10.152.183.1:443&quot;,&quot;KUBERNETES_PORT_443_TCP_ADDR&quot;:&quot;10.152.183.1&quot;,&quot;KUBERNETES_PORT_443_TCP_PORT&quot;:&quot;443&quot;,&quot;KUBERNETES_PORT_443_TCP_PROTO&quot;:&quot;tcp&quot;,&quot;KUBERNETES_SERVICE_HOST&quot;:&quot;10.152.183.1&quot;,&quot;KUBERNETES_SERVICE_PORT&quot;:&quot;443&quot;,&quot;KUBERNETES_SERVICE_PORT_HTTPS&quot;:&quot;443&quot;,&quot;PATH&quot;:&quot;/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;}# 
</code></pre>
<ul>
<li>option 3 is to change the service type from &quot;ClusterIP&quot; to &quot;NodePort&quot; and you can access the service outside of the microk8s cluster. Get your local-ip using ifconfig command and curl the node port.</li>
</ul>
<p>forex: curl http://local-ip:31223</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  creationTimestamp: &quot;2021-11-03T09:55:20Z&quot;
  labels:
    app: httpenv
  name: httpenv
  namespace: default
  resourceVersion: &quot;2013136&quot;
  selfLink: /api/v1/namespaces/default/services/httpenv
  uid: 908f4bbd-fef2-4435-b8c4-a80796e03b13
spec:
  clusterIP: 10.152.183.170
  clusterIPs:
  - 10.152.183.170
  externalTrafficPolicy: Cluster
  ipFamilies:
  - IPv4
  ipFamilyPolicy: SingleStack
  ports:
  - nodePort: 31223
    port: 8888
    protocol: TCP
    targetPort: 8888
  selector:
    app: httpenv
  sessionAffinity: None
  type: NodePort

 k get svc
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
httpenv      NodePort    10.152.183.170   &lt;none&gt;        8888:31223/TCP   22m


</code></pre>
