Skip to content

Commit

Permalink
Tracing Add-on For Linkerd (#3955)
Browse files Browse the repository at this point in the history
* Moves Common templates needed to partials

As add-ons re-use the partials helm chart, all the templates needed by multiple charts should be present in partials
This commit also updates the helm tests
Signed-off-by: Tarun Pothulapati <[email protected]>

* add tracing add-on helm chart

Tracing sub-chart includes open-census and jaeger components as a sub-chart which can be enabled as needed

* Updated Install path to also install add-ons

This includes new interface for add-ons to implement, with example tracing implementation

* Updates Linkerd install path to also install add-ons

Changes include:
 - Adds an optional Linkerd Values configmap which stores add-on configuration when add-ons are present.
 - Updates Linkerd install path to check for add-ons and render their sub-charts.
 - Adds a install Option called config, which is used to pass confiugration for add-ons.
 - Uses a fork of mergo, to over-write default Values with the Values struct generated from config.

* Updates the upgrade path about add-ons.

Upgrade path now checks for the linkerd-values cm, and overwrites the default values with it, if present.
It then checks the config option, for any further overwrites

* Refactor linkerd-values and re-update tests
also adds relevant nil checks
* Refactor code to fix linting issues
* Fixes an error with linkerd-config global values

Also refactors the linkerd-values cm to work the same with helm

* Fix a nil pointer issue for tests
* Updated Tracing add-on chart meta-data
Also introduced a defaultGetFiles method for add-ons

* Add add-on/charts to gitignore
* refactor gitignore for chart deps
* Moves sub-charts to /charts directly
* Refactor linkerd values cm
* Add comment in linkerd-values
* remove extra controlplanetracing flag
* Support Stages deployment for add-ons along with tests
* linting fix
* update tracing rbac
* Removes the need for add-on Interface
- Uses helm loading capabiltiies to get info about add-ons
- Uses reflection to not have to unnecessarily add checks for each add-on type

* disable tracing flag
* Remove dep on forked mergo
- Re-use merge from helm

* Re-use helm's merge
* Override the chartDir path during tests
* add error check
* Updated the dependency iteration code

Currently, the charts directory, will not have the deps in the repo. So, Code is updated to read the dependencies from requirements.yaml
and use that info to read templates from the relevant add-ons directory.

* Hard Code add-ons name
* Remove struct details for add-ons

- As we don't use fields of a add-on struct, we don't have them to be typed. Instead we can just use the `enabled` flag using reflection
- Users can just use map[string]interface{} as the add-on type.

* update unit tests
* linting fix
* Rename flag to addon-config
* Use Chart loading logic
- This code uses chart loading to read the files and keep in a vfs.
- Once we have those files read we will then use them for generation of sub-charts.

* Go fmt fix
* Update the linkerd-values cm to use second level field
* Add relevant unit tests for mergeRaw
* linting fix
* Move addon tests to a new file
* Fix golden files
* remove addon install unit test
* Refactor sub-chart load logic
* Add install tracing unit test
* golden file update for tracing install
* Update golden files to reflect another pr changes
* Move addon-config flag to recordFlagSet
* add relevant tracing enabled checks
* linting fix

Signed-off-by: Tarun Pothulapati <[email protected]>
  • Loading branch information
Pothulapati authored Feb 26, 2020
1 parent ae880f0 commit 948dc22
Show file tree
Hide file tree
Showing 27 changed files with 4,221 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ web/app/yarn-error.log
.gorun
**/*.gogen*
**/*.swp
charts/*/charts/
charts/**/charts
22 changes: 22 additions & 0 deletions charts/add-ons/tracing/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions charts/add-ons/tracing/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for the tracing add-on in Linkerd
name: tracing
version: 0.1.0
maintainers:
- name: Linkerd authors
email: [email protected]
url: https://linkerd.io/
6 changes: 6 additions & 0 deletions charts/add-ons/tracing/requirements.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: partials
repository: file://../../partials
version: 0.1.0
digest: sha256:2202cf6f3783f79e78414e7a94b651589f322f3724ab220f0ea3bf8f31954de4
generated: "2020-01-30T00:01:30.861787731+05:30"
4 changes: 4 additions & 0 deletions charts/add-ons/tracing/requirements.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dependencies:
- name: partials
version: 0.1.0
repository: file://../../partials
26 changes: 26 additions & 0 deletions charts/add-ons/tracing/templates/tracing-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
###
### linkerd-collector RBAC
###
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: {{.Values.collector.name}}
namespace: {{.Values.global.namespace}}
labels:
{{.Values.global.controllerComponentLabel}}: {{.Values.collector.name}}
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
---
###
### linkerd-jaeger RBAC
###
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: {{.Values.jaeger.name}}
namespace: {{.Values.global.namespace}}
labels:
{{.Values.global.controllerComponentLabel}}: {{.Values.jaeger.name}}
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
223 changes: 223 additions & 0 deletions charts/add-ons/tracing/templates/tracing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
---
###
### Tracing Collector Service
###
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{printf "%s-config" .Values.collector.name}}
namespace: {{.Values.global.namespace}}
labels:
{{.Values.global.controllerComponentLabel}}: {{.Values.collector.name}}
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
annotations:
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
data:
linkerd-collector-config: |
receivers:
opencensus:
port: 55678
zipkin:
port: 9411
queued-exporters:
jaeger-all-in-one:
num-workers: 4
queue-size: 100
retry-on-failure: true
sender-type: jaeger-thrift-http
jaeger-thrift-http:
collector-endpoint: {{printf "http://%s.%s:14268/api/traces" .Values.jaeger.name .Values.global.namespace }}
timeout: 5s
---
apiVersion: v1
kind: Service
metadata:
name: {{.Values.collector.name}}
namespace: {{.Values.global.namespace}}
labels:
{{.Values.global.controllerComponentLabel}}: {{.Values.collector.name}}
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
annotations:
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
spec:
type: ClusterIP
ports:
- name: opencensus
port: 55678
protocol: TCP
targetPort: 55678
- name: zipkin
port: 9411
protocol: TCP
targetPort: 9411
selector:
{{.Values.global.controllerComponentLabel}}: {{.Values.collector.name}}
---
{{ if empty .Values.global.proxy.image.version -}}
{{ $_ := set .Values.global.proxy.image "Version" .Values.global.linkerdVersion -}}
{{ end -}}
{{ $_ := set .Values.global.proxy "workloadKind" "deployment" -}}
{{ $_ := set .Values.global.proxy "component" .Values.collector.name -}}
{{ include "linkerd.proxy.validation" .Values.global.proxy -}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
labels:
app.kubernetes.io/name: {{.Values.collector.name}}
app.kubernetes.io/part-of: Linkerd
app.kubernetes.io/version: {{default .Values.global.linkerdVersion .Values.controllerImageVersion}}
{{.Values.global.controllerComponentLabel}}: {{.Values.collector.name}}
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
name: {{.Values.collector.name}}
namespace: {{.Values.global.namespace}}
spec:
replicas: 1
selector:
matchLabels:
{{.Values.global.controllerComponentLabel}}: {{.Values.collector.name}}
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
{{- include "partials.proxy.labels" .Values.global.proxy | nindent 6}}
minReadySeconds: 5
progressDeadlineSeconds: 120
template:
metadata:
annotations:
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
{{- include "partials.proxy.annotations" .Values.global.proxy| nindent 8}}
prometheus.io/path: /metrics
prometheus.io/port: "8888"
prometheus.io/scrape: "true"
labels:
{{.Values.global.controllerComponentLabel}}: {{.Values.collector.name}}
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
{{- include "partials.proxy.labels" .Values.global.proxy | nindent 8}}
spec:
containers:
- command:
- /occollector_linux
- --config=/conf/linkerd-collector-config.yaml
env:
- name: GOGC
value: "80"
image: {{.Values.collector.image}}
imagePullPolicy: {{.Values.global.imagePullPolicy}}
livenessProbe:
httpGet:
path: /
port: 13133
name: oc-collector
ports:
- containerPort: 55678
- containerPort: 9411
readinessProbe:
httpGet:
path: /
port: 13133
{{- if .Values.collector.resources -}}
{{- include "partials.resources" .Values.collector.resources | nindent 8 }}
{{- end }}
volumeMounts:
- mountPath: /conf
name: {{ printf "%s-config-val" .Values.collector.name}}
- {{- include "partials.proxy" . | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.noInitContainer -}}
initContainers:
- {{- include "partials.proxy-init" . | indent 8 | trimPrefix (repeat 7 " ") }}
{{ end -}}
serviceAccountName: {{.Values.collector.name}}
volumes:
- configMap:
items:
- key: linkerd-collector-config
path: linkerd-collector-config.yaml
name: {{printf "%s-config" .Values.collector.name}}
name: {{ printf "%s-config-val" .Values.collector.name}}
- {{- include "partials.proxy.volumes.identity" . | indent 8 | trimPrefix (repeat 7 " ") }}
---
###
### Tracing Jaeger Service
###
---
apiVersion: v1
kind: Service
metadata:
name: {{.Values.jaeger.name}}
namespace: {{.Values.global.namespace}}
labels:
{{.Values.global.controllerComponentLabel}}: {{.Values.jaeger.name}}
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
annotations:
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
spec:
type: ClusterIP
selector:
{{.Values.global.controllerComponentLabel}}: {{.Values.jaeger.name}}
ports:
- name: collection
port: 14268
- name: ui
port: 16686
---
{{ if empty .Values.global.proxy.image.version -}}
{{ $_ := set .Values.global.proxy.image "Version" .Values.global.linkerdVersion -}}
{{ end -}}
{{ $_ := set .Values.global.proxy "workloadKind" "deployment" -}}
{{ $_ := set .Values.global.proxy "component" .Values.jaeger.name -}}
{{ include "linkerd.proxy.validation" .Values.global.proxy -}}
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
labels:
app.kubernetes.io/name: {{.Values.jaeger.name}}
app.kubernetes.io/part-of: Linkerd
app.kubernetes.io/version: {{default .Values.global.linkerdVersion .Values.controllerImageVersion}}
{{.Values.global.controllerComponentLabel}}: {{.Values.jaeger.name}}
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
name: {{.Values.jaeger.name}}
namespace: {{.Values.global.namespace}}
spec:
replicas: 1
selector:
matchLabels:
{{.Values.global.controllerComponentLabel}}: {{.Values.jaeger.name}}
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
{{- include "partials.proxy.labels" .Values.global.proxy | nindent 6}}
template:
metadata:
annotations:
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
{{- include "partials.proxy.annotations" .Values.global.proxy| nindent 8}}
prometheus.io/path: /metrics
prometheus.io/port: "8888"
prometheus.io/scrape: "true"
labels:
{{.Values.global.controllerComponentLabel}}: {{.Values.jaeger.name}}
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
{{- include "partials.proxy.labels" .Values.global.proxy | nindent 8}}
spec:
containers:
- image: {{.Values.jaeger.image}}
imagePullPolicy: {{.Values.global.imagePullPolicy}}
name: jaeger
ports:
- containerPort: 14268
name: collection
- containerPort: 16686
name: ui
{{- if .Values.jaeger.resources -}}
{{- include "partials.resources" .Values.jaeger.resources | nindent 8 }}
{{- end }}
- {{- include "partials.proxy" . | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.noInitContainer -}}
initContainers:
- {{- include "partials.proxy-init" . | indent 8 | trimPrefix (repeat 7 " ") }}
{{ end -}}
dnsPolicy: ClusterFirst
serviceAccountName: linkerd-jaeger
volumes:
- {{- include "partials.proxy.volumes.identity" . | indent 8 | trimPrefix (repeat 7 " ") }}
1 change: 1 addition & 0 deletions charts/add-ons/tracing/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Default values for tracing.
7 changes: 5 additions & 2 deletions charts/linkerd2/requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ dependencies:
- name: partials
repository: file://../partials
version: 0.1.0
digest: sha256:3a86b96a2966f03ba04518723838b49719a3277dfb9bea0b3f067e83d370e0b3
generated: 2019-07-24T19:51:15.04322926-07:00
- name: tracing
repository: file://../add-ons/tracing
version: 0.1.0
digest: sha256:e33d9505af13cd9a047d9a2d6094af4b4d62cdc9ee64970dc3d2bba6809066d0
generated: "2020-01-30T00:02:25.011181273+05:30"
4 changes: 4 additions & 0 deletions charts/linkerd2/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ dependencies:
- name: partials
version: 0.1.0
repository: file://../partials
- name: tracing
version: 0.1.0
repository: file://../add-ons/tracing
condition: tracing.enabled
29 changes: 29 additions & 0 deletions charts/linkerd2/templates/linkerd-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- /*
This config-map is used to store the configuration of add-ons, which is useful during upgrades.
As fields like global, etc are added by helm and we would not want them in the data, second level fields should be used
instead of directly specifying the add-on field.
*/ -}}
{{ if or (.Values.tracing.enabled) -}}
---
###
### linkerd values
###
---
kind: ConfigMap
apiVersion: v1
metadata:
name: linkerd-values
namespace: {{.Values.global.namespace}}
labels:
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
annotations:
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
data:
values: |-
tracing:
enabled: {{.Values.tracing.enabled}}
collector:
{{- toYaml .Values.tracing.collector | trim | nindent 8}}
jaeger:
{{- toYaml .Values.tracing.jaeger | trim | nindent 8}}
{{ end -}}
20 changes: 20 additions & 0 deletions charts/linkerd2/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,23 @@ installNamespace: true
# https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector.
nodeSelector:
beta.kubernetes.io/os: linux


# Configuration for Add-ons
tracing:
enabled: false
collector:
name: linkerd-collector
image: omnition/opencensus-collector:0.1.10
resources:
cpu:
limit: 1
request: 200m
memory:
limit: 2Gi
request: 400Mi
jaeger:
name: linkerd-jaeger
image: jaegertracing/all-in-one:1.8
resources:

File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 948dc22

Please sign in to comment.