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
a072941
commit 66b5514
Showing
30 changed files
with
999 additions
and
426 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
VERSION:=4.1.0 | ||
VERSION:=5.0.0 | ||
|
||
OWNER:=Talend | ||
REPO:=vault-sidecar-injector | ||
|
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: 2.1.0 | ||
version: 3.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: 4.1.0 | ||
appVersion: 5.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
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,80 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: job-sa | ||
namespace: default | ||
--- | ||
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: job-pod-status | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods"] | ||
verbs: ["get"] | ||
--- | ||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: job-pod-status | ||
subjects: | ||
- kind: ServiceAccount | ||
name: job-sa | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: job-pod-status | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: test-app-job-proxy | ||
namespace: default | ||
spec: | ||
backoffLimit: 1 | ||
template: | ||
metadata: | ||
annotations: | ||
sidecar.vault.talend.org/inject: "true" | ||
sidecar.vault.talend.org/mode: "proxy" # Enable only 'proxy' mode | ||
# Vault Sidecar Injector receive the pod spec: don't know whether it is a job or a deployment. Need annotation below. | ||
sidecar.vault.talend.org/workload: "job" | ||
labels: | ||
com.talend.application: test | ||
spec: | ||
restartPolicy: Never | ||
# custom serviceAccountName with role allowing to perform GET on pods (needed to poll for job's pod status) | ||
serviceAccountName: job-sa | ||
containers: | ||
- name: test-app-job-proxy-container | ||
image: everpeace/curl-jq | ||
command: | ||
- "sh" | ||
- "-c" | ||
- | | ||
set -e | ||
echo "Wait a while to make sure Vault Agent is started and authenticated..." | ||
sleep 10 | ||
echo "Job started" | ||
echo "Now using Vault Agent as a proxy to leverage Encryption as a Service feature" | ||
echo "Advantage: you do not need to deal with any Vault tokens and you just have to send requests to the local Vault Agent sidecar (available at 127.0.0.1) that will then forward everything to Vault server." | ||
echo | ||
plaintext="Secret data to protect" | ||
echo "Data that is going to be ciphered and deciphered: $plaintext" | ||
echo | ||
b64Plaintext=$(echo "$plaintext" | base64) | ||
ciphertext=$(curl -s -X POST --data "{\"plaintext\": \"$b64Plaintext\"}" http://127.0.0.1:8200/v1/transit/encrypt/test-key | jq --raw-output .data.ciphertext) | ||
echo "Ciphertext" | ||
echo "==========" | ||
echo "$ciphertext" | ||
echo | ||
cleartext=$(curl -s -X POST --data "{\"ciphertext\": \"$ciphertext\"}" http://127.0.0.1:8200/v1/transit/decrypt/test-key | jq --raw-output .data.plaintext) | ||
echo "Cleartext" | ||
echo "==========" | ||
echo "$cleartext" | base64 -d | ||
echo | ||
echo "Job stopped" | ||
# Note in this sample we do not add 'secrets' volume definition as we only asked for the 'proxy' mode. |
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,94 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: job-sa | ||
namespace: default | ||
--- | ||
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: job-pod-status | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["pods"] | ||
verbs: ["get"] | ||
--- | ||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: job-pod-status | ||
subjects: | ||
- kind: ServiceAccount | ||
name: job-sa | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: job-pod-status | ||
--- | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: test-app-job-secrets-proxy | ||
namespace: default | ||
spec: | ||
backoffLimit: 1 | ||
template: | ||
metadata: | ||
annotations: | ||
sidecar.vault.talend.org/inject: "true" | ||
sidecar.vault.talend.org/mode: "secrets,proxy" # Enable both 'secrets' and 'proxy' modes | ||
sidecar.vault.talend.org/proxy-port: "9999" # Override default proxy port value (8200) | ||
# Vault Sidecar Injector receive the pod spec: don't know whether it is a job or a deployment. Need annotation below. | ||
sidecar.vault.talend.org/workload: "job" | ||
labels: | ||
com.talend.application: test | ||
com.talend.service: test-app-svc | ||
spec: | ||
restartPolicy: Never | ||
# custom serviceAccountName with role allowing to perform GET on pods (needed to poll for job's pod status) | ||
serviceAccountName: job-sa | ||
containers: | ||
- name: test-app-job-secrets-proxy-container | ||
image: everpeace/curl-jq | ||
command: | ||
- "sh" | ||
- "-c" | ||
- | | ||
set -e | ||
while true; do | ||
echo "Wait for secrets file before running job..." | ||
if [ -f "/opt/talend/secrets/secrets.properties" ]; then | ||
echo "Secrets available" | ||
break | ||
fi | ||
sleep 2 | ||
done | ||
echo "Job started" | ||
echo "Now using Vault Agent as a proxy to leverage Encryption as a Service feature (will encrypt and decrypt our secrets here)" | ||
echo "Advantage: you do not need to deal with any Vault tokens and you just have to send requests to the local Vault Agent sidecar (available at 127.0.0.1) that will then forward everything to Vault server." | ||
echo | ||
plaintext=$(cat /opt/talend/secrets/secrets.properties | grep SECRET1) | ||
echo "Data that is going to be ciphered and deciphered: $plaintext" | ||
echo | ||
b64Plaintext=$(echo "$plaintext" | base64) | ||
ciphertext=$(curl -s -X POST --data "{\"plaintext\": \"$b64Plaintext\"}" http://127.0.0.1:9999/v1/transit/encrypt/test-key | jq --raw-output .data.ciphertext) | ||
echo "Ciphertext" | ||
echo "==========" | ||
echo "$ciphertext" | ||
echo | ||
cleartext=$(curl -s -X POST --data "{\"ciphertext\": \"$ciphertext\"}" http://127.0.0.1:9999/v1/transit/decrypt/test-key | jq --raw-output .data.plaintext) | ||
echo "Cleartext" | ||
echo "==========" | ||
echo "$cleartext" | base64 -d | ||
echo | ||
echo "Job stopped" | ||
volumeMounts: | ||
- name: secrets | ||
mountPath: /opt/talend/secrets | ||
volumes: | ||
- 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
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 |
---|---|---|
@@ -1,7 +1,14 @@ | ||
# To read secrets | ||
path "secret/test/test-app-svc" { | ||
capabilities = ["read"] | ||
} | ||
|
||
# To list secrets | ||
path "secret/test/test-app-svc/" { | ||
capabilities = ["list"] | ||
} | ||
|
||
# Manage the transit secrets engine | ||
path "transit/*" { | ||
capabilities = [ "create", "read", "update", "delete", "list" ] | ||
} |
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,9 @@ | ||
# To read secrets | ||
path "secret/test2/test-app2-svc" { | ||
capabilities = ["read"] | ||
} | ||
|
||
# To list secrets | ||
path "secret/test2/test-app2-svc/" { | ||
capabilities = ["list"] | ||
} |
Oops, something went wrong.