How to parameterize ports in OpenShift JSON Project Template -


i'm trying create custom project template in openshift origin. service configuration specifically, looks below:

{   "kind": "service",   "apiversion": "v1",   "metadata": {     "name": "${name}",     "annotations": {       "description": "exposes , load balances node.js application pods"     }   },   "spec": {     "ports": [       {         "name": "web",         "port": "${application_port}",         "targetport": "${application_port}",         "protocol": "tcp"       }     ],     "selector": {       "name": "${name}"     }   } }, 

where, application_port supplied user parameter:

"parameters": [   {     "name": "application_port",     "displayname": "application port",     "description": "the exposed port route node.js application",     "value": "8000"   }, 

when try use template create project, following error:

spec.ports[0].targetport: invalid value: "8000": must iana_svc_name (at 15 characters, matching regex [a-z0-9]([a-z0-9-]*[a-z0-9])*... 

i similar error in deploymentconfig well, http ports in liveness , readiness probes:

"readinessprobe": {   "timeoutseconds": 3,   "initialdelayseconds": 3,   "httpget": {     "path": "/info",     "port": "${application_admin_port}"   } }, "livenessprobe": {   "timeoutseconds": 3,   "initialdelayseconds": 30,   "httpget": {     "path": "/info",     "port": "${application_admin_port}"   } }, 

where, application_admin_port, again, user-supplied.

error:

spec.template.spec.containers[0].livenessprobe.httpget.port: invalid value: "8001": must iana_svc_name...  spec.template.spec.containers[0].readinessprobe.httpget.port: invalid value: "8001": must iana_svc_name... 

i've been following https://blog.openshift.com/part-2-creating-a-template-a-technical-walkthrough/ understand templates, , it, unfortunately, not have examples of ports being parameterized anywhere.

it seems if strings not allowed values of these ports. case? what's right way parameterize these values? should switch yaml?

versions:

openshift master: v1.1.6-3-g9c5694f

kubernetes master: v1.2.0-36-g4a3f9c5

edit 1: tried same configuration in yaml format, , got same error. so, json vs yaml not issue.

unfortunately not possible parameterize non-string field values: https://docs.openshift.org/latest/dev_guide/templates.html#writing-parameters

" parameters can referenced placing values in form "${parameter_name}" in place of string field in template."

templates in process of being upstreamed kubernetes , limitation being addressed there: https://github.com/kubernetes/kubernetes/blob/master/docs/proposals/templates.md

the proposal being implemented in prs 25622 , 25293 in kubernetes repo.

edit: templates support non-string parameters documented here: https://docs.openshift.org/latest/dev_guide/templates.html#writing-parameters


Comments