Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running wiremock docker container in K8S with custom port generates "port xxxx is not a recognized option" #1825

Closed
grahambunce opened this issue Mar 2, 2022 · 1 comment

Comments

@grahambunce
Copy link

grahambunce commented Mar 2, 2022

Version: Wiremock docker container: wiremock/wiremock:latest-alpine (v2.32)
How starting:

Running wiremock in K8S to act as our service virtualization platform. Architecture is:

Custom Proxy as single endpoint to calling service. This proxy forwards to individual wiremock instances. each responsible for virtualizing a specific remote service (we cannot have one wiremock responsible for 2 remote services due to #1783).

We run this within a single K8S service/pod - our custom proxy container and 2 wiremock containers. Since it is in a single pod each container needs it's own port - we cannot use 8080 for both wiremock containers as they will conflict.

We run one wiremock container on port 8080 and wish to run the other on port 8081 (or anything else really, doesn't matter).

We pass an Args to the second wiremock (--port 8081). Container fails to start with

Exception in thread "main" joptsimple.UnrecognizedOptionException: port 8081 is not a recognized option
	at joptsimple.OptionException.unrecognizedOption(OptionException.java:108)
	at joptsimple.OptionParser.handleLongOptionToken(OptionParser.java:510)
	at joptsimple.OptionParserState$2.handleArgument(OptionParserState.java:56)
	at joptsimple.OptionParser.parse(OptionParser.java:396)
	at com.github.tomakehurst.wiremock.standalone.CommandLineOptions.<init>(CommandLineOptions.java:342)
	at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.run(WireMockServerRunner.java:49)
	at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.main(WireMockServerRunner.java:133)

Somehow it looks like port is not being picked up correctly by the docker container though this works fine when running as a plain docker container.

examples:

Works fine:

docker run --name virtualservice ^
  -d -p:9000:9000 ^
  -v C:\dev\local-environment\wiremock\data:/home/wiremock ^
  wiremock/wiremock:latest-alpine --port 9000

fails:

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: virtual-services
  name: proxyservice
  labels:
    app: proxyservice
spec:
  minReadySeconds: 5
  replicas: 1
  selector:
    matchLabels:
      app: proxyservice
  template:
    metadata:
      labels:
        app: proxyservice
    spec:
      volumes:
        - name: proxyservice-service1-volume
          hostPath:
            path: /run/desktop/mnt/host/c/dev/local-environment/wiremock/data/service1
            type: Directory
        - name: proxyservice-service2-volume
          hostPath:
            path: /run/desktop/mnt/host/c/dev/local-environment/wiremock/data/service2
            type: Directory  
      containers:
        - name: proxyservice
          image: proxyservice:latest
          imagePullPolicy: Never
          ports:
            - containerPort: 80
          env:
            - name: service.virtualization.enabled
              value: "false"
        - name: virtualservice1
          image: wiremock/wiremock:latest-alpine
          ports:
            - containerPort: 8080
          volumeMounts:
            - name: proxyservice-service1-volume
              mountPath : "/home/wiremock"
              readOnly: false
        - name: virtualservice2
          image: wiremock/wiremock:latest-alpine
          ports:
            - containerPort: 8081
          args: ["--port 8081"]
          volumeMounts:
            - name: proxyservice-service1-volume2
              mountPath : "/home/wiremock"
              readOnly: false
---

In K8S it's my understanding that the "args" are passed to the ENTRYPOINT in the underlying docker container.

Alternative ARGS (e.g. --verbose) appear to work fine so it seems that "port" specifically has an issue somehow

@tomakehurst
Copy link
Member

Since this is a question rather than a bug report, please can you post it to the mailing list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants