Why helm ignoring node port section?

7/29/2019

I'm tring install helm chart with nodeport on specific port. For example: 30005, but helm ignoring nodeport section.

==> v1/Service
NAME       TYPE      CLUSTER-IP     EXTERNAL-IP  PORT(S)         AGE
hello-app  NodePort  10.109.69.245  <none>       8080:32146/TCP  0s

I tried set specific port:

helm install --set service.type=NodePort,service.nodePort=30005 --name hello-app /home/ubuntu/hello-app

My values.yaml "service" section.

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

service:
  type: NodePort
  port: 8080
  nodePort: 30005

My expected result:

==> v1/Service
NAME       TYPE      CLUSTER-IP     EXTERNAL-IP  PORT(S)         AGE
hello-app  NodePort  10.109.69.245  <none>       8080:30005/TCP  0s
-- user_1771
kubernetes
kubernetes-helm

1 Answer

7/29/2019

Apparently you have somewhere in your service's helm template a typo, or skipped the fact, that variable names are case sensitive. Please double check it.

Take a look also at the official reference nginx chart example, where service helm template lets type and nodePort be configurable by the end user too, which works perfectly with helm overridden parameters (--set).

You can verify the manifest files rendered by helm before release installation with following command:

helm template --set service.type=NodePort --set service.nodePort=31000 --debug docs/examples/nginx/

Last thing:

Be sure, that specified by you nodePort is not in use already.
You can do it using --server-dry-run option with kubectl, e.g.

kubectl apply -f service-31000-nodeport-conflict.yaml --server-dry-run

In case it's already occupied you would see similar error to this one, returned from API server:

The Service "release-name-nginx-conflict" is invalid: spec.ports[0].nodePort: Invalid value: 31000: provided port is already allocated
-- Nepomucen
Source: StackOverflow