Answer a question

I have a local kubernetes cluster on my local docker desktop.

This is how my kubernetes service looks like when I do a kubectl describe service

Name:              helloworldsvc
Namespace:         test
Labels:            app=helloworldsvc
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                     {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"helloworldsvc"},"name":"helloworldsvc","namespace":"test...
Selector:          app=helloworldapp
Type:              ClusterIP
IP:                10.108.182.240
Port:              http  9111/TCP
TargetPort:        80/TCP
Endpoints:         10.1.0.28:80
Session Affinity:  None
Events:            <none>

This service is pointing to a deployment with a web app.

My question how to I find the url for this service? I already tried http://localhost:9111/ and that did not work.

I verified that the pod that this service points to is up and running.

Answers

The service you have created is of type ClusterIP which is only accessible from inside the cluster. You have two ways to access it from your desktop:

  1. Create a nodeport type service and then access it via nodeip:nodeport

  2. Use Kubectl port forward and then access it via localhost:forwardedport

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐