forked from hashicorp/vault-helm
-
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.
Support deploying multiple injector replicas with auto-TLS (hashicorp…
- Loading branch information
Showing
9 changed files
with
431 additions
and
4 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,10 @@ | ||
{{- if and (eq (.Values.injector.enabled | toString) "true" ) (eq (.Values.global.enabled | toString) "true") (eq (.Values.injector.leaderElector.enabled | toString) "true") (gt (.Values.injector.replicas | int) 1) }} | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: vault-injector-certs | ||
labels: | ||
app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- 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
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,12 @@ | ||
{{- if and (eq (.Values.injector.enabled | toString) "true" ) (eq (.Values.global.enabled | toString) "true") (eq (.Values.injector.leaderElector.enabled | toString) "true") (gt (.Values.injector.replicas | int) 1) }} | ||
# This is created here so it can be cleaned up easily, since if | ||
# the endpoint is left around the leader won't expire for about a minute. | ||
apiVersion: v1 | ||
kind: Endpoints | ||
metadata: | ||
name: {{ template "vault.fullname" . }}-agent-injector-leader | ||
labels: | ||
app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- 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,19 @@ | ||
{{- if and (eq (.Values.injector.enabled | toString) "true" ) (eq (.Values.global.enabled | toString) "true") (eq (.Values.injector.leaderElector.enabled | toString) "true") (gt (.Values.injector.replicas | int) 1) }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ template "vault.fullname" . }}-agent-injector-leader-elector-role | ||
labels: | ||
app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["endpoints", "secrets"] | ||
verbs: | ||
- "create" | ||
- "get" | ||
- "watch" | ||
- "list" | ||
- "update" | ||
{{- 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,18 @@ | ||
{{- if and (eq (.Values.injector.enabled | toString) "true" ) (eq (.Values.global.enabled | toString) "true") (eq (.Values.injector.leaderElector.enabled | toString) "true") (gt (.Values.injector.replicas | int) 1) }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ template "vault.fullname" . }}-agent-injector-leader-elector-binding | ||
labels: | ||
app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ template "vault.fullname" . }}-agent-injector-leader-elector-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "vault.fullname" . }}-agent-injector | ||
namespace: {{ .Release.Namespace }} | ||
{{- 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,46 @@ | ||
#!/usr/bin/env bats | ||
|
||
load _helpers | ||
|
||
@test "injector: testing leader elector" { | ||
cd `chart_dir` | ||
|
||
kubectl delete namespace acceptance --ignore-not-found=true | ||
kubectl create namespace acceptance | ||
kubectl config set-context --current --namespace=acceptance | ||
|
||
helm install "$(name_prefix)" \ | ||
--set="injector.replicas=3" . | ||
kubectl wait --for condition=Ready pod -l app.kubernetes.io/name=vault-agent-injector | ||
|
||
pods=($(kubectl get pods -l app.kubernetes.io/name=vault-agent-injector -o json | jq -r '.items[] | .metadata.name')) | ||
[ "${#pods[@]}" == 3 ] | ||
|
||
leader="$(echo "$(kubectl exec ${pods[0]} -c sidecar-injector -- wget --quiet --output-document - localhost:4040)" | jq -r .name)" | ||
# Check the leader name is valid - i.e. one of the 3 pods | ||
[[ " ${pods[@]} " =~ " ${leader} " ]] | ||
|
||
# Check every pod agrees on who the leader is | ||
for pod in "${pods[@]}" | ||
do | ||
pod_leader="$(echo "$(kubectl exec $pod -c sidecar-injector -- wget --quiet --output-document - localhost:4040)" | jq -r .name)" | ||
[ "${pod_leader}" == "${leader}" ] | ||
done | ||
} | ||
|
||
setup() { | ||
kubectl delete namespace acceptance --ignore-not-found=true | ||
kubectl create namespace acceptance | ||
kubectl config set-context --current --namespace=acceptance | ||
} | ||
|
||
# Clean up | ||
teardown() { | ||
if [[ ${CLEANUP:-true} == "true" ]] | ||
then | ||
echo "helm/pvc teardown" | ||
helm delete vault | ||
kubectl delete --all pvc | ||
kubectl delete namespace acceptance | ||
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
Oops, something went wrong.