Bug 1479660 - MYSQL_DATABASE environment variable not available to other pods
MYSQL_DATABASE environment variable not available to other pods
Status: CLOSED CURRENTRELEASE
Product: OpenShift Online
Classification: Red Hat
Component: Templates (Show other bugs)
3.x
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Ben Parees
XiuJuan Wang
: OnlineStarter
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-08-09 01:21 EDT by Robin Williams
Modified: 2017-11-09 13:50 EST (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2017-11-09 13:50:26 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Robin Williams 2017-08-09 01:21:52 EDT
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 08:40:25 EDT
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 10:18:43 EDT
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 12:05:49 EDT
The service catalog is still in technology preview for 3.6. I'd have to defer to sspeiche@redhat.com 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 12:13:04 EDT
No particular reason, we can add it.
Comment 6 Steve Speicher 2017-08-11 08:49:29 EDT
(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@redhat.com 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 13:08:52 EDT
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 01:57:26 EDT
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 10:06:28 EDT
No, the "all-in-one" templates don't need that information.
Comment 10 XiuJuan Wang 2017-09-15 03:57:58 EDT
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 11:12:35 EDT
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 04:08:10 EDT
@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.