stefanprodan / podinfo

Go microservice template for Kubernetes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting a port on the PodSpec results in a HTTP server crash

luxas opened this issue · comments

{"level":"fatal","ts":"2019-03-21T17:48:59.820Z","caller":"api/server.go:127","msg":"HTTP server crashed","error":"listen tcp: address :tcp://10.111.55.252:9898: too many colons in address","stacktrace":"github.com/stefanprodan/k8s-podinfo/pkg/api.(*Server).ListenAndServe.func1\n\t/go/src/github.com/stefanprodan/k8s-podinfo/pkg/api/server.go:127"}

Seems like the HTTP server's Config object's Port field somehow became tcp://10.111.55.252:9898 due to some viper auto-detection from env variables created by k8s?

ref: https://github.com/stefanprodan/k8s-podinfo/blob/master/pkg/api/server.go#L104

Ah.. the Kubernetes ENV is prefixing the vars with PODINFO probably...

Yep, PODINFO_PORT=tcp://10.100.7.158:9898 is present in a k8s-run container with a Pod port set

Do you have the --port=9898 arg in pod spec?

Use this:

        image: quay.io/stefanprodan/podinfo:1.4.0
        command:
          - ./podinfo
          - --port=9898

The arg should overwrite the env var.

Yeah, but can we detect it after viper's auto-detection so that e.g. kubectl run-demos work?

@luxas it should work now with version 1.4.3