From b306c11df7bf42ce3b5ad01908a5640fe0c587ca Mon Sep 17 00:00:00 2001 From: wangchenyu07 Date: Thu, 14 Oct 2021 14:33:25 +0800 Subject: [PATCH] change global-sidecar and global-sidecar-pilot template file --- doc/en/lazy_load.md | 10 ++++-- doc/en/slime-boot.md | 11 ++++--- doc/zh/lazy_load.md | 12 +++++-- doc/zh/slime-boot.md | 7 ++-- .../samples/lazyload/slimeboot_lazyload.yaml | 3 ++ ...eboot_lazyload_cluster_global_sidecar.yaml | 3 ++ .../templates/cluster-globalsidecar.yaml | 10 +++++- .../templates/namespaced-globalsidecar.yaml | 10 +++++- .../slimeboot/templates/pilot.yaml | 4 +++ .../lazyload/test/e2e/lazyload_test.go | 33 ++++++++++++++----- .../install/init/deployment_slime-boot.yaml | 2 +- .../samples/lazyload/slimeboot_lazyload.yaml | 13 +++++--- 12 files changed, 90 insertions(+), 28 deletions(-) diff --git a/doc/en/lazy_load.md b/doc/en/lazy_load.md index 91d92a90..13001519 100644 --- a/doc/en/lazy_load.md +++ b/doc/en/lazy_load.md @@ -65,6 +65,9 @@ spec: limits: cpu: 200m memory: 200Mi + image: + repository: {{your_sidecar_repo}} + tag: {{your_sidecar_tag}} pilot: enable: true resources: @@ -75,7 +78,7 @@ spec: cpu: 200m memory: 200Mi image: - repository: docker.io/slimeio/pilot + repository: {{your_pilot_repo}} tag: {{your_pilot_tag}} ``` @@ -228,10 +231,13 @@ spec: globalSidecar: enable: true type: cluster + image: + repository: {{your_sidecar_repo}} + tag: {{your_sidecar_tag}} pilot: enable: true image: - repository: docker.io/slimeio/pilot + repository: {{your_pilot_repo}} tag: {{your_pilot_tag}} ``` diff --git a/doc/en/slime-boot.md b/doc/en/slime-boot.md index 729c34df..c8e2b6f2 100644 --- a/doc/en/slime-boot.md +++ b/doc/en/slime-boot.md @@ -127,10 +127,10 @@ apiVersion: config.netease.com/v1alpha1 kind: SlimeBoot metadata: name: lazyload - namespace: slime #customize the namespace deployed slime + namespace: slime #customize the namespace deployed slime spec: namespace: slime #customize the namespace deployed slime, same with config.global.slimeNamespace - istioNamespace: istio-operator #customize the namespace deployed istio, same with config.global.istioNamespace + istioNamespace: istio-system #customize the namespace deployed istio, same with config.global.istioNamespace healthProbePort: 9091 #same with the port contained by config.global.misc["aux-addr"] image: pullPolicy: Always @@ -143,8 +143,8 @@ spec: wormholePort: - "9080" global: - slimeNamespace: slime #customize the slime deployed namespace filled in sidecar, same with spec.namespace - istioNamespace: istio-operator #customize the istio deployed namespace filled in sidecar, same with spec.istioNamespace + slimeNamespace: slime #customize the slime deployed namespace filled in sidecar, same with spec.namespace + istioNamespace: istio-system #customize the istio deployed namespace filled in sidecar, same with spec.istioNamespace log: #customize log level logLevel: debug klogLevel: 10 @@ -172,6 +172,9 @@ spec: limits: cpu: 200m memory: 200Mi + image: + repository: istio/proxyv2 + tag: 1.7.0 pilot: enable: true resources: #customize resources diff --git a/doc/zh/lazy_load.md b/doc/zh/lazy_load.md index ddcefc61..0000fd87 100644 --- a/doc/zh/lazy_load.md +++ b/doc/zh/lazy_load.md @@ -66,6 +66,9 @@ spec: limits: cpu: 200m memory: 200Mi + image: + repository: {{your_sidecar_repo}} + tag: {{your_sidecar_tag}} pilot: enable: true resources: @@ -76,7 +79,7 @@ spec: cpu: 200m memory: 200Mi image: - repository: docker.io/slimeio/pilot + repository: {{your_pilot_repo}} tag: {{your_pilot_tag}} ``` @@ -231,10 +234,13 @@ spec: globalSidecar: enable: true type: cluster + image: + repository: {{your_sidecar_repo}} + tag: {{your_sidecar_tag}} pilot: enable: true image: - repository: docker.io/slimeio/pilot + repository: {{your_pilot_repo}} tag: {{your_pilot_tag}} ``` @@ -319,7 +325,7 @@ metadata: lazyload/fence默认会将envoy无法匹配路由(缺省)的流量兜底发送到global sidecar,应对短暂服务数据缺失的问题,这是“懒加载”所必然面对的。 该方案因为技术细节上的局限性,对于目标(如域名)是集群外的流量,无法正常处理,详见 [[Configuration Lazy Loading]: Failed to access external service #3](https://github.com/slime-io/slime/issues/3)。 -基于这个背景,设计了本特性,同时也能用于更灵活的业务场景。 大致思路是通过域名匹配的方式讲不同的缺省流量分派到不同的目标做正确处理。 +基于这个背景,设计了本特性,同时也能用于更灵活的业务场景。 大致思路是通过域名匹配的方式将不同的缺省流量分派到不同的目标做正确处理。 diff --git a/doc/zh/slime-boot.md b/doc/zh/slime-boot.md index 9fcae260..bf3c74f4 100644 --- a/doc/zh/slime-boot.md +++ b/doc/zh/slime-boot.md @@ -129,7 +129,7 @@ metadata: namespace: slime spec: namespace: slime #自定义slime部署的namespace,和config.global.slimeNamespace一致 - istioNamespace: istio-operator #自定义istio部署的namespace,和config.global.istioNamespace一致 + istioNamespace: istio-system #自定义istio部署的namespace,和config.global.istioNamespace一致 healthProbePort: 9091 #和config.global.misc["aux-addr"]包含的端口值一致 image: pullPolicy: Always @@ -143,7 +143,7 @@ spec: - "9080" global: slimeNamespace: slime #自定义sidecar默认配置中部署slime的namespace,与spec.namespace保持一致 - istioNamespace: istio-operator #自定义sidecar默认配置中部署istio的namespace,与spec.istioNamespace保持一致 + istioNamespace: istio-system #自定义sidecar默认配置中部署istio的namespace,与spec.istioNamespace保持一致 log: #自定义log级别 logLevel: debug klogLevel: 10 @@ -171,6 +171,9 @@ spec: limits: cpu: 200m memory: 200Mi + image: + repository: istio/proxyv2 + tag: 1.7.0 pilot: enable: true resources: #自定义resources diff --git a/install/samples/lazyload/slimeboot_lazyload.yaml b/install/samples/lazyload/slimeboot_lazyload.yaml index 4c1dea8a..1d40b993 100644 --- a/install/samples/lazyload/slimeboot_lazyload.yaml +++ b/install/samples/lazyload/slimeboot_lazyload.yaml @@ -36,6 +36,9 @@ spec: limits: cpu: 200m memory: 200Mi + image: + repository: istio/proxyv2 + tag: 1.7.0 pilot: enable: true resources: diff --git a/install/samples/lazyload/slimeboot_lazyload_cluster_global_sidecar.yaml b/install/samples/lazyload/slimeboot_lazyload_cluster_global_sidecar.yaml index 7873e641..56f1f174 100644 --- a/install/samples/lazyload/slimeboot_lazyload_cluster_global_sidecar.yaml +++ b/install/samples/lazyload/slimeboot_lazyload_cluster_global_sidecar.yaml @@ -29,6 +29,9 @@ spec: globalSidecar: enable: true type: cluster + image: + repository: istio/proxyv2 + tag: 1.7.0 pilot: enable: true image: diff --git a/slime-boot/helm-charts/slimeboot/templates/cluster-globalsidecar.yaml b/slime-boot/helm-charts/slimeboot/templates/cluster-globalsidecar.yaml index 9bcde705..aac1141e 100644 --- a/slime-boot/helm-charts/slimeboot/templates/cluster-globalsidecar.yaml +++ b/slime-boot/helm-charts/slimeboot/templates/cluster-globalsidecar.yaml @@ -29,6 +29,10 @@ spec: nsf.skiff.netease.com/app: qz-ingress nsf.skiff.netease.com/isIngress: "true" spec: + {{- with $.Values.component.globalSidecar.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} affinity: nodeAffinity: preferredDuringSchedulingIgnoredDuringExecution: @@ -126,7 +130,11 @@ spec: value: NONE - name: ISTIO_METAJSON_ANNOTATIONS value: '{"sidecar.istio.io/statsInclusionPrefixes": "listener,cluster.outbound,cluster_manager,listener_manager,http_mixer_filter,tcp_mixer_filter,server,cluster.xds-grpc"}' - image: istio/proxyv2:1.7.0 + {{- if $.Values.component.globalSidecar.image.tag }} + image: "{{ $.Values.component.globalSidecar.image.repository }}:{{ $.Values.component.globalSidecar.image.tag}}" + {{- else }} + image: "{{ $.Values.component.globalSidecar.image.repository }}" + {{- end }} imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 3 diff --git a/slime-boot/helm-charts/slimeboot/templates/namespaced-globalsidecar.yaml b/slime-boot/helm-charts/slimeboot/templates/namespaced-globalsidecar.yaml index 090ce320..10d76e30 100644 --- a/slime-boot/helm-charts/slimeboot/templates/namespaced-globalsidecar.yaml +++ b/slime-boot/helm-charts/slimeboot/templates/namespaced-globalsidecar.yaml @@ -30,6 +30,10 @@ spec: nsf.skiff.netease.com/app: qz-ingress nsf.skiff.netease.com/isIngress: "true" spec: + {{- with $.Values.component.globalSidecar.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} affinity: nodeAffinity: preferredDuringSchedulingIgnoredDuringExecution: @@ -127,7 +131,11 @@ spec: value: NONE - name: ISTIO_METAJSON_ANNOTATIONS value: '{"sidecar.istio.io/statsInclusionPrefixes": "listener,cluster.outbound,cluster_manager,listener_manager,http_mixer_filter,tcp_mixer_filter,server,cluster.xds-grpc"}' - image: istio/proxyv2:1.7.0 + {{- if $.Values.component.globalSidecar.image.tag }} + image: "{{ $.Values.component.globalSidecar.image.repository }}:{{ $.Values.component.globalSidecar.image.tag}}" + {{- else }} + image: "{{ $.Values.component.globalSidecar.image.repository }}" + {{- end }} imagePullPolicy: IfNotPresent livenessProbe: failureThreshold: 3 diff --git a/slime-boot/helm-charts/slimeboot/templates/pilot.yaml b/slime-boot/helm-charts/slimeboot/templates/pilot.yaml index 7b829b06..cb1fc799 100644 --- a/slime-boot/helm-charts/slimeboot/templates/pilot.yaml +++ b/slime-boot/helm-charts/slimeboot/templates/pilot.yaml @@ -185,6 +185,10 @@ spec: app: pilot istio: pilot spec: + {{- with $.Values.component.pilot.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} affinity: nodeAffinity: preferredDuringSchedulingIgnoredDuringExecution: diff --git a/slime-modules/lazyload/test/e2e/lazyload_test.go b/slime-modules/lazyload/test/e2e/lazyload_test.go index 365c42ae..5506a220 100644 --- a/slime-modules/lazyload/test/e2e/lazyload_test.go +++ b/slime-modules/lazyload/test/e2e/lazyload_test.go @@ -5,8 +5,8 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" + "os" "path/filepath" - commonutils "slime.io/slime/slime-framework/test/e2e/common" "slime.io/slime/slime-framework/test/e2e/framework" e2epod "slime.io/slime/slime-framework/test/e2e/framework/pod" "slime.io/slime/slime-framework/test/e2e/framework/testfiles" @@ -15,13 +15,17 @@ import ( ) var ( - testResourceToDelete []*TestResource - nsSlime = "mesh-operator" - nsApps = "example-apps" - test = "test/e2e/testdata/install" - slimebootName = "slime-boot" - istiodLabelKey = "istio.io/rev" - istiodLabelV = "1-10-2" + testResourceToDelete []*TestResource + nsSlime = "mesh-operator" + nsApps = "example-apps" + test = "test/e2e/testdata/install" + slimebootName = "slime-boot" + istiodLabelKey = "istio.io/rev" + istiodLabelV = "1-10-2" + slimebootTag = "v0.2.3-a3f72fe" + lazyloadTag = "v0.2.6-d808438" + globalSidecarTag = "1.7.0" + globalSidecarPilotTag = "globalPilot-7.0-v0.0.3-833f1bd5c1" ) type TestResource struct { @@ -65,6 +69,7 @@ func createSlimeBoot(f *framework.Framework) { testResourceToDelete = append(testResourceToDelete, &TestResource{Namespace: "", Contents: crdYaml}) }() deploySlimeBootYaml := readFile(test, "init/deployment_slime-boot.yaml") + deploySlimeBootYaml = strings.ReplaceAll(deploySlimeBootYaml, "{{slimebootTag}}", substituteValue("slimeBootTag", slimebootTag)) framework.RunKubectlOrDieInput(nsSlime, deploySlimeBootYaml, "create", "-f", "-") defer func() { testResourceToDelete = append(testResourceToDelete, &TestResource{Namespace: nsSlime, Contents: deploySlimeBootYaml}) @@ -99,6 +104,9 @@ func createSlimeModuleLazyload(f *framework.Framework) { // create slimeboot/lazyload slimebootLazyloadYaml := readFile(test, "samples/lazyload/slimeboot_lazyload.yaml") + slimebootLazyloadYaml = strings.ReplaceAll(slimebootLazyloadYaml, "{{lazyloadTag}}", substituteValue("lazyloadTag", lazyloadTag)) + slimebootLazyloadYaml = strings.ReplaceAll(slimebootLazyloadYaml, "{{globalSidecarTag}}", substituteValue("globalSidecarTag", globalSidecarTag)) + slimebootLazyloadYaml = strings.ReplaceAll(slimebootLazyloadYaml, "{{globalSidecarPilotTag}}", substituteValue("globalSidecarPilotTag", globalSidecarPilotTag)) framework.RunKubectlOrDieInput(nsSlime, slimebootLazyloadYaml, "create", "-f", "-") defer func() { testResourceToDelete = append(testResourceToDelete, &TestResource{Namespace: nsSlime, Contents: slimebootLazyloadYaml}) @@ -332,13 +340,20 @@ func verifyAccessLogs(f *framework.Framework) { ginkgo.By("access log verified successfully") } +func substituteValue(value, defaultValue string) string { + if os.Getenv(value) != "" { + return os.Getenv(value) + } + return defaultValue +} + func readFile(test, file string) string { from := filepath.Join(test, file) data, err := testfiles.Read(from) if err != nil { framework.ExpectNoError(err, "failed to read file %s/%s", test, file) } - return commonutils.SubstituteImageName(string(data)) + return string(data) } func deleteTestResource() { diff --git a/slime-modules/lazyload/test/e2e/testdata/install/init/deployment_slime-boot.yaml b/slime-modules/lazyload/test/e2e/testdata/install/init/deployment_slime-boot.yaml index d177e5fa..989d33c9 100644 --- a/slime-modules/lazyload/test/e2e/testdata/install/init/deployment_slime-boot.yaml +++ b/slime-modules/lazyload/test/e2e/testdata/install/init/deployment_slime-boot.yaml @@ -17,7 +17,7 @@ spec: containers: - name: slime-boot # Replace this with the built image name - image: docker.io/slimeio/slime-boot:v0.2.2 + image: docker.io/slimeio/slime-boot:{{slimebootTag}} imagePullPolicy: Always env: - name: WATCH_NAMESPACE diff --git a/slime-modules/lazyload/test/e2e/testdata/install/samples/lazyload/slimeboot_lazyload.yaml b/slime-modules/lazyload/test/e2e/testdata/install/samples/lazyload/slimeboot_lazyload.yaml index 3e81250c..0584ad0f 100644 --- a/slime-modules/lazyload/test/e2e/testdata/install/samples/lazyload/slimeboot_lazyload.yaml +++ b/slime-modules/lazyload/test/e2e/testdata/install/samples/lazyload/slimeboot_lazyload.yaml @@ -8,7 +8,7 @@ spec: image: pullPolicy: Always repository: docker.io/slimeio/slime-lazyload - tag: v0.2.2 + tag: {{lazyloadTag}} module: - name: lazyload enable: true @@ -34,8 +34,11 @@ spec: cpu: 200m memory: 200Mi limits: - cpu: 200m + cpu: 400m memory: 200Mi + image: + repository: istio/proxyv2 + tag: {{globalSidecarTag}} pilot: enable: true resources: @@ -43,8 +46,8 @@ spec: cpu: 200m memory: 200Mi limits: - cpu: 200m - memory: 200Mi + cpu: 400m + memory: 800Mi image: repository: docker.io/slimeio/pilot - tag: globalPilot-7.0-v0.0.3-833f1bd5c1 \ No newline at end of file + tag: {{globalSidecarPilotTag}} \ No newline at end of file