I have a git hub workflow which builds an image and pushers to gcr container as below
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v2
- uses: 'google-github-actions/auth@v1'
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}
export_default_credentials: true
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Configure Docker
run: gcloud auth configure-docker --quiet
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Build Docker image in prod
run: docker build . --tag gcr.io/${{ secrets.GCP_PROJECT_ID }}/pythonapp:latest
# Generates an execution plan for Terraform
- name: Push Docker image in prod
run: docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/pythonapp:latest
as u see everytime it builds an image with latest tag.
Now i have the deployment yaml file as below
spec:
replicas: 1
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: gcr.io/projectid/pythonapp:latest
ports:
- containerPort: 5000
imagePullPolicy: Always
However the code doesnt get updated in the deployment automatically when a new image with 'latest' tage is pushed.
I have to do
kubectl delete -f app.yaml
kubectl create -f app.yaml
for the changes to take into effect. Is there any other things to be taken care so that it gets updated automatically when a new image is found?