From 19e693bf52702c3f245f9546a142c16fe0867857 Mon Sep 17 00:00:00 2001 From: Ta-Ching Chen Date: Mon, 11 Nov 2019 22:41:40 +0800 Subject: [PATCH] Set jaeger collector endpoint as an environment variable (#1399) To follow 12-factor app rules, make jaeger collector endpoint as an environment variable instead of CLI args. It's easier to replace the value in different deployments. Also, we can utilize valueFrom to get value from the configmap. --- charts/fission-all/templates/deployment.yaml | 40 ++++++++++++------- charts/fission-all/templates/router.yaml | 4 +- charts/fission-core/templates/deployment.yaml | 24 +++++++---- charts/fission-core/templates/router.yaml | 4 +- cmd/fission-bundle/main.go | 21 +++++----- pkg/fetcher/config/config.go | 2 +- 6 files changed, 59 insertions(+), 36 deletions(-) diff --git a/charts/fission-all/templates/deployment.yaml b/charts/fission-all/templates/deployment.yaml index 94786018..394eb93b 100644 --- a/charts/fission-all/templates/deployment.yaml +++ b/charts/fission-all/templates/deployment.yaml @@ -137,10 +137,12 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--controllerPort", "8888", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--controllerPort", "8888"] env: - name: FISSION_FUNCTION_NAMESPACE value: "{{ .Values.functionNamespace }}" + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} - name: DEBUG_ENV @@ -205,7 +207,7 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--executorPort", "8888", "--namespace", "{{ .Values.functionNamespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--executorPort", "8888", "--namespace", "{{ .Values.functionNamespace }}"] env: - name: FETCHER_IMAGE value: "{{ .Values.fetcherImage }}:{{ .Values.fetcherImageTag }}" @@ -213,10 +215,12 @@ spec: value: "{{ .Values.pullPolicy }}" - name: RUNTIME_IMAGE_PULL_POLICY value: "{{ .Values.pullPolicy }}" - - name: TRACE_JAEGER_COLLECTOR_ENDPOINT - value: "{{ .Values.traceCollectorEndpoint }}" - name: ENABLE_ISTIO value: "{{ .Values.enableIstio }}" + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" + - name: TRACING_SAMPLING_RATE + value: {{ .Values.traceSamplingRate | default "0.5" | quote }} - name: FETCHER_MINCPU value: {{ .Values.fetcherMinCpu | default "10m" | quote }} - name: FETCHER_MINMEM @@ -225,8 +229,6 @@ spec: value: {{ .Values.fetcherMaxCpu | default "1000m" | quote }} - name: FETCHER_MAXMEM value: {{ .Values.fetcherMaxMem | default "128Mi" | quote }} - - name: TRACING_SAMPLING_RATE - value: {{ .Values.traceSamplingRate | default "0.5" | quote }} - name: DEBUG_ENV value: {{ .Values.debugEnv | quote }} readinessProbe: @@ -275,7 +277,7 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--builderMgr", "--storageSvcUrl", "http://storagesvc.{{ .Release.Namespace }}", "--envbuilder-namespace", "{{ .Values.builderNamespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--builderMgr", "--storageSvcUrl", "http://storagesvc.{{ .Release.Namespace }}", "--envbuilder-namespace", "{{ .Values.builderNamespace }}"] env: - name: FETCHER_IMAGE value: "{{ .Values.fetcherImage }}:{{ .Values.fetcherImageTag }}" @@ -283,10 +285,10 @@ spec: value: "{{ .Values.pullPolicy }}" - name: BUILDER_IMAGE_PULL_POLICY value: "{{ .Values.pullPolicy }}" - - name: TRACE_JAEGER_COLLECTOR_ENDPOINT - value: "{{ .Values.traceCollectorEndpoint }}" - name: ENABLE_ISTIO value: "{{ .Values.enableIstio }}" + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} - name: FETCHER_MINCPU @@ -327,8 +329,10 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--kubewatcher", "--routerUrl", "http://router.{{ .Release.Namespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--kubewatcher", "--routerUrl", "http://router.{{ .Release.Namespace }}"] env: + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} - name: DEBUG_ENV @@ -577,12 +581,14 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--mqt", "--routerUrl", "http://router.{{ .Release.Namespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--mqt", "--routerUrl", "http://router.{{ .Release.Namespace }}"] env: - name: MESSAGE_QUEUE_TYPE value: nats-streaming - name: MESSAGE_QUEUE_URL value: nats://{{ .Values.nats.authToken }}@nats-streaming:4222 + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} - name: DEBUG_ENV @@ -620,7 +626,7 @@ spec: image: "{{ .Values.image }}:{{ .Values.imageTag }}" imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--mqt", "--routerUrl", "http://router.{{ .Release.Namespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--mqt", "--routerUrl", "http://router.{{ .Release.Namespace }}"] env: - name: MESSAGE_QUEUE_TYPE value: kafka @@ -628,6 +634,8 @@ spec: value: "{{.Values.kafka.brokers}}" - name: MESSAGE_QUEUE_KAFKA_VERSION value: "{{.Values.kafka.version}}" + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} - name: DEBUG_ENV @@ -708,8 +716,10 @@ spec: image: "{{ .Values.image }}:{{ .Values.imageTag }}" imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--mqt", "--routerUrl", "http://router.{{ .Release.Namespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--mqt", "--routerUrl", "http://router.{{ .Release.Namespace }}"] env: + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} - name: MESSAGE_QUEUE_TYPE @@ -754,8 +764,10 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--storageServicePort", "8000", "--filePath", "/fission", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--storageServicePort", "8000", "--filePath", "/fission"] env: + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} - name: PRUNE_INTERVAL diff --git a/charts/fission-all/templates/router.yaml b/charts/fission-all/templates/router.yaml index 27675a91..6ba16ea2 100644 --- a/charts/fission-all/templates/router.yaml +++ b/charts/fission-all/templates/router.yaml @@ -33,7 +33,7 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--routerPort", "8888", "--executorUrl", "http://executor.{{ .Release.Namespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--routerPort", "8888", "--executorUrl", "http://executor.{{ .Release.Namespace }}"] env: - name: POD_NAMESPACE valueFrom: @@ -53,6 +53,8 @@ spec: value: {{ .Values.router.svcAddressMaxRetries | default 5 | quote }} - name: ROUTER_SVC_ADDRESS_UPDATE_TIMEOUT value: {{ .Values.router.svcAddressUpdateTimeout | default "30s" | quote }} + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.router.traceSamplingRate | default "0.5" | quote }} - name: USE_ENCODED_PATH diff --git a/charts/fission-core/templates/deployment.yaml b/charts/fission-core/templates/deployment.yaml index 00b80e8b..c0dc8a2f 100644 --- a/charts/fission-core/templates/deployment.yaml +++ b/charts/fission-core/templates/deployment.yaml @@ -138,8 +138,10 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--controllerPort", "8888", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--controllerPort", "8888"] env: + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} - name: FISSION_FUNCTION_NAMESPACE @@ -205,18 +207,18 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--executorPort", "8888", "--namespace", "{{ .Values.functionNamespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--executorPort", "8888", "--namespace", "{{ .Values.functionNamespace }}"] env: - name: FETCHER_IMAGE value: "{{ .Values.fetcherImage }}:{{ .Values.fetcherImageTag }}" - name: FETCHER_IMAGE_PULL_POLICY value: "{{ .Values.pullPolicy }}" + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} - name: ENABLE_ISTIO value: "{{ .Values.enableIstio }}" - - name: TRACE_JAEGER_COLLECTOR_ENDPOINT - value: "{{ .Values.traceCollectorEndpoint }}" - name: FETCHER_MINCPU value: {{ .Values.fetcherMinCpu | default "10m" | quote }} - name: FETCHER_MINMEM @@ -271,7 +273,7 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--builderMgr", "--storageSvcUrl", "http://storagesvc.{{ .Release.Namespace }}", "--envbuilder-namespace", "{{ .Values.builderNamespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--builderMgr", "--storageSvcUrl", "http://storagesvc.{{ .Release.Namespace }}", "--envbuilder-namespace", "{{ .Values.builderNamespace }}"] env: - name: FETCHER_IMAGE value: "{{ .Values.fetcherImage }}:{{ .Values.fetcherImageTag }}" @@ -321,8 +323,10 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--kubewatcher", "--routerUrl", "http://router.{{ .Release.Namespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--kubewatcher", "--routerUrl", "http://router.{{ .Release.Namespace }}"] env: + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} serviceAccountName: fission-svc @@ -353,8 +357,10 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--timer", "--routerUrl", "http://router.{{ .Release.Namespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--timer", "--routerUrl", "http://router.{{ .Release.Namespace }}"] env: + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} serviceAccountName: fission-svc @@ -388,10 +394,12 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--storageServicePort", "8000", "--filePath", "/fission", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--storageServicePort", "8000", "--filePath", "/fission"] env: - name: PRUNE_INTERVAL value: "{{.Values.pruneInterval}}" + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.traceSamplingRate | default "0.5" | quote }} volumeMounts: diff --git a/charts/fission-core/templates/router.yaml b/charts/fission-core/templates/router.yaml index 27675a91..6ba16ea2 100644 --- a/charts/fission-core/templates/router.yaml +++ b/charts/fission-core/templates/router.yaml @@ -33,7 +33,7 @@ spec: image: {{ include "fission-bundleImage" . | quote }} imagePullPolicy: {{ .Values.pullPolicy }} command: ["/fission-bundle"] - args: ["--routerPort", "8888", "--executorUrl", "http://executor.{{ .Release.Namespace }}", "--collectorEndpoint", "{{ .Values.traceCollectorEndpoint }}"] + args: ["--routerPort", "8888", "--executorUrl", "http://executor.{{ .Release.Namespace }}"] env: - name: POD_NAMESPACE valueFrom: @@ -53,6 +53,8 @@ spec: value: {{ .Values.router.svcAddressMaxRetries | default 5 | quote }} - name: ROUTER_SVC_ADDRESS_UPDATE_TIMEOUT value: {{ .Values.router.svcAddressUpdateTimeout | default "30s" | quote }} + - name: TRACE_JAEGER_COLLECTOR_ENDPOINT + value: "{{ .Values.traceCollectorEndpoint }}" - name: TRACING_SAMPLING_RATE value: {{ .Values.router.traceSamplingRate | default "0.5" | quote }} - name: USE_ENCODED_PATH diff --git a/cmd/fission-bundle/main.go b/cmd/fission-bundle/main.go index 76695696..1acdf35a 100644 --- a/cmd/fission-bundle/main.go +++ b/cmd/fission-bundle/main.go @@ -118,8 +118,8 @@ func getStringArgWithDefault(arg interface{}, defaultValue string) string { } func registerTraceExporter(logger *zap.Logger, arguments map[string]interface{}) error { - collectorEndpoint := getStringArgWithDefault(arguments["--collectorEndpoint"], "") - if collectorEndpoint == "" { + collectorEndpoint := os.Getenv("TRACE_JAEGER_COLLECTOR_ENDPOINT") + if len(collectorEndpoint) == 0 { logger.Info("skipping trace exporter registration") return nil } @@ -196,18 +196,17 @@ Use it to start one or more of the fission servers: backends. Usage: - fission-bundle --controllerPort= [--collectorEndpoint=] - fission-bundle --routerPort= [--executorUrl=] [--collectorEndpoint=] - fission-bundle --executorPort= [--namespace=] [--fission-namespace=] [--collectorEndpoint=] - fission-bundle --kubewatcher [--routerUrl=] [--collectorEndpoint=] - fission-bundle --storageServicePort= --filePath= [--collectorEndpoint=] - fission-bundle --builderMgr [--storageSvcUrl=] [--envbuilder-namespace=] [--collectorEndpoint=] - fission-bundle --timer [--routerUrl=] [--collectorEndpoint=] - fission-bundle --mqt [--routerUrl=] [--collectorEndpoint=] + fission-bundle --controllerPort= + fission-bundle --routerPort= [--executorUrl=] + fission-bundle --executorPort= [--namespace=] [--fission-namespace=] + fission-bundle --kubewatcher [--routerUrl=] + fission-bundle --storageServicePort= --filePath= + fission-bundle --builderMgr [--storageSvcUrl=] [--envbuilder-namespace=] + fission-bundle --timer [--routerUrl=] + fission-bundle --mqt [--routerUrl=] fission-bundle --logger fission-bundle --version Options: - --collectorEndpoint= Jaeger HTTP Thrift collector URL. --controllerPort= Port that the controller should listen on. --routerPort= Port that the router should listen on. --executorPort= Port that the executor should listen on. diff --git a/pkg/fetcher/config/config.go b/pkg/fetcher/config/config.go index fd3c69e6..7050edb5 100644 --- a/pkg/fetcher/config/config.go +++ b/pkg/fetcher/config/config.go @@ -96,7 +96,7 @@ func MakeFetcherConfig(sharedMountPath string) (*Config, error) { sharedMountPath: sharedMountPath, sharedSecretPath: "/secrets", sharedCfgMapPath: "/configs", - jaegerCollectorEndpoint: os.Getenv("OPENCENSUS_TRACE_JAEGER_COLLECTOR_ENDPOINT"), + jaegerCollectorEndpoint: os.Getenv("TRACE_JAEGER_COLLECTOR_ENDPOINT"), serviceAccount: types.FissionFetcherSA, }, nil }