Skip to content
Closed
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
17 changes: 17 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,23 @@ Reduce duplication of the st2.*.conf volume details
{{- end }}
{{- end -}}

{{- define "stackstorm-ha.init-containers-wait-for-auth" -}}
- name: wait-for-auth
image: "alpine/curl:8.4.0"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- 'sh'
- '-c'
- >
until curl -skSL --fail -w '\n' -X POST -u {{ .Values.st2.username }}:{{ .Values.st2.password }} "https://{{ required ".Values.ingress.fqdn is required if .Values.ingress.class is non-empty" .Values.ingress.fqdn | printf (ternary "canary-%s" "%s" .Values.phaseCanary)}}/auth/tokens"; do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see these vars in our values file:

  • ingress.fqdn
  • ingress.class
  • phaseCanary

stackstorm-k8s/values.yaml

Lines 298 to 321 in 17e5fca

##
## StackStorm HA Ingress
##
ingress:
# As recommended, ingress is disabled by default.
enabled: false
# Annotations are used to configure the ingress controller
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
# Map hosts to paths
hosts: []
# - host: hostname.domain.tld
# # Map paths to services
# paths:
# - path: /
# serviceName: service
# servicePort: port
# Secure the Ingress by specifying a secret that contains a TLS private key and certificate
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.test
# ingressClassName: nginx-ingress

I also do not use the ingress, so these would never be defined for me.

user/pass is also only available in my cluster(s) during initial bootstrap. Once I switch to ldap, I exclusively use api tokens within helm.

Do you have any ideas on how to make this more generic?

echo 'Waiting for StackStorm API'
sleep 2;
done
{{- with .Values.securityContext }}
securityContext: {{- toYaml . | nindent 8 }}
{{- end }}
{{- end -}}

{{- define "stackstorm-ha.init-containers-wait-for-db" -}}
{{- if index .Values "mongodb" "enabled" }}
{{- $mongodb_port := (int (index .Values "mongodb" "service" "port")) }}
Expand Down
2 changes: 1 addition & 1 deletion templates/tests/st2tests-configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-st2tests
name: {{ .Release.Name }}-job-st2-tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need the helm annotations if you are planning to run this on a real st2 cluster instead of only running it in CI.

I'm not sure the st2tests.sh is designed to run on a real instance of st2--there might be some unintended side effects.

labels: {{- include "stackstorm-ha.labels" (list $ "st2tests") | nindent 4 }}
data:
st2tests.sh: |
Expand Down
89 changes: 89 additions & 0 deletions templates/tests/st2tests-job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}-job-st2-tests"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name changed from {{ .Release.Name }}-st2tests

labels: {{- include "stackstorm-ha.labels" (list $ "st2tests") | nindent 4 }}
annotations:
"helm.sh/hook": test-success
"helm.sh/hook-delete-policy": hook-succeeded
spec:
template:
metadata:
name: "{{ .Release.Name }}-job-st2-tests"
labels: {{- include "stackstorm-ha.labels" (list $ "st2tests") | nindent 8 }}
annotations:
"helm.sh/hook": test-success
"helm.sh/hook-delete-policy": hook-succeeded
Comment on lines +14 to +16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the pod needs these helm annotations, just the top-level Job. Is that right?

spec:
initContainers:
{{- include "stackstorm-ha.init-containers-wait-for-auth" . | nindent 6 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new templated init container you've added to ensure the tests wait until st2 is up and running.

# Sidecar container to copy BATS framework to the main container
- name: bats-core
image: "bats/bats:1.8.2"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
{{- with .Values.securityContext }}
securityContext: {{- toYaml . | nindent 12 }}
{{- end }}
Comment on lines +23 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new.

command:
- bash
- -ec
- |
cp -R /opt/bats /tools/
volumeMounts:
- name: tools
mountPath: /tools
- name: bats-addons
image: "alpine/git:2.36.3"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
{{- with .Values.securityContext }}
securityContext: {{- toYaml . | nindent 12 }}
{{- end }}
Comment on lines +37 to +40
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new.

command:
- ash
- -ec
- |
git clone --config advice.detachedHead=false --depth 1 --branch v0.3.0 \
https://github.com/ztombol/bats-assert /tools/bats-assert
git clone --config advice.detachedHead=false --depth 1 --branch v0.2.0 \
https://github.com/ztombol/bats-file /tools/bats-file
git clone --config advice.detachedHead=false --depth 1 --branch v0.3.0 \
https://github.com/ztombol/bats-support /tools/bats-support
volumeMounts:
- name: tools
mountPath: /tools
# Run the actual BATS tests
containers:
- name: st2tests
image: '{{ template "stackstorm-ha.imageRepository" . }}/st2actionrunner:{{ tpl (.Values.st2actionrunner.image.tag | default .Values.image.tag) $ }}'
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.securityContext }}
securityContext: {{- toYaml . | nindent 12 }}
{{- end }}
Comment on lines +59 to +61
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new. (imagePullPolicy was already present)

envFrom:
- configMapRef:
name: {{ .Release.Name }}-st2-urls
- secretRef:
name: {{ include "stackstorm-ha.secrets.st2Auth" . }}
env:
- name: BATS_HELPERS_DIR
value: /tools
- name: ST2_VERSION
value: "{{ .Values.image.tag }}"
- name: ST2_RBAC_ENABLED
value: "{{ .Values.st2.rbac.enabled }}"
volumeMounts:
- name: tools
mountPath: /tools
- name: tests
mountPath: /tests
command:
- /tools/bats/bin/bats
- /tests/st2tests.sh
volumes:
- name: tools
emptyDir: {}
- name: tests
configMap:
name: {{ .Release.Name }}-job-st2-tests
restartPolicy: Never
backoffLimit: 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backoffLimit is new.

68 changes: 0 additions & 68 deletions templates/tests/st2tests-pod.yaml

This file was deleted.