diff --git a/examples/bundle-info-alpha.yaml b/examples/bundle-info-alpha.yaml new file mode 100644 index 0000000..ee19e5c --- /dev/null +++ b/examples/bundle-info-alpha.yaml @@ -0,0 +1,119 @@ +apiVersion: troubleshoot.sh/v1beta2 +kind: SupportBundle +metadata: + name: StorageOS +spec: + collectors: + - clusterResources: {} + - logs: + name: storageos-cluster-operator-logs + selector: + - name=storageos-cluster-operator + namespace: storageos-operator + limits: + maxLines: 10000 + - logs: + name: storageos-logs + selector: + - app=storageos + namespace: kube-system + limits: + maxLines: 1000000 + - run: + name: "network-checks" + collectorName: "netcat" + image: arau/tools:0.9 + namespace: kube-system + hostNetwork: true + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: + - "/bin/sh" + - "-c" + - " + #!/bin/bash + # + # IOPort = 5703 # DataPlane + # SupervisorPort = 5704 # For sync + # ExternalAPIPort = 5705 # REST API + # InternalAPIPort = 5710 # Grpc API + # GossipPort = 5711 # Gossip+Healthcheck + + echo \"Source node for the test:\"; + hostname -f -I; echo; + + parallel -j2 nc -vnz ::: $(echo $NODES_PRIVATE_IPS| sed \"s/,/ /g\" ) \ + ::: 5703 5704 5705 5710 5711 + " + timeout: 90s + - exec: + name: "backend-disks" + collectorName: "lsblk" + selector: + - kind=daemonset + - app=storageos + namespace: kube-system + command: ["lsblk"] + timeout: 90s + - exec: + name: "free-disk-space" + collectorName: "df" + namespace: kube-system + selector: + - kind=daemonset + - app=storageos + command: ["df", "-h"] + timeout: 90s + - run: + name: "ps-all-nodes" + collectorName: "processlist" + image: arau/tools:0.9 + namespace: kube-system + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: ["ps"] + args: ["auxwwwf"] + timeout: 90s + - run: + name: "loadAvg-all-nodes" + collectorName: "top" + image: arau/tools:0.9 + namespace: kube-system + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: ["top"] + args: + - "-b" + - "-c" + - "-n4" + - "-d2" + - "-w500" + timeout: 90s + - exec: + name: storageos-cli-info + collectorName: storageos-cli + selector: + - run=cli + namespace: kube-system + timeout: 90s + command: ["/bin/sh"] + args: + - -c + - " + export STORAGEOS_ENDPOINTS='http://storageos.kube-system.svc:5705'; + echo STORAGEOS CLUSTER; + storageos get cluster -ojson; + echo '-----------------------------------------'; + echo STORAGEOS LICENCE; + storageos get licence -ojson; + echo '-----------------------------------------'; + echo STORAGEOS NAMESPACE; + storageos get namespace -ojson; + echo '-----------------------------------------'; + echo STORAGEOS VOLUMES; + storageos get volumes --all-namespaces -ojson --timeout 30s; + echo '-----------------------------------------'; + " diff --git a/examples/bundle-info.yaml b/examples/bundle-info.yaml new file mode 100644 index 0000000..81ab406 --- /dev/null +++ b/examples/bundle-info.yaml @@ -0,0 +1,103 @@ +apiVersion: troubleshoot.sh/v1beta2 +kind: SupportBundle +metadata: + name: StorageOS +spec: + collectors: + - clusterResources: {} + - logs: + selector: + - name=storageos-cluster-operator + namespace: storageos-operator + limits: + maxLines: 10000 + - logs: + selector: + - app=storageos + namespace: kube-system + limits: + maxLines: 1000000 + - run: + name: "network-checks" + collectorName: "netcat" + image: arau/tools:0.9 + namespace: kube-system + hostNetwork: true + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: + - "/bin/sh" + - "-c" + - " + #!/bin/bash + # + # IOPort = 5703 # DataPlane + # SupervisorPort = 5704 # For sync + # ExternalAPIPort = 5705 # REST API + # InternalAPIPort = 5710 # Grpc API + # GossipPort = 5711 # Gossip+Healthcheck + + echo \"Source node for the test:\"; + hostname -f -I; echo; + + parallel -j2 nc -vnz ::: $(echo $NODES_PRIVATE_IPS| sed \"s/,/ /g\" ) \ + ::: 5703 5704 5705 5710 5711 + " + timeout: 90s + - run: + name: "backend-disks" + collectorName: "lsblk" + image: arau/tools:0.9 + namespace: kube-system + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: ["lsblk"] + timeout: 90s + - run: + name: "free-disk-space" + collectorName: "df" + image: arau/tools:0.9 + namespace: kube-system + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: ["df -h"] + timeout: 90s + - run: + name: "ps-all-nodes" + collectorName: "processlist" + image: arau/tools:0.9 + namespace: kube-system + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: ["ps"] + args: ["auxwwwf"] + timeout: 90s + - exec: + name: storageos-cli-info + collectorName: storageos-cli + selector: + - run=cli + namespace: kube-system + timeout: 90s + command: ["/bin/sh"] + args: + - -c + - " + export STORAGEOS_ENDPOINTS='http://storageos.kube-system.svc:5705'; + echo STORAGEOS CLUSTER; + storageos get cluster -ojson; + echo '-----------------------------------------'; + echo STORAGEOS LICENCE; + storageos get licence -ojson; + echo '-----------------------------------------'; + echo STORAGEOS NAMESPACE; + storageos get namespace -ojson; + echo '-----------------------------------------'; + echo STORAGEOS VOLUMES; + storageos get volumes --all-namespaces -ojson --timeout 30s; + echo '-----------------------------------------'; + " diff --git a/examples/bundle-with-execs.yaml b/examples/bundle-with-execs.yaml new file mode 100644 index 0000000..8e234a3 --- /dev/null +++ b/examples/bundle-with-execs.yaml @@ -0,0 +1,113 @@ +apiVersion: troubleshoot.sh/v1beta2 +kind: SupportBundle +metadata: + name: StorageOS +spec: + collectors: + - clusterResources: {} + - logs: + name: storageos-cluster-operator-logs + selector: + - name=storageos-cluster-operator + namespace: storageos-operator + limits: + maxLines: 10000 + - logs: + name: storageos-logs + selector: + - app=storageos + namespace: kube-system + limits: + maxLines: 1000000 + - exec: + name: "network-checks" + collectorName: "netcat" + image: arau/tools:0.9 + namespace: kube-system + selector: + - app=tools + command: + - "/bin/sh" + - "-c" + - " + #!/bin/bash + # + # IOPort = 5703 # DataPlane + # SupervisorPort = 5704 # For sync + # ExternalAPIPort = 5705 # REST API + # InternalAPIPort = 5710 # Grpc API + # GossipPort = 5711 # Gossip+Healthcheck + + echo \"Source node for the test:\"; + hostname -f -I; echo; + + parallel -j2 nc -vnz ::: $(echo $NODES_PRIVATE_IPS| sed \"s/,/ /g\" ) \ + ::: 5703 5704 5705 5710 5711 + " + timeout: 90s + - exec: + name: "backend-disks" + collectorName: "lsblk" + selector: + - kind=daemonset + - app=storageos + namespace: kube-system + command: ["lsblk"] + timeout: 90s + - exec: + name: "free-disk-space" + collectorName: "df" + namespace: kube-system + selector: + - kind=daemonset + - app=storageos + command: ["df", "-h"] + timeout: 90s + - exec: + name: "ps-all-nodes" + collectorName: "processlist" + namespace: kube-system + selector: + - app=tools + command: ["ps"] + args: ["auxwwwf"] + timeout: 90s + - exec: + name: "loadAvg-all-nodes" + collectorName: "top" + namespace: kube-system + selector: + - app=tools + command: ["top"] + args: + - "-b" + - "-c" + - "-n4" + - "-d2" + - "-w500" + timeout: 90s + - exec: + name: storageos-cli-info + collectorName: storageos-cli + selector: + - run=cli + namespace: kube-system + timeout: 90s + command: ["/bin/sh"] + args: + - -c + - " + export STORAGEOS_ENDPOINTS='http://storageos.kube-system.svc:5705'; + echo STORAGEOS CLUSTER; + storageos get cluster -ojson; + echo '-----------------------------------------'; + echo STORAGEOS LICENCE; + storageos get licence -ojson; + echo '-----------------------------------------'; + echo STORAGEOS NAMESPACE; + storageos get namespace -ojson; + echo '-----------------------------------------'; + echo STORAGEOS VOLUMES; + storageos get volumes --all-namespaces -ojson --timeout 30s; + echo '-----------------------------------------'; + " diff --git a/examples/bundle.yaml b/examples/bundle.yaml index cd126fd..2035ae2 100644 --- a/examples/bundle.yaml +++ b/examples/bundle.yaml @@ -4,6 +4,7 @@ metadata: name: StorageOS spec: collectors: + - clusterResources: {} - logs: selector: - name=storageos-cluster-operator @@ -13,32 +14,96 @@ spec: - logs: selector: - app=storageos - - app.kubernetes.io/component=storageos-csi-helper namespace: kube-system limits: - maxLines: 10000 - - logs: - selector: - - app=storageos - - app.kubernetes.io/component=storageos-daemonset + maxLines: 1000000 + - run: + name: "network-checks" + collectorName: "netcat" + image: arau/tools:0.9 namespace: kube-system - limits: - maxLines: 10000 - - logs: - selector: - - app=storageos - - app.kubernetes.io/component=storageos-api-manager + hostNetwork: true + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: + - "/bin/sh" + - "-c" + - " + #!/bin/bash + # + # IOPort = 5703 # DataPlane + # SupervisorPort = 5704 # For sync + # ExternalAPIPort = 5705 # REST API + # InternalAPIPort = 5710 # Grpc API + # GossipPort = 5711 # Gossip+Healthcheck + + echo \"Source node for the test:\"; + hostname -f -I; echo; + + parallel -j2 nc -vnz ::: $(echo $NODES_PRIVATE_IPS| sed \"s/,/ /g\" ) \ + ::: 5703 5704 5705 5710 5711 + " + timeout: 90s + - run: + name: "backend-disks" + collectorName: "lsblk" + image: arau/tools:0.9 namespace: kube-system - limits: - maxLines: 10000 - - logs: + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: ["lsblk"] + timeout: 90s + - run: + name: "free-disk-space" + collectorName: "df" + image: arau/tools:0.9 + namespace: kube-system + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: ["df -h"] + timeout: 90s + - run: + name: "ps-all-nodes" + collectorName: "processlist" + image: arau/tools:0.9 + namespace: kube-system + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: ["ps"] + args: ["auxwwwf"] + timeout: 90s + - exec: + name: storageos-cli-info + collectorName: storageos-cli selector: - - app=storageos - - app.kubernetes.io/component=storageos-scheduler + - run=cli namespace: kube-system - limits: - maxLines: 10000 - - clusterResources: {} + timeout: 90s + command: ["/bin/sh"] + args: + - -c + - " + export STORAGEOS_ENDPOINTS='http://storageos.kube-system.svc:5705'; + echo STORAGEOS CLUSTER; + storageos get cluster -ojson; + echo '-----------------------------------------'; + echo STORAGEOS LICENCE; + storageos get licence -ojson; + echo '-----------------------------------------'; + echo STORAGEOS NAMESPACE; + storageos get namespace -ojson; + echo '-----------------------------------------'; + echo STORAGEOS NODES; + storageos get nodes -o json; + echo '-----------------------------------------'; + echo STORAGEOS VOLUMES; + storageos get volumes --all-namespaces -ojson; + echo '-----------------------------------------'; + " analyzers: - clusterVersion: outcomes: @@ -99,7 +164,7 @@ spec: when: "< 1" message: The CSI helper deployment does not have any ready replicas. - pass: - message: The CSI helper deployment is ready. + message: The CSI helper deployment is ready. - deploymentStatus: name: storageos-scheduler namespace: kube-system @@ -108,4 +173,4 @@ spec: when: "< 1" message: The scheduler deployment does not have any ready replicas. - pass: - message: The scheduler deployment is ready. \ No newline at end of file + message: The scheduler deployment is ready. diff --git a/examples/cli.yaml b/examples/cli.yaml new file mode 100644 index 0000000..108a2f9 --- /dev/null +++ b/examples/cli.yaml @@ -0,0 +1,44 @@ +apiVersion: troubleshoot.sh/v1beta2 +kind: SupportBundle +metadata: + name: StorageOS +spec: + collectors: + - exec: + collectorName: storageos-nodes + name: storageos-nodes + selector: + - run=cli + namespace: kube-system + command: ["storageos"] + args: ["get", "nodes"] + timeout: 20s + - run: + collectorName: "run-storageos-cli" + image: storageos/cli:v2.2.0 + namespace: kube-system + command: ["storageos"] + args: + - --endpoints + - "http://storageos.kube-system.svc:5705" + - get + - nodes + - -o + - yaml + imagePullPolicy: IfNotPresent + - run: + collectorName: "run-storageos-cli2" + image: storageos/cli:v2.2.0 + namespace: kube-system + command: ["/bin/sh"] + args: + - -c + - " + echo STORAGEOS NODES; + storageos --endpoints http://storageos.kube-system.svc:5705 get nodes -o yaml; + echo '-----------------------------------------'; + echo STORAGEOS VOLUMES; + storageos --endpoints http://storageos.kube-system.svc:5705 get volumes --all-namespaces -oyaml; + echo '-----------------------------------------'; + " + imagePullPolicy: IfNotPresent diff --git a/examples/netcat.yaml b/examples/netcat.yaml new file mode 100644 index 0000000..a2ec089 --- /dev/null +++ b/examples/netcat.yaml @@ -0,0 +1,32 @@ +apiVersion: troubleshoot.sh/v1beta2 +kind: SupportBundle +metadata: + name: StorageOS +spec: + collectors: + - run: + collectorName: "network-check" + image: arau/tools:0.9 + namespace: kube-system + hostNetwork: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: + - "/bin/sh" + - "-c" + - " + #!/bin/bash + # + # IOPort = 5703 # DataPlane + # SupervisorPort = 5704 # For sync + # ExternalAPIPort = 5705 # REST API + # InternalAPIPort = 5710 # Grpc API + # GossipPort = 5711 # Gossip+Healthcheck + + echo \"Source node for the test:\"; + hostname -f -I; echo; + + parallel -j2 nc -vnz ::: $(echo $NODES_PRIVATE_IPS| sed \"s/,/ /g\" ) \ + ::: 5703 5704 5705 5710 5711 + " + timeout: 90s diff --git a/examples/ps-with-external-daemonset.yaml b/examples/ps-with-external-daemonset.yaml new file mode 100644 index 0000000..e9895d5 --- /dev/null +++ b/examples/ps-with-external-daemonset.yaml @@ -0,0 +1,120 @@ +apiVersion: troubleshoot.sh/v1beta2 +kind: SupportBundle +metadata: + name: StorageOS +spec: + collectors: + - exec: + # This collector would need the DaemonSet definition below to be created + # before hand + collectorName: ps + name: ps + selector: + - app=tools + namespace: kube-system + command: ["ps"] + args: ["auxwwwf"] + timeout: 60s + +# We created the following Daemonset Pod to execute on it +# kubectl create -f ./daemonset-tools.yaml +# +# cat ./daemonset-tools.yaml +#apiVersion: apps/v1 +#kind: DaemonSet +#metadata: +# name: tools +# namespace: kube-system +#spec: +# revisionHistoryLimit: 10 +# selector: +# matchLabels: +# app: tools +# template: +# metadata: +# labels: +# app: tools +# spec: +# containers: +# - command: +# - /bin/sh +# - -c +# - "while true; do sleep 3600; done" +# image: arau/tools:0.8 +# name: tools +# securityContext: +# allowPrivilegeEscalation: true +# capabilities: +# add: +# - SYS_ADMIN +# privileged: true +# volumeMounts: +# - mountPath: /sys +# name: sys +# - mountPath: /var/lib/storageos +# mountPropagation: Bidirectional +# name: state +# - mountPath: /lib/modules +# name: kernel-modules +# readOnly: true +# - mountPath: /etc/storageos +# name: config +# - mountPath: /csi +# name: plugin-dir +# - mountPath: /var/lib/csi/sockets/ +# name: registrar-socket-dir +# dnsPolicy: ClusterFirstWithHostNet +# hostNetwork: true +# hostPID: true +# priorityClassName: system-node-critical +# tolerations: +# - key: node.kubernetes.io/disk-pressure +# operator: Exists +# - key: node.kubernetes.io/memory-pressure +# operator: Exists +# - key: node.kubernetes.io/network-unavailable +# operator: Exists +# - key: node.kubernetes.io/not-ready +# operator: Exists +# - key: node.kubernetes.io/out-of-disk +# operator: Exists +# - key: node.kubernetes.io/pid-pressure +# operator: Exists +# - key: node.kubernetes.io/unreachable +# operator: Exists +# - key: node.kubernetes.io/unschedulable +# operator: Exists +# volumes: +# - hostPath: +# path: /lib/modules +# type: "" +# name: kernel-modules +# - hostPath: +# path: /sys +# type: "" +# name: sys +# - hostPath: +# path: /var/lib/storageos +# type: "" +# name: state +# - configMap: +# defaultMode: 384 +# name: storageos-node-config +# optional: false +# name: config +# - hostPath: +# path: /var/lib/kubelet +# type: Directory +# name: kubelet-dir +# - hostPath: +# path: /var/lib/kubelet/plugins_registry +# type: Directory +# name: registration-dir +# - hostPath: +# path: /var/lib/kubelet/device-plugins/ +# type: DirectoryOrCreate +# name: registrar-socket-dir +# - hostPath: +# path: /var/lib/kubelet/plugins_registry/storageos +# type: DirectoryOrCreate +# name: plugin-dir diff --git a/examples/ps-workers.yaml b/examples/ps-workers.yaml new file mode 100644 index 0000000..f3f5314 --- /dev/null +++ b/examples/ps-workers.yaml @@ -0,0 +1,18 @@ +apiVersion: troubleshoot.sh/v1beta2 +kind: SupportBundle +metadata: + name: StorageOS +spec: + collectors: + - run: + # Because of the nodeSelector, this runner will create + # one Pod for each node that matches the nodeSelector Term + collectorName: "ps-all-nodes" + image: arau/tools:0.9 + namespace: kube-system + hostPID: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: ["ps"] + args: ["auxwwwf"] + timeout: 20s diff --git a/examples/runmanynodes.yaml b/examples/runmanynodes.yaml new file mode 100644 index 0000000..ea244ec --- /dev/null +++ b/examples/runmanynodes.yaml @@ -0,0 +1,38 @@ +apiVersion: troubleshoot.sh/v1beta2 +kind: SupportBundle +metadata: + name: StorageOS +spec: + collectors: + - run: + collectorName: "hostname-one" + name: "runonenode" + image: arau/tools:0.9 + namespace: kube-system + hostNetwork: true + command: + - "/bin/sh" + - "-c" + - " + #!/bin/bash + + hostname + " + timeout: 20s + - run: + collectorName: "hostname-worker" + name: "runmanynodes" + image: arau/tools:0.9 + namespace: kube-system + hostNetwork: true + nodeSelector: + node-role.kubernetes.io/worker: "true" + command: + - "/bin/sh" + - "-c" + - " + #!/bin/bash + + hostname + " + timeout: 30s diff --git a/go.mod b/go.mod index ec52300..fb96cbb 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/croomes/kubectl-plugin go 1.12 +replace github.com/replicatedhq/troubleshoot => /Users/ferran/repos/troubleshoot + require ( github.com/ahmetalpbalkan/go-cursor v0.0.0-20131010032410-8136607ea412 github.com/fatih/color v1.7.0