Last active
January 10, 2021 17:25
-
-
Save im-infamou5/6b37b5ec9f7705a94ffebd087db079ff to your computer and use it in GitHub Desktop.
postgres gce instance creation
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
# Firstly you'll need to introduce volume as follows: | |
# gcloud compute disks create --size=10GB --zone=europe-north1-a pgdata | |
# | |
kind: PersistentVolume | |
apiVersion: v1 | |
metadata: | |
name: postgres-pv | |
labels: | |
type: local | |
app: postgres | |
spec: | |
capacity: | |
storage: 10Gi | |
storageClassName: standard | |
accessModes: | |
- ReadWriteMany | |
gcePersistentDisk: | |
pdName: pgdata | |
fsType: ext4 | |
readOnly: true | |
--- | |
kind: PersistentVolumeClaim | |
apiVersion: v1 | |
metadata: | |
name: postgres-pv-claim | |
labels: | |
app: postgres | |
spec: | |
storageClassName: standard | |
accessModes: | |
- ReadWriteMany | |
resources: | |
requests: | |
storage: 10Gi | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: postgres-config | |
labels: | |
app: postgres | |
data: | |
postgresql.conf: | | |
shared_buffers=256MB | |
postgresql.conf: | | |
max_connections=300 | |
POSTGRES_USER: user | |
POSTGRES_PASSWORD: 'password' | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: postgres | |
spec: | |
replicas: 1 | |
selector: | |
matchLabels: | |
app: postgres | |
template: | |
metadata: | |
labels: | |
app: postgres | |
spec: | |
containers: | |
- name: postgres | |
image: postgres:13-alpine | |
imagePullPolicy: "IfNotPresent" | |
ports: | |
- containerPort: 5432 | |
envFrom: | |
- configMapRef: | |
name: postgres-config | |
volumeMounts: | |
- mountPath: /data/database | |
name: postgres-pv | |
volumes: | |
- name: postgres-pv | |
persistentVolumeClaim: | |
claimName: postgres-pv-claim | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: postgres | |
labels: | |
app: postgres-default | |
spec: | |
selector: | |
app: postgres | |
type: ClusterIP | |
ports: | |
- port: 5432 | |
targetPort: 5432 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment