namespace actions don't work

Bug #1914359 reported by Chris Johnston
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Kubernetes Control Plane Charm
Fix Released
High
Hemanth Nakkina

Bug Description

After upgrading from ck1.18 to ck1.19, the namespace-list (and other namespace related) action doesn't work.

juju run-action kubernetes-master/0 --wait namespace-list
unit-kubernetes-master-0:
  UnitId: kubernetes-master/0
  id: "4"
  message: exit status 1
  results:
    ReturnCode: 1
    Stderr: |
      The connection to the server localhost:8080 was refused - did you specify the right host or port?
      Traceback (most recent call last):
        File "/var/lib/juju/agents/unit-kubernetes-master-0/charm/actions/namespace-list", line 57, in <module>
          namespace_list()
        File "/var/lib/juju/agents/unit-kubernetes-master-0/charm/actions/namespace-list", line 23, in namespace_list
          y = load(kubectl(['get', 'namespaces', '-o', 'yaml']))
        File "/var/lib/juju/agents/unit-kubernetes-master-0/charm/actions/namespace-list", line 19, in kubectl
          return check_output(cmd)
        File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
          **kwargs).stdout
        File "/usr/lib/python3.6/subprocess.py", line 438, in run
          output=stdout, stderr=stderr)
      subprocess.CalledProcessError: Command '['kubectl', 'get', 'namespaces', '-o', 'yaml']' returned non-zero exit status 1.
  status: failed
  timing:
    completed: 2021-02-03 05:45:13 +0000 UTC
    enqueued: 2021-02-03 05:45:12 +0000 UTC
    started: 2021-02-03 05:45:12 +0000 UTC

Tags: sts
tags: added: sts
Revision history for this message
George Kraft (cynerva) wrote :

Thanks for the report. I believe namespace-create and namespace-delete are also affected.

In Charmed Kubernetes 1.19, kube-apiserver no longer serves traffic on the insecure 8080 localhost port. Juju runs actions without the HOME environment variable set, so kubectl does not pick up the kubeconfig in /root/.kube/config automatically. I believe the fix here is to add --kubeconfig=/root/.kube/config to the kubectl call[1] in the namespace actions.

[1]: https://github.com/charmed-kubernetes/charm-kubernetes-master/blob/036b0bc4cc25d4a864266b3b9329dd8d40affdc3/actions/namespace-create#L18

summary: - namespace-list action doesn't work
+ namespace actions don't work
Changed in charm-kubernetes-master:
importance: Undecided → High
status: New → Triaged
Changed in charm-kubernetes-master:
assignee: nobody → Hemanth Nakkina (hemanth-n)
Revision history for this message
Hemanth Nakkina (hemanth-n) wrote :
George Kraft (cynerva)
tags: added: review-needed
Changed in charm-kubernetes-master:
status: Triaged → In Progress
Cory Johns (johnsca)
tags: removed: review-needed
Changed in charm-kubernetes-master:
status: In Progress → Fix Committed
Revision history for this message
Hemanth Nakkina (hemanth-n) wrote :

This is released in stable channel of kubernetes-master charm - https://jaas.ai/u/containers/kubernetes-master/974

So can be marked as Fix Released

George Kraft (cynerva)
Changed in charm-kubernetes-master:
milestone: none → 1.21
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.