|
11 | 11 | "* Access to OpenShift\n",
|
12 | 12 | "* Install oc client\n",
|
13 | 13 | "* Git clone a repo\n",
|
| 14 | + "* Set env Variables\n", |
14 | 15 | "* Deploy new app\n",
|
15 | 16 | "* Expose it as a service\n",
|
16 | 17 | "* Interact with the service"
|
|
107 | 108 | "Once the user has made the appropriate changes to their notebook they can push it back to github for the s2i builder. "
|
108 | 109 | ]
|
109 | 110 | },
|
| 111 | + { |
| 112 | + "cell_type": "markdown", |
| 113 | + "metadata": {}, |
| 114 | + "source": [ |
| 115 | + "## Set Environment Variables as Secrets\n", |
| 116 | + "\n", |
| 117 | + "Any environment variables needed for the notebook to execute such as s3 bucket credentials can be configured as [Secrets](https://docs.openshift.com/container-platform/3.11/dev_guide/secrets.html) in OpenShift. Using the web console, by navigating to Resources and Secrets, we can create \"Generic\" Secret types for the environment variable, set a \"Secret Name\", specify the name of the key referenced in the notebook as \"Key\" and the value of the environment variable as \"Value\".\n", |
| 118 | + "\n", |
| 119 | + "After launching the service, we can add these Secrets to the Build Environment Variables and selecting \"Add Value from Config Map or Secret\". We can let the initial build fail and upon triggering a \"Rebuild\", the secrets will be used." |
| 120 | + ] |
| 121 | + }, |
110 | 122 | {
|
111 | 123 | "cell_type": "markdown",
|
112 | 124 | "metadata": {},
|
|
128 | 140 | "~https://github.com/MichaelClifford/example-model-s2i-notebook"
|
129 | 141 | ]
|
130 | 142 | },
|
| 143 | + { |
| 144 | + "cell_type": "markdown", |
| 145 | + "metadata": {}, |
| 146 | + "source": [ |
| 147 | + "When building from a private Git repo, we need to follow some additional steps. We can use deploy keys to authenticate the private Git repository.\n", |
| 148 | + "By following the steps outlined [here](https://www.openshift.com/blog/private-git-repositories-part-2a-repository-ssh-keys), we can generate an ssh key to be used with the repository. We need to add the Public key (the .pub file) that we generated to the Github Repo by going to the repo settings under \"Add deploy key\". \n", |
| 149 | + "\n", |
| 150 | + "The private key can be added as a Source Secret on OpenShift the same way we added environment variables. For adding the private ssh key, we can create a new Source Secret and select authentication type as \"SSH Key\", specify a secret name and paste the private key that we generated in the Private SSH Key section.\n", |
| 151 | + "\n", |
| 152 | + "Once we have set up the Secret, we can run the `new-app` command with the ssh url of the repo and specify the --source-secret parameter." |
| 153 | + ] |
| 154 | + }, |
| 155 | + { |
| 156 | + "cell_type": "code", |
| 157 | + "execution_count": null, |
| 158 | + "metadata": {}, |
| 159 | + "outputs": [], |
| 160 | + "source": [ |
| 161 | + "%%bash\n", |
| 162 | + "oc new-app --name model \\\n", |
| 163 | + "quay.io/willbenton/simple-model-s2i:demo\\\n", |
| 164 | + "~git@github.com:MichaelClifford/example-model-s2i-notebook.git \\\n", |
| 165 | + "--source-secret secretname" |
| 166 | + ] |
| 167 | + }, |
131 | 168 | {
|
132 | 169 | "cell_type": "markdown",
|
133 | 170 | "metadata": {},
|
|
197 | 234 | "name": "python",
|
198 | 235 | "nbconvert_exporter": "python",
|
199 | 236 | "pygments_lexer": "ipython3",
|
200 |
| - "version": "3.6.3" |
| 237 | + "version": "3.8.3" |
201 | 238 | },
|
202 | 239 | "varInspector": {
|
203 | 240 | "cols": {
|
|
230 | 267 | }
|
231 | 268 | },
|
232 | 269 | "nbformat": 4,
|
233 |
| - "nbformat_minor": 2 |
| 270 | + "nbformat_minor": 4 |
234 | 271 | }
|
0 commit comments