<p>I have created an pub/sub topic to which I will publish a message every time an new object is uploaded to the bucket. Now I want to create a subscription to push a notification to an endpoint every time a new object is uploaded to that bucket. Following the documentation, I wanted something like that:</p>

<p><code>
gcloud alpha pubsub subscriptions create orderComplete \
        --topic projects/PROJECT-ID/topics/TOPIC \
        --push-endpoint http://localhost:5000/ENDPOINT/
        --ack-deadline=60
</code>
However my app is running on kubernetes and it seems that pub/sub cannot reach my endpoint. Any suggestions?</p>

gr7
<p>In order for Cloud Pub/Sub to push messages to your application, you need to provide a publicly accessible endpoint. In Kubernetes, this most likely means exposing a <a href="https://kubernetes.io/docs/tutorials/kubernetes-basics/expose/expose-intro/" rel="nofollow noreferrer">Service</a>. With this, you should have a non-local (i.e. no “localhost”) URL to reach the pods running your binaries.</p>

<p>Before creating the Cloud Pub/Sub subscription, you should also <a href="https://cloud.google.com/pubsub/docs/push#domain_ownership_validation" rel="nofollow noreferrer">verify your domain</a> with the Cloud Console.</p>

<p>Finally, you can set your subscription to push messages by <a href="https://cloud.google.com/pubsub/docs/admin#subscriber-update-push-configuration-gcloud#change_pull_push" rel="nofollow noreferrer">changing its configuration</a>:</p>

<pre><code>gcloud pubsub subscriptions modify-push-config mySubscription \
  --push-endpoint="https://publicly-available-domain.com/push-endpoint"
</code></pre>
