Created
September 30, 2024 15:10
-
-
Save brianpursley/65411bbd16b10c3c60f0af5b08efbe80 to your computer and use it in GitHub Desktop.
Run Postgres in Kubernetes with a self-signed certificate (for testing purposes)
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
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: pg | |
spec: | |
initContainers: | |
- name: generate-cert | |
image: postgres:16 | |
command: ["sh", "-c", " | |
openssl req -x509 -nodes -newkey rsa:4096 -keyout /cert/ssl.key -out /cert/ssl.crt -days 365 -subj '/CN=example.com'; | |
chown postgres:postgres /cert/*; | |
chmod 600 /cert/ssl.key; | |
chmod 644 /cert/ssl.crt; | |
"] | |
volumeMounts: | |
- name: cert | |
mountPath: /cert | |
containers: | |
- name: pg | |
image: postgres:16 | |
args: ["-c", "ssl=on", "-c", "ssl_cert_file=/cert/ssl.crt", "-c", "ssl_key_file=/cert/ssl.key"] | |
env: | |
- name: POSTGRES_PASSWORD | |
value: test1234 | |
volumeMounts: | |
- name: cert | |
mountPath: /cert | |
volumes: | |
- name: cert | |
emptyDir: {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment