<p>We have a little internal tool listing our Kubernetes services using <a href="https://godoc.org/k8s.io/client-go/kubernetes" rel="nofollow noreferrer">Go client for Kubernetes</a>.</p>

<p>Now we have added Traefik to map our services to meaningful dns names using ingress controllers. We see that there is an <a href="https://github.com/kubernetes/client-go/blob/master/listers/extensions/v1beta1/ingress.go" rel="nofollow noreferrer">ingress lister extension</a> in Go client for Kubernetes that can be used to list ingress controllers. However, we could not make it work.</p>

<p>Are there any Go client code snippets listing ingress controllers? </p>

Maksim Sorokin
<p>What have you tried so far? Posting examples helps. Try the following arbitrary example to get you started:</p>

<pre><code>    // imports
    // metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    // "k8s.io/client-go/kubernetes"
    // "k8s.io/client-go/tools/clientcmd"

    // create the clientset
    clientset, err := kubernetes.NewForConfig(config)
    if err != nil {
            panic(err.Error())
    }
    for {
            ingressList, err := clientset.ExtensionsV1beta1().Ingresses("").List(metav1.ListOptions{})
            if err != nil {
                    // handle err
            }
            ingressCtrls := ingressList.Items
            if len(ingressCtrls) &gt; 0 {
                    for _, ingress := range ingressCtrls {
                            fmt.Printf("ingress %s exists in namespace %s\n", ingress.Name, ingress.Namespace)
                    }
            } else {
                    fmt.Println("no ingress found")
            }
            time.Sleep(10 * time.Second)
    }
</code></pre>
