-
Notifications
You must be signed in to change notification settings - Fork 894
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
Support deploying multiple injector replicas with auto-TLS #436
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
eda45dc
Support multiple replicas
tomhjp 4794cc3
Add injector.leaderElector.enabled and injector.leaderElector.image c…
tomhjp 47b6a24
Small fixes, acceptance test and a few unit tests
tomhjp 9ab2221
More unit tests
tomhjp e0d2353
Update affinity test
tomhjp 6a440dc
Add helm annotations, consistent image values, wget instead of curl
tomhjp 05302b2
Add configurable value for leader elector TTL
tomhjp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | ||
jasonodonnell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this being used a few times, should we just make it a helper function?