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
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)
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?
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
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)?
Fix is on master: https://github.com/openshift/origin/pull/9178
Verified in oc v1.3.0-alpha.1-178-gc5bd429, '--container-port' takes effect now. Fixed.