14

I just installed the controller via Helm, I can list the helm packages via helm list, but is it possible to list all the controllers running in the cluster via kubectl or api-query?

3 Answers 3

5

Not sure if there is a way to list controllers in k8s. every resource/object in k8s is controlled by a controller (control loop) with spec fields as values for desired state. if you have deployed a controller outside control plane (built-in controllers) then what i will do to find the controller:

  1. find the resource/object by running kubectl api-resources
  2. verify the list and find the resource name
  3. search all pods and grep the resource name kubectl get pods --all-namespaces |grep <resource-name>
  4. the pod in the above search will be running you controller
  5. NOTE: the pod name might not contain the resource name but it will contain some similar name. i just share this info to understand what a controller is and how external controller works other than (build in controllers).

more info - https://kubernetes.io/docs/concepts/architecture/controller/

4

If you mean replication controller then you can list them by kubectl:

kubectl get replicationcontroller -n my-namespace

Or list them all from all the namespaces:

kubectl get rc --all-namespaces

And you can also use API:

curl http://localhost:8080/api/v1/replicationcontrollers

Update: You can list other controller types like replicaset (rs), deployment (deploy), statefulset, daemonset (ds) and job in the same way.

5
  • 1
    actually I was looking if it's possible to list all controller running in my cluster, like https://github.com/kubernetes-sigs/aws-alb-ingress-controller Commented Sep 13, 2018 at 6:57
  • I think you want the absolute 'all' controller in k8s. Don't think there's a command for that.
    – Rico
    Commented Sep 13, 2018 at 14:32
  • 1
    That alb-ingress-controller is realized by Deployment so you can list it by kubectl get deployment - -all-namespaces -l app=alb-ingress-controller
    – cgrim
    Commented Sep 13, 2018 at 17:03
  • @Rico You are mixing up resources and controllers. kubectl get all doesn't list controllers. It lists workload resources, i.e. resources under the apps Api Group.
    – adamency
    Commented Mar 30 at 21:50
  • Does my answer have kubectl get all? I see kubectl .... --all-namespaces
    – Rico
    Commented Mar 30 at 22:11
3

General answer ignoring the specifics of the original question:
You could check the --controllers argument set for kube-controller-manager daemon. To quote from the docs (as of v1.26):

A list of controllers to enable. '*' enables all on-by-default controllers, 'foo' enables the controller named 'foo', '-foo' disables the controller named 'foo'.

You can also check the logs of this process. For example, if you have a setup where kube-controller-manager runs as static pod, you can run kubectl logs -n kube-system kube-controller-manager (make sure to get exact namespace and pod name right) and inspect the logs. The logs indicate what controllers are started and skipped.
More specifically you could do kubectl logs -n kube-system kube-controller-manager | grep Started. This should reflect all controllers that were successfully started and returns output like this:

I0114 11:09:28.124108       1 controllermanager.go:622] Started "pvc-protection"
I0114 11:09:28.126523       1 controllermanager.go:622] Started "root-ca-cert-publisher"
I0114 11:09:28.130637       1 controllermanager.go:622] Started "disruption"
(...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.