<p>How can I expose a StatefulSet service (cassandra, mysql, etc...) with <code>ClusterIP=None</code> on Kubernetes in Google Cloud Platform?</p>

<p>I need to change the ClusterIP config? Or I need to configure Google Cloud NAT? Or I need to change other things?</p>

<p>Thanks</p>

<p>EDIT: I want to connect to cassandra from an external IP, from anyplace on the internet</p>

<p>EDIT2: I guess that the solution is to use <code>LoadBalance</code> instead of <code>ClusterIP</code>, but when I use <code>LoadBalance</code>, the Cassandra nodes can't find the seed node. Then I sill using <code>ClusterIP=None</code> to Cassandra cluster, and I created another POD with <code>type=LoadBalance</code> to connect to Cassandra and to have connections to exterior. And now it's working :)</p>

<p>If by "<strong><em>expose</em></strong>" you mean ability to reach your service endpoints without cluster IP , then just use <code>selector</code> in your headless service, i.e.</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: cassandra
spec:
  clusterIP: None
  selector:
    app: cassandra
  ports:
  - port: 80
    targetPort: 80
</code></pre>

<p>For more details refer to  <a href="https://kubernetes.io/docs/concepts/services-networking/service/#with-selectors" rel="noreferrer">documentation</a>  </p>

<p>Otherwise, if you want to expose your deployments outside of the cluster, you won't be able to do it with headless service.</p>
