This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ab5813
commit f708f20
Showing
91 changed files
with
3,167 additions
and
869 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
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
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 @@ | ||
3.2.0 |
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 @@ | ||
6.0.0 |
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 @@ | ||
6.0.0 |
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,7 +1,7 @@ | ||
apiVersion: v1 | ||
name: vault-sidecar-injector | ||
description: A Helm chart for Talend Vault Sidecar Injector (OSS) | ||
version: 3.1.1 | ||
version: 0.0.0 | ||
icon: https://www.talend.com/wp-content/uploads/talend-logo.svg | ||
keywords: | ||
- Talend | ||
|
@@ -14,4 +14,4 @@ sources: | |
maintainers: | ||
- name: Talend | ||
email: [email protected] | ||
appVersion: 5.0.1 | ||
appVersion: 0.0.0 |
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,229 @@ | ||
initContainers: | ||
- name: tvsi-vault-agent-init | ||
image: {{ include "talend-vault-sidecar-injector.injectconfig.vault.image" .Values }} | ||
imagePullPolicy: {{ .Values.injectconfig.vault.image.pullPolicy }} | ||
env: | ||
- name: SKIP_SETCAP | ||
value: "true" | ||
- name: VAULT_ADDR | ||
value: {{ required "Vault server's address must be specified" .Values.vault.addr | quote }} | ||
# env var set by webhook | ||
- name: VSI_SECRETS_TEMPLATES_PLACEHOLDER | ||
value: "" | ||
# env var set by webhook | ||
- name: VSI_VAULT_ROLE | ||
value: "" | ||
command: | ||
- "sh" | ||
- "-c" | ||
- | | ||
cat <<EOF > vault-agent-config.hcl | ||
pid_file = "/home/vault/pidfile" | ||
auto_auth { | ||
method "kubernetes" { | ||
mount_path = "auth/{{ .Values.vault.authMethods.kubernetes.path }}" | ||
config = { | ||
role = "${VSI_VAULT_ROLE}" | ||
token_path = "/var/run/secrets/talend/vault-sidecar-injector/serviceaccount/token" | ||
} | ||
} | ||
sink "file" { | ||
config = { | ||
path = "/home/vault/.vault-token" | ||
} | ||
} | ||
} | ||
${VSI_SECRETS_TEMPLATES_PLACEHOLDER} | ||
EOF | ||
docker-entrypoint.sh agent -config=vault-agent-config.hcl -exit-after-auth=true {{ include "talend-vault-sidecar-injector.vault.cert.skip.verify" .Values }} -log-level={{- .Values.injectconfig.vault.loglevel }} | ||
export VAULT_TOKEN=$(cat /home/vault/.vault-token) | ||
vault token revoke {{ include "talend-vault-sidecar-injector.vault.cert.skip.verify" .Values }} -self | ||
volumeMounts: | ||
# Mount path used to share secrets. The associated volume is expected to be defined in application's manifest but in case it is not, | ||
# a default 'secrets' volume will be injected in the requesting pod (see definition below) so that mutation process does not fail. | ||
- name: secrets | ||
mountPath: /opt/talend/secrets | ||
# The name's value will be overridden by the webhook to point to container's service account volume to use for Vault authentication. | ||
- name: TVSI_SA_SECRETS_VOL_NAME | ||
mountPath: /var/run/secrets/talend/vault-sidecar-injector/serviceaccount | ||
readOnly: true | ||
{{- if .Values.injectconfig.vault.resources }} | ||
resources: | ||
{{ toYaml .Values.injectconfig.vault.resources | indent 6 }} | ||
{{- end }} | ||
containers: | ||
# This container is only injected in K8S jobs to monitor app job's container termination and send signal to vault sidecar | ||
- name: tvsi-job-babysitter | ||
image: {{ include "talend-vault-sidecar-injector.injectconfig.jobbabysitter.image" .Values }} | ||
imagePullPolicy: {{ .Values.injectconfig.jobbabysitter.image.pullPolicy }} | ||
env: | ||
- name: POD_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
# env var set by webhook | ||
- name: VSI_JOB_CNT_NAME | ||
value: "" | ||
command: | ||
- "sh" | ||
- "-c" | ||
- | | ||
jwt_sa_token=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) | ||
pod_ns=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace) | ||
retCode=$(curl -s -X GET -H "Authorization: Bearer $jwt_sa_token" --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt https://$KUBERNETES_SERVICE_HOST/api/v1/namespaces/$pod_ns/pods/$POD_NAME?pretty=false | jq .code) | ||
if [ $retCode = "403" ]; then | ||
curl -s -X GET -H "Authorization: Bearer $jwt_sa_token" --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt https://$KUBERNETES_SERVICE_HOST/api/v1/namespaces/$pod_ns/pods/$POD_NAME?pretty=false | jq .message | ||
exit 1 | ||
fi | ||
while true; do | ||
cntStatus=$(curl -s -X GET -H "Authorization: Bearer $jwt_sa_token" --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt https://$KUBERNETES_SERVICE_HOST/api/v1/namespaces/$pod_ns/pods/$POD_NAME?pretty=false | jq -c --raw-output --arg cntname "${VSI_JOB_CNT_NAME}" '.status.containerStatuses[] | select(.name == $cntname).state | keys[0]') | ||
if [ "$cntStatus" = "terminated" ]; then | ||
echo "=> job container terminated: send signal" | ||
touch /opt/talend/tvsi/vault-sidecars-signal-terminate | ||
exit 0 | ||
fi | ||
sleep 2 | ||
done | ||
volumeMounts: | ||
# Mount path used by injected sidecars to share data | ||
- name: tvsi-shared | ||
mountPath: /opt/talend/tvsi | ||
# The name's value will be overridden by the webhook | ||
- name: K8S_SA_SECRETS_VOL_NAME | ||
mountPath: /var/run/secrets/kubernetes.io/serviceaccount | ||
readOnly: true | ||
{{- if .Values.injectconfig.jobbabysitter.resources }} | ||
resources: | ||
{{ toYaml .Values.injectconfig.jobbabysitter.resources | indent 6 }} | ||
{{- end }} | ||
- name: tvsi-vault-agent | ||
image: {{ include "talend-vault-sidecar-injector.injectconfig.vault.image" .Values }} | ||
imagePullPolicy: {{ .Values.injectconfig.vault.image.pullPolicy }} | ||
env: | ||
- name: SKIP_SETCAP | ||
value: "true" | ||
- name: VAULT_ADDR | ||
value: {{ required "Vault server's address must be specified" .Values.vault.addr | quote }} | ||
# env var set by webhook | ||
- name: VSI_JOB_WORKLOAD | ||
value: "false" | ||
# env var set by webhook | ||
- name: VSI_PROXY_CONFIG_PLACEHOLDER | ||
value: "" | ||
# env var set by webhook | ||
- name: VSI_SECRETS_TEMPLATES_PLACEHOLDER | ||
value: "" | ||
# env var set by webhook | ||
- name: VSI_VAULT_AUTH_METHOD | ||
value: "kubernetes" | ||
# env var set by webhook | ||
- name: VSI_VAULT_ROLE | ||
value: "" | ||
command: | ||
- "sh" | ||
- "-c" | ||
- | | ||
if [ "${VSI_VAULT_AUTH_METHOD}" = "kubernetes" ]; then | ||
cat <<EOF > vault-agent-config.hcl | ||
pid_file = "/home/vault/pidfile" | ||
auto_auth { | ||
method "kubernetes" { | ||
mount_path = "auth/{{ .Values.vault.authMethods.kubernetes.path }}" | ||
config = { | ||
role = "${VSI_VAULT_ROLE}" | ||
token_path = "/var/run/secrets/talend/vault-sidecar-injector/serviceaccount/token" | ||
} | ||
} | ||
sink "file" { | ||
config = { | ||
path = "/home/vault/.vault-token" | ||
} | ||
} | ||
} | ||
${VSI_PROXY_CONFIG_PLACEHOLDER} | ||
${VSI_SECRETS_TEMPLATES_PLACEHOLDER} | ||
EOF | ||
elif [ "${VSI_VAULT_AUTH_METHOD}" = "approle" ]; then | ||
cat <<EOF > vault-agent-config.hcl | ||
pid_file = "/home/vault/pidfile" | ||
auto_auth { | ||
method "approle" { | ||
mount_path = "auth/{{ .Values.vault.authMethods.approle.path }}" | ||
config = { | ||
role_id_file_path = "/opt/talend/secrets/{{ .Values.vault.authMethods.approle.roleid_filename }}" | ||
secret_id_file_path = "/opt/talend/secrets/{{ .Values.vault.authMethods.approle.secretid_filename }}" | ||
} | ||
} | ||
sink "file" { | ||
config = { | ||
path = "/home/vault/.vault-token" | ||
} | ||
} | ||
} | ||
${VSI_PROXY_CONFIG_PLACEHOLDER} | ||
${VSI_SECRETS_TEMPLATES_PLACEHOLDER} | ||
EOF | ||
else | ||
echo "Unsupported Vault Auth Method: ${VSI_VAULT_AUTH_METHOD}" | ||
exit 1 | ||
fi | ||
if [ "${VSI_JOB_WORKLOAD}" = "true" ]; then | ||
docker-entrypoint.sh agent -config=vault-agent-config.hcl {{ include "talend-vault-sidecar-injector.vault.cert.skip.verify" .Values }} -log-level={{- .Values.injectconfig.vault.loglevel }} & | ||
while true; do | ||
if [ -f "/opt/talend/tvsi/vault-sidecars-signal-terminate" ]; then | ||
echo "=> exit (signal received)" | ||
export VAULT_TOKEN=$(cat /home/vault/.vault-token); | ||
vault token revoke {{ include "talend-vault-sidecar-injector.vault.cert.skip.verify" .Values }} -self; | ||
exit 0 | ||
fi | ||
sleep 2 | ||
done | ||
else | ||
docker-entrypoint.sh agent -config=vault-agent-config.hcl {{ include "talend-vault-sidecar-injector.vault.cert.skip.verify" .Values }} -log-level={{- .Values.injectconfig.vault.loglevel }} | ||
fi | ||
lifecycle: | ||
preStop: | ||
exec: | ||
command: | ||
- "sh" | ||
- "-c" | ||
- > | ||
export VAULT_TOKEN=$(cat /home/vault/.vault-token); | ||
vault token revoke {{ include "talend-vault-sidecar-injector.vault.cert.skip.verify" .Values }} -self; | ||
volumeMounts: | ||
# Mount path used by injected sidecars to share data | ||
- name: tvsi-shared | ||
mountPath: /opt/talend/tvsi | ||
# Mount path used to share secrets. The associated volume is expected to be defined in application's manifest but in case it is not, | ||
# a default 'secrets' volume will be injected in the requesting pod (see definition below) so that mutation process does not fail. | ||
- name: secrets | ||
mountPath: /opt/talend/secrets | ||
# The name's value will be overridden by the webhook to point to container's service account volume to use for Vault authentication. | ||
- name: TVSI_SA_SECRETS_VOL_NAME | ||
mountPath: /var/run/secrets/talend/vault-sidecar-injector/serviceaccount | ||
readOnly: true | ||
{{- if .Values.injectconfig.vault.resources }} | ||
resources: | ||
{{ toYaml .Values.injectconfig.vault.resources | indent 6 }} | ||
{{- end }} | ||
volumes: | ||
- name: tvsi-shared | ||
emptyDir: | ||
medium: Memory | ||
# Note: if 'secrets' volume is defined in pod's manifest then it will be considered instead of the default definition below | ||
- name: secrets | ||
emptyDir: | ||
medium: Memory |
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,6 @@ | ||
postStart: | ||
exec: | ||
command: | ||
- "sh" | ||
- "-c" | ||
- cat <VSI_SECRETS_VOL_MOUNTPATH>/* >/dev/null 2>&1 |
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 @@ | ||
cache { | ||
use_auto_auth_token = true | ||
} | ||
|
||
listener "tcp" { | ||
address = "127.0.0.1:<VSI_PROXY_PORT>" | ||
tls_disable = true | ||
} |
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,11 @@ | ||
template { | ||
destination = "/opt/talend/secrets/<VSI_SECRETS_DESTINATION>" | ||
contents = <<EOH | ||
<VSI_SECRETS_TEMPLATE_CONTENT> | ||
EOH | ||
command = "<VSI_SECRETS_TEMPLATE_COMMAND_TO_RUN>" | ||
wait { | ||
min = "1s" | ||
max = "2s" | ||
} | ||
} |
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,3 @@ | ||
{{`{{ with secret "<VSI_SECRETS_VAULT_SECRETS_PATH>" }}{{ range $k, $v := .Data }} | ||
{{ $k }}={{ $v }} | ||
{{ end }}{{ 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Thank you for installing {{ .Chart.Name }}. | ||
|
||
Your release is named {{ .Release.Name }}. | ||
|
||
===== | ||
To get status: | ||
$ helm status {{ .Release.Name }} | ||
|
||
To uninstall: | ||
# Using Helm 2 | ||
$ helm delete --purge {{ .Release.Name }} | ||
|
||
# Using Helm 3 | ||
$ helm delete {{ .Release.Name }} -n {{ .Release.Namespace }} | ||
===== |
Oops, something went wrong.