Kubernetes "rollout history" command fails with "namespace not found" for service account

11/15/2019

I try to run this command with a service account from Jenkins: kubectl rollout history deployment.v1.apps/config-service-deployment The command fails with the following error:

Error from server (NotFound): namespaces "build" not found

I would like to mention, we have only one namespace: default;

This is the service account:

apiVersion: v1
kind: ServiceAccount
metadata:
  creationTimestamp: "2019-09-09T05:50:56Z"
  name: jenkins-user
  namespace: default
  resourceVersion: "387323"
  selfLink: /api/v1/namespaces/default/serviceaccounts/jenkins-user
  uid: ********
secrets:
- name: ********

If I login from bash and use the default account the command runs successfully and the history is returned. The service account is working for creating new deployments and services. The only issue is, I can't get the rollout history.

What do I miss?

-- Zsolt Tolvaly
jenkins
kubernetes

1 Answer

11/19/2019

You can side-step all doubt about what namespace is in the global $KUBECONFIG by being explicit about the namespace in which the deployment is happening:

kubectl -n default rollout history deploy/config-service-deployment

-- mdaniel
Source: StackOverflow