Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[simple-app] Add support for Prometheus ServiceMonitors and Istio Met…
…rics Merging (#28) This PR adds support for configuring metrics-collection in two ways - through a Prometheus `ServiceMonitor` resource, or through the Istio Sidecar using ["Metrics Merging"](https://istio.io/latest/docs/ops/integrations/prometheus/#option-1-metrics-merging). ## Scenario 1: `istio.enabled=false`, `monitor.enabled=true` ```diff install.go:173: [debug] Original chart version: "" install.go:190: [debug] CHART PATH: /Users/diranged/git/nextdoor/k8s-charts/charts/simple-app --- orig 2021-06-21 16:40:29.000000000 -0700 +++ new 2021-06-22 07:00:39.000000000 -0700 @@ -8,7 +8,7 @@ metadata: name: simple-app-ingress-access labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -32,7 +32,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -44,7 +44,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -70,7 +70,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -83,8 +83,9 @@ app.kubernetes.io/instance: simple-app template: metadata: + annotations: labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -108,6 +109,9 @@ - containerPort: 443 name: https protocol: TCP + - name: metrics + containerPort: 9090 + protocol: TCP livenessProbe: httpGet: path: / @@ -123,7 +127,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -327,6 +331,27 @@ name: redis protocol: REDIS --- +# Source: simple-app/templates/servicemonitor.yaml +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: simple-app + labels: + helm.sh/chart: simple-app-0.10.0 + app.kubernetes.io/version: "latest" + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: simple-app + app.kubernetes.io/instance: simple-app +spec: + selector: + matchLabels: + app.kubernetes.io/name: simple-app + app.kubernetes.io/instance: simple-app + endpoints: + - port: metrics + path: /metrics + scheme: http +--- # Source: simple-app/charts/istio-endpoints/templates/sidecar.yaml apiVersion: networking.istio.io/v1beta1 kind: Sidecar @@ -361,7 +386,7 @@ metadata: name: "simple-app-test-connection" labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app ``` ## Scenario 2: `istio.enabled=true`, `monitor.enabled=true` ```diff install.go:173: [debug] Original chart version: "" install.go:190: [debug] CHART PATH: /Users/diranged/git/nextdoor/k8s-charts/charts/simple-app --- orig 2021-06-21 16:40:29.000000000 -0700 +++ new 2021-06-22 07:00:20.000000000 -0700 @@ -8,7 +8,7 @@ metadata: name: simple-app-ingress-access labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -32,7 +32,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -44,7 +44,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -70,7 +70,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -83,8 +83,13 @@ app.kubernetes.io/instance: simple-app template: metadata: + annotations: + proxy.istio.io/config: '{ "holdApplicationUntilProxyStarts": true }' + prometheus.io/scrape: "true" + prometheus.io/port: "metrics" + prometheus.io/path: /metrics labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -108,6 +113,9 @@ - containerPort: 443 name: https protocol: TCP + - name: metrics + containerPort: 9090 + protocol: TCP livenessProbe: httpGet: path: / @@ -123,7 +131,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -361,7 +369,7 @@ metadata: name: "simple-app-test-connection" labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app ``` ## Scenario 3: `istio.enabled=true`, `monitor.enabled=false` ```diff install.go:173: [debug] Original chart version: "" install.go:190: [debug] CHART PATH: /Users/diranged/git/nextdoor/k8s-charts/charts/simple-app --- orig 2021-06-21 16:40:29.000000000 -0700 +++ new 2021-06-22 07:02:07.000000000 -0700 @@ -8,7 +8,7 @@ metadata: name: simple-app-ingress-access labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -32,7 +32,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -44,7 +44,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -70,7 +70,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -83,8 +83,10 @@ app.kubernetes.io/instance: simple-app template: metadata: + annotations: + proxy.istio.io/config: '{ "holdApplicationUntilProxyStarts": true }' labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -123,7 +125,7 @@ metadata: name: simple-app labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app @@ -361,7 +363,7 @@ metadata: name: "simple-app-test-connection" labels: - helm.sh/chart: simple-app-0.9.5 + helm.sh/chart: simple-app-0.10.0 app.kubernetes.io/version: "latest" app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: simple-app ```
- Loading branch information