Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds eureka and test infrastructure to support it #15

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ You can then run `helm search repo zipkin` to see the charts.
| Key | Type | Default | Description |
|--------------------------------------------|--------|------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| affinity | object | `{}` | |
| args | list | `[]` | arguments to the zipkin start command |
| autoscaling.enabled | bool | `false` | |
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| command | list | `["start-zipkin"]` | command used to start zipkin |
| fullnameOverride | string | `""` | |
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"openzipkin/zipkin-slim"` | |
Expand Down Expand Up @@ -54,6 +56,11 @@ You can then run `helm search repo zipkin` to see the charts.
| serviceAccount.name | string | `""` | If not set and create is true, a name is generated using the fullname template |
| serviceAccount.psp | bool | `false` | |
| tolerations | list | `[]` | |
| zipkin.discovery.eureka.serviceUrl | string | no default | v2 endpoint of Eureka, e.g. `https://eureka-prod/eureka/v2` |
| zipkin.discovery.eureka.app | string | `"zipkin"` | The application this instance registers to |
| zipkin.discovery.eureka.hostName | string | detects | The instance `hostName` and `vipAddress` |
| zipkin.discovery.eureka.instanceId | string | `"hostName:app:port"` | |
| zipkin.storage.type | string | `"mem"` | |
| zipkin.selfTracing.enabled | bool | `false` | |
| zipkin.storage.elasticsearch.hosts | string | no default | |
| zipkin.storage.elasticsearch.index | string | `"zipkin"` | |
Expand Down
2 changes: 0 additions & 2 deletions charts/zipkin/ci/default-values.yaml

This file was deleted.

27 changes: 27 additions & 0 deletions charts/zipkin/ci/eureka-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
# To avoid a race, sleep until Eureka is running before starting zipkin.
command: ['/bin/sh', '-c']
args:
- 'while ! wget -q --spider http://localhost:8761/eureka/v2/apps;do sleep 1; done && start-zipkin'

zipkin:
discovery:
eureka:
serviceUrl: http://localhost:8761/eureka/v2
hostName: zipkin

# extra containers are in the same pod, so this means Eureka is accessible to
# zipkin via localhost.
extraContainers:
- name: eureka
image: 'ghcr.io/openzipkin/zipkin-eureka'
ports:
- containerPort: 8761

# test-connection runs in a different pod, so it can't verify Eureka unless we
# expose a service port.
extraServicePorts:
- port: 8761
targetPort: 8761
protocol: TCP
name: eureka
8 changes: 8 additions & 0 deletions charts/zipkin/ci/servicePort-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Tests use a different pod and access zipkin via its service port.
# This makes sure we can change this to a value different from what the
# container listens on (9411).
service:
port: 9413

zipkin: {}
11 changes: 11 additions & 0 deletions charts/zipkin/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,14 @@ Add extra containers to the pod spec
{{- end }}
{{- end }}
{{- end }}

{{/*
Add extra ports to the pod spec
*/}}
{{- define "zipkin.extraServicePorts" -}}
{{- if .Values.extraServicePorts }}
{{- with .Values.extraServicePorts }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
{{- end }}
30 changes: 30 additions & 0 deletions charts/zipkin/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,41 @@ spec:
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
{{- if .Values.command }}
command:
{{- range .Values.command }}
- {{ . }}
{{- end }}
{{- end }}
{{- if .Values.args }}
args:
{{- range .Values.args }}
- {{ . }}
{{- end }}
{{- end }}
env:
{{- if .Values.zipkin.selfTracing.enabled }}
- name: SELF_TRACING_ENABLED
value: "true"
{{- end }}
{{- if .Values.zipkin.discovery.eureka }}
{{- with .Values.zipkin.discovery.eureka }}
- name: EUREKA_SERVICE_URL
value: {{ .serviceUrl | quote }}
{{- if .app }}
- name: EUREKA_APP_NAME
value: {{ .app | quote }}
{{- end }}
{{- if .hostName }}
- name: EUREKA_APP_NAME
value: {{ .hostName | quote }}
{{- end }}
{{- if .instanceId }}
- name: EUREKA_INSTANCE_ID
value: {{ .instanceId | quote }}
{{- end }}
{{- end }}
{{- end }}
- name: STORAGE_TYPE
value: "{{ .Values.zipkin.storage.type }}"
{{- if eq .Values.zipkin.storage.type "elasticsearch" }}
Expand Down
1 change: 1 addition & 0 deletions charts/zipkin/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ spec:
targetPort: 9411
protocol: TCP
name: http-query
{{- include "zipkin.extraServicePorts" . | nindent 2 }}
selector:
{{- include "zipkin.selectorLabels" . | nindent 4 }}
13 changes: 10 additions & 3 deletions charts/zipkin/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ metadata:
"helm.sh/hook": test
spec:
containers:
- name: get-api-services
{{- if .Values.zipkin.discovery.eureka }}
- name: verify-eureka
image: 'ghcr.io/openzipkin/alpine:3.19.1'
command: [ '/bin/sh', '-c' ]
# Make sure zipkin registered in Eureka at startup
args: [ 'wget -q --spider http://{{ include "zipkin.fullname" . }}:8761/eureka/v2/apps/ZIPKIN' ]
{{- end }}
- name: get-api
image: "ghcr.io/openzipkin/alpine:3.19.1"
command: [ '/bin/sh', '-c' ]
# Get an arbitrary API endpoint using the ClusterIP and service port
args: [ 'wget -qO ---spider --header "b3: cafebabecafebabe-cafebabecafebabe-1" http://{{ include "zipkin.fullname" . }}:{{ .Values.service.port }}/api/v2/services' ]
args: [ 'wget -q --spider --header "b3: cafebabecafebabe-cafebabecafebabe-1" http://{{ include "zipkin.fullname" . }}:{{ .Values.service.port }}/api/v2/services' ]
{{- if .Values.zipkin.selfTracing.enabled }}
- name: get-trace
image: 'ghcr.io/openzipkin/alpine:3.19.1'
command: [ '/bin/sh', '-c' ]
# If self-tracing, sleep for the trace to process. Then, get it by the constant ID passed above.
args: [ 'sleep 3 && wget -qO ---spider http://{{ include "zipkin.fullname" . }}:{{ .Values.service.port }}/api/v2/trace/cafebabecafebabe' ]
args: [ 'sleep 3 && wget -q --spider http://{{ include "zipkin.fullname" . }}:{{ .Values.service.port }}/api/v2/trace/cafebabecafebabe' ]
{{- end }}
restartPolicy: Never
57 changes: 57 additions & 0 deletions charts/zipkin/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"affinity": {
"type": "object"
},
"args": {
"description": "Arguments to the zipkin start command",
"type": "array",
"items": {
"type": "string"
}
},
"autoscaling": {
"type": "object",
"properties": {
Expand All @@ -22,6 +29,26 @@
}
}
},
"command": {
"description": "Zipkin start command",
"type": "array",
"items": {
"type": "string"
}
},
"extraServicePorts": {
"type": "array",
"items": {
"type": "object",
"required": ["name"],
"properties": {
"name": {"type": "string"},
"protocol": {"enum": ["TCP", "UDP", "SCTP"]},
"port": {"type": "integer"},
"targetPort": {"type": "integer"}
}
}
},
"extraContainers": {
"type": "array",
"items": {
Expand Down Expand Up @@ -173,6 +200,36 @@
"zipkin": {
"type": "object",
"properties": {
"discovery": {
"type": "object",
"properties": {
"eureka": {
"type": "object",
"properties": {
"serviceUrl": {
"type": "string"
},
"app": {
"type": "string"
},
"hostName": {
"type": "string"
},
"instanceId": {
"type": "string"
}
},
"required": [
"serviceUrl"
]
},
"type": {
"enum": [
"eureka"
]
}
}
},
"storage": {
"type": "object",
"properties": {
Expand Down
16 changes: 15 additions & 1 deletion charts/zipkin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ image:
# Overrides the image tag whose default is the chart appVersion.
tag: ""

# Zipkin start command
command: ["start-zipkin"]
# Arguments to pass to the zipkin start command
args: []

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
Expand Down Expand Up @@ -101,6 +106,7 @@ affinity: {}
priorityClassName: ""

zipkin:
discovery: {}
# selfTracing generates traces for HTTP paths under /api
selfTracing:
enabled: false
Expand All @@ -113,5 +119,13 @@ zipkin:
extraEnv: {}
# JAVA_OPTS: "-Xms128m -Xmx512m -XX:+ExitOnOutOfMemoryError"

# extra containers to add to the same pod (accessible via localhost)
# The below are typically only used in tests:
# extra containers to add to the same pod.
extraContainers: []

# extra ports to add besides the default service.port
extraServicePorts: []
# - port: 9410
# targetPort: 9410
# protocol: TCP
# name: scribe
Loading