Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving set env section #12

Open
kameshsampath opened this issue Apr 15, 2020 · 1 comment
Open

Improving set env section #12

kameshsampath opened this issue Apr 15, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@kameshsampath
Copy link
Contributor

Improve the set env section with examples by adding examples to show variable interpolation in the command and args attributes of the deployment YAML. The args in command and args 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.

@kameshsampath kameshsampath changed the title Imporving set env section Improving set env section Apr 15, 2020
@kameshsampath
Copy link
Contributor Author

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)"

@sebastienblanc sebastienblanc added the enhancement New feature or request label Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants