I'm using Docker For Desktop with the built-in Kubernetes cluster. I have installed a Pod
that serves resources over HTTP, but I'm not sure how to access it using my browser. I have the following ServiceSpec
that correctly routes traffic to the Pod
:
spec:
clusterIP: 10.99.132.220
externalTrafficPolicy: Cluster
ports:
- name: myport
nodePort: 31534
port: 8037
protocol: TCP
targetPort: 80
type: LoadBalancer
And I can see it set up when I query it with kubectl
:
$ kubectl get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
myservice LoadBalancer 10.99.132.220 localhost 8037:31534/TCP 1h
How do I reach this service using my browser?
How To run Local Kubernetes Cluster in Docker Containers Step 1: Install Docker Step 2: Install Go Step 3: Install kind Tool Step 4: Run local Kubernetes clusters using Docker container “nodes”. Step 5: Install Kubectl command-line tool Step 6: Configure kubectl
The Kubernetes server runs locally within your Docker instance, is not configurable, and is a single-node cluster. The Kubernetes server runs within a Docker container on your local system, and is only for local testing.
Kubernetes uses a different tool called kubectl to manage apps - Docker Desktop installs kubectl for you too. You should see a single node in the output called docker-desktop. That’s a full Kubernetes cluster, with a single node that runs the Kubernetes API and your own applications.
Now, to access service inside Kubernetes cluster, you need to use the IP address of one of your Nodes and the port from the field nodePort For example, 12.34.56.78:30001 For more information, look through the official documentation.
That service will be available in your browser at http://localhost:8037
Note that the port 8037
corresponds to the port
property on the ServiceSpec
object.
If you are unable to reach the service at that URL, then it could be one of several things, including but not limited to:
Service
in your cluster that has claimed that port. Either delete the other Service
, or change the port
property to an unclaimed port.Pod
is not running and ready. Check kubectl get pods
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With