Istio 1.1.4 helm setup --set global.defaultNodeSelector sample

5/6/2019

Regarding the current installation options for Istio 1.1.4 it should be possible to define a default node selector which gets added to all Istio deployments

The documentation does not show a dedicated sample how the selector has to be defined, only {} as value.

Currently I was not able to find a working format to pass the values to the helm charts by using --set, e.g:

 --set global.defaultNodeSelector="{cloud.google.com/gke-nodepool:istio-pool}"

I tried several variations, with and without escapes, JSON map, ... But currently everything results into the same Helm error message:

2019/05/06 15:58:10 Warning: Merging destination map for chart 'istio'. Cannot overwrite table item 'defaultNodeSelector', with non table value: map[]

Istio version 1.1.4

Helm 2.13.1

The expectation would be to have a more detailed documentation, giving some samples on Istio side.

-- Peter
istio
kubernetes
kubernetes-helm

2 Answers

5/7/2019

When specifying overrides with --set, multiple key/value pairs are deeply merged based on keys.
It means in your case, that only last item will be present in the generated template.
The same will happen even if you override with -f (YAML file) option.

Here is an example of -f option usage with custom_values.yaml, with distinguished keys:

#custom_values.yaml

global:
  defaultNodeSelector:
    cloud.google.com/bird: stork
    cloud.google.com/bee: wallace

helm template . -x charts/pilot/templates/deployment.yaml -f custom_values.yaml

Snippet of rendered Istio`s Pilot deployment.yaml manifest file:

 volumes:
      - name: config-volume
        configMap:
          name: istio
      - name: istio-certs
        secret:
          secretName: istio.istio-pilot-service-account
          optional: true
      affinity:      
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: beta.kubernetes.io/arch
                operator: In
                values:
                - amd64
                - ppc64le
                - s390x
              - key: cloud.google.com/bee
                operator: In
                values:
                - wallace
              - key: cloud.google.com/bird
                operator: In
                values:
                - stork
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 2
            preference:
              matchExpressions:
              - key: beta.kubernetes.io/arch
                operator: In
                values:
                - amd64

The same can be achieved with --set:

--set global.defaultNodeSelector."cloud\.google\.com/bird"=stork,global.defaultNodeSelector."cloud\.google\.com/bee"=wallace
-- Nepomucen
Source: StackOverflow

5/6/2019

After searching for some hours I found a solution right after posting the question by digging in the Istio commits.

I'll leave my findings as a reference, maybe someone can safe some time that way.

Setting a default node selector works, at least for me, by separating the key by dots and escaping additional ones with \ (if there are dots in the label of interest)

--set global.defaultNodeSelector.cloud\\.google\\.com/gke-nodepool=istio-pool

To create a defaultNodeSelector for a node pool labeled with

cloud.google.com/gke-nodepool: istio-pool

I was not able to add multiple values that way the {} notation for adding lists in Helm doesn't seem to get respected.

-- Peter
Source: StackOverflow