Skip to content

Commit

Permalink
Make sure to use microk8s-kubectl.wrapper (#3176) (#3208)
Browse files Browse the repository at this point in the history
If we call kubectl simply, the system installed kubectl has precedence.
That may lead to some weird issues like an error due to a discrepancy
between kubectl cli and kubernetes API versions.

Closes: #3175

Co-authored-by: Nobuto Murata <[email protected]>
neoaggelos and nobuto-m authored Jun 8, 2022

Verified

This commit was signed with the committer’s verified signature.
kayhhh kayh
1 parent bdb1b48 commit a794c53
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scripts/wrappers/common/utils.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
import click
import yaml

kubeconfig = "--kubeconfig=" + os.path.expandvars("${SNAP_DATA}/credentials/client.config")
KUBECTL = os.path.expandvars("$SNAP/microk8s-kubectl.wrapper")


def get_current_arch():
@@ -166,14 +166,19 @@ def ensure_started():

def kubectl_get(cmd, namespace="--all-namespaces"):
if namespace == "--all-namespaces":
return run("kubectl", kubeconfig, "get", cmd, "--all-namespaces", die=False)
return run(KUBECTL, "get", cmd, "--all-namespaces", die=False)
else:
return run("kubectl", kubeconfig, "get", cmd, "-n", namespace, die=False)
return run(KUBECTL, "get", cmd, "-n", namespace, die=False)


def kubectl_get_clusterroles():
return run(
"kubectl", kubeconfig, "get", "clusterroles", "--show-kind", "--no-headers", die=False
KUBECTL,
"get",
"clusterroles",
"--show-kind",
"--no-headers",
die=False,
)


0 comments on commit a794c53

Please sign in to comment.