expose pod in Kubernetes engine as service. | Nutanix Community
Skip to main content

Hi

I have a pod with cluster IP already. I want to expose this as load balacner or nodeport service and take one of the private IP from the subnet. However none seem to be working. I just want to know if there is some annotations or additional settings that we need to do to achieve this or exposing pods as service via standard yaml or kubectl commands should work?

for example this - kubectl expose deployment sandbox-airflow-web --type=LoadBalancer --name=sandbox-airflow-web-service --namespace=sandbox-airflow

didnt generate any external IP or errors. was stuck in pending. I later patched it to get an IP but there IP didnt return the website.

Kubectl patch svc sandbox-airflow-web-service -n sandbox-airflow -p'{"spec": {"type": "LoadBalancer", "externalIPs"::"172.20.8.50"]}}'

thanks.

NKE does not include a load balancer out-of-the-box. You can install MetalLB using their official documentation, or change your service type to NodePort and use the IP address of one of your workers along the dynamically asigned port.


I have a pod
sandbox-airflow-web-7b56d96b-jrmk8               1/1     Running   0          4d22h

exposed by service
sandbox-airflow-web                   ClusterIP   10.96.127.207   <none>        8080/TCP         4d22h

I then created a nodeport yaml
apiVersion: v1
kind: Service
metadata:
  name: sandbox-airflow-web-service-v4
spec:
  selector:
    app: sandbox-airflow-web-7b56d96b-jrmk8
  type: NodePort
  ports:
  - name: http
    port: 8080
    targetPort: 8080
    nodePort: 31226

and got a nodeport
sandbox-airflow-web-service-v4        NodePort    10.96.160.52    <none>        8080:31226/TCP   39h

I then have 2 workers
dev-scl-itinfra-k8-02-14bcf3-worker-0
172.20.8.16
dev-scl-itinfra-k8-02-14bcf3-worker-1
172.20.8.111

I am trying to acces http://172.20.8.16:31226 but no access.
Do you see anything wrong? I am also rechecking firewalls and yamls. But want to make sure above is ok. If you can help??

Thanks for your help.