Search code examples
kubectl

How to get the status of multiple services with kubectl?


As per my understanding of the docs, the -R flag should do exactly this, but for me the command kubectl rollout status -R -f k8s/services fails with error: rollout status is only supported on individual resources and resource collections - 3 resources were found.

In the k8s/services directory I have 3 service manifests. What is a resource collection, mentioned in the error message, if not 3 services for example? What should be in the directory when using -R?

kubectl rollout status --help:

Show the status of the rollout.

 By default 'rollout status' will watch the status of the latest rollout until it's done. If you don't want to wait for
the rollout to finish then you can use --watch=false. Note that if a new rollout starts in-between, then 'rollout
status' will continue watching the latest revision. If you want to pin to a specific revision and abort if it is rolled
over by another revision, use --revision=N where N is the revision you need to watch for.

Examples:
  # Watch the rollout status of a deployment
  kubectl rollout status deployment/nginx

Options:
  -f, --filename=[]: Filename, directory, or URL to files identifying the resource to get from a server.
  -k, --kustomize='': Process the kustomization directory. This flag can't be used together with -f or -R.
  -R, --recursive=false: Process the directory used in -f, --filename recursively. Useful when you want to manage
related manifests organized within the same directory.
      --revision=0: Pin to a specific revision for showing its status. Defaults to 0 (last revision).
      --timeout=0s: The length of time to wait before ending watch, zero means never. Any other values should contain a
corresponding time unit (e.g. 1s, 2m, 3h).
  -w, --watch=true: Watch the status of the rollout until it's done.

Usage:
  kubectl rollout status (TYPE NAME | TYPE/NAME) [flags] [options]

Use "kubectl options" for a list of global command-line options (applies to all commands).

I have tested with kubectl version 1.14 and 1.15.


Solution

  • It means that it found 3 services, but you can only see roll out status for a specific service. like :

    kubectl rollout status -f k8s/services/<svc-name>.yaml

    You don't need to use -R when all yamls are the child of services.

    Take a look why -R flag was added in this issue