<p>I have a very simple go application that works fine under Windows and Mac. (I am a golang newbie btw). The purpose of the application is to subscribe to a google cloud pubsub subscription and forward the messages to another application using REST.</p>

<p>The code looks like:</p>

<pre><code>func getOrCreateTopic() {
    log.Infof("1")
    ctx := context.Background()

    log.Infof("2")
    topicName := viper.GetString("gce.pubsub.topic")
    log.Infof("3")
    topic = client.Topic(topicName)
    log.Infof("4")
    exists, _ := topic.Exists(ctx)
    log.Infof("5")
    if topic == nil || !exists {
        topic, err = client.CreateTopic(ctx, topicName)
        if err != nil {
            log.Errorf("Failed to create topic %s: %v", topicName, err)
            os.Exit(2)
        }
    }
}

func main() {
    ...
    getOrCreateTopic();
    ...
}
</code></pre>

<p>I created a docker container and published it to our kubernetes cluster in google cloud. What I see in the logs is everything until "4" and then nothing more. But the process is still shown as running in kubernetes.</p>

<p>I am lost, it seems like the call to the API just hangs.</p>

SebastianStehle
<p>In case anyone else is encountering this same issue, I was able to solve it using the link from the OP.  However, I looked past this link the first time I saw it because it mentioned using the cloud pubsub emulator.</p>

<p>I am not using the pubsub emulator in my project so I continued to read until I got to the section about SSL certificates.  The absence of SSL certificates was the root cause of the hanging function.</p>

<p>I am using the <code>scratch</code> docker image in my project which does not include ssl certificates by default.  I was able to resolve the hanging code by copying the ssl certificates from my golang build image in my multi-stage build.</p>

<pre><code>FROM golang
COPY ./ /go/src/app
WORKDIR /go/src/app
RUN CGO_ENABLED=0 GOOS=linux go build -o /build/main

FROM scratch
COPY --from=0 /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=0 /build/main /main
CMD ["/main"]
</code></pre>

<p>ps: I know this post is old, but I nearly missed the resolution so I wanted to help anyone else who might enounter this issue in the future.</p>
