<p>I'm trying to run the following command:</p>

<pre><code>npx sequelize-cli db:migrate
</code></pre>

<p><code>sequelize-cli</code> uses a <code>./config/config.js</code> file that contains the following:</p>

<pre><code>module.exports = {
  username: process.env.PGUSER,
  host: process.env.PGHOST,
  database: process.env.PGDATABASE,
  password: process.env.PGPASSWORD,
  port: process.env.PGPORT,
};
</code></pre>

<p>If you <code>console.log()</code> all of thee <code>process.env.&lt;var&gt;</code>, it all comes back <code>undefined</code>.</p>

<p>However, if go into the <code>index.js</code> where the Express app resides and <code>console.log</code> the same thing, it comes back with the expected values.</p>

<p>I have Kubernete running with <code>skaffold.yaml</code> and <code>minikube</code> during all of this.</p>

<p>Is there a way to get this working without creating a <code>.env</code> just to run these commands?</p>

<p><strong>server-deployment.yaml</strong></p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: server-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      component: server
  template:
    metadata:
      labels:
        component: server
    spec:
      containers:
        - name: server
          image: sockpuppet/server
          ports:
            - containerPort: 5000
          env:
            - name: PGUSER
              value: postgres
            - name: PGHOST
              value: postgres-cluster-ip-service
            - name: PGPORT
              value: '5432'
            - name: PGDATABASE
              value: postgres
            - name: PGPASSWORD
              value: ''
</code></pre>

cjones
<p>Well, it isn't pretty, but this is the best I could figure out. Hopefully someone has a better answer...</p>

<p>Since this is a <code>deployment</code> that consists of three replicas, it produces three pods. Have to get the id for one first:</p>

<pre><code>kubectl get pod
</code></pre>

<p>Once I have that I can do the following:</p>

<pre><code>kubectl exec -it server-deployment-84cf685559-gwkvt -- npx sequelize-cli db:migrate
</code></pre>

<p>That works, but kind of messy.</p>

<p>Came across <a href="https://tobernguyen.com/execute-command-on-pod-of-deployment-single-command/" rel="nofollow noreferrer">this link</a> that be more efficient especially if just making an <code>alias</code>:</p>

<pre><code>kubectl exec -it $(kubectl get pods -o name | grep -m1 INSERT_DEPLOYMENT_NAME_HERE | cut -d'/' -f 2) INSERT_YOUR_COMMAND_HERE

kubectl exec -it $(kubectl get pods -o name | grep -m1 server-deployment | cut -d'/' -f 2) "npx sequelize-cli db:migrate" 
</code></pre>
