ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Istio Helm Chart 详解 - 全局变量

2021-05-28 09:55:07  阅读:238  来源: 互联网

标签:templates istio Istio 缺省值 yamlDeployment deployment Helm Chart sidecar


前言

我们在使用现有 Chart 的时候,通常都不会修改 Chart 的本体,仅通过对变量的控制来实现对部署过程的定制。Istio Helm Chart 提供了大量的变量来帮助用户进行定制。

第一篇中我们提到过,Istio Chart 分为父子两层,因此变量也具有全局和本地两级,全局变量使用保留字 global 来进行定义,子 Chart 可以通过 .Values.global 的方式引用全局变量,而主 Chart 中也可以用 chart.var 的方式为子 Chart 指定变量值,本篇会首先讲解一下 values.yaml 中涉及到的全局变量,也就是 global 一节;各个 Chart 涉及到的专属变量会留在各个 Chart 的章节中。

hub 和 tag

缺省值分别为 docker.io/istio 和 1.0.2

这里看到版本的控制主要是在镜像层面的,Chart 自身的版本控制并不是很规矩,差评。

多数情况下,这一配置代表所有镜像的地址,具体名称一般由 {{ .Values.global.hub }}/[component]/:{{ .Values.global.tag }} 的形式拼接而成。proxy_init、Mixer、Grafana 和 Pilot 中,一旦其 image 变量中包含了路径符 /,则会弃用 global.hub,直接采用 image的定义。

影响范围

文件对象备注
charts/certmanager/templates/deployment.yamlDeployment:certmanager
charts/galley/templates/deployment.yamlDeployment:istio-galley
charts/gateways/templates/deployment.yaml所有 Gateway 的 DeploymentContainer:istio-proxy
charts/grafana/templates/create-custom-resources-job.yamlJob:istio-grafana-post-install
charts/grafana/templates/deployment.yamlDeployment:grafana
charts/ingress/templates/deployment.yamlDeployment:istio-ingress
charts/kiali/templates/deployment.yamlDeployment:kiali
charts/mixer/templates/deployment.yamlDeployment:istio-policy/istio-telemetryContainer:istio-proxy/mixer
charts/mixer/templates/statsdtoprom.yamlDeployment:istio-statsd-prom-bridge
charts/pilot/templates/deployment.yamlDeployment:istio-pilot
charts/prometheus/templates/deployment.yamlDeployment:prometheus
charts/security/templates/cleanup-secrets.yamlJob:istio-cleanup-secrets
charts/security/templates/create-custom-resources-job.yamlJob:istio-security-post-install
charts/security/templates/deployment.yamlDeployment:istio-citadel
charts/servicegraph/templates/deployment.yamlDeployment:servicegraph
charts/sidecarInjectorWebhook/templates/deployment.yamlDeployment:istio-sidecar-injector
charts/tracing/templates/deployment.yamlDeployment:istio-tracing
templates/sidecar-injector-configmap.yamlConfigMap:istio-sidecar-injectoristio-initenable-core-dumpistio-proxy

k8sIngressSelector

缺省值为 ingress

这一变量比较 Buggy。原则上讲,他仅在 ingress.enabled 为 true 的时候生效。

影响范围

charts/pilot/templates/gateway.yaml

这个文件中定义了一个 Gateway - istio-autogenerated-k8s-ingress,其中的 spec.selector 是这样设计的:istio: {{ .Values.global.k8sIngressSelector }},实际上该文件中并没有针对 ingress.enabled 开关做出是否生成网关的判断,该网关一定会创建,但是只有在 Ingress Chart 中才会创建符合该条件的 Deployment,因此在 Ingress Chart 没有创建的情况下,该网关的 Selector 就无法匹配成功,也就无法生效了。

templates/configmap.yaml

这里会引用 ingress.enabled 进行判断,如果判断成功,则在 istio ConfigMap 对象中写入 ingressService: istio-{{ .Values.global.k8sIngressSelector }}

k8sIngressHttps

缺省值为 false

影响范围

charts/pilot/templates/gateway.yaml

如果启用该字段,会给 Gateway 定义中加入 443 端口及其 TLS 配置。

这段配置中对 /etc/istio/ingress/certs/ 下面的证书文件有依赖,因此需要启用这一选项,首先要启用 ingress.enabled,从而能够成功创建 ingress Chart 的 Deployment;另外还需要创建一个命名为 ingress-certs 的 tls secret,给 istio-ingress Deployment 进行加载。这些条件如果没有满足,LDS 会拒绝服务,从而无法提供 Ingress 功能。

proxy.image

缺省值为 proxyv2

影响范围

istio/templates/sidecar-injector-configmap.yaml

其中的 ConfigMap istio-sidecar-injector 中的注入部分会使用该值作为 istio-proxy 的镜像名。

image: {{ "[[ if (isset .ObjectMeta.Annotations \"sidecar.istio.io/proxyImage\") -]]" }}
{{ "\"[[ index .ObjectMeta.Annotations \"sidecar.istio.io/proxyImage\" ]]\"" }}
{{ "[[ else -]]" }}
{{ .Values.global.hub }}/{{ .Values.global.proxy.image }}:{{ .Values.global.tag }}
{{ "[[ end -]]" }}

这段代码表明,首先会判断 Pod 的 sidecar.istio.io/proxyImage 注解,如果注解不存在,才会使用这一变量,拼接方式为:{{ .Values.global.hub }}/{{ .Values.global.proxy.image }}:{{ .Values.global.tag }}

proxy.resources

这里为 Sidecar 定义了资源分配的方案。根据官方的伸缩性和规模调整指南:

开启访问日志(默认开启)时,为 Sidecar 每分配 1 个 vCPU 能够负担 1000 qps 的访问峰值,没有开启则 0.5 vCPU 即可负担同样峰值,节点上的 fluentd 由于需要捕获和上传日志,是主要的性能消耗者。

影响范围

文件对象备注
charts/mixer/templates/deployment.yamlDeployment:istio-policy/istio-telemetry Container:istio-proxy/mixer
charts/pilot/templates/deployment.yamlDeployment:istio-pilot
templates/sidecar-injector-configmap.yamlConfigMap:istio-sidecar-injector会注入到所有 Pod

proxy.concurrency

缺省值为 0

Proxy worker 线程数量,如果设置为 0,则根据 CPU 线程/核的数量进行分配。

影响范围

文件对象
istio/templates/configmap.yamlConfigMap:istio

proxy.accessLogFile

缺省值为 /dev/stdout

Sidecar 的访问日志位置,如果设置为空字符串,则关闭访问日志功能。

影响范围

文件对象
templates/configmap.yamlConfigMap:istio

proxy.privileged

缺省值为 false

istio-initistio-proxy 的特权模式开关。

影响范围

文件对象
templates/sidecar-injector-configmap.yamlConfigMap istio-sidecar-injector

proxy.enableCoreDump

缺省值为 false

如果打开,新注入的 Sidecar 会启动 CoreDump 功能,加入初始化容器 enable-core-dump

影响范围

文件对象
templates/sidecar-injector-configmap.yamlConfigMap istio-sidecar-injector

proxy.includeIPRanges

缺省值为 "*"

劫持白名单,仅劫持该 CIDR 范围内的 IP。

影响范围

文件对象
templates/sidecar-injector-configmap.yamlConfigMap istio-sidecar-injector

修改 istio-init 的 -i 参数,等价的 Pod Annotation 为 traffic.sidecar.istio.io/includeOutboundIPRanges

proxy.excludeIPRanges

缺省值为 ""

CIDR 范围之外的所有 IP 都会被劫持。

影响范围

文件对象
templates/sidecar-injector-configmap.yamlConfigMap istio-sidecar-injector

修改 istio-init 的 -x 参数,等价的 Pod Annotation 为 traffic.sidecar.istio.io/excludeOutboundIPRanges

proxy.includeInboundPorts

缺省值为 "*"

进入端口的劫持白名单,所有从范围内端口进入 Pod 的流量会被劫持。

影响范围

文件对象
templates/sidecar-injector-configmap.yamlConfigMap istio-sidecar-injector

修改 istio-init 的 -b 参数,等价的 Pod Annotation 为 traffic.sidecar.istio.io/includeInboundPorts

proxy.excludeInboundPorts

缺省值为 ""

进入端口的劫持黑名单,所有从范围外端口进入 Pod 的流量会被劫持。

影响范围

文件对象
templates/sidecar-injector-configmap.yamlConfigMap istio-sidecar-injector

修改 istio-init 的 -d 参数,等价的 Pod Annotation 为 traffic.sidecar.istio.io/excludeOutboundIPRanges

proxy.autoInject

缺省值为 enabled。用于指定 Sidecar 注入器的策略。

影响范围

文件对象
templates/sidecar-injector-configmap.yamlConfigMap istio-sidecar-injector

proxy.envoyStatsd

缺省值为:

enabled: true
host: istio-statsd-prom-bridge
port: 9125

设置 Envoy 的 statsd 目标,也就是 Envoy 的 "--statsdUdpAddress 参数。某些情况下(例如没有安装 Mixer)可以关闭。

影响范围

文件对象备注
charts/ingress/templates/deployment.yamlDeployment:istio-ingress
templates/configmap.yamlConfigMap:istio
templates/sidecar-injector-configmap.yamlConfigMap:istio-sidecar-injectoristio-initenable-core-dumpistio-proxy 三个容器的镜像

proxy_init.image

缺省值为 proxy_init,指定初始化镜像。

前面提到过,如果这里使用一个带有路径符号 / 的镜像名称,会忽略前面的 global.hub/tag 的设置。

影响范围

文件对象
templates/sidecar-injector-configmap.yamlConfigMap istio-sidecar-injector

imagePullPolicy

缺省值为 IfNotPresent。镜像的拉取策略。

影响范围

文件对象说明
charts/certmanager/templates/deployment.yamlDeployment:certmanager
charts/galley/templates/deployment.yamlDeployment:istio-galley
charts/gateways/templates/deployment.yaml所有 Gateway 的 DeploymentContainer:istio-proxy
charts/grafana/templates/deployment.yamlDeployment:grafana
charts/ingress/templates/deployment.yamlDeployment:istio-ingress
charts/mixer/templates/deployment.yamlDeployment:istio-policy/istio-telemetryContainer:istio-proxy/mixer
charts/mixer/templates/statsdtoprom.yamlDeployment:istio-statsd-prom-bridge
charts/pilot/templates/deployment.yamlDeployment:istio-pilot
charts/prometheus/templates/deployment.yamlDeployment:prometheus
charts/security/templates/deployment.yamlDeployment:istio-citadel
charts/servicegraph/templates/deployment.yamlDeployment:servicegraph
charts/sidecarInjectorWebhook/templates/deployment.yamlDeployment:istio-sidecar-injector
charts/tracing/templates/deployment.yamlDeployment:istio-tracing
templates/sidecar-injector-configmap.yamlConfigMap:istio-sidecar-injectorContainer:istio-initistio-proxyenable-core-dump 未受影响

controlPlaneSecurityEnabled

缺省值为 false。控制面是否启用 mTLS。

影响范围

文件对象说明
charts/ingress/templates/deployment.yamlDeployment:istio-ingress控制 Ingress 参数 --controlPlaneAuthPolicy 的取值,MUTUAL_TLS 或者 NONE
charts/mixer/templates/config.yamlDestinationRule: istio-policy和  DestinationRule: istio-telemetry为端口 15004启用 ISTIO_MUTUAL
charts/mixer/templates/deployment.yamlDeployment:istio-policy/istio-telemetry控制 Sidecar istio-proxy 参数 --controlPlaneAuthPolicy 的值,可选 MUTUAL_TLS 或者 NONE
charts/pilot/templates/deployment.yamlDeployment:istio-pilot控制 Sidecar istio-proxy 参数 --controlPlaneAuthPolicy 的值,可选 MUTUAL_TLS 或者 NONE
templates/configmap.yamlConfigMap:istio控制 Sidecar istio-proxy 参数 --controlPlaneAuthPolicy 的值,可选 MUTUAL_TLS 或者 NONE

disablePolicyChecks

缺省值 false

禁用 Mixer 策略检查。

影响范围

文件对象
templates/configmap.yamlConfigMap istio

enableTracing

缺省值 true

设置请求跟踪。

文件对象
templates/configmap.yamlConfigMap istio

影响范围

文件对象
templates/configmap.yamlConfigMap istio

mtls.enabled

缺省值 false。服务间 mTLS 的缺省设置,可以使用目标规则或者服务注解进行覆盖。这一开关会控制生成一系列的 Job、ConfigMap 以及 Kubernetes RBAC 的相关内容,详情将会在 Security Chart 中讲解。

影响范围

文件对象说明
charts/security/templates/configmap.yamlConfigMap:istio-security-custom-resources
charts/security/templates/create-custom-resources-job.yamlServiceAccount: istio-security-post-install-account ClusterRole: istio-security-post-install-istio-system ClusterRoleBinding: istio-security-post-install-role-binding-istio-system Job:istio-security-post-install这几个对象都需要启动这一开关才会创建

imagePullSecrets

缺省为空。

用于为 ServiceAccount 分配镜像拉取过程所需的凭证。

影响范围

文件对象
charts/certmanager/templates/serviceaccount.yamlServiceAccount: certmanager
charts/galley/templates/serviceaccount.yamlServiceAccount: istio-galley-service-account
charts/gateways/templates/serviceaccount.yaml所有 Gateways 自动生成的 ServiceAccount
charts/ingress/templates/serviceaccount.yamlServiceAccount: istio-ingress-service-account
charts/kiali/templates/serviceaccount.yamlServiceAccount: kiali-service-account
charts/mixer/templates/serviceaccount.yamlServiceAccount: istio-mixer-service-account
charts/pilot/templates/serviceaccount.yamlServiceAccount: istio-pilot-service-account
charts/prometheus/templates/serviceaccount.yamlServiceAccount: prometheus
charts/security/templates/serviceaccount.yamlServiceAccount: istio-citadel-service-account
charts/sidecarInjectorWebhook/templates/serviceaccount.yamlServiceAccount: istio-sidecar-injector-service-account

arch

缺省值:

amd64: 2
s390x: 2
ppc64le: 2

用于 Kubernetes 的节点亲和性调度过程。

这里列出了几种支持的服务器架构,并给出了优先级。详情请参看本文系列第一篇。

oneNamespace

缺省值 false

如果设置为 true,会对控制面管理的应用命名空间进行限制。如果没有设置,则监控所有命名空间。

影响范围

文件对象
charts/pilot/templates/deployment.yamlDeployment:istio-pilot

设置 Pilot discovery 的 -a 参数。这一参数取值为监控的命名空间名称,目前会选用 Istio 所在的命名空间。

configValidation

缺省值 ture。用于配置是否开启服务端的配置验证。该选项开启之后,会生成一个 ValidatingWebhookConfiguration 对象,并被包含到 Galley 的配置之中,从而启用校验功能。

影响范围

文件说明
charts/galley/templates/validatingwehookconfiguration.yaml.tplValidatingWebhookConfiguration: istio-galley

meshExpansion

缺省值为 false。如果启用,Pilot 和 Citadel 会在 Ingress Gateway 上公开服务。

影响范围

文件对象说明
charts/pilot/templates/gateway.yamlGateway:meshexpansion-gateway用于公开服务的 Gateway
charts/pilot/templates/meshexpansion.yamlVirtualService:meshexpansion-pilotPilot 的 VirtualService
charts/security/templates/meshexpansion.yamlVirtualService:meshexpansion-citadelCitadel 的  的 VirtualService

meshExpansionILB

缺省值为 false。Pilot 和 Citadel 的 mTLS 和明文端口会在内部网关进行公开。

影响范围

文件对象说明
charts/pilot/templates/gateway.yamlGateway:meshexpansion-ilb-gateway用于公开服务的 Gateway
charts/pilot/templates/meshexpansion.yamlVirtualService:ilb-meshexpansion-pilotPilot 的 VirtualService
charts/security/templates/meshexpansion.yamlVirtualService:meshexpansion-ilb-citadelCitadel 的  的 VirtualService

defaultResources

缺省值:

requests:
  cpu: 10m

为 Istio 组件提供一个最小的资源定义,以便 HPA 工作方便,每个组件可以定义自己的资源定义进行覆盖。

影响范围

文件对象说明
charts/galley/templates/deployment.yamlDeployment:istio-galley
charts/gateways/templates/deployment.yaml所有网关创建的 Deployment
charts/grafana/templates/deployment.yamlDeployment:grafana
charts/ingress/templates/deployment.yamlDeployment:istio-ingress
charts/kiali/templates/deployment.yamlDeployment:kiali
charts/mixer/templates/deployment.yamlDeployment:istio-policy/istio-telemetryContainer:istio-proxy/mixer
charts/mixer/templates/statsdtoprom.yamlDeployment:istio-statsd-prom-bridge
charts/pilot/templates/deployment.yamlDeployment:istio-pilotContainer:istio-proxy/discovery
charts/prometheus/templates/deployment.yamlDeployment:prometheus
charts/security/templates/deployment.yamlDeployment:istio-citadel
charts/servicegraph/templates/deployment.yamlDeployment:servicegraph
charts/sidecarInjectorWebhook/templates/deployment.yamlDeploymet: istio-sidecar-injector
charts/tracing/templates/deployment.yamlDeployment:istio-tracing

hyperkube

缺省值:

hub: quay.io/coreos
tag: v1.7.6_coreos.0

用于创建 CRD 的容器镜像。

影响范围

文件对象
charts/grafana/templates/create-custom-resources-job.yamlJob:istio-grafana-post-install
charts/security/templates/cleanup-secrets.yamlJob:istio-cleanup-secrets
charts/security/templates/create-custom-resources-job.yamlJob:istio-security-post-install

priorityClassName

Kubernetes 1.11.0 以上有两个 PriorityClass,用这种方式创建 Istio 组件 Pod,可以防止因较低的优先级被杀掉。

影响范围

文件对象
charts/certmanager/templates/deployment.yamlDeployment:certmanager
charts/galley/templates/deployment.yamlDeployment:istio-galley
charts/gateways/templates/deployment.yaml所有网管创建的 Deployment
charts/grafana/templates/deployment.yamlDeployment:grafana
charts/ingress/templates/deployment.yamlDeployment:istio-ingress
charts/kiali/templates/deployment.yamlDeployment:kiali
charts/mixer/templates/deployment.yamlDeployment:istio-policy/istio-telemetry
charts/pilot/templates/deployment.yamlDeployment:istio-pilot
charts/prometheus/templates/deployment.yamlDeployment:prometheus
charts/security/templates/deployment.yamlDeployment:istio-citadel
charts/servicegraph/templates/deployment.yamlDeployment:servicegraph
charts/sidecarInjectorWebhook/templates/deployment.yamlDeployment:istio-sidecar-injector
charts/tracing/templates/deployment.yamlDeployment:istio-tracing

crds

缺省值 true

如果使用的是 Helm 2.10 以上的 helm install,或者是 helm template 方式的安装,应该设置为 true;如果 Helm 版本小于 2.9,必须设置为 false,并手工执行 kubectl apply -f install/kubernetes/helm/istio/templates/crds.yaml来首先创建 CRD。

影响范围

文件说明
templates/crds.yaml随这一开关确定是否创建所有 CRD

小结

本节中很多涉及到下层 Chart 的内容并未深入,会在子 Chart 的相关章节中尝试进一步说明。


标签:templates,istio,Istio,缺省值,yamlDeployment,deployment,Helm,Chart,sidecar
来源: https://blog.51cto.com/u_15127693/2824780

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有