|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": { |
| 6 | + "tags": [] |
| 7 | + }, |
| 8 | + "source": [ |
| 9 | + "* We will need to run some oc commands\n", |
| 10 | + "* You will have to to authenticate yourself against the OpenShift cluster.\n", |
| 11 | + "* Run this cell to get the full instructions." |
| 12 | + ] |
| 13 | + }, |
| 14 | + { |
| 15 | + "cell_type": "code", |
| 16 | + "execution_count": null, |
| 17 | + "metadata": { |
| 18 | + "tags": [] |
| 19 | + }, |
| 20 | + "outputs": [], |
| 21 | + "source": [ |
| 22 | + "import re\n", |
| 23 | + "import os\n", |
| 24 | + "\n", |
| 25 | + "NOTEBOOK_ARGS = os.environ.get('NOTEBOOK_ARGS', '')\n", |
| 26 | + "match = re.search(r'\"hub_host\":\"https://.*?(apps\\.[^\"]+)\"', NOTEBOOK_ARGS)\n", |
| 27 | + "hub_host_value = match.group(1)\n", |
| 28 | + "\n", |
| 29 | + "login_url = 'https://oauth-openshift.' + hub_host_value + \"/oauth/token/request\"\n", |
| 30 | + "\n", |
| 31 | + "print('1. Open the following URL to get your authentication token.')\n", |
| 32 | + "print('2. Authenticate, then click on \"Display token\"')\n", |
| 33 | + "print('3. Copy the content of the line under \"Log in with this token\" (starts with <oc login ...>)')\n", |
| 34 | + "print('4. Come back here and paste that <oc login ...> line in the next cell.')\n", |
| 35 | + "print('Login URL: '+login_url)" |
| 36 | + ] |
| 37 | + }, |
| 38 | + { |
| 39 | + "cell_type": "code", |
| 40 | + "execution_count": null, |
| 41 | + "metadata": { |
| 42 | + "tags": [] |
| 43 | + }, |
| 44 | + "outputs": [], |
| 45 | + "source": [ |
| 46 | + "%%bash\n", |
| 47 | + "\n", |
| 48 | + "# paste the oc command just below here:\n", |
| 49 | + "oc login --token=sha256~jyO90Ojaj5KTYfBICZTIrwmG30pYJnkpXuIoqUtaNRM --server=https://api.cluster-pjpd8.pjpd8.sandbox664.opentlc.com:6443\n" |
| 50 | + ] |
| 51 | + }, |
| 52 | + { |
| 53 | + "cell_type": "markdown", |
| 54 | + "metadata": { |
| 55 | + "tags": [] |
| 56 | + }, |
| 57 | + "source": [ |
| 58 | + "* if this has worked, this next cell will return your user id. " |
| 59 | + ] |
| 60 | + }, |
| 61 | + { |
| 62 | + "cell_type": "code", |
| 63 | + "execution_count": null, |
| 64 | + "metadata": { |
| 65 | + "tags": [] |
| 66 | + }, |
| 67 | + "outputs": [], |
| 68 | + "source": [ |
| 69 | + "! oc whoami" |
| 70 | + ] |
| 71 | + }, |
| 72 | + { |
| 73 | + "cell_type": "markdown", |
| 74 | + "metadata": { |
| 75 | + "tags": [] |
| 76 | + }, |
| 77 | + "source": [ |
| 78 | + "* if in the above you see: \n", |
| 79 | + "\n", |
| 80 | + "* `system:serviceaccount:userX:my-workbench` then it's failed\n", |
| 81 | + "* `userX` then it's worked" |
| 82 | + ] |
| 83 | + } |
| 84 | + ], |
| 85 | + "metadata": { |
| 86 | + "kernelspec": { |
| 87 | + "display_name": "Python 3.9", |
| 88 | + "language": "python", |
| 89 | + "name": "python3" |
| 90 | + }, |
| 91 | + "language_info": { |
| 92 | + "codemirror_mode": { |
| 93 | + "name": "ipython", |
| 94 | + "version": 3 |
| 95 | + }, |
| 96 | + "file_extension": ".py", |
| 97 | + "mimetype": "text/x-python", |
| 98 | + "name": "python", |
| 99 | + "nbconvert_exporter": "python", |
| 100 | + "pygments_lexer": "ipython3", |
| 101 | + "version": "3.9.18" |
| 102 | + } |
| 103 | + }, |
| 104 | + "nbformat": 4, |
| 105 | + "nbformat_minor": 4 |
| 106 | +} |
0 commit comments