pact-foundation/pact-broker-docker

Can't use Kubernetes with deployment name 'pact-broker', conflicts with PACT_BROKER_PORT

maelvls opened this issue · 3 comments

I have already (please mark the applicable with an `x`):
  • Confirmed this is the right place to raise the issue - only issues related to the Dockerization of the Pact Broker should be raised here. Issues related to the Pact Broker application itself should be raised in the Pact Broker project.
  • Upgraded to the latest Pact Broker Docker image OR
  • Checked the CHANGELOG to see if the issue I am about to raise has been fixed
  • Read the Troubleshooting page

Software versions

  • pact-broker gem version: 2.34.0
  • pact-broker docker version: 2.34.0-1
  • OS: macOS 10.14.5 (18F132)
  • using Docker for Mac 2.1.0.0 (Docker Engine 19.03.1 + docker-desktop Kubernetes v1.14.3)

Description of the issue

When creating a Deployment, kubernetes injects environment variables such as PACT_BROKER_PORT (this issue only appears when the deployment name is pact-broker)

% kubectl exec -n pact pact-6755d8cb98-jbdlm
[...]
PACT_BROKER_PORT=tcp://10.103.77.49:80
KUBERNETES_SERVICE_HOST=10.96.0.1
KUBERNETES_PORT_443_TCP_PORT=443
KUBERNETES_PORT_443_TCP_ADDR=10.96.0.1
PACT_BROKER_SERVICE_HOST=10.103.77.49
PACT_BROKER_PORT_80_TCP_PROTO=tcp
PACT_BROKER_PORT_80_TCP_PORT=80
PACT_BROKER_PORT_80_TCP_ADDR=10.103.77.49
KUBERNETES_PORT=tcp://10.96.0.1:443
KUBERNETES_PORT_443_TCP=tcp://10.96.0.1:443
PACT_BROKER_SERVICE_PORT=80
PACT_BROKER_PORT_80_TCP=tcp://10.103.77.49:80
KUBERNETES_SERVICE_PORT_HTTPS=443
KUBERNETES_SERVICE_PORT=443
KUBERNETES_PORT_443_TCP_PROTO=tcp
PACT_BROKER_SERVICE_PORT_80=80

Some of these conflict with what pact-broker expects: Kubernetes sets PACT_BROKER_PORT to tcp://10.103.77.49:80 but pact-broker expects 80 which gives the error:

Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.3-p62), codename: Llamas in Pajamas
* Min threads: 0, max threads: 16
* Environment: production
URI::InvalidURIError: bad URI(is not URI?): "tcp://0.0.0.0:tcp://10.103.77.49:9292"

What is your thought on that?

Workaround

Change the deployment name from pact-broker to pact-broker2 for example.

Steps to reproduce

git clone https://github.com/maelvls/pact-broker-kubernetes --branch=pact-broker-docker-issue-7
cd pact-broker-kubernetes/kubernetes
ls *.yaml | xargs -L1 kubectl apply -f

I'm not sure if there's anything that we can do about it. We can't change the name without breaking backwards compatibility. The only thing I can think of is to maintain your own dockerfile.

I've got the same issue.
Thanks for the clear description and suggested fix.
Fixed by renaming to pact-broker-prod

I'm closing this issue as there isn't a code change that we can make to fix this - it has to be done on the kube side. If someone would like to add some documentation to help future Kubernetes users, that would be great.