<p>In my gcloud console it shows the following error for my defined ingresses: </p>

<blockquote>
  <p>Error during sync: error while evaluating the ingress spec: service
  "monitoring/kube-prometheus" is type "ClusterIP", expected "NodePort"
  or "LoadBalancer"</p>
</blockquote>

<p>I am using traefik as reverse proxy (instead of nginx) and therefore I define an ingress using a ClusterIP. As far as I understand the process all traffic is proxied through the traefik service (which has a Loadbalancer ingress defined) and therefore all my other ingresses SHOULD actually have a ClusterIP instead of NodePort or Loadbalancer?</p>

<p><strong>Question:</strong></p>

<p>So why does Google Cloud warn me that it expected a NodePort or LoadBalancer?</p>

<p><a href="https://i.stack.imgur.com/WzOKi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WzOKi.png" alt="enter image description here"></a></p>

kentor
<p>I don't know why that error happens, because it seems (to me) to be a valid configuration.  But to clear the error, you can switch your service to a named NodePort.  Then switch your ingress to use the port name instead of the number.  For example:</p>

<p>Service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: testapp
spec:
  ports:
  - name: testapp-http # ADD THIS
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: testapp
  type: NodePort
</code></pre>

<p>Ingress:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: testapp
spec:
  rules:
  - host: hostname.goes.here
    http:
      paths:
      - backend:
          serviceName: testapp
          # USE THE PORT NAME FROM THE SERVICE INSTEAD OF THE PORT NUMBER
          servicePort: testapp-http
        path: /
</code></pre>

<p>Update:</p>

<p>This is the explanation I received from Google.</p>

<p>Since services by default are ClusterIP [1] and this type of service is meant to be accessible from inside the cluster. It can be accessed from outside when kube-proxy is used, not meant to be directly accessed with an ingress.</p>

<p>As a suggestion, I personally find this article [2] good for understanding the difference between these types of services.</p>

<p>[1] <a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types</a></p>

<p>[2] <a href="https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0" rel="noreferrer">https://medium.com/google-cloud/kubernetes-nodeport-vs-loadbalancer-vs-ingress-when-should-i-use-what-922f010849e0</a></p>
