About cbopinfo

cbopinfo is a command-line tool that is provided in the Couchbase Autonomous Operator package. It is used to collect resources and logs via the Kubernetes API in order to support the Operator and Couchbase Server.

By default, cbopinfo will collect resources for all Couchbase clusters defined in the selected namespace. Certain resource types such as services, pods, and persistent volume claims are scoped to those created by the Operator. The scope can be further restricted to only the clusters specified on the command line.

Other unscoped resources are collected without any filtering, such as roles, role bindings, and service accounts, as they cannot be distinguished as belonging to a particular cluster.

Any secrets that are collected have their data redacted so only the presence of a secret or a key within it are visible.

The output is a compressed archive of resource YAML manifests organized by namespace, resource type, and name. Logs and events are also collected and collated with resource configuration where relevant.

The cbopinfo command requires permission to read resources related to the cluster in order to function correctly e.g. deplyoments, pods, couchbaseclusters, etc. When running this command ensure it is run by a user with sufficient permission to collect the required resources. If permission is denied to access a particular resource type the command will notify the user and continue with the collection on a best attempt basis. In general the required permissions are similar to those required by the operator but read-only.

Installation

Make sure that you have downloaded the Operator package and unpacked it on the same computer where you normally run kubectl or oc.

After you unpack the download, the resulting directory will be titled something like couchbase-autonomous-operator-kubernetes_x.x.x-linux_x86_64.

  • macOS

  • Linux

  • Windows

  1. Open a Terminal window and go to the directory where the cbopinfo binary is located:

    cd couchbase-autonomous-operator-kubernetes_x.x.x-macos_x86_64/bin/
  2. Make the cbopinfo binary executable:

    chmod +x ./cbopinfo
  3. Move the binary into your PATH:

    sudo mv ./cbopinfo /usr/local/bin/cbopinfo
  1. Open a command prompt and go to the directory where the cbopinfo binary is located:

    cd couchbase-autonomous-operator-kubernetes_x.x.x-linux_x86_64/bin/
  2. Make the cbopinfo binary executable:

    chmod +x ./cbopinfo
  3. Move the binary into your PATH:

    sudo mv ./cbopinfo /usr/local/bin/cbopinfo
  1. Open a command prompt and go to the directory where the cbopinfo binary is located:

    cd couchbase-autonomous-operator-kubernetes_x.x.x-windows_x86_64\bin\
  2. Add the cbopinfo binary into your PATH.

Options

--all

If specified, this flag ignores any scoping rules for a particular resource type, and collects all instances within the namespace.

--collectinfo

If specified, this flag will trigger collection of Couchbase logs via the cbcollect_info command locally on each pod belonging to a Couchbase cluster. The logs are left in situ as they may be relatively large. The cbopinfo command will report how to extract the logs from each pod. Logs are automatically redacted of sensitive information, and cbopinfo will provide a choice of download options.

For log volumes which were previously attached to ephemeral pods, it will display a table of available logs that are available for collection. Once you select which logs to collect, cbopinfo will create a temporary pod (as defined by --server-image), run cbcollect_info, and download the logs before finally deleting the temporary pod.

Example Output of --collectinfo
./cbopinfo -namespace operator-example-namespace  --collectinfo
Plain text server logs accessible with the following commands (use 'oc' command for OpenShift deployments):
  kubectl cp operator-example-namespace/cb-example-0003:/tmp/cbinfo-operator-example-namespace-cb-example-0003-20181115T194919+0000.zip .
  kubectl cp operator-example-namespace/cb-example-0001:/tmp/cbinfo-operator-example-namespace-cb-example-0001-20181115T194919+0000.zip .
  kubectl cp operator-example-namespace/cb-example-0000:/tmp/cbinfo-operator-example-namespace-cb-example-0000-20181115T194919+0000.zip .
  Redacted server logs accessible with the following commands (use 'oc' command for OpenShift deployments):
  kubectl cp operator-example-namespace/cb-example-0003:/tmp/cbinfo-operator-example-namespace-cb-example-0003-20181115T194919+0000-redacted... .
  kubectl cp operator-example-namespace/cb-example-0001:/tmp/cbinfo-operator-example-namespace-cb-example-0001-20181115T194919+0000-redacted... .
  kubectl cp operator-example-namespace/cb-example-0000:/tmp/cbinfo-operator-example-namespace-cb-example-0000-20181115T194919+0000-redacted... .

Detected detached log volumes:
┌────┬─────────────────┬──────────────────────┐
│ ID │ Pod             │ Detached             │
├────┼─────────────────┼──────────────────────┤
│ 0  │ cb-example-0002 │ 2018-11-15T19:42:48Z │
└────┴─────────────────┴──────────────────────┘
Please select volumes to collect [e.g. 1,2,5-6 or leave blank for none]: 0
Plain text server logs downloaded to the following locations:
  cbinfo-operator-example-namespace-cb-example-0002-20181115T194919+0000.zip
Redacted server logs downloaded to the following locations:
  cbinfo-operator-example-namespace-cb-example-0002-20181115T194919+0000-redacted.zip
Wrote cluster information to cbopinfo-20181115T194919+0000.tar.gz
--kubeconfig <config>

If specified, this points to a Kubernetes configuration file used to locate and poll the cluster API. If not set, it will default to ~/.kube/config.

--namespace <namespace>

If specified, this selects which namespace to collect resources and logs from. If not set, it will default to default.

--operator-image

If specified this sets the Operator image name. It is used to match containers running the Operator for collection of runtime information. If not set it will default to couchbase/operator:1.1.0.

--operator-rest-port

If specified this sets the Operator rest port. It is used for collection of runtime information. If not set it will default to 8080.

--server-image

If specified this defines the Couchbase Server image to use when collecting logs from detached log volumes. If not set, it will default to couchbase/server:enterprise-5.5.2

--system

If specified, this flag will additionally collect all resources from the kube-system namespace, which may be useful in diagnosing problems with cluster-level roles, custom resource definitions, or system services.

All options may also be specified as environment variables, with the command line arguments taking precendence. For example:

$ KUBECONFIG=/etc/kube/config SYSTEM=1 ALL=TRUE cbopinfo

Options which do not take any parameters must be specified as valid boolean strings as specified by the Go ParseBool function.

Examples

To perform a basic collection of all Couchbase clusters and their associated resources within a name space:

$ cbopinfo
Wrote cluster information to cbopinfo-20180629T123256+0100.tar.gz

To collect basic logs on OpenShift from a specific name space:

$ oc login -u developer
Authentication required for https://192.168.99.100:8443 (openshift)
Username: developer
Password:
Login successful.

You have access to the following projects and can switch between them with 'oc project <projectname>':

    myproject

Using project "myproject".

$ cbopinfo --namespace myproject --operator-image couchbase/operator:1.1.0-1
Wrote cluster information to cbopinfo-20180801T141838+0100.tar.gz

To collect all Couchbase clusters, their associated resources within a namespace, Couchbase server logs, and Kubernetes system logs:

$ cbopinfo --collectinfo --system
Plain text server logs accessible with the following commands (use 'oc' command for OpenShift deployments):
    kubectl cp default/cb-example-0001:/tmp/cbinfo-default-cb-example-0001-20180919T092607+0100.zip .
    kubectl cp default/cb-example-0002:/tmp/cbinfo-default-cb-example-0002-20180919T092607+0100.zip .
    kubectl cp default/cb-example-0000:/tmp/cbinfo-default-cb-example-0000-20180919T092607+0100.zip .
Redacted server logs accessible with the following commands (use 'oc' command for OpenShift deployments):
    kubectl cp default/cb-example-0001:/tmp/cbinfo-default-cb-example-0001-20180919T092607+0100-redacted.zip .
    kubectl cp default/cb-example-0002:/tmp/cbinfo-default-cb-example-0002-20180919T092607+0100-redacted.zip .
    kubectl cp default/cb-example-0000:/tmp/cbinfo-default-cb-example-0000-20180919T092607+0100-redacted.zip .
Wrote cluster information to cbopinfo-20180919T092607+0100.tar.gz