aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Guimaraes <pedro.guimaraes@canonical.com>2024-02-13 19:53:55 +0100
committerJake Hunsaker <jacob.r.hunsaker@gmail.com>2024-02-14 17:46:12 -0500
commit37aac3c51d083e72eedc9a9bc581bd32a4c2d488 (patch)
tree7fb6cda98a1352572e2d7fbb01a25e5aefa2f8a5
parent9c01d8f4933af3613d72819b7535ac8b6a989256 (diff)
downloadsos-37aac3c51d083e72eedc9a9bc581bd32a4c2d488.tar.gz
[UbuntuKubernetes] Extend plugin to support microk8s
Currently, we are not supporting microk8s with the same options as provided by kubernetes. This PR extends the UbuntuKubernetes to get information from microk8s. Following the review, it also extends microk8s plugin to add the credentials file to the copy spec. Closes: #3500 Co-authored-by: Arif Ali <arif.ali@canonical.com> Signed-off-by: Pedro Guimaraes <pedro.guimaraes@canonical.com>
-rw-r--r--sos/report/plugins/kubernetes.py10
-rw-r--r--sos/report/plugins/microk8s.py3
2 files changed, 10 insertions, 3 deletions
diff --git a/sos/report/plugins/kubernetes.py b/sos/report/plugins/kubernetes.py
index cfdec619..4f0c1c6f 100644
--- a/sos/report/plugins/kubernetes.py
+++ b/sos/report/plugins/kubernetes.py
@@ -176,12 +176,12 @@ class Kubernetes(Plugin):
# like "pass", "pwd", "key" or "token"
env_regexp = r'(?P<var>{\s*"name":\s*[^,]*' \
r'(pass|pwd|key|token|cred|PASS|PWD|KEY)[^,]*,\s*"value":)[^}]*'
- self.do_cmd_output_sub('kubectl', env_regexp,
+ self.do_cmd_output_sub(self.kube_cmd, env_regexp,
r'\g<var> "********"')
# Next, we need to handle the private keys and certs in some
# output that is not hit by the previous iteration.
- self.do_cmd_private_sub('kubectl')
+ self.do_cmd_private_sub(self.kube_cmd)
class RedHatKubernetes(Kubernetes, RedHatPlugin):
@@ -211,7 +211,8 @@ class UbuntuKubernetes(Kubernetes, UbuntuPlugin, DebianPlugin):
packages = ('kubernetes',)
files = (
'/root/cdk/cdk_addons_kubectl_config',
- '/etc/kubernetes/admin.conf'
+ '/etc/kubernetes/admin.conf',
+ '/var/snap/microk8s/current/credentials/client.config',
)
services = (
@@ -228,6 +229,9 @@ class UbuntuKubernetes(Kubernetes, UbuntuPlugin, DebianPlugin):
for svc in self.services:
self.add_journal(units=svc)
+ if self.is_installed('microk8s'):
+ self.kube_cmd = 'microk8s kubectl'
+
super(UbuntuKubernetes, self).setup()
diff --git a/sos/report/plugins/microk8s.py b/sos/report/plugins/microk8s.py
index fd54d813..52346ecc 100644
--- a/sos/report/plugins/microk8s.py
+++ b/sos/report/plugins/microk8s.py
@@ -40,6 +40,9 @@ class Microk8s(Plugin, UbuntuPlugin):
'status',
'version'
]
+ self.add_copy_spec(
+ "/var/snap/microk8s/current/credentials/client.config"
+ )
self.add_cmd_output([
f"microk8s {subcmd}" for subcmd in microk8s_subcmds