Re: route hostname generation in template

2016-04-09 Thread Dale Bewley


- On Apr 8, 2016, at 2:38 PM, Aleksandar Lazic 
aleksandar.la...@cloudwerkstatt.com wrote:

> Hi Dale.
> 
> I have solved this with the
> 
> https://docs.openshift.org/latest/dev_guide/downward_api.html
> 

Thanks for the tip! Looks like it would not solve the route generation problem, 
however.

> Maybe it would be a good idea to have some default variables in the template
> which can be used such as.
> 
> namespace
> defaultdomain
> ...
> 

I agree that would be helpful.

For now I just made the hostname a required field in the template and provided 
an example hostname in the description.

___
users mailing list
users@lists.openshift.redhat.com
http://lists.openshift.redhat.com/openshiftmm/listinfo/users


Re: route hostname generation in template

2016-04-08 Thread Aleksandar Lazic
Hi Dale.

I have solved this with the 

https://docs.openshift.org/latest/dev_guide/downward_api.html

We use in the template the following.

###
DeploymentConfig
spec
  template
spec
  containers
env
  - name: PROJECT
valueFrom:
  fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
###

"parameters": [
{
"name": "PROJECT",
"description": "Project namespace",
"required": true
}


Then in the container is the namespace as ENV var PROJECT available.

But I'm not sure if you can use the same syntax fo the Routes.
Maybe it would be a good idea to have some default variables in the template 
which can be used such as.

namespace
defaultdomain
...

BR Aleks

From: users-boun...@lists.openshift.redhat.com 
<users-boun...@lists.openshift.redhat.com> on behalf of Dale Bewley 
<d...@bewley.net>
Sent: Friday, April 08, 2016 21:29
To: users@lists.openshift.redhat.com
Subject: route hostname generation in template

I'm creating a template which has 2 services. One is a python gunicorn and one 
is httpd.

I want the first service reachable at app-project.domain/ and the second 
service to be reachable at app-project.domain/static. That works, but I'm 
having trouble automating it in a template.

Unfortunately if I use default value of ${APPLICATION_DOMAIN} it includes the 
service name and I wind up with a distinct hostname in each route: 
app-static-project.domain and app-py-project.domain

{
  "kind": "Route",
  "apiVersion": "v1",
  "metadata": {
"name": "${NAME}-static"
  },
  "spec": {
"host": "${APPLICATION_DOMAIN}",
"path": "/${STATIC_DIR}",
"to": {
  "kind": "Service",
  "name": "${NAME}-static"
},
"tls": {
  "termination" : "edge"
}
  }
},
{
  "kind": "Route",
  "apiVersion": "v1",
  "metadata": {
"name": "${NAME}-py"
  },
  "spec": {
"host": "${APPLICATION_DOMAIN}",
"to": {
  "kind": "Service",
  "name": "${NAME}-py"
},
"tls": {
  "termination" : "edge"
}
  }
},


I could prompt for a hostname, but I would like to auto-generate the hostname 
to include the project by default. What I would like is 
-. in both routes.


Is is there a list somewhere of the variables available to templates?

___
users mailing list
users@lists.openshift.redhat.com
http://lists.openshift.redhat.com/openshiftmm/listinfo/users

___
users mailing list
users@lists.openshift.redhat.com
http://lists.openshift.redhat.com/openshiftmm/listinfo/users


Re: route hostname generation in template

2016-04-08 Thread Ben Parees
On Fri, Apr 8, 2016 at 4:01 PM, Jordan Liggitt  wrote:

> I'm pretty sure it is intentional that the only variables available are
> the ones defined in the template itself.
>

​right, those are not system variables or anything, they are just
parameters that users can provide values for.  if you provide no value for
a route hostname, you get a generated default, as seen when you left
APPLICATION_DOMAIN blank.

​


>
> On Fri, Apr 8, 2016 at 3:29 PM, Dale Bewley  wrote:
>
>> I'm creating a template which has 2 services. One is a python gunicorn
>> and one is httpd.
>>
>> I want the first service reachable at app-project.domain/ and the second
>> service to be reachable at app-project.domain/static. That works, but I'm
>> having trouble automating it in a template.
>>
>> Unfortunately if I use default value of ${APPLICATION_DOMAIN} it includes
>> the service name and I wind up with a distinct hostname in each route:
>> app-static-project.domain and app-py-project.domain
>>
>> {
>>   "kind": "Route",
>>   "apiVersion": "v1",
>>   "metadata": {
>> "name": "${NAME}-static"
>>   },
>>   "spec": {
>> "host": "${APPLICATION_DOMAIN}",
>> "path": "/${STATIC_DIR}",
>> "to": {
>>   "kind": "Service",
>>   "name": "${NAME}-static"
>> },
>> "tls": {
>>   "termination" : "edge"
>> }
>>   }
>> },
>> {
>>   "kind": "Route",
>>   "apiVersion": "v1",
>>   "metadata": {
>> "name": "${NAME}-py"
>>   },
>>   "spec": {
>> "host": "${APPLICATION_DOMAIN}",
>> "to": {
>>   "kind": "Service",
>>   "name": "${NAME}-py"
>> },
>> "tls": {
>>   "termination" : "edge"
>> }
>>   }
>> },
>>
>>
>> I could prompt for a hostname, but I would like to auto-generate the
>> hostname to include the project by default. What I would like is
>> -. in both routes.
>>
>>
>> Is is there a list somewhere of the variables available to templates?
>>
>> ___
>> users mailing list
>> users@lists.openshift.redhat.com
>> http://lists.openshift.redhat.com/openshiftmm/listinfo/users
>>
>
>
> ___
> users mailing list
> users@lists.openshift.redhat.com
> http://lists.openshift.redhat.com/openshiftmm/listinfo/users
>
>


-- 
Ben Parees | OpenShift
___
users mailing list
users@lists.openshift.redhat.com
http://lists.openshift.redhat.com/openshiftmm/listinfo/users


Re: route hostname generation in template

2016-04-08 Thread Jordan Liggitt
I'm pretty sure it is intentional that the only variables available are the
ones defined in the template itself.

On Fri, Apr 8, 2016 at 3:29 PM, Dale Bewley  wrote:

> I'm creating a template which has 2 services. One is a python gunicorn and
> one is httpd.
>
> I want the first service reachable at app-project.domain/ and the second
> service to be reachable at app-project.domain/static. That works, but I'm
> having trouble automating it in a template.
>
> Unfortunately if I use default value of ${APPLICATION_DOMAIN} it includes
> the service name and I wind up with a distinct hostname in each route:
> app-static-project.domain and app-py-project.domain
>
> {
>   "kind": "Route",
>   "apiVersion": "v1",
>   "metadata": {
> "name": "${NAME}-static"
>   },
>   "spec": {
> "host": "${APPLICATION_DOMAIN}",
> "path": "/${STATIC_DIR}",
> "to": {
>   "kind": "Service",
>   "name": "${NAME}-static"
> },
> "tls": {
>   "termination" : "edge"
> }
>   }
> },
> {
>   "kind": "Route",
>   "apiVersion": "v1",
>   "metadata": {
> "name": "${NAME}-py"
>   },
>   "spec": {
> "host": "${APPLICATION_DOMAIN}",
> "to": {
>   "kind": "Service",
>   "name": "${NAME}-py"
> },
> "tls": {
>   "termination" : "edge"
> }
>   }
> },
>
>
> I could prompt for a hostname, but I would like to auto-generate the
> hostname to include the project by default. What I would like is
> -. in both routes.
>
>
> Is is there a list somewhere of the variables available to templates?
>
> ___
> users mailing list
> users@lists.openshift.redhat.com
> http://lists.openshift.redhat.com/openshiftmm/listinfo/users
>
___
users mailing list
users@lists.openshift.redhat.com
http://lists.openshift.redhat.com/openshiftmm/listinfo/users