|
|
c33036 |
From 6372a7f7f09511d864aa6bd894109d937f4fda65 Mon Sep 17 00:00:00 2001
|
|
|
c33036 |
From: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
c33036 |
Date: Thu, 12 Jul 2018 12:36:25 -0400
|
|
|
c33036 |
Subject: [PATCH 1/3] [kubernetes|etcd] Support OpenShift 3.10 deployments
|
|
|
c33036 |
|
|
|
c33036 |
The 3.10 version of OCP changes the deployment configurations for etcd
|
|
|
c33036 |
and kubernetes components, and additionally changes the way the etcdctl
|
|
|
c33036 |
command is called when running in a static pod. Update these plugins to
|
|
|
c33036 |
support this new deployment style.
|
|
|
c33036 |
|
|
|
c33036 |
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
c33036 |
---
|
|
|
c33036 |
sos/plugins/etcd.py | 11 ++-
|
|
|
c33036 |
sos/plugins/kubernetes.py | 148 +++++++++++++++++++-------------------
|
|
|
c33036 |
2 files changed, 83 insertions(+), 76 deletions(-)
|
|
|
c33036 |
|
|
|
c33036 |
diff --git a/sos/plugins/etcd.py b/sos/plugins/etcd.py
|
|
|
c33036 |
index c343f750..c8ee3849 100644
|
|
|
c33036 |
--- a/sos/plugins/etcd.py
|
|
|
c33036 |
+++ b/sos/plugins/etcd.py
|
|
|
c33036 |
@@ -10,6 +10,7 @@
|
|
|
c33036 |
# See the LICENSE file in the source distribution for further information.
|
|
|
c33036 |
|
|
|
c33036 |
from sos.plugins import Plugin, RedHatPlugin
|
|
|
c33036 |
+from os import path
|
|
|
c33036 |
|
|
|
c33036 |
|
|
|
c33036 |
class etcd(Plugin, RedHatPlugin):
|
|
|
c33036 |
@@ -19,10 +20,14 @@ class etcd(Plugin, RedHatPlugin):
|
|
|
c33036 |
plugin_name = 'etcd'
|
|
|
c33036 |
packages = ('etcd',)
|
|
|
c33036 |
profiles = ('container', 'system', 'services', 'cluster')
|
|
|
c33036 |
-
|
|
|
c33036 |
- cmd = 'etcdctl'
|
|
|
c33036 |
+ files = ('/etc/origin/node/pods/etcd.yaml',)
|
|
|
c33036 |
|
|
|
c33036 |
def setup(self):
|
|
|
c33036 |
+ if path.exists('/etc/origin/node/pods/etcd.yaml'):
|
|
|
c33036 |
+ etcd_cmd = 'master-exec etcd etcd etcdctl'
|
|
|
c33036 |
+ else:
|
|
|
c33036 |
+ etcd_cmd = 'etcdctl'
|
|
|
c33036 |
+
|
|
|
c33036 |
etcd_url = self.get_etcd_url()
|
|
|
c33036 |
|
|
|
c33036 |
self.add_forbidden_path('/etc/etcd/ca')
|
|
|
c33036 |
@@ -35,7 +40,7 @@ class etcd(Plugin, RedHatPlugin):
|
|
|
c33036 |
'ls --recursive',
|
|
|
c33036 |
]
|
|
|
c33036 |
|
|
|
c33036 |
- self.add_cmd_output(['%s %s' % (self.cmd, sub) for sub in subcmds])
|
|
|
c33036 |
+ self.add_cmd_output(['%s %s' % (etcd_cmd, sub) for sub in subcmds])
|
|
|
c33036 |
|
|
|
c33036 |
urls = [
|
|
|
c33036 |
'/v2/stats/leader',
|
|
|
c33036 |
diff --git a/sos/plugins/kubernetes.py b/sos/plugins/kubernetes.py
|
|
|
c33036 |
index e75c7a37..21cb51df 100644
|
|
|
c33036 |
--- a/sos/plugins/kubernetes.py
|
|
|
c33036 |
+++ b/sos/plugins/kubernetes.py
|
|
|
c33036 |
@@ -18,11 +18,16 @@ class kubernetes(Plugin, RedHatPlugin):
|
|
|
c33036 |
"""Kubernetes plugin
|
|
|
c33036 |
"""
|
|
|
c33036 |
|
|
|
c33036 |
- # Red Hat Atomic Platform and OpenShift Enterprise use the
|
|
|
c33036 |
- # atomic-openshift-master package to provide kubernetes
|
|
|
c33036 |
+ # OpenShift Container Platform uses the atomic-openshift-master package
|
|
|
c33036 |
+ # to provide kubernetes
|
|
|
c33036 |
packages = ('kubernetes', 'kubernetes-master', 'atomic-openshift-master')
|
|
|
c33036 |
profiles = ('container',)
|
|
|
c33036 |
- files = ("/etc/origin/master/master-config.yaml",)
|
|
|
c33036 |
+ # use files only for masters, rely on package list for nodes
|
|
|
c33036 |
+ files = (
|
|
|
c33036 |
+ "/var/run/kubernetes/apiserver.key",
|
|
|
c33036 |
+ "/etc/origin/master/",
|
|
|
c33036 |
+ "/etc/origin/node/pods/master-config.yaml"
|
|
|
c33036 |
+ )
|
|
|
c33036 |
|
|
|
c33036 |
option_list = [
|
|
|
c33036 |
("all", "also collect all namespaces output separately",
|
|
|
c33036 |
@@ -33,12 +38,7 @@ class kubernetes(Plugin, RedHatPlugin):
|
|
|
c33036 |
]
|
|
|
c33036 |
|
|
|
c33036 |
def check_is_master(self):
|
|
|
c33036 |
- if any([
|
|
|
c33036 |
- path.exists("/var/run/kubernetes/apiserver.key"),
|
|
|
c33036 |
- path.exists("/etc/origin/master/master-config.yaml")
|
|
|
c33036 |
- ]):
|
|
|
c33036 |
- return True
|
|
|
c33036 |
- return False
|
|
|
c33036 |
+ return any([path.exists(f) for f in self.files])
|
|
|
c33036 |
|
|
|
c33036 |
def setup(self):
|
|
|
c33036 |
self.add_copy_spec("/etc/kubernetes")
|
|
|
c33036 |
@@ -56,74 +56,76 @@ class kubernetes(Plugin, RedHatPlugin):
|
|
|
c33036 |
self.add_journal(units=svc)
|
|
|
c33036 |
|
|
|
c33036 |
# We can only grab kubectl output from the master
|
|
|
c33036 |
- if self.check_is_master():
|
|
|
c33036 |
- kube_cmd = "kubectl "
|
|
|
c33036 |
- if path.exists('/etc/origin/master/admin.kubeconfig'):
|
|
|
c33036 |
- kube_cmd += "--config=/etc/origin/master/admin.kubeconfig"
|
|
|
c33036 |
-
|
|
|
c33036 |
- kube_get_cmd = "get -o json "
|
|
|
c33036 |
- for subcmd in ['version', 'config view']:
|
|
|
c33036 |
- self.add_cmd_output('%s %s' % (kube_cmd, subcmd))
|
|
|
c33036 |
-
|
|
|
c33036 |
- # get all namespaces in use
|
|
|
c33036 |
- kn = self.get_command_output('%s get namespaces' % kube_cmd)
|
|
|
c33036 |
- knsps = [n.split()[0] for n in kn['output'].splitlines()[1:] if n]
|
|
|
c33036 |
-
|
|
|
c33036 |
- resources = [
|
|
|
c33036 |
- 'limitrange',
|
|
|
c33036 |
- 'pods',
|
|
|
c33036 |
- 'pvc',
|
|
|
c33036 |
- 'rc',
|
|
|
c33036 |
- 'resourcequota',
|
|
|
c33036 |
- 'services'
|
|
|
c33036 |
- ]
|
|
|
c33036 |
-
|
|
|
c33036 |
- # nodes and pvs are not namespaced, must pull separately.
|
|
|
c33036 |
- # Also collect master metrics
|
|
|
c33036 |
- self.add_cmd_output([
|
|
|
c33036 |
- "{} get -o json nodes".format(kube_cmd),
|
|
|
c33036 |
- "{} get -o json pv".format(kube_cmd),
|
|
|
c33036 |
- "{} get --raw /metrics".format(kube_cmd)
|
|
|
c33036 |
- ])
|
|
|
c33036 |
-
|
|
|
c33036 |
- for n in knsps:
|
|
|
c33036 |
- knsp = '--namespace=%s' % n
|
|
|
c33036 |
- if self.get_option('all'):
|
|
|
c33036 |
- k_cmd = '%s %s %s' % (kube_cmd, kube_get_cmd, knsp)
|
|
|
c33036 |
-
|
|
|
c33036 |
- self.add_cmd_output('%s events' % k_cmd)
|
|
|
c33036 |
+ if not self.check_is_master():
|
|
|
c33036 |
+ return
|
|
|
c33036 |
+
|
|
|
c33036 |
+ kube_cmd = "kubectl "
|
|
|
c33036 |
+ if path.exists('/etc/origin/master/admin.kubeconfig'):
|
|
|
c33036 |
+ kube_cmd += "--config=/etc/origin/master/admin.kubeconfig"
|
|
|
c33036 |
+
|
|
|
c33036 |
+ kube_get_cmd = "get -o json "
|
|
|
c33036 |
+ for subcmd in ['version', 'config view']:
|
|
|
c33036 |
+ self.add_cmd_output('%s %s' % (kube_cmd, subcmd))
|
|
|
c33036 |
+
|
|
|
c33036 |
+ # get all namespaces in use
|
|
|
c33036 |
+ kn = self.get_command_output('%s get namespaces' % kube_cmd)
|
|
|
c33036 |
+ knsps = [n.split()[0] for n in kn['output'].splitlines()[1:] if n]
|
|
|
c33036 |
+
|
|
|
c33036 |
+ resources = [
|
|
|
c33036 |
+ 'limitrange',
|
|
|
c33036 |
+ 'pods',
|
|
|
c33036 |
+ 'pvc',
|
|
|
c33036 |
+ 'rc',
|
|
|
c33036 |
+ 'resourcequota',
|
|
|
c33036 |
+ 'services'
|
|
|
c33036 |
+ ]
|
|
|
c33036 |
+
|
|
|
c33036 |
+ # nodes and pvs are not namespaced, must pull separately.
|
|
|
c33036 |
+ # Also collect master metrics
|
|
|
c33036 |
+ self.add_cmd_output([
|
|
|
c33036 |
+ "{} get -o json nodes".format(kube_cmd),
|
|
|
c33036 |
+ "{} get -o json pv".format(kube_cmd),
|
|
|
c33036 |
+ "{} get --raw /metrics".format(kube_cmd)
|
|
|
c33036 |
+ ])
|
|
|
c33036 |
+
|
|
|
c33036 |
+ for n in knsps:
|
|
|
c33036 |
+ knsp = '--namespace=%s' % n
|
|
|
c33036 |
+ if self.get_option('all'):
|
|
|
c33036 |
+ k_cmd = '%s %s %s' % (kube_cmd, kube_get_cmd, knsp)
|
|
|
c33036 |
+
|
|
|
c33036 |
+ self.add_cmd_output('%s events' % k_cmd)
|
|
|
c33036 |
|
|
|
c33036 |
- for res in resources:
|
|
|
c33036 |
- self.add_cmd_output('%s %s' % (k_cmd, res))
|
|
|
c33036 |
-
|
|
|
c33036 |
- if self.get_option('describe'):
|
|
|
c33036 |
- # need to drop json formatting for this
|
|
|
c33036 |
- k_cmd = '%s get %s' % (kube_cmd, knsp)
|
|
|
c33036 |
- for res in resources:
|
|
|
c33036 |
- r = self.get_command_output(
|
|
|
c33036 |
- '%s %s' % (k_cmd, res))
|
|
|
c33036 |
- if r['status'] == 0:
|
|
|
c33036 |
- k_list = [k.split()[0] for k in
|
|
|
c33036 |
- r['output'].splitlines()[1:]]
|
|
|
c33036 |
- for k in k_list:
|
|
|
c33036 |
- k_cmd = '%s %s' % (kube_cmd, knsp)
|
|
|
c33036 |
- self.add_cmd_output(
|
|
|
c33036 |
- '%s describe %s %s' % (k_cmd, res, k))
|
|
|
c33036 |
-
|
|
|
c33036 |
- if self.get_option('podlogs'):
|
|
|
c33036 |
- k_cmd = '%s %s' % (kube_cmd, knsp)
|
|
|
c33036 |
- r = self.get_command_output('%s get pods' % k_cmd)
|
|
|
c33036 |
- if r['status'] == 0:
|
|
|
c33036 |
- pods = [p.split()[0] for p in
|
|
|
c33036 |
- r['output'].splitlines()[1:]]
|
|
|
c33036 |
- for pod in pods:
|
|
|
c33036 |
- self.add_cmd_output('%s logs %s' % (k_cmd, pod))
|
|
|
c33036 |
-
|
|
|
c33036 |
- if not self.get_option('all'):
|
|
|
c33036 |
- k_cmd = '%s get --all-namespaces=true' % kube_cmd
|
|
|
c33036 |
for res in resources:
|
|
|
c33036 |
self.add_cmd_output('%s %s' % (k_cmd, res))
|
|
|
c33036 |
|
|
|
c33036 |
+ if self.get_option('describe'):
|
|
|
c33036 |
+ # need to drop json formatting for this
|
|
|
c33036 |
+ k_cmd = '%s get %s' % (kube_cmd, knsp)
|
|
|
c33036 |
+ for res in resources:
|
|
|
c33036 |
+ r = self.get_command_output(
|
|
|
c33036 |
+ '%s %s' % (k_cmd, res))
|
|
|
c33036 |
+ if r['status'] == 0:
|
|
|
c33036 |
+ k_list = [k.split()[0] for k in
|
|
|
c33036 |
+ r['output'].splitlines()[1:]]
|
|
|
c33036 |
+ for k in k_list:
|
|
|
c33036 |
+ k_cmd = '%s %s' % (kube_cmd, knsp)
|
|
|
c33036 |
+ self.add_cmd_output(
|
|
|
c33036 |
+ '%s describe %s %s' % (k_cmd, res, k))
|
|
|
c33036 |
+
|
|
|
c33036 |
+ if self.get_option('podlogs'):
|
|
|
c33036 |
+ k_cmd = '%s %s' % (kube_cmd, knsp)
|
|
|
c33036 |
+ r = self.get_command_output('%s get pods' % k_cmd)
|
|
|
c33036 |
+ if r['status'] == 0:
|
|
|
c33036 |
+ pods = [p.split()[0] for p in
|
|
|
c33036 |
+ r['output'].splitlines()[1:]]
|
|
|
c33036 |
+ for pod in pods:
|
|
|
c33036 |
+ self.add_cmd_output('%s logs %s' % (k_cmd, pod))
|
|
|
c33036 |
+
|
|
|
c33036 |
+ if not self.get_option('all'):
|
|
|
c33036 |
+ k_cmd = '%s get --all-namespaces=true' % kube_cmd
|
|
|
c33036 |
+ for res in resources:
|
|
|
c33036 |
+ self.add_cmd_output('%s %s' % (k_cmd, res))
|
|
|
c33036 |
+
|
|
|
c33036 |
def postproc(self):
|
|
|
c33036 |
# First, clear sensitive data from the json output collected.
|
|
|
c33036 |
# This will mask values when the "name" looks susceptible of
|
|
|
c33036 |
--
|
|
|
c33036 |
2.17.1
|
|
|
c33036 |
|
|
|
c33036 |
|
|
|
c33036 |
From 63ad6c251ab88ab2f0e07ae9e3f1b2771d5e90ca Mon Sep 17 00:00:00 2001
|
|
|
c33036 |
From: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
c33036 |
Date: Thu, 12 Jul 2018 13:07:34 -0400
|
|
|
c33036 |
Subject: [PATCH 2/3] [kubernetes] Correct config option syntax
|
|
|
c33036 |
|
|
|
c33036 |
Versions of kubernetes after 1.5 use --kubeconfig instead of --config to
|
|
|
c33036 |
specify a configuration file to use for kubectl commands. Update the
|
|
|
c33036 |
kubernetes plugin to use the proper syntax.
|
|
|
c33036 |
|
|
|
c33036 |
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
c33036 |
---
|
|
|
c33036 |
sos/plugins/kubernetes.py | 2 +-
|
|
|
c33036 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
c33036 |
|
|
|
c33036 |
diff --git a/sos/plugins/kubernetes.py b/sos/plugins/kubernetes.py
|
|
|
c33036 |
index 21cb51df..c14e078e 100644
|
|
|
c33036 |
--- a/sos/plugins/kubernetes.py
|
|
|
c33036 |
+++ b/sos/plugins/kubernetes.py
|
|
|
c33036 |
@@ -61,7 +61,7 @@ class kubernetes(Plugin, RedHatPlugin):
|
|
|
c33036 |
|
|
|
c33036 |
kube_cmd = "kubectl "
|
|
|
c33036 |
if path.exists('/etc/origin/master/admin.kubeconfig'):
|
|
|
c33036 |
- kube_cmd += "--config=/etc/origin/master/admin.kubeconfig"
|
|
|
c33036 |
+ kube_cmd += "--kubeconfig=/etc/origin/master/admin.kubeconfig"
|
|
|
c33036 |
|
|
|
c33036 |
kube_get_cmd = "get -o json "
|
|
|
c33036 |
for subcmd in ['version', 'config view']:
|
|
|
c33036 |
--
|
|
|
c33036 |
2.17.1
|
|
|
c33036 |
|
|
|
c33036 |
|
|
|
c33036 |
From 46fffd469f4f3d07337dc335cfc24341e836f23b Mon Sep 17 00:00:00 2001
|
|
|
c33036 |
From: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
c33036 |
Date: Thu, 12 Jul 2018 13:11:44 -0400
|
|
|
c33036 |
Subject: [PATCH 3/3] [origin] Collect statistics information
|
|
|
c33036 |
|
|
|
c33036 |
Adds collection of 'oc adm top' output for images and imagestreams.
|
|
|
c33036 |
|
|
|
c33036 |
Resolves: #1165
|
|
|
c33036 |
Closes: #1383
|
|
|
c33036 |
|
|
|
c33036 |
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
|
|
|
c33036 |
---
|
|
|
c33036 |
sos/plugins/origin.py | 26 ++++++++++++++++++++------
|
|
|
c33036 |
1 file changed, 20 insertions(+), 6 deletions(-)
|
|
|
c33036 |
|
|
|
c33036 |
diff --git a/sos/plugins/origin.py b/sos/plugins/origin.py
|
|
|
c33036 |
index 02bc047a..0e384117 100644
|
|
|
c33036 |
--- a/sos/plugins/origin.py
|
|
|
c33036 |
+++ b/sos/plugins/origin.py
|
|
|
c33036 |
@@ -124,14 +124,28 @@ class OpenShiftOrigin(Plugin):
|
|
|
c33036 |
#
|
|
|
c33036 |
# Note: Information about nodes, events, pods, and services
|
|
|
c33036 |
# is already collected by the Kubernetes plugin
|
|
|
c33036 |
+
|
|
|
c33036 |
+ subcmds = [
|
|
|
c33036 |
+ "describe projects",
|
|
|
c33036 |
+ "adm top images",
|
|
|
c33036 |
+ "adm top imagestreams"
|
|
|
c33036 |
+ ]
|
|
|
c33036 |
+
|
|
|
c33036 |
self.add_cmd_output([
|
|
|
c33036 |
- "%s describe projects" % oc_cmd_admin,
|
|
|
c33036 |
- "%s get -o json hostsubnet" % oc_cmd_admin,
|
|
|
c33036 |
- "%s get -o json clusternetwork" % oc_cmd_admin,
|
|
|
c33036 |
- "%s get -o json netnamespaces" % oc_cmd_admin,
|
|
|
c33036 |
- # Registry and router configs are typically here
|
|
|
c33036 |
- "%s get -o json dc -n default" % oc_cmd_admin,
|
|
|
c33036 |
+ '%s %s' % (oc_cmd_admin, subcmd) for subcmd in subcmds
|
|
|
c33036 |
])
|
|
|
c33036 |
+
|
|
|
c33036 |
+ jcmds = [
|
|
|
c33036 |
+ "hostsubnet",
|
|
|
c33036 |
+ "clusternetwork",
|
|
|
c33036 |
+ "netnamespaces",
|
|
|
c33036 |
+ "dc -n default"
|
|
|
c33036 |
+ ]
|
|
|
c33036 |
+
|
|
|
c33036 |
+ self.add_cmd_output([
|
|
|
c33036 |
+ '%s get -o json %s' % (oc_cmd_admin, jcmd) for jcmd in jcmds
|
|
|
c33036 |
+ ])
|
|
|
c33036 |
+
|
|
|
c33036 |
if self.get_option('diag'):
|
|
|
c33036 |
diag_cmd = "%s adm diagnostics -l 0" % oc_cmd_admin
|
|
|
c33036 |
if self.get_option('diag-prevent'):
|
|
|
c33036 |
--
|
|
|
c33036 |
2.17.1
|
|
|
c33036 |
|