- 1 year ago
Microk8s Access nginx pod to other Host Machines
To access a pod running in MicroK8s from other host machines, you can use the Kubernetes port forwarding feature.
Here's how you can do it:
Get the pod name: First, get the name of the Nginx pod that you want to access by running the following command in your MicroK8s cluster:
arduinomicrok8s kubectl get pods
This will list all the pods running in your MicroK8s cluster.
Forward the pod port: Once you have the name of the pod, you can forward its port to your local machine using the following command:
rubymicrok8s kubectl port-forward <pod-name> <local-port>:<pod-port>
Replace
<pod-name>
with the name of your Nginx pod,<local-port>
with the local port on your machine that you want to use to access the pod, and<pod-port>
with the port that Nginx is listening on inside the pod.For example, if your Nginx pod is named
nginx-pod
and is listening on port80
, and you want to access it on port8080
on your local machine, you would run the following command:yamlmicrok8s kubectl port-forward nginx-pod 8080:80
Access Nginx from your local machine: Once the port forwarding is set up, you can access Nginx by opening a web browser and navigating to
http://localhost:<local-port>
(where<local-port>
is the port you specified in step 2).
That's it! You should now be able to access the Nginx pod running in MicroK8s from your local machine.