Istio helm configuration - istio-ingressgateway port configuration doesn't work (or make sense)

10/22/2018

I am using the helm to create a YML with customized istio-ingressgateway configurations. See my script below:

#!/usr/bin/env bash

helm template $ISTIO_DIR/install/kubernetes/helm/istio \
    --name istio \
    --namespace istio-system \
    --set gateways.istio-ingressgateway.type=NodePort \
    --set gateways.istio-ingressgateway.enabled=true \
    --set gateways.istio-ingressgateway.replicaCount=1 \
    --set gateways.istio-ingressgateway.ports.targetPort=80 \
    --set gateways.istio-ingressgateway.ports.name=http2 \
    --set gateways.istio-ingressgateway.ports.nodePort=30000 \
    \
    --set gateways.istio-ingressgateway.ports.targetPort=443 \
    --set gateways.istio-ingressgateway.ports.name=https \
    --set gateways.istio-ingressgateway.ports.nodePort=30443 \
    \
    --set gateways.istio-ingressgateway.ports.targetPort=31400 \
    --set gateways.istio-ingressgateway.ports.name=tcp \
    --set gateways.istio-ingressgateway.ports.nodePort=31400 \
    \
    --set gateways.istio-ingressgateway.ports.targetPort=15011 \
    --set gateways.istio-ingressgateway.ports.name=tcp-pilot-grpc-tls \
    --set gateways.istio-ingressgateway.ports.nodePort=32460 \
    \
    --set gateways.istio-ingressgateway.ports.targetPort=8060 \
    --set gateways.istio-ingressgateway.ports.name=tcp-citadel-grpc-tls \
    --set gateways.istio-ingressgateway.ports.nodePort=32027 \
    \
    --set gateways.istio-ingressgateway.ports.targetPort=15030 \
    --set gateways.istio-ingressgateway.ports.name=http2-prometheus \
    --set gateways.istio-ingressgateway.ports.nodePort=31926 \
    \
    --set gateways.istio-ingressgateway.ports.targetPort=15031 \
    --set gateways.istio-ingressgateway.ports.name=http2-grafana \
    --set gateways.istio-ingressgateway.ports.nodePort=31336 \
    > eraseme.yaml

But I get this error:

2018/10/22 12:04:54 warning: destination for ports is a table. Ignoring non-table value [map[nodePort:31380 port:80 targetPort:80 name:http2] map[name:https nodePort:31390 port:443] map[name:tcp nodePort:31400 port:31400] map[port:15011 targetPort:15011 name:tcp-pilot-grpc-tls] map[name:tcp-citadel-grpc-tls port:8060 targetPort:8060] map[name:tcp-dns-tls port:853 targetPort:853] map[name:http2-prometheus port:15030 targetPort:15030] map[name:http2-grafana port:15031 targetPort:15031]] 2018/10/22 12:04:54 warning: destination for ports is a table. Ignoring non-table value [map[name:http2 nodePort:31380 port:80 targetPort:80] map[name:https nodePort:31390 port:443] map[name:tcp nodePort:31400 port:31400] map[name:tcp-pilot-grpc-tls port:15011 targetPort:15011] map[name:tcp-citadel-grpc-tls port:8060 targetPort:8060] map[targetPort:853 name:tcp-dns-tls port:853] map[name:http2-prometheus port:15030 targetPort:15030] map[name:http2-grafana port:15031 targetPort:15031]] Error: render error in "istio/charts/gateways/templates/service.yaml": template: istio/charts/gateways/templates/service.yaml:32:32: executing "istio/charts/gateways/templates/service.yaml" at : range can't iterate over http2-grafana

How am I supposed to do this correctly?

-- Ronnie Diaz
istio
kubernetes-helm

2 Answers

3/29/2019

I met similar issues, instead of adding long parameters in command line, it is better to add it in yaml files.

helm template $ISTIO_DIR/install/kubernetes/helm/istio \
    --name istio \
    --namespace istio-system > istio-default.yaml

Then u can edit the istio-default.yaml to add extra port you wanted like

# istio-default.yaml (tips: search 31380 to locate this segment)
    -
      name: http2
      nodePort: 31380
      port: 80
      targetPort: 80
# below is customized port for flask app for example
    -
      name: http-flask
      nodePort: 31500
      port: 5000
      targetPort: 5000

Now you can create/apply the configuration to the system

$ kubectl create -f istio-default.yaml
$ kubectl get svc istio-ingressgateway -n istio-system
NAME                   TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                                                                                                                                                     AGE
istio-ingressgateway   LoadBalancer   10.111.192.149   <pending>     80:31380/TCP,5000:31500/TCP,443:31390/TCP,31400:31400/TCP,15029:32630/TCP,15030:31878/TCP,15031:30152/TCP,15032:32060/TCP,15443:31852/TCP,15020:32235/TCP   8m26s

This is also the good way to add/delete the port after the istio installation

For more istio installation, see Option 1: Install with Helm via helm template

-- Larry Cai
Source: StackOverflow

10/23/2018

The question is about the Helm syntax for specifying array variables. You do it this way:

--set gateways.istio-ingressgateway.ports[0].targetPort=80 \
--set gateways.istio-ingressgateway.ports[0].name=http2 \
--set gateways.istio-ingressgateway.ports[0].nodePort=30000 \
\
--set gateways.istio-ingressgateway.ports[1].targetPort=443 \
--set gateways.istio-ingressgateway.ports[1].name=https \
--set gateways.istio-ingressgateway.ports[1].nodePort=30443 \

etc., specifying the indices of the array members.

-- Vadim Eisenberg
Source: StackOverflow