kubernetescolima

how to access pods from host?


I'm running colima with kubernetes like: colima start --kuberenetes

I created a few running pods, and I want to see access the through the browsers. But I don't know what is the colima IP (or kubernetes node IP).

help appreciated


Solution

  • You can get the nodeIp so:

    kubectl get node
    
    NAME       STATUS   ROLES    AGE   VERSION
    nodeName   Ready    <none>   15h   v1.26.0
    

    Then with the nodeName:

    kubectl describe node nodeName
    

    That gives you a descrition of the node and you should look for this section:

    Addresses:
      InternalIP:  10.165.39.165
      Hostname:    master
    

    Ping it to verify the network.

    Find your host file on Mac and make an entry like:

    10.165.39.165 test.local
    

    This let you access the cluster with a domain name.

    Ping it to verify.

    You can not access from outside the cluster a ClusterIp. To access your pod you have several possibilities.

    1. if your service is type ClusterIp, you can create a temporary connection from your host with a port forward.
    kubectl port-forward svc/yourservicename localport:podport
    
    1. (i would raccomend this) create a service type: NodePort

    Then

    kubectl get svc -o wide
    

    Shows you the NodePort: between(30000-32000).

    You can access now the Pod by: test.local:nodePort or Ipaddress:NodePort.

    Note: If you deployed in a namespace other than default, add -n yournamespace in the kubectl commands.

    Update:

    if you want to start colima with an ipAddress, first find one of your local network which is available.

    Your network setting you can get with:

    ifconfig
    

    find the network. Should be the same of that of your Internet router.

    Look for the subnet. Most likely 255.255.255.0.

    The value to pass then:

      --network-address xxx.xxx.xxx.xxx/24
    

    In case the subnet is 255.255.0.0 then /16. But i dont think, if you are connect from home. Inside a company however this is possible.

    Again check with ping and follow the steps from begining to verify the kubernetes node configuration.