<p>I'm just getting started with GCP and Kubernetes Engine. So far I managed to start a Kubernetes cluster, run my app in a pod and connect it to a Cloud SQL instance. I also added a load balancer so now my app has a static IP and I should be able to connect to it from the outside. </p>

<p>However, I just get a <code>DisallowedHost</code> error? Which IP should I allow? The IP of the pod that is completely random or the IP of the load balancer?</p>

tarikki
<p>Turns out, it's the IP of the load balancer. In the settings.py file I changed the allowed hosts to</p>

<pre><code>ALLOWED_HOSTS = [os.environ.get('LOAD_BALANCER_IP', '127.0.0.1')]
</code></pre>

<p>and in my deployment yaml I added the load balancer IP as an evironment variable to my container:</p>

<pre><code>spec:
  containers:
    - env:
      - name: LOAD_BALANCER_IP
        value: xx.xx.xx.xx
</code></pre>

<p>This way I can have the app work automatically both on deploy to the kubernetes cluster and on localhost for development.</p>
