I'm trying to make kubernetes deployment like this
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-claim
labels:
app: data-db
tier: database
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
---
apiVersion: v1
kind: ConfigMap
metadata:
name: data-initdb-config
data:
init.sql:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: data-db
labels:
app: data-db
tier: database
spec:
selector:
matchLabels:
app: data-db
tier: database
strategy:
type: Recreate
template:
metadata:
labels:
app: data-db
tier: database
spec:
containers:
- image: postgres:15.5
name: database
env:
- name: POSTGRES_DB
value: data
- name: POSTGRES_USER
value: user
- name: POSTGRES_PASSWORD
value: user
ports:
- containerPort: 5432
name: data-db
volumeMounts:
- name: data-db-persistent-storage
mountPath: /var/lib/postgresql/data
- name: data-db-initdb
mountPath: /docker-entrypoint-initdb.d
volumes:
- name: data-db-persistent-storage
persistentVolumeClaim:
claimName: data-claim
- name: data-db-initdb
configMap:
name: data-initdb-config
---
apiVersion: v1
kind: Service
metadata:
name: data-db-service
labels:
app: data-db
tier: database
spec:
ports:
- port: 5432
targetPort: 5432
selector:
app: data-db
tier: database
I know that if I type initial sql at init.sql, it runs and shows on the deployment db.
But the problem is that sql is so long. I tried to deploy it but it cannot handle so that long (the sql line is about 2000s.) so I need to get sql file or get other way.
And I need to make .sh start for create extension
. How should I make configmap with long .sql and .sh?