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?
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/
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
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.
No particular reason, we can add it.
Commit pushed to master at https://github.com/openshift/origin https://github.com/openshift/origin/commit/b9361db054c4a616be4842a2f2c7a000396e1b3d add db name to the provided secret https://bugzilla.redhat.com/show_bug.cgi?id=1479660 bug 1479660
(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.
This is fixed, not sure when it'll make it into online, but the templates have been updated.
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?
No, the "all-in-one" templates don't need that information.
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.
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.
@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