Open kameshsampath opened 4 years ago
Take an example of running psql to load DB schema:
template:
spec:
volumes:
- name: leaderboard-schema
configMap:
name: leaderboard-schema
items:
- key: schema.sql
path: schemas/schema.sql
containers:
- name: pgsql12-client
image: quay.io/rhdevelopers/openshift-pgsql12-primary:centos7-clients
imagePullPolicy: Always
env:
- name: PGHOST
value: postgresql
- name: PGDATABASE
valueFrom:
secretKeyRef:
name: openshift-pgsql12-primary-secret
key: database-db
- name: PGUSER
valueFrom:
secretKeyRef:
name: openshift-pgsql12-primary-secret
key: database-username
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: openshift-pgsql12-primary-secret
key: database-username-password
command: ["/usr/pgsql-12/bin/psql"]
args:
[
"--dbname=$(PGDATABASE)",
"--file=/opt/sql/schemas/schema.sql",
"--no-password",
]
volumeMounts:
- name: leaderboard-schema
mountPath: /opt/sql
for variable PGDATABASE
to be interpolated in command args we need to use the syntax "--dbname=$(PGDATABASE)"
Improve the set env section with examples by adding examples to show variable interpolation in the
command
andargs
attributes of the deployment YAML. The args incommand
andargs
need to follow the variable substitution pattern like$(ENV_VAR_NAME)
.I feel we need to call this out in the tutorial as developers will follow the natural instinct of using
$ENV_VAR_NAME
pattern.