Add project files.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: init-db-config
|
||||
data:
|
||||
init-db.sh: |
|
||||
#!/bin/bash
|
||||
echo "Starting database initialization"
|
||||
|
||||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||
GRANT ALL ON SCHEMA public TO elsa;
|
||||
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO elsa;
|
||||
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO elsa;
|
||||
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public TO elsa;
|
||||
CREATE USER tracelens WITH PASSWORD 'tracelenspass';
|
||||
CREATE DATABASE tracelens;
|
||||
GRANT ALL PRIVILEGES ON DATABASE tracelens TO tracelens;
|
||||
GRANT ALL ON SCHEMA public TO tracelens;
|
||||
EOSQL
|
||||
|
||||
echo "Database initialization completed"
|
||||
@@ -0,0 +1,41 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: postgres-deployment
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: postgres
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
containers:
|
||||
- name: postgres
|
||||
imagePullPolicy: Always
|
||||
image: postgres:latest
|
||||
# command: ["-c", "max_connections=2000"]
|
||||
volumeMounts:
|
||||
- name: postgres-data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
- name: init-db
|
||||
mountPath: /docker-entrypoint-initdb.d/init-db.sh
|
||||
subPath: init-db.sh
|
||||
ports:
|
||||
- containerPort: 5432
|
||||
env:
|
||||
- name: POSTGRES_USER
|
||||
value: "elsa"
|
||||
- name: POSTGRES_PASSWORD
|
||||
value: "elsa"
|
||||
- name: POSTGRES_DB
|
||||
value: "elsa"
|
||||
|
||||
volumes:
|
||||
- name: postgres-data
|
||||
emptyDir: {}
|
||||
- name: init-db
|
||||
configMap:
|
||||
name: init-db-config
|
||||
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: postgres
|
||||
labels:
|
||||
app: postgres
|
||||
spec:
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
- port: 5432
|
||||
targetPort: 5432
|
||||
selector:
|
||||
app: postgres
|
||||
Reference in New Issue
Block a user