init
This commit is contained in:
53
README.md
Normal file
53
README.md
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
# Postgres for Kube
|
||||||
|
|
||||||
|
## Pre-deploy
|
||||||
|
|
||||||
|
### Secrets
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl create secret generic postgres --from-literal=POSTGRES_USER=postgres --from-literal=POSTGRES_PASSWORD=$(python -c "import secrets; print(secrets.token_urlsafe(64))")
|
||||||
|
|
||||||
|
kubectl create secret generic pgadmin --from-literal=PGADMIN_DEFAULT_EMAIL=postgres --from-literal=PGADMIN_DEFAULT_PASSWORD=$(python -c "import secrets; print(secrets.token_urlsafe(64))")
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploy Postgres
|
||||||
|
|
||||||
|
### Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
helm template postgres ./postgres | kubectl --context test-casepipeline apply -f -
|
||||||
|
```
|
||||||
|
|
||||||
|
### Prod
|
||||||
|
|
||||||
|
```bash
|
||||||
|
helm template postgres ./postgres | kubectl --context prod-casepipeline apply -f -
|
||||||
|
```
|
||||||
|
|
||||||
|
### Get Password
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl get secret postgres --output=jsonpath='{.data.POSTGRES_PASSWORD}' | base64 --decode
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploy PG Admin
|
||||||
|
|
||||||
|
### Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
prefix=<custom prefix>
|
||||||
|
helm template pgadmin ./pgadmin --set host=$prefix-pgadmin.apps-test.aws.e1.nwie.net | kubectl --context test-casepipeline apply -f -
|
||||||
|
```
|
||||||
|
|
||||||
|
### Prod
|
||||||
|
|
||||||
|
```bash
|
||||||
|
prefix=<custom prefix>
|
||||||
|
helm template pgadmin ./pgadmin --set host=$prefix-pgadmin.apps.aws.e1.nwie.net | kubectl --context prod-casepipeline apply -f -
|
||||||
|
```
|
||||||
|
|
||||||
|
### Login
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl get secret pgadmin --output=jsonpath='{.data.PGADMIN_DEFAULT_PASSWORD}' | base64 --decode
|
||||||
|
```
|
||||||
24
docker-compose.yaml
Normal file
24
docker-compose.yaml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
version: '3.5'
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:12
|
||||||
|
volumes:
|
||||||
|
- data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
|
||||||
|
pgadmin:
|
||||||
|
image: dpage/pgadmin4:4
|
||||||
|
ports:
|
||||||
|
- 8090:80
|
||||||
|
volumes:
|
||||||
|
- pgadmin:/var/lib/pgadmin
|
||||||
|
environment:
|
||||||
|
PGADMIN_DEFAULT_EMAIL: postgres
|
||||||
|
PGADMIN_DEFAULT_PASSWORD: postgres
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
data:
|
||||||
|
pgadmin:
|
||||||
23
pgadmin/.helmignore
Normal file
23
pgadmin/.helmignore
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Patterns to ignore when building packages.
|
||||||
|
# This supports shell glob matching, relative path matching, and
|
||||||
|
# negation (prefixed with !). Only one pattern per line.
|
||||||
|
.DS_Store
|
||||||
|
# Common VCS dirs
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
.bzr/
|
||||||
|
.bzrignore
|
||||||
|
.hg/
|
||||||
|
.hgignore
|
||||||
|
.svn/
|
||||||
|
# Common backup files
|
||||||
|
*.swp
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
*.orig
|
||||||
|
*~
|
||||||
|
# Various IDEs
|
||||||
|
.project
|
||||||
|
.idea/
|
||||||
|
*.tmproj
|
||||||
|
.vscode/
|
||||||
23
pgadmin/Chart.yaml
Normal file
23
pgadmin/Chart.yaml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: pgadmin
|
||||||
|
description: A Helm chart for Kubernetes
|
||||||
|
|
||||||
|
# A chart can be either an 'application' or a 'library' chart.
|
||||||
|
#
|
||||||
|
# Application charts are a collection of templates that can be packaged into versioned archives
|
||||||
|
# to be deployed.
|
||||||
|
#
|
||||||
|
# Library charts provide useful utilities or functions for the chart developer. They're included as
|
||||||
|
# a dependency of application charts to inject those utilities and functions into the rendering
|
||||||
|
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
||||||
|
type: application
|
||||||
|
|
||||||
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
|
# to the chart and its templates, including the app version.
|
||||||
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
|
version: 0.1.0
|
||||||
|
|
||||||
|
# This is the version number of the application being deployed. This version number should be
|
||||||
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
|
appVersion: 1.16.0
|
||||||
35
pgadmin/templates/deploy.yaml
Normal file
35
pgadmin/templates/deploy.yaml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ .Release.Name }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: {{ .Values.image }}:{{ .Values.tag }}
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: pgadmin
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: "1Gi"
|
||||||
|
cpu: "1"
|
||||||
|
requests:
|
||||||
|
memory: "1Mi"
|
||||||
|
cpu: "1m"
|
||||||
|
volumeMounts:
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/pgadmin
|
||||||
|
volumes:
|
||||||
|
- name: data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: {{ .Release.Name }}
|
||||||
17
pgadmin/templates/ingress.yaml
Normal file
17
pgadmin/templates/ingress.yaml
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
annotations:
|
||||||
|
kubernetes.io/ingress.class: default
|
||||||
|
spec:
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- {{ .Values.host }}
|
||||||
|
rules:
|
||||||
|
- host: {{ .Values.host }}
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- backend:
|
||||||
|
serviceName: {{ .Release.Name }}
|
||||||
|
servicePort: 80
|
||||||
11
pgadmin/templates/pvc.yaml
Normal file
11
pgadmin/templates/pvc.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
storageClassName: efs-gp
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteMany
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 64Gi
|
||||||
15
pgadmin/templates/service.yaml
Normal file
15
pgadmin/templates/service.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ .Release.Name }}
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 80
|
||||||
|
protocol: TCP
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
targetPort: 80
|
||||||
|
selector:
|
||||||
|
app: {{ .Release.Name }} # This selects the pod(s) that match the selector
|
||||||
|
type: ClusterIP
|
||||||
2
pgadmin/values.yaml
Normal file
2
pgadmin/values.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
image: dpage/pgadmin4
|
||||||
|
tag: 4.22
|
||||||
23
postgres/.helmignore
Normal file
23
postgres/.helmignore
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Patterns to ignore when building packages.
|
||||||
|
# This supports shell glob matching, relative path matching, and
|
||||||
|
# negation (prefixed with !). Only one pattern per line.
|
||||||
|
.DS_Store
|
||||||
|
# Common VCS dirs
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
.bzr/
|
||||||
|
.bzrignore
|
||||||
|
.hg/
|
||||||
|
.hgignore
|
||||||
|
.svn/
|
||||||
|
# Common backup files
|
||||||
|
*.swp
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
*.orig
|
||||||
|
*~
|
||||||
|
# Various IDEs
|
||||||
|
.project
|
||||||
|
.idea/
|
||||||
|
*.tmproj
|
||||||
|
.vscode/
|
||||||
23
postgres/Chart.yaml
Normal file
23
postgres/Chart.yaml
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
apiVersion: v2
|
||||||
|
name: helm
|
||||||
|
description: A Helm chart for Kubernetes
|
||||||
|
|
||||||
|
# A chart can be either an 'application' or a 'library' chart.
|
||||||
|
#
|
||||||
|
# Application charts are a collection of templates that can be packaged into versioned archives
|
||||||
|
# to be deployed.
|
||||||
|
#
|
||||||
|
# Library charts provide useful utilities or functions for the chart developer. They're included as
|
||||||
|
# a dependency of application charts to inject those utilities and functions into the rendering
|
||||||
|
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
||||||
|
type: application
|
||||||
|
|
||||||
|
# This is the chart version. This version number should be incremented each time you make changes
|
||||||
|
# to the chart and its templates, including the app version.
|
||||||
|
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||||
|
version: 0.1.0
|
||||||
|
|
||||||
|
# This is the version number of the application being deployed. This version number should be
|
||||||
|
# incremented each time you make changes to the application. Versions are not expected to
|
||||||
|
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||||
|
appVersion: 1.16.0
|
||||||
35
postgres/templates/deploy.yaml
Normal file
35
postgres/templates/deploy.yaml
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ .Release.Name }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: {{ .Values.image }}:{{ .Values.tag }}
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
ports:
|
||||||
|
- containerPort: 5432
|
||||||
|
envFrom:
|
||||||
|
- secretRef:
|
||||||
|
name: postgres
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: "4Gi"
|
||||||
|
cpu: "4"
|
||||||
|
requests:
|
||||||
|
memory: "1Mi"
|
||||||
|
cpu: "1m"
|
||||||
|
volumeMounts:
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
|
volumes:
|
||||||
|
- name: data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: {{ .Release.Name }}
|
||||||
11
postgres/templates/pvc.yaml
Normal file
11
postgres/templates/pvc.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
storageClassName: efs-gp
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteMany
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 64Gi
|
||||||
15
postgres/templates/service.yaml
Normal file
15
postgres/templates/service.yaml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ .Release.Name }}
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 5432
|
||||||
|
protocol: TCP
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
targetPort: 5432
|
||||||
|
selector:
|
||||||
|
app: {{ .Release.Name }} # This selects the pod(s) that match the selector
|
||||||
|
type: ClusterIP
|
||||||
2
postgres/values.yaml
Normal file
2
postgres/values.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
image: postgres
|
||||||
|
tag: 12.3-alpine
|
||||||
Reference in New Issue
Block a user