Is there a command I can run or is there some way to identify whether a cluster has one or more ingress controllers configured?
I'm not asking about the actual ingresses themselves (which I know can be found with kubectl get ingress --all-namespaces
).
As each IngressController needs the privilege to access Ingresses, we can find out all Roles and ClusterRoles which could access Ingress, and then RoleBindings/ClusterRoleBindings, associated ServiceAccounts, finally get all Pods using those ServiceAccounts.
There is no specific way since an ingress controller is really just a daemon that talks to the kubernetes API. There is no centralized registration for them. You can start from kubectl get pods --all-namespaces
and compare against the names of known controllers.
There is no fancy way to achieve what you need. These two commands can help you and it really depends on what you need to choose between them.
$ kubectl get pods --all-namespaces -o=jsonpath='{range .items[*]}{"\n"}{.metadata.name}{":\t"}{range .metadata}{.labels}{", "}{end}{end}' | grep ingress | grep controller
$ kubectl get pods --show-labels --all-namespaces | grep ingress | grep controller
Both commands are similar but with different outputs.
These commands are based on this documation page.
You can list all ingress controller pod by using selector. For example
kubectl get pods --all-namespaces --selector app=nginx-ingress,component=controller