-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for pgbouncer * restart pgbouncer on config change Co-authored-by: Colin Copeland <copelco@caktusgroup.com> * support k8s_pgbouncer_replicas Co-authored-by: Ronard <ronardcaktus@users.noreply.github.com> Co-authored-by: Joel Sleppy <Jdsleppy@users.noreply.github.com> --------- Co-authored-by: Colin Copeland <copelco@caktusgroup.com> Co-authored-by: Ronard <ronardcaktus@users.noreply.github.com> Co-authored-by: Joel Sleppy <Jdsleppy@users.noreply.github.com>
- Loading branch information
1 parent
3b63855
commit 42c0168
Showing
2 changed files
with
93 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: "pgbouncer-secrets" | ||
labels: | ||
app: "pgbouncer" | ||
namespace: "{{ k8s_namespace }}" | ||
type: Opaque | ||
{% if k8s_pgbouncer_enabled %} | ||
{# fail loudly if k8s_pgbouncer_environment not defined when enabled (see defaults/main.yml) #} | ||
stringData: {{ k8s_pgbouncer_environment | to_json }} | ||
{% else %} | ||
stringData: {{ k8s_pgbouncer_environment | default({}) | to_json }} | ||
{% endif %} | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: "pgbouncer" | ||
namespace: "{{ k8s_namespace }}" | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: "pgbouncer" | ||
replicas: {{ k8s_pgbouncer_replicas }} | ||
template: | ||
metadata: | ||
labels: | ||
app: "pgbouncer" | ||
spec: | ||
affinity: | ||
podAntiAffinity: | ||
preferredDuringSchedulingIgnoredDuringExecution: | ||
- weight: 100 | ||
podAffinityTerm: | ||
labelSelector: | ||
matchExpressions: | ||
- key: app | ||
operator: In | ||
values: | ||
- pgbouncer | ||
topologyKey: kubernetes.io/hostname | ||
containers: | ||
- name: "pgbouncer" | ||
image: "{{ k8s_pgbouncer_repo }}:{{ k8s_pgbouncer_version }}" | ||
imagePullPolicy: IfNotPresent | ||
env: | ||
- name: GET_HOSTS_FROM | ||
value: dns | ||
- name: PGBOUNCER_SECRETS_HASH | ||
value: "{{ k8s_pgbouncer_environment | default({}) | to_json | hash('sha256') }}" | ||
envFrom: | ||
- secretRef: | ||
name: "pgbouncer-secrets" | ||
ports: | ||
- containerPort: 5432 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: "pgbouncer" | ||
labels: | ||
app: "pgbouncer" | ||
namespace: "{{ k8s_namespace }}" | ||
spec: | ||
type: "{{ k8s_pgbouncer_service_type }}" | ||
{% if k8s_pgbouncer_load_balancer_ip is defined %} | ||
loadBalancerIP: "{{ k8s_pgbouncer_load_balancer_ip }}" | ||
{% endif %} | ||
ports: | ||
- protocol: TCP | ||
# Where other things in the cluster should try to connect to our application | ||
port: 5432 | ||
# Where our application is listening: | ||
targetPort: 5432 | ||
selector: | ||
app: "pgbouncer" |