Bug 1340148 - oc expose --container-port not regarded
Summary: oc expose --container-port not regarded
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: oc
Version: 3.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Michail Kargakis
QA Contact: Xingxing Xia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-05-26 14:18 UTC by Aleksandar Kostadinov
Modified: 2016-09-19 13:53 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-09-19 13:53:06 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Aleksandar Kostadinov 2016-05-26 14:18:49 UTC
Description of problem:
See output. When using --container-port it is not regarded but port 22 is used.

$ oc expose dc git-server --port=22 --container-port=2022 -o yaml
apiVersion: v1
kind: Service
metadata:
  creationTimestamp: 2016-05-26T14:15:16Z
  labels:
    run: git-server
  name: git-server
  namespace: test
  resourceVersion: "8436"
  selfLink: /api/v1/namespaces/test/services/git-server
  uid: 44fd2671-234c-11e6-9c1d-fa163ea772b0
spec:
  clusterIP: 172.30.43.154
  portalIP: 172.30.43.154
  ports:
  - port: 22
    protocol: TCP
    targetPort: 22
  selector:
    run: git-server
  sessionAffinity: None
  type: ClusterIP
status:
  loadBalancer: {}

Version-Release number of selected component (if applicable):
oc v3.2.0.45

How reproducible:
always

Comment 1 Michail Kargakis 2016-05-31 09:01:17 UTC
Fixed upstream in https://github.com/kubernetes/kubernetes/pull/26554

Note that --container-port is deprecated in favor of --target-port (--target-port works as expected)

Comment 2 Aleksandar Kostadinov 2016-05-31 09:11:49 UTC
container port is clearer than target-port. When thinking about it which is the target? Source port or the port service will listen on? I know the answer, just saying that `target` is the less descriptive word.

Also where it is stated that `container-port` is deprecated?

Comment 3 Michail Kargakis 2016-05-31 09:19:54 UTC
As per the service spec[1], "targetPort" is the name of the field so --target-port seems more intuitive than --container-port. We will get the deprecation message once the rebase lands (hopefully around this week). In the meantime, you can observe it if you run vanilla kubectl or look at the source code[2]

[1] https://github.com/openshift/origin/blob/681170a6794859a24dcf35c6694a7718083ad853/api/swagger-spec/api-v1.json#L19367
[2] https://github.com/kubernetes/kubernetes/blob/3d1b1a77e4aca2db25d465243cad753b913f39c4/pkg/kubectl/cmd/expose.go#L114

Comment 4 Aleksandar Kostadinov 2016-05-31 12:34:05 UTC
More intuitive to those that know the API. I'm sure cli non-advanced users will understand container-port better.

The thing is that if `container-port` did not ever worked, then maybe it's better to just remove the option (although I prefer to keep it forever). But why fix it and then deprecate? If you remove the option, nobody is really hurt. Or document it as a noop? Or leave it out of help but keep it acceptable for old scripts (but still being noop)?

Comment 5 Michail Kargakis 2016-06-07 11:53:56 UTC
Fix is on master: https://github.com/openshift/origin/pull/9178

Comment 6 Xingxing Xia 2016-06-08 09:05:38 UTC
Verified in oc v1.3.0-alpha.1-178-gc5bd429, '--container-port' takes effect now. Fixed.


Note You need to log in before you can comment on or make changes to this bug.