This is an automated email from the ASF dual-hosted git repository.
jedcunningham pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 758530d Chart: Make PgBouncer cmd/args configurable (#18910)
758530d is described below
commit 758530d7ca39311d3c67939defefb983f1907cd0
Author: Jed Cunningham <[email protected]>
AuthorDate: Tue Oct 12 12:03:31 2021 -0600
Chart: Make PgBouncer cmd/args configurable (#18910)
---
.../templates/pgbouncer/pgbouncer-deployment.yaml | 11 +++---
chart/tests/test_cleanup_pods.py | 2 +-
chart/tests/test_pgbouncer.py | 43 ++++++++++++++++++++++
chart/values.schema.json | 27 ++++++++++++++
chart/values.yaml | 4 ++
5 files changed, 81 insertions(+), 6 deletions(-)
diff --git a/chart/templates/pgbouncer/pgbouncer-deployment.yaml
b/chart/templates/pgbouncer/pgbouncer-deployment.yaml
index d5c489c..79a87f3 100644
--- a/chart/templates/pgbouncer/pgbouncer-deployment.yaml
+++ b/chart/templates/pgbouncer/pgbouncer-deployment.yaml
@@ -77,11 +77,12 @@ spec:
- name: pgbouncer
image: {{ template "pgbouncer_image" . }}
imagePullPolicy: {{ .Values.images.pgbouncer.pullPolicy }}
- command:
- - pgbouncer
- - -u
- - nobody
- - /etc/pgbouncer/pgbouncer.ini
+ {{- if .Values.pgbouncer.command }}
+ command: {{ tpl (toYaml .Values.pgbouncer.command) . | nindent 12 }}
+ {{- end }}
+ {{- if .Values.pgbouncer.args }}
+ args: {{ tpl (toYaml .Values.pgbouncer.args) . | nindent 12 }}
+ {{- end }}
resources:
{{ toYaml .Values.pgbouncer.resources | indent 12 }}
ports:
diff --git a/chart/tests/test_cleanup_pods.py b/chart/tests/test_cleanup_pods.py
index e91eb6f..7727e9f 100644
--- a/chart/tests/test_cleanup_pods.py
+++ b/chart/tests/test_cleanup_pods.py
@@ -142,7 +142,7 @@ class CleanupPodsTest(unittest.TestCase):
)
assert args ==
jmespath.search("spec.jobTemplate.spec.template.spec.containers[0].args",
docs[0])
- def test_log_groomer_command_and_args_overrides_are_templated(self):
+ def test_command_and_args_overrides_are_templated(self):
docs = render_chart(
values={
"cleanup": {
diff --git a/chart/tests/test_pgbouncer.py b/chart/tests/test_pgbouncer.py
index a24a388..98f7ae9 100644
--- a/chart/tests/test_pgbouncer.py
+++ b/chart/tests/test_pgbouncer.py
@@ -223,6 +223,49 @@ class PgbouncerTest(unittest.TestCase):
},
} == jmespath.search("spec.template.spec.containers[1].resources",
docs[0])
+ def test_default_command_and_args(self):
+ docs = render_chart(
+ values={"pgbouncer": {"enabled": True}},
+ show_only=["templates/pgbouncer/pgbouncer-deployment.yaml"],
+ )
+
+ assert ["pgbouncer", "-u", "nobody", "/etc/pgbouncer/pgbouncer.ini"]
== jmespath.search(
+ "spec.template.spec.containers[0].command", docs[0]
+ )
+ assert jmespath.search("spec.template.spec.containers[0].args",
docs[0]) is None
+
+ @parameterized.expand(
+ [
+ (None, None),
+ (None, ["custom", "args"]),
+ (["custom", "command"], None),
+ (["custom", "command"], ["custom", "args"]),
+ ]
+ )
+ def test_command_and_args_overrides(self, command, args):
+ docs = render_chart(
+ values={"pgbouncer": {"enabled": True, "command": command, "args":
args}},
+ show_only=["templates/pgbouncer/pgbouncer-deployment.yaml"],
+ )
+
+ assert command ==
jmespath.search("spec.template.spec.containers[0].command", docs[0])
+ assert args ==
jmespath.search("spec.template.spec.containers[0].args", docs[0])
+
+ def test_command_and_args_overrides_are_templated(self):
+ docs = render_chart(
+ values={
+ "pgbouncer": {
+ "enabled": True,
+ "command": ["{{ .Release.Name }}"],
+ "args": ["{{ .Release.Service }}"],
+ }
+ },
+ show_only=["templates/pgbouncer/pgbouncer-deployment.yaml"],
+ )
+
+ assert ["RELEASE-NAME"] ==
jmespath.search("spec.template.spec.containers[0].command", docs[0])
+ assert ["Helm"] ==
jmespath.search("spec.template.spec.containers[0].args", docs[0])
+
class PgbouncerConfigTest(unittest.TestCase):
def test_config_not_created_by_default(self):
diff --git a/chart/values.schema.json b/chart/values.schema.json
index 927b2a4..5b0ceda 100644
--- a/chart/values.schema.json
+++ b/chart/values.schema.json
@@ -2431,6 +2431,33 @@
"x-docsSection": "Common",
"default": false
},
+ "command": {
+ "description": "Command to use for PgBouncer (templated).",
+ "type": [
+ "array",
+ "null"
+ ],
+ "items": {
+ "type": "string"
+ },
+ "default": [
+ "pgbouncer",
+ "-u",
+ "nobody",
+ "/etc/pgbouncer/pgbouncer.ini"
+ ]
+ },
+ "args": {
+ "description": "Args to use for PgBouncer (templated).",
+ "type": [
+ "array",
+ "null"
+ ],
+ "items": {
+ "type": "string"
+ },
+ "default": null
+ },
"extraNetworkPolicies": {
"description": "Additional NetworkPolicies as needed.",
"type": "array",
diff --git a/chart/values.yaml b/chart/values.yaml
index df01c3a..423dd84 100644
--- a/chart/values.yaml
+++ b/chart/values.yaml
@@ -969,6 +969,10 @@ statsd:
pgbouncer:
# Enable PgBouncer
enabled: false
+ # Command to use for PgBouncer(templated).
+ command: ["pgbouncer", "-u", "nobody", "/etc/pgbouncer/pgbouncer.ini"]
+ # Args to use for PgBouncer(templated).
+ args: ~
# Create ServiceAccount
serviceAccount: