Rollout restart a kubernetes deployment from github actions

7/3/2021

I want to rollout restart a deployment from github actions, So i do

name: DeployXXY
on:
  push:
    branches:
    - main
jobs:
  build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Docker container
  uses: docker/login-action@v1
  with:
    registry: registry.xxy.in:5000
    username: ${{ secrets.REGISTRY_USER }}
    password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Push to XXY registry
  uses: docker/build-push-action@v2
  with:
    push: true
    tags: registry.xxy.in:5000/xxy-web:latest

- name: Kubernetes context
  uses: Azure/k8s-set-context@v1
  with:
    method: kubeconfig
    kubeconfig: ${{ secrets.KUBE_CONFIG }}
    namespace: xxy-namespace
    
- name: Deploy
  run: kubectl rollout restart deployment xxy-deployment

But, this always throw error

Error from server (NotFound): deployments.apps "xxy-deployment" not found

The deployment is live on server and i am able to restart deployment from my local.

-- Aishwarya
github-actions
kubernetes

1 Answer

3/9/2022

I was able to get around this by appending the --namespace argument to the run command in the final action.

- name: Deploy
  run: kubectl rollout restart deployment xxy-deployment --namespace=xxy-namespace
-- Yuukari
Source: StackOverflow