This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copying a vault pr hashicorp/vault-helm#252
- Loading branch information
Mads Hennings Thyssen
committed
May 17, 2021
1 parent
909bcc4
commit 9a71154
Showing
5 changed files
with
99 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
set +x | ||
while ! nslookup vault </dev/null || ! nc -w1 vault 8200 </dev/null; do | ||
echo "Waiting for Vault to Come up!" | ||
sleep 0.1 | ||
done | ||
sleep 10 | ||
|
||
echo "Vault Up, Will be initlising the it" | ||
|
||
export VAULT_ADDR=http://$VAULT_SERVICE_HOST:$VAULT_SERVICE_PORT_HTTP | ||
echo "vault address is: $VAULT_ADDR" | ||
|
||
echo "Initialising the vault" | ||
vault operator init -n 1 -t 1 > /tmp/stdout | ||
cat /tmp/stdout | head -n 1 | awk '{print $4}' > /tmp/key | ||
cat /tmp/stdout | grep -i "Root" |awk '{print $4}' > /tmp/token | ||
export KEY=$(cat /tmp/key) | ||
export VAULT_TOKEN=$(cat /tmp/token) | ||
|
||
echo "vault key is : $KEY" | ||
echo "vault token is : $VAULT_TOKEN" | ||
|
||
echo "Unsealing the vault" | ||
vault operator unseal $KEY | ||
vault status | ||
|
||
if [ "{{.Values.initvault.ldapauth.enabled}}" == "true" ]; then | ||
echo "Enabling the LDAP auth" | ||
export ldap_url="{{.Values.initvault.ldapauth.ldap_url}}" | ||
export userattr="{{.Values.initvault.ldapauth.userattr}}" | ||
export userdn="{{.Values.initvault.ldapauth.userdn}}" | ||
export groupdn="{{.Values.initvault.ldapauth.groupdn}}" | ||
export upndomain="{{.Values.initvault.ldapauth.upndomain}}" | ||
vault auth enable ldap | ||
vault login $VAULT_TOKEN | ||
vault write auth/ldap/config \ | ||
url="${ldap_url}" \ | ||
userattr="${userattr}" \ | ||
userdn="${userdn}" \ | ||
groupdn="${groupdn}" \ | ||
upndomain="${upndomain}" \ | ||
insecure_tls=true starttls=true \ | ||
tls_min_version=tls10 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{{- if .Values.initvault.enabled }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: vault-config-sh | ||
data: | ||
{{ (tpl (.Files.Glob "files/vault-config.sh").AsConfig . ) | indent 4 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,30 @@ | ||
{{- if .Values.autoconfig.enabled}} | ||
{{- if .Values.initvault.enabled }} | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: {{ template "vault.fullname" . }}-config-job | ||
labels: | ||
app: {{ include "vault.name" . }}-config-job | ||
chart: {{ .Chart.Name }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
name: vault-config-job | ||
annotations: | ||
"helm.sh/hook": pre-install,pre-upgrade | ||
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation | ||
"helm.sh/hook": "post-install" | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
app: {{ .Release.Name }}-config-job | ||
release: {{ .Release.Name }} | ||
{{- if .Values.autoconfig.job.podLabels }} | ||
{{ toYaml .Values.autoconfig.job.podLabels | indent 8 }} | ||
{{- end }} | ||
{{- if .Values.autoconfig.job.podAnnotations }} | ||
annotations: | ||
{{ toYaml .Values.autoconfig.job.podAnnotations | indent 8 }} | ||
{{- end }} | ||
spec: | ||
restartPolicy: OnFailure | ||
volumes: | ||
- name: init-secrets | ||
secret: | ||
secretName: {{ template "vault.fullname" . }}-job-secret | ||
containers: | ||
- name: vault-init-job | ||
image: hashicorp/vault | ||
command: | ||
- "/bin/sh" | ||
- "-c" | ||
args: | ||
- > | ||
echo "this is a job!" | ||
while true do; sleep 100; done; | ||
- name: vault-config-install | ||
image: {{ .Values.server.image.repository }}:{{ .Values.server.image.tag | default "latest" }} | ||
imagePullPolicy: IfNotPresent | ||
command: ["sh", "/tmp/vault-config.sh"] | ||
volumeMounts: | ||
- name: init-secrets | ||
mountPath: /secrets | ||
{{- end }} | ||
- name: vault-config-sh | ||
mountPath: /tmp/vault-config.sh | ||
subPath: vault-config.sh | ||
restartPolicy: OnFailure | ||
terminationGracePeriodSeconds: 0 | ||
volumes: | ||
- name: vault-config-sh | ||
configMap: | ||
name: vault-config-sh | ||
defaultMode: 0777 | ||
backoffLimit: 5 | ||
completions: 1 | ||
parallelism: 1 | ||
{{- end }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters