Search code examples
apache-kafkakubernetes-helmkubernetes-ingressconfluent-platformnginx-ingress

How to enable ingress in minikube cluster for kafka-confluent


I searched for a solution to have confluentic-kafka work with ingress, and I reached this PR that did such implementation, but this PR isn't accepted (yet - the repository owner dropped and the repo doesn't exist any more).

So, I tried to implement something very simple as a proof of concept using as a reference this manual.

Currently I have ingress enabled:

$ kubectl get ingress
NAME            CLASS    HOSTS         ADDRESS   PORTS   AGE
kafka-ingress   <none>   kafka.local             80      40m

using this yaml file that was applied :

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: kafka-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
spec:
  rules:
    - host: kafka.local
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: kafka-cp-kafka-rest
                port:
                  number: 8082

The kafka was installed from helm-charts, and the services in my minikube cluster (on linux machine) looks like:

kubectl get svc
NAME                          TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)             AGE
kafka-cp-control-center       ClusterIP   10.111.250.7     <none>        9021/TCP            63m
kafka-cp-kafka                ClusterIP   10.100.60.8      <none>        9092/TCP,5556/TCP   63m
kafka-cp-kafka-connect        ClusterIP   10.99.105.18     <none>        8083/TCP,5556/TCP   63m
kafka-cp-kafka-headless       ClusterIP   None             <none>        9092/TCP            63m
kafka-cp-kafka-rest           ClusterIP   10.108.102.194   <none>        8082/TCP,5556/TCP   63m
kafka-cp-ksql-server          ClusterIP   10.104.173.97    <none>        8088/TCP,5556/TCP   63m
kafka-cp-schema-registry      ClusterIP   10.110.6.112     <none>        8081/TCP,5556/TCP   63m
kafka-cp-zookeeper            ClusterIP   10.109.42.247    <none>        2181/TCP,5556/TCP   63m
kafka-cp-zookeeper-headless   ClusterIP   None             <none>        2888/TCP,3888/TCP   63m
minio 

                    ClusterIP   10.98.39.90      <none>        9000/TCP            63m

and I had added to my /etc/hosts a mapping from my minikube address to kafka.local host:

192.168.49.2 kafka.local

when using this curl call I get a response:

curl http://10.108.102.194:8082/topics

But when I'm trying to call:

curl http://kafka.local/topics

I'm getting:

curl: (7) Failed to connect to kafka.local port 80: Connection refused

How can I manage to call the kafka-rest service via ingress using a host?


Solution

  • It worked only when I started my minikube without a driver (to be created on the storage of the machine and not as a VM) and specifying the 9.x ingress network ip (to get it I ran: ip a):

    minikube start --driver=none --apiserver-ips <9.x.x.x>
    

    One more thing that I did is removing the:

    annotations: nginx.ingress.kubernetes.io/rewrite-target: /$1

    from my resource yaml.

    Hope it can help others.