Skip to content

Commit

Permalink
Add certgenerator affinity (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhoherd committed May 19, 2023
1 parent 971433b commit 2f27575
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
1 change: 1 addition & 0 deletions templates/generate-ssl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ spec:
component: pgbouncer
release: {{ .Release.Name }}
spec:
affinity: {{- toYaml .Values.certgenerator.affinity | nindent 10 }}
{{- if or .Values.airflow.registry.secretName .Values.airflow.registry.connection }}
imagePullSecrets:
- name: {{ template "astro.registry_secret" . }}
Expand Down
47 changes: 43 additions & 4 deletions tests/chart_tests/test_pgbouncer_certgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_pgbouncer_certgenerator_with_sslmode_enabled(self, kube_version):
assert "Role" == jmespath.search("kind", docs[1])
assert expected_rbac in docs[1]["rules"]
assert "RoleBinding" == jmespath.search("kind", docs[2])
assert docs[3]["spec"]["template"]["spec"]["affinity"] == {}

def test_pgbouncer_certgenerator_with_custom_registry_secret(self, kube_version):
"""Test pgbouncer certgenerator sslmode opts result."""
Expand All @@ -54,7 +55,8 @@ def test_pgbouncer_certgenerator_with_custom_registry_secret(self, kube_version)
]

def test_pgbouncer_certgenerator_pgbouncerssl_extraannotations(self, kube_version):
"""Test that pgbouncerssl extraAnnotations correctly inserts the annotations."""
"""Test that certgenerator.extraAnnotations correctly inserts the annotations."""
extraAnnotations = {"test": "test"}
docs = render_chart(
kube_version=kube_version,
values={
Expand All @@ -65,12 +67,49 @@ def test_pgbouncer_certgenerator_pgbouncerssl_extraannotations(self, kube_versio
}
},
"certgenerator": {
"extraAnnotations": {"test": "test"},
"extraAnnotations": extraAnnotations,
},
},
show_only="templates/generate-ssl.yaml",
)
assert len(docs) == 4
assert docs[3]["spec"]["template"]["metadata"]["annotations"] == {
"test": "test"
assert (
docs[3]["spec"]["template"]["metadata"]["annotations"] == extraAnnotations
)

def test_pgbouncer_certgenerator_pgbouncerssl_affinity(self, kube_version):
"""Test that certgenerator.affinity correctly inserts the affinity."""
affinity = {
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [
{
"matchExpressions": [
{
"key": "foo",
"operator": "In",
"values": ["bar", "baz"],
}
]
}
]
}
}
}
docs = render_chart(
kube_version=kube_version,
values={
"airflow": {
"pgbouncer": {
"enabled": True,
"sslmode": "require",
}
},
"certgenerator": {
"affinity": affinity,
},
},
show_only="templates/generate-ssl.yaml",
)
assert len(docs) == 4
assert docs[3]["spec"]["template"]["spec"]["affinity"] == affinity
1 change: 1 addition & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -551,3 +551,4 @@ gitSyncRelay:

certgenerator:
extraAnnotations: {}
affinity: {}

0 comments on commit 2f27575

Please sign in to comment.