How to get annotation from namespace in side car injector

1/30/2019

I am working with Istio. There are certain annotations that we add to our kubernetes namespace. One out of these namespace annotations also needs to be applied to the pods that are created with sidecar-enabled=true label. For this purpose, I looked at using the Istio sidecar injector webhook, but I am not able to find the reference to namespace's annotations.

Is there a way to do this?

-- trailblazer
istio
kubernetes

1 Answer

1/30/2019

You can find all need namespaces annotations using below command in Annotations: section.

kubectl describe namespaces

EDIT:

Your initial question is not clear. As far as I understand your question and additional clarification - you want to get annotations that are applied to a namespace from a configMap.

Official Istio Sidecar Injection Documentation says that

Manual and automatic injection both use the configuration from the istio-sidecar-injector and istio ConfigMaps in the istio-system namespace.

Based on this fact you can dump the configMap in the Istio cluster you are interested in by next command:

$ kubectl describe configmap --namespace=istio-system istio-sidecar-injector 

This will show you references for pod annotations, global values, etc.

Example:

[[ annotation .ObjectMeta `traffic.sidecar.istio.io/includeOutboundIPRanges` "*" ]] 

The above queries traffic.sidecar.istio.io/includeOutboundIPRanges annotation on the pod, and defaults to "*" if it's not present.

-- VKR
Source: StackOverflow