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

Re: How to access built-in env vars for service name and fqdn



A belated thank you.  I have figured this out.  What I need to do is creating an "installer" container that runs a couple oc commands to gather all the required values before launching the actual app.


----- Original Message -----
From: "Ram Ranganathan" <rrangana redhat com>
To: "Viet Nguyen" <vnguyen redhat com>
Cc: "users" <users lists openshift redhat com>
Sent: Thursday, December 17, 2015 3:03:21 PM
Subject: Re: How to access built-in env vars for service name and fqdn

D'oh, where are them doughnuts and the coffee!!

The instruction are missing that you also need to create the secret
   oc create -f gallifrey.json

before doing the oc volume command
  oc volume dc/<dc-name>  --add --overwrite --name=v1 --type=secret
--secret-name=gallifrey --mount-path=/path/to/arcadia


On Thu, Dec 17, 2015 at 2:58 PM, Ram Ranganathan <rrangana redhat com>
wrote:

> One option for portability and reading at the startup time case, would be
> to have your app read a well known properties file.
> That way it works standalone - just the access path is read from a file on
> disk.
>
> And then for the case of running on OpenShift, just use a volume mount to
> put a secret (not really a secret but use a secret)
> into the container at that same file ala something like:
>
> route=$(echo "www.gallifrey.time" | base64)
> cat > gallifrey.json <<ONESECOUT
> {
>   "apiVersion": "v1",
>   "kind": "Secret",
>   "metadata": { "name": "gallifrey" },
>   "data": { "route": "${route}" }
> }
> ONESECOUT
>
> oc volume dc/<dc-name>  --add --overwrite --name=v1 --type=secret
> --secret-name=gallifrey --mount-path=/path/to/arcadia
>
> And there should be a file in the container  /path/to/arcadia/route   that
> contains the route name.
>
> Just be a careful to use a directory that _only_ contains the property
> file (named "route" in the example above) to override
> with the volume mount.
>
> HTH
>
> On Thu, Dec 17, 2015 at 1:07 PM, Viet Nguyen <vnguyen redhat com> wrote:
>
>> >> Doing this in another code path (ala at app startup time), you will
>> need to
>> pass an env variable to the container.
>>
>> That's what I'm doing at the moment but the solution is not portable. I
>> want to the app to figure out the default value at start up time.
>>
>>
>>
>> ----- Original Message -----
>> From: "Ram Ranganathan" <rrangana redhat com>
>> To: "Viet Nguyen" <vnguyen redhat com>
>> Cc: "users" <users lists openshift redhat com>
>> Sent: Thursday, December 17, 2015 1:52:52 PM
>> Subject: Re: How to access built-in env vars for service name and fqdn
>>
>> If the app needs to know the public endpoint when it is serving/handling
>> an
>> HTTP request, the HTTP request will contain a
>> "Host" HTTP header which should have the route name set.
>> Doing this in another code path (ala at app startup time), you will need
>> to
>> pass an env variable to the container.
>>
>> HTH.
>>
>> On Thu, Dec 17, 2015 at 11:26 AM, Viet Nguyen <vnguyen redhat com> wrote:
>>
>> > I can create the route manually and my DNS is setup to enable access to
>> > the service by FQDN.  The challenge is the app inside the container
>> needs
>> > to know the public endpoint - either programmatically or via some sort
>> of
>> > built-in environment variables.  I know the service public endpoint is
>> > ${namespace}-${service name}.${cluster subdomain}.
>> >
>> >
>> >
>> > ----- Original Message -----
>> > From: "Jordan Liggitt" <jliggitt redhat com>
>> > To: "Viet Nguyen" <vnguyen redhat com>
>> > Cc: "users" <users lists openshift redhat com>
>> > Sent: Thursday, December 17, 2015 11:10:16 AM
>> > Subject: Re: How to access built-in env vars for service name and fqdn
>> >
>> > Services are not inherently publicly visible... you need a route to do
>> > that. Part of the route is a status that includes the host name.
>> >
>> > On Thu, Dec 17, 2015 at 12:01 PM, Viet Nguyen <vnguyen redhat com>
>> wrote:
>> >
>> > > My app uses keycloak so when starting up it needs to know FQDN of the
>> > > public endpoint.   For example I want to be able in the template to
>> > define
>> > > my service fqdn as ${namespace}-${service}.${cluster subdomain}
>> > >
>> > > Is introspection possible?
>> > >
>> > >
>> > > thanks!
>> > >
>> > > Viet
>> > >
>> > > _______________________________________________
>> > > 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
>> >
>>
>>
>>
>> --
>> Ram//
>> main(O,s){s=--O;10<putchar(3^O?97-(15&7183>>4*s)*(O++?-1:1):10)&&\
>> main(++O,s++);}
>>
>> _______________________________________________
>> users mailing list
>> users lists openshift redhat com
>> http://lists.openshift.redhat.com/openshiftmm/listinfo/users
>>
>
>
>
> --
> Ram//
> main(O,s){s=--O;10<putchar(3^O?97-(15&7183>>4*s)*(O++?-1:1):10)&&\
> main(++O,s++);}
>



-- 
Ram//
main(O,s){s=--O;10<putchar(3^O?97-(15&7183>>4*s)*(O++?-1:1):10)&&\
main(++O,s++);}


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