Skip to content

cub k8s collect

cub k8s collect

Collect facts from a Kubernetes cluster and store them on a Target

Synopsis

Collect facts about a Kubernetes cluster (version, CRDs, storage classes, ingress classes, the managed service it runs on, its nodes' zones and label keys, and what enforces NetworkPolicy) and store them on a Target under the reserved "Cluster." fact prefix. Without permission to list Nodes, the facts read from them are left out. Without permission to get the amazon-vpc-cni ConfigMap in kube-system, Cluster.NetworkPolicyEnforcer is left out on clusters running the Amazon VPC CNI.

Collection owns the "Cluster." namespace: it (re)writes those facts and removes stale ones, while leaving user-defined facts (any key outside the prefix) untouched. Cluster.Name is not discoverable, so it is set only from --cluster-name or --kube-context, and otherwise left as it was.

The kubeconfig is loaded with the same precedence as 'cub k8s source':

  1. --kubeconfig flag (highest priority, no merging)
  2. KUBECONFIG environment variable (merges multiple files)
  3. $HOME/.kube/config (default)

Examples:

  # Collect facts and store them on a target
  cub k8s collect --space my-space --kube-context kind-kind my-target

  # Preview the facts without updating any target
  cub k8s collect --kube-context kind-kind --dry-run
cub k8s collect [<target-slug-or-id>] [flags]

Options

      --cluster-name string   value for the Cluster.Name fact (defaults to the kube context name)
      --component string      the Component of --variant, when that names the variant alone; --variant <component>/<variant> says the same in one flag
      --dry-run               print the collected facts without updating any target
  -h, --help                  help for collect
      --kube-context string   kubeconfig context of the cluster to collect facts from (defaults to the current context)
      --kubeconfig string     path to the kubeconfig file to use
      --space string          space to operate in, by slug or UUID. Omitted, a list or bulk operation spans the organization and a single entity is named as <space>/<slug>; "*" means the same as omitting it
      --variant string        variant to operate in, as <component>/<variant>, or as <variant> with --component: the space naming that Component whose Variant label is <variant>. The same scope as --space, named by what it is rather than by the space's slug; the two cannot be combined

Options inherited from parent commands

      --context string   The context to use for this command
      --debug            Debug output

SEE ALSO