I want to deploy a k8s job in k8s cluster with GitHub Actions.
But there are some env variables in job.yaml
:
apiVersion: batch/v1
kind: Job
metadata:
name: pi01
spec:
template:
spec:
containers:
- name: pi01
image: xx:version
command: ["node", "schedule/schedule.js"]
env:
- name: DB_HOST
value: {{ ${{ secrets.DB_HOST }} }}
- name: DB_PORT
value: {{ ${{ secrets.DB_PORT }} }}
- name: DB_USER
value: {{ ${{ secrets.DB_USER }} }}
- name: DB_PASSWORD
value: {{ ${{ secrets.DB_PASSWORD }} }}
because those env variables are sensitive, I save them as secrets.
In GitHub Actions workflow, I don't know how to put secrets into env variables of job.yaml
.
With this command, I don't know which option I should use:
kubectl apply -f job.yaml [Options]
Could you please provide an example for me to refer?
In workflow, I used this script but I don't know how to input ${{ secrets.DB_PASSWORD }}
into YAML file:
- name: Deploy app to AKS
run: |
kubectl apply -f job.yaml