Bug 1479660 - MYSQL_DATABASE environment variable not available to other pods
Summary: MYSQL_DATABASE environment variable not available to other pods
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Templates
Version: 3.x
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Ben Parees
QA Contact: XiuJuan Wang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-08-09 05:21 UTC by Robin Williams
Modified: 2017-11-09 18:50 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-11-09 18:50:26 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Robin Williams 2017-08-09 05:21:52 UTC
Description of problem:

When adding a mysql datastore, the MYSQL_DATABASE environment variable is only available to the MYSQL deployment - it is not available as an environment variable to other deployments.  It would be useful for it to be.

Version-Release number of selected component (if applicable):

3.5?

Comment 1 Samuel Padgett 2017-08-10 12:40:25 UTC
Robin, we've added a service catalog tech preview feature in 3.6. It allows you to bind to services like mysql, which puts connection information into a secret that you can use as environment variables to your pods. Is this what you're looking for?

Have a look at

https://blog.openshift.com/whats-new-openshift-3-6-enhanced-usability/
https://blog.openshift.com/whats-new-openshift-3-6-service-catalog-brokers-tech-preview/

Comment 2 Robin Williams 2017-08-10 14:18:43 UTC
Hi Samuel

That sounds good - I had a quick look at the documentation, but it's about a million times easier to make sense of it by actually playing with it.

MYSQL_USER and MYSQL_PASSWORD are already automatically set up as secrets, but MYSQL_DATABASE was not.  Will it now be added in 3.6?

And do you have an idea of when 3.6 is likely to be deployed to Online [Starter]?

Really appreciate your response.

Thanks very much

Robin

Comment 3 Samuel Padgett 2017-08-10 16:05:49 UTC
The service catalog is still in technology preview for 3.6. I'd have to defer to sspeiche on when it might be enabled for Online.

> MYSQL_USER and MYSQL_PASSWORD are already automatically set up as secrets, but MYSQL_DATABASE was not.

Ah, so you are saying the secret from the template here should also include the database?

https://github.com/openshift/origin/blob/master/examples/db-templates/mysql-persistent-template.json#L22-L38

@bparees, do you know what database is not included?

Changing the component to templates.

Comment 4 Ben Parees 2017-08-10 16:13:04 UTC
No particular reason, we can add it.

Comment 6 Steve Speicher 2017-08-11 12:49:29 UTC
(In reply to Samuel Padgett from comment #3)
> The service catalog is still in technology preview for 3.6. I'd have to
> defer to sspeiche on when it might be enabled for Online.
> 
We don't have a time yet when we'll enable it for Online. Though I expect starter to have it before OCP 3.7 ships and Pro to get it some point shortly after OCP 3.7 ships, pending upgrade schedule.

Comment 7 Ben Parees 2017-09-12 17:08:52 UTC
This is fixed, not sure when it'll make it into online, but the templates have been updated.

Comment 8 XiuJuan Wang 2017-09-14 05:57:26 UTC
One question, the comment #0 said:
MYSQL_DATABASE environment variable is not available as an environment variable to other deployments. 
Could I understand that app which is create from cakephp-mysql-example template, cakephp-mysql-example-*** pod also should have MYSQL_DATABASE shown?

Comment 9 Ben Parees 2017-09-14 14:06:28 UTC
No, the "all-in-one" templates don't need that information.

Comment 10 XiuJuan Wang 2017-09-15 07:57:58 UTC
Ben,
I have no idea how to test this bug, could you give some suggesion?

DB templates only create db pods, if create other deployments, no DB related env vars shown in other pods.

Comment 11 Ben Parees 2017-09-15 15:12:35 UTC
XiuJuan you can just confirm that the "database-name" is now a valid key in the db secret (along with database-user and database-password).

By virtue of it being available as a key in the secret, pods can reference the value as an environment variable via the downward api.

Comment 12 XiuJuan Wang 2017-09-18 08:08:10 UTC
@Ben, thanks for your advice.
db secret has been exposed with database-name.

$ oc  get secret mysql
NAME                       TYPE                                  DATA      AGE
mysql                      Opaque                                4         1m

$ oc  get  secret mysql -o yaml 
apiVersion: v1
data:
  database-name: c2FtcGxlZGI=
  database-password: ZVV4dllzRmt1RElUR1dPYw==
  database-root-password: YUN3c29JTGw1eTNNM0hHaA==
  database-user: dXNlclNIWA==
kind: Secret
metadata:
  annotations:
    openshift.io/generated-by: OpenShiftNewApp
    template.openshift.io/expose-database_name: '{.data[''database-name'']}'
    template.openshift.io/expose-password: '{.data[''database-password'']}'
    template.openshift.io/expose-root_password: '{.data[''database-root-password'']}'
    template.openshift.io/expose-username: '{.data[''database-user'']}'
  creationTimestamp: 2017-09-18T08:03:26Z
  labels:
    app: mysql-ephemeral
    template: mysql-ephemeral-template
  name: mysql
  namespace: xiu
  resourceVersion: "23913"
  selfLink: /api/v1/namespaces/xiu/secrets/mysql
  uid: d9ba6c08-9c47-11e7-ae4e-42010af0000d
type: Opaque


Note You need to log in before you can comment on or make changes to this bug.