<p>I am trying to create a service using following yaml. As you can see I am trying to restrict access to the service from 10.0.0.0/8 range.</p>

<pre><code>apiVersion: v1
kind: Service
metadata: 
  name: nginx-service
spec: 
  ports:
    # the port that this service should serve on
    - port: 443
      targetPort: 443
  # label keys and values that must match in order to receive traffic for this service
  selector: 
    name: nginx
  type: LoadBalancer
  loadBalancerSourceRanges:
  - 10.0.0.0/8
</code></pre>

<p>There are a few Kubernetes documents (listed below) that discuss how to use loadBalancerSourceRanges annotation to control service access. </p>

<p><a href="http://kubernetes.io/docs/user-guide/services-firewalls/" rel="noreferrer">http://kubernetes.io/docs/user-guide/services-firewalls/</a></p>

<p>However when I try to create this service, I get an error as follows</p>

<blockquote>
  <p>error validating "sdp-cluster.yaml": error validating data: found
  invalid field loadBalancerSourceRanges for v1.ServiceSpec; if you
  choose to ignore these errors, turn validation off with
  --validate=false</p>
</blockquote>

<p>I looked at the v1.ServiceSpec and could not find it there too. </p>

<p>Am I missing something? How can I restrict traffic to a service in Kubernetes?</p>

<p>This is now supported on GCE, GKE and AWS. If the provider does not support it, it'll be ignored.<a href="https://kubernetes.io/docs/tasks/access-application-cluster/configure-cloud-provider-firewall/" rel="noreferrer">Kubernetes Doc</a></p>

<pre><code>apiVersion: v1
kind: Service
metadata:
    name: myapp
spec:
    ports:
    - port: 8765
        targetPort: 9376
    selector:
    app: example
    type: LoadBalancer
    loadBalancerSourceRanges:
    - 10.0.0.0/8
</code></pre>
