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

Add helm hook for custom secret validation #294

Merged
merged 2 commits into from
Nov 17, 2021
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{- if not .Values.secret.create }}
# Helm hook validating that custom secret provided by user has all the required
# fields.
apiVersion: v1
kind: Pod
metadata:
name: {{ template "splunk-otel-collector.fullname" . }}-validate-secret
labels:
{{- include "splunk-otel-collector.commonLabels" . | nindent 4 }}
annotations:
"helm.sh/hook": pre-upgrade,pre-install
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
restartPolicy: Never
containers:
- name: validate-secret
image: {{ template "splunk-otel-collector.image.otelcol" . }}
imagePullPolicy: {{ .Values.image.otelcol.pullPolicy }}
command: ["sh", "-c"]
Copy link
Contributor

Choose a reason for hiding this comment

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

this image doesn't have sh, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does have it

Copy link
Contributor

Choose a reason for hiding this comment

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

oh i see it does. but how? just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

args:
- if [ "{{ include "splunk-otel-collector.splunkO11yEnabled" . }}" = "true" ] && [ ! -f /otel/secret/splunk_observability_access_token ]; then
echo Splunk Observability destination is enabled, but custom\
Kubernetes secret \"{{ template "splunk-otel-collector.secret" . }}\"\
doesn\'t have required field \"splunk_observability_access_token\".;
export TOKEN_INVALID=true;
fi;
if [ "{{ include "splunk-otel-collector.splunkPlatformEnabled" . }}" = "true" ] && [ ! -f /otel/secret/splunk_platform_hec_token ]; then
echo Splunk Platform destination is enabled, but custom Kubernetes\
secret \"{{ template "splunk-otel-collector.secret" . }}\" doesn\'t\
have required field \"splunk_platform_hec_token\".;
export TOKEN_INVALID=true;
fi;
if [ "$TOKEN_INVALID" = "true" ]; then
echo Please update the secret.;
exit 1;
fi
volumeMounts:
- name: secret
mountPath: /otel/secret
readOnly: true
volumes:
- name: secret
secret:
secretName: {{ template "splunk-otel-collector.secret" . }}
{{- end }}