[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: route hostname generation in template



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-bounces lists openshift redhat com <users-bounces lists openshift redhat com> on behalf of Dale Bewley <dale 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 <app>-<project>.<cloud_apps_domain> 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]