<p>Similar to <a href="https://stackoverflow.com/questions/53299238/how-can-i-check-what-ingress-controller-i-have-on-my-kube-and-what-is-the-defaul">this question</a> but for generic kubernetes. How can software I'm writing programmatically detect whether there is any ingress controller already existing in the cluster? </p>

<p>Yes it's a bit tricky because there is no such API object as <code>ingress-controler</code> but only <code>ingress</code>. <code>Ingress</code> in it's turn is only loosely coupled to ingress controller and do not need the latter to be deployed successfully. So the presence of Ingress resource could not be the indication of ingress controller on it's own.</p>

<p>However the trick you <strong><em>might</em></strong> want to exploit is using the <code>Events</code> section of Ingress as a source of some indicative information.</p>

<p>So when you deploy an Ingress in the fresh k8s cluster with no ingress-controller yet deployed the Events section is empty:</p>

<pre><code># deploy Ingress (no ingress controller yet)
$ kubectl apply -f - &lt;&lt;EOF
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test-ingress
spec:
  rules:
  - http:
      paths:
      - path: /testpath
        backend:
          serviceName: test
          servicePort: 80
EOF

# check that Ingress deployed successfully
$ k get ing
NAME           HOSTS   ADDRESS   PORTS   AGE
test-ingress   *                 80      36m

# confirm there are no Events so far
$ k describe ing
Name:             test-ingress
Namespace:        default
Address:          
Default backend:  default-http-backend:80 (&lt;none&gt;)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *     
        /testpath   test:80 (&lt;none&gt;)
...
  nginx.ingress.kubernetes.io/rewrite-target:  /
Events:                                        &lt;none&gt;

</code></pre>

<p>Then if you <a href="https://kubernetes.github.io/ingress-nginx/deploy/" rel="nofollow noreferrer">deploy the ingress controller</a> the Ingress' Events does get some extra info:</p>

<pre><code># deploy ingress controller
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/mandatory.yaml
namespace/ingress-nginx created
configmap/nginx-configuration created
configmap/tcp-services created
configmap/udp-services created
serviceaccount/nginx-ingress-serviceaccount created
clusterrole.rbac.authorization.k8s.io/nginx-ingress-clusterrole created
role.rbac.authorization.k8s.io/nginx-ingress-role created
rolebinding.rbac.authorization.k8s.io/nginx-ingress-role-nisa-binding created
clusterrolebinding.rbac.authorization.k8s.io/nginx-ingress-clusterrole-nisa-binding created
deployment.apps/nginx-ingress-controller created

# check Ingress details once again
$ k describe ing test-ingress
Name:             test-ingress
Namespace:        default
Address:          
Default backend:  default-http-backend:80 (&lt;none&gt;)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *     
        /testpath   test:80 (&lt;none&gt;)
...
  nginx.ingress.kubernetes.io/rewrite-target:  /
Events:
  Type    Reason  Age    From                      Message
  ----    ------  ----   ----                      ------- 

Normal  CREATE  7m11s  nginx-ingress-controller  Ingress default/test-ingress
</code></pre>
