text: (window.webpackJsonp=window.webpackJsonp||[]).push([[3],{366:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_06.2cfa827e.png"},437:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_01.48986bee.png"},438:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_02.2333ab8b.png"},439:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_04.eb91d6f6.png"},440:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_03.2822fb2a.png"},441:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_05.d8bed398.png"},442:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_07.aa1fd569.png"},443:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_08.76eecf0e.png"},444:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_09.2ad080ac.png"},445:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_10.560d3d86.png"},446:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_11.27deff01.png"},447:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_12.eff7da96.png"},448:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_13.8c732809.png"},449:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_14.eff81c0e.png"},450:function(e,t,a){e.exports=a.p+"assets/img/07_persistent_config_15.9d0461c4.png"},487:function(e,t,a){"use strict";a.r(t);var s=a(32),n=Object(s.a)({},(function(){var e=this,t=e.$createElement,s=e._self._c||t;return s("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[s("h1",{attrs:{id:"persistent-configurations"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#persistent-configurations"}},[e._v("#")]),e._v(" Persistent Configurations")]),e._v(" "),s("p",[e._v("In cases where configurations need to change frequently or common configurations should be shared across deployments or pods, it is not ideal to build said configurations into the container image or maintain multiple copies of the configuration. OpenShift supports "),s("code",[e._v("configMaps")]),e._v(" which can be a standalone object that is easily mounted into pods. In cases where the configuration file or data is sensitive in nature, OpenShift supports "),s("code",[e._v("secrets")]),e._v(" to handle this sensitive data.")]),e._v(" "),s("h3",{attrs:{id:"configmaps"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#configmaps"}},[e._v("#")]),e._v(" ConfigMaps")]),e._v(" "),s("h4",{attrs:{id:"creating-a-config-map-and-adding-it-to-a-deployment"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#creating-a-config-map-and-adding-it-to-a-deployment"}},[e._v("#")]),e._v(" Creating a Config Map and Adding it to a Deployment")]),e._v(" "),s("p",[e._v("Create a configMap with arbitrary data and mount it inside of your "),s("code",[e._v("rocketchat-[username]")]),e._v(" pod:")]),e._v(" "),s("p",[s("img",{attrs:{src:a(437),alt:""}}),e._v(" "),s("img",{attrs:{src:a(438),alt:""}})]),e._v(" "),s("ul",[s("li",[e._v("In the Web Console, go to "),s("code",[e._v("+Add")]),e._v(" and select "),s("code",[e._v("YAML")])]),e._v(" "),s("li",[e._v("Paste in the following ConfigMap Code and save")])]),e._v(" "),s("div",{staticClass:"language-yaml extra-class"},[s("pre",{pre:!0,attrs:{class:"language-yaml"}},[s("code",[s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("apiVersion")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" v1\n"),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("data")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v("\n  "),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("myfile.txt")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" Hello world\n"),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("kind")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" ConfigMap\n"),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("metadata")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v("\n  "),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("name")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" rocketchat"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("[")]),e._v("username"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),e._v("configmap\n")])])]),s("ul",[s("li",[s("p",[e._v("Attach the "),s("code",[e._v("configMap")]),e._v(" to your "),s("code",[e._v("rocketchat-[username]")]),e._v(" deployment by navigating to the "),s("code",[e._v("YAML")]),e._v(" tab in your Rocket Chat DeploymentConfig and pasting in the following code")]),e._v(" "),s("ol",[s("li",[e._v("You will first need to create a "),s("code",[e._v("volume")]),e._v(". This is located under "),s("code",[e._v(".spec.template.spec.volumes")])])]),e._v(" "),s("div",{staticClass:"language-yaml extra-class"},[s("pre",{pre:!0,attrs:{class:"language-yaml"}},[s("code",[e._v("  "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("configMap")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v("\n      "),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("name")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" rocketchat"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("[")]),e._v("username"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),e._v("configmap\n    "),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("name")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" rocketchat"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("[")]),e._v("username"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),e._v("volume\n")])])]),s("ol",{attrs:{start:"2"}},[s("li",[e._v("Then create a "),s("code",[e._v("volumeMount")]),e._v(" under "),s("code",[e._v(".spec.template.spec.containers.volumeMounts")])])]),e._v(" "),s("div",{staticClass:"language-yaml extra-class"},[s("pre",{pre:!0,attrs:{class:"language-yaml"}},[s("code",[e._v("  "),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("name")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" rocketchat"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("[")]),e._v("username"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),e._v("volume\n    "),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("mountPath")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" /opt/configs\n")])])])])]),e._v(" "),s("blockquote",[s("p",[e._v("pro tip: if you are not sure what fields are available you can always use oc explain! "),s("code",[e._v("oc explain deployment.spec.template.spec.containers.volumeMounts")])])]),e._v(" "),s("p",[s("img",{attrs:{src:a(439),alt:""}}),e._v(" "),s("img",{attrs:{src:a(440),alt:""}})]),e._v(" "),s("blockquote",[s("p",[e._v("it should like similar to this\n"),s("img",{attrs:{src:a(441),alt:""}})])]),e._v(" "),s("ul",[s("li",[s("p",[e._v("Save the changes which will trigger a new deployment of your "),s("code",[e._v("rocketchat-[username]")]),e._v(" pod")])]),e._v(" "),s("li",[s("p",[e._v("Using the pod terminal in the Web Console or "),s("code",[e._v("oc rsh")]),e._v(", explore the path of the mounted configMap")])])]),e._v(" "),s("p",[s("img",{attrs:{src:a(366),alt:""}})]),e._v(" "),s("h4",{attrs:{id:"changing-config-map-content"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#changing-config-map-content"}},[e._v("#")]),e._v(" Changing Config Map Content")]),e._v(" "),s("p",[e._v("The content in your "),s("code",[e._v("configMap")]),e._v(" can be changed and in most cases it's NOT dynamically updated in the pod. With that said, a new deployment will be required for the changes to be picked up.")]),e._v(" "),s("ul",[s("li",[e._v("Edit your "),s("code",[e._v("configMap")]),e._v(" to add a new key-value pair that represents another file")])]),e._v(" "),s("p",[e._v("Navigate to "),s("code",[e._v("Administrator View -> Workloads -> Configmaps")]),e._v(" from the console and select your ConfigMap from the list")]),e._v(" "),s("p",[s("img",{attrs:{src:a(366),alt:""}}),e._v(" "),s("img",{attrs:{src:a(442),alt:""}})]),e._v(" "),s("ul",[s("li",[e._v("Using the pod terminal in the Web Console or "),s("code",[e._v("oc rsh")]),e._v(", explore the path of the mounted configMap")])]),e._v(" "),s("p",[s("img",{attrs:{src:a(443),alt:""}})]),e._v(" "),s("h3",{attrs:{id:"secrets"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#secrets"}},[e._v("#")]),e._v(" Secrets")]),e._v(" "),s("p",[e._v("Secrets can be added in a similar way as config maps but are geared towards the management of sensitive information. In OpenShift, these are base64 encoded, and encrypted on disk when stored in the cluster. In Pods, they never live on disk (unlike configmaps) and are only in memory.\nSecrets, from the Web Console, are focused on supporting:")]),e._v(" "),s("ul",[s("li",[e._v("Username/Passwords")]),e._v(" "),s("li",[e._v("SSH Keys")]),e._v(" "),s("li",[e._v("SSL Certificates")]),e._v(" "),s("li",[e._v("Git config files")])]),e._v(" "),s("p",[e._v('"Opaque" secrets are supported and can contain any type of data, however, these must be configured on the command line with the '),s("code",[e._v("oc")]),e._v(" cli.")]),e._v(" "),s("h3",{attrs:{id:"creating-secrets"}},[s("a",{staticClass:"header-anchor",attrs:{href:"#creating-secrets"}},[e._v("#")]),e._v(" Creating Secrets")]),e._v(" "),s("ul",[s("li",[e._v("In the Web Console, go to "),s("code",[e._v("+Add")]),e._v(" and select "),s("code",[e._v("YAML")])]),e._v(" "),s("li",[e._v("Paste in the following Secret Code and save")])]),e._v(" "),s("div",{staticClass:"language-yaml extra-class"},[s("pre",{pre:!0,attrs:{class:"language-yaml"}},[s("code",[s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("apiVersion")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" v1\n"),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("stringData")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v("\n  "),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("SECRET_API_KEY")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token string"}},[e._v('"I\'m ULTRA SECRET"')]),e._v("\n"),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("kind")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" Secret\n"),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("metadata")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v("\n  "),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("creationTimestamp")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" "),s("span",{pre:!0,attrs:{class:"token null important"}},[e._v("null")]),e._v("\n  "),s("span",{pre:!0,attrs:{class:"token key atrule"}},[e._v("name")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v(":")]),e._v(" rocketchat"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("[")]),e._v("username"),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("]")]),s("span",{pre:!0,attrs:{class:"token punctuation"}},[e._v("-")]),e._v("secret\n")])])]),s("p",[s("img",{attrs:{src:a(444),alt:""}})]),e._v(" "),s("ul",[s("li",[e._v("Explore the other mongo secrets to see different variations of secret data by navigating to "),s("code",[e._v("Administrator View -> Workloads -> Secrets")])])]),e._v(" "),s("p",[s("img",{attrs:{src:a(445),alt:""}}),e._v(" "),s("img",{attrs:{src:a(446),alt:""}})]),e._v(" "),s("ul",[s("li",[s("p",[e._v("Navigate back to your "),s("code",[e._v("rocketchat-[username]-secret")]),e._v(" and attach the "),s("code",[e._v("secret")]),e._v(" to your "),s("code",[e._v("rocketchat-[username]")]),e._v(" DeploymentConfig by navigating to the "),s("code",[e._v("Add Secret to Workload")])])]),e._v(" "),s("li",[s("p",[e._v("Attach the secret as an environment variable")])])]),e._v(" "),s("p",[s("img",{attrs:{src:a(447),alt:""}}),e._v(" "),s("img",{attrs:{src:a(448),alt:""}})]),e._v(" "),s("ul",[s("li",[s("p",[e._v("This change will trigger a new deployment of your "),s("code",[e._v("rocketchat-[username]")]),e._v(" pod")])]),e._v(" "),s("li",[s("p",[e._v("Once the pods have been redeployed the environment variable should be available for them to use. This is a very common pattern that applications can use to hold sensitive information like api keys in memory. You can verify that the environment variable exists by accessing the pod terminal or using "),s("code",[e._v("oc rsh")]),e._v(" and outputting its value with a simple "),s("code",[e._v("echo $SECRET_API_KEY")])])]),e._v(" "),s("li",[s("p",[e._v("From the cli, review the secret with "),s("code",[e._v("oc describe secret rocketchat-[username]-secret")])])])]),e._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("oc describe secret rocketchat-[username]-secret\nName:         rocketchat-[username]-secret\nNamespace:    [namespace]\nLabels:       <none>\nAnnotations:  <none>\n\nType:  Opaque\n\nData\n====\nSECRET_API_KEY:  16 bytes\n")])])]),s("ul",[s("li",[e._v("Export the secret to view the contents with "),s("code",[e._v("oc get --export secret rocketchat-[username]-secret -o yaml")])])]),e._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v("oc get --export secret rocketchat-[username]-secret -o yaml\napiVersion: v1\ndata:\n  SECRET_API_KEY: SSdtIFVMVFJBIFNFQ1JFVA==\nkind: Secret\nmetadata:\n  creationTimestamp: null\n  name: rocketchat-[username]-secret\n  selfLink: /api/v1/namespaces/[namespace]/secrets/rocketchat-[username]-secret\ntype: Opaque\n")])])]),s("blockquote",[s("p",[e._v("on Mac's and Linux machines that have the base64 binary, you can decode the value as a reference")])]),e._v(" "),s("div",{staticClass:"language- extra-class"},[s("pre",{pre:!0,attrs:{class:"language-text"}},[s("code",[e._v('echo "c2hlYXN0ZXdhcnQ=" | base64 -d\n')])])]),s("ul",[s("li",[s("p",[e._v("To edit an existing secret, from the webconsole you can navigate to the secret and select the "),s("code",[e._v("YAML")]),e._v(" tab or "),s("code",[e._v("oc edit secret rocketchat-[username]-secret")]),e._v(" from the cli. Secrets are base64 encoded. If adding new values or editing existing values of a Secret it is often easier to\nedit in plain text and have it b64 encoded for you. To do this you will need to modify the "),s("code",[e._v("data")]),e._v(" field and change it to\n"),s("code",[e._v("stringData")]),e._v(" prior to adding or editing values.")])]),e._v(" "),s("li",[s("p",[e._v("Add another secret value but this time as a sensitive configuration file such as an ssh key")])])]),e._v(" "),s("p",[e._v("From the web console\n"),s("img",{attrs:{src:a(449),alt:""}}),e._v("\nWith "),s("code",[e._v("oc edit")]),e._v(" "),s("img",{attrs:{src:a(450),alt:""}})]),e._v(" "),s("blockquote",[s("p",[e._v("take note that you were adding a new value "),s("code",[e._v("id_rsa")]),e._v(" under a field called "),s("code",[e._v("stringData")]),e._v(". Openshift will automatically, encode that as base64 and place it in the "),s("code",[e._v("data")]),e._v(" field upon saving. You can confirm this with "),s("code",[e._v("oc get secret rocketchat-[username]-secret -o yaml")]),e._v(" after saving.")])]),e._v(" "),s("ul",[s("li",[e._v("Redeploy the application after secret changes")])])])}),[],!1,null,null,null);t.default=n.exports}}]);