1

I am trying to expose a new app created via openshift command line(oc). This is a nodeJS server listening on port=3000. However, opeshift defaults the target-port to 8080 as shown in the following service.yaml:

kind: Service
apiVersion: v1
.............
.............
spec: 
  ports:
    - name: 8080-tcp
      protocol: TCP
      port: 8080
      targetPort: 8080
.........

I want to be able to update targetPort via the command line. I already followed these steps, but no luck so far:

step1: oc new-project my-new-project

step2: oc new-app https:\\github.org.com\my-new-app.git

step3: oc expose service my-new-app --target-port=3000

Error: **cannot use --target-port with --generator=route/v1**

Note: I am able to access the app(i.e. port=3000) only when I manually update targetPort to 3000 in Services.yaml.

Mario Galic
  • 47,285
  • 6
  • 56
  • 98
nihal
  • 357
  • 1
  • 3
  • 18

1 Answers1

-1

You didnt specify port . Try this.

oc expose service my-new-app --target-port=3000 --port=8080

Saurabh Nigam
  • 795
  • 6
  • 12
  • Same error even after adding the port parameter error: cannot use --target-port with --generator=route/v1 – nihal Sep 06 '20 at 16:26