Skip to content

Commit

Permalink
Adds extraContainers to integration test elasticsearch (#14)
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Cole <[email protected]>
  • Loading branch information
codefromthecrypt authored Feb 20, 2024
1 parent 88717ad commit 3038dc9
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/ct.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
check-version-increment: False
check-version-increment: false
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
fi
- name: Run chart-testing (lint)
run: ct lint
run: ct lint --config .github/ct.yml

- name: Create kind cluster
uses: helm/kind-action@v1
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ 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.storage.elasticsearch.hosts | string | `"hostA hostB"` | |
| zipkin.storage.elasticsearch.index | string | `"fooIndex"` | |
| zipkin.storage.type | string | `"elasticsearch"` | |
| zipkin.selfTracing.enabled | bool | `false` | |
| zipkin.storage.elasticsearch.hosts | string | no default | |
| zipkin.storage.elasticsearch.index | string | `"zipkin"` | |
| zipkin.storage.type | string | `"mem"` | |

The values are validated using a JSON schema, which contains logic to enforce either:

- `zipkin.storage.type` is set to `mem`
- `zipkin.storage.type` is set to `elasticsearch` *AND* both `z.s.elasticsearch.hosts` and `z.s.elasticsearch.index` is set
- `zipkin.storage.type` is set to `elasticsearch` *AND* `z.s.elasticsearch.hosts` is set
13 changes: 13 additions & 0 deletions charts/zipkin/ci/elasticsearch-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
zipkin:
storage:
type: elasticsearch
elasticsearch:
hosts: http://localhost:9200

# extra containers are in the same pod, so accessible by localhost
extraContainers:
- name: elasticsearch
image: 'ghcr.io/openzipkin/zipkin-elasticsearch8'
ports:
- containerPort: 9200
11 changes: 11 additions & 0 deletions charts/zipkin/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,14 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Add extra containers to the pod spec
*/}}
{{- define "zipkin.extraContainers" -}}
{{- if .Values.extraContainers }}
{{- with .Values.extraContainers }}
{{- toYaml . | nindent 2 }}
{{- end }}
{{- end }}
{{- end }}
23 changes: 17 additions & 6 deletions charts/zipkin/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,32 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
env:
{{- if .Values.zipkin.selfTracing.enabled }}
- name: SELF_TRACING_ENABLED
value: "{{ .Values.zipkin.selfTracing.enabled }}"
value: "true"
{{- end }}
- name: STORAGE_TYPE
value: "{{ .Values.zipkin.storage.type }}"
{{- if eq .Values.zipkin.storage.type "elasticsearch" }}
{{- with .Values.zipkin.storage.elasticsearch }}
- name: ES_HOSTS
value: "{{ .hosts }}"
value: {{ .hosts | quote }}
{{- if .index }}
- name: ES_INDEX
value: "{{ .index }}"
value: {{ .index | quote }}
{{- end }}
{{- if .username }}
- name: ES_USERNAME
value: "{{ .username }}"
value: {{ .username | quote }}
{{- end }}
{{- if .password }}
- name: ES_PASSWORD
value: "{{ .password }}"
value: {{ .password | quote }}
{{- end }}
{{- if .sslNoVerify }}
- name: ES_SSL_NO_VERIFY
value: "{{ default false .sslNoVerify }}"
value: "true"
{{- end }}
{{- end }}
{{- end }}
{{- range $key, $value := .Values.zipkin.extraEnv }}
Expand All @@ -79,6 +89,7 @@ spec:
periodSeconds: 5
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- include "zipkin.extraContainers" . | nindent 6 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
Expand Down
1 change: 1 addition & 0 deletions charts/zipkin/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: v1
kind: Pod
metadata:
Expand Down
21 changes: 17 additions & 4 deletions charts/zipkin/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
}
}
},
"extraContainers": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true,
"properties": {
"name": {
"type": "string"
}
},
"required": ["name"]
}
},
"fullnameOverride": {
"type": "string"
},
Expand Down Expand Up @@ -182,7 +195,7 @@
"type": "string"
}
},
"required": ["hosts", "index"]
"required": ["hosts"]
},
"type": {
"enum": ["mem", "elasticsearch"]
Expand All @@ -203,9 +216,9 @@
}
]
},
"extraEnv": {
"type": "object"
}
"extraEnv": {
"type": "object"
}
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions charts/zipkin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,6 @@ zipkin:
# index: fooIndex
extraEnv: {}
# JAVA_OPTS: "-Xms128m -Xmx512m -XX:+ExitOnOutOfMemoryError"

# extra containers to add to the same pod (accessible via localhost)
extraContainers: []

0 comments on commit 3038dc9

Please sign in to comment.