|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "attachments": {}, |
| 5 | + "cell_type": "markdown", |
| 6 | + "id": "9865ee8c", |
| 7 | + "metadata": {}, |
| 8 | + "source": [ |
| 9 | + "In this second notebook, we will go over the basics of using InstaScale to scale up/down necessary resources that are not currently available on your OpenShift Cluster (in cloud environments)." |
| 10 | + ] |
| 11 | + }, |
| 12 | + { |
| 13 | + "cell_type": "code", |
| 14 | + "execution_count": null, |
| 15 | + "id": "b55bc3ea-4ce3-49bf-bb1f-e209de8ca47a", |
| 16 | + "metadata": {}, |
| 17 | + "outputs": [], |
| 18 | + "source": [ |
| 19 | + "# Import pieces from codeflare-sdk\n", |
| 20 | + "from codeflare_sdk.cluster.cluster import Cluster, ClusterConfiguration\n", |
| 21 | + "from codeflare_sdk.cluster.auth import TokenAuthentication" |
| 22 | + ] |
| 23 | + }, |
| 24 | + { |
| 25 | + "cell_type": "code", |
| 26 | + "execution_count": null, |
| 27 | + "id": "614daa0c", |
| 28 | + "metadata": {}, |
| 29 | + "outputs": [], |
| 30 | + "source": [ |
| 31 | + "# Create authentication object for oc user permissions\n", |
| 32 | + "auth = TokenAuthentication(\n", |
| 33 | + " token = \"XXXXX\",\n", |
| 34 | + " server = \"XXXXX\",\n", |
| 35 | + " skip_tls=False\n", |
| 36 | + ")\n", |
| 37 | + "auth.login()" |
| 38 | + ] |
| 39 | + }, |
| 40 | + { |
| 41 | + "attachments": {}, |
| 42 | + "cell_type": "markdown", |
| 43 | + "id": "bc27f84c", |
| 44 | + "metadata": {}, |
| 45 | + "source": [ |
| 46 | + "This time, we are working in a cloud environment, and our OpenShift cluster does not have the resources needed for our desired workloads. We will use InstaScale to dynamically scale-up guaranteed resources based on our request (that will also automatically scale-down when we are finished working):" |
| 47 | + ] |
| 48 | + }, |
| 49 | + { |
| 50 | + "cell_type": "code", |
| 51 | + "execution_count": null, |
| 52 | + "id": "0f4bc870-091f-4e11-9642-cba145710159", |
| 53 | + "metadata": {}, |
| 54 | + "outputs": [], |
| 55 | + "source": [ |
| 56 | + "# Create and configure our cluster object (and appwrapper)\n", |
| 57 | + "cluster = Cluster(ClusterConfiguration(\n", |
| 58 | + " name='instascaletest',\n", |
| 59 | + " namespace='default',\n", |
| 60 | + " min_worker=2,\n", |
| 61 | + " max_worker=2,\n", |
| 62 | + " min_cpus=2,\n", |
| 63 | + " max_cpus=2,\n", |
| 64 | + " min_memory=8,\n", |
| 65 | + " max_memory=8,\n", |
| 66 | + " gpu=1,\n", |
| 67 | + " instascale=True, # InstaScale now enabled, will scale OCP cluster to guarantee resource request\n", |
| 68 | + " machine_types=[\"m5.xlarge\", \"g4dn.xlarge\"] # Head, worker AWS machine types desired\n", |
| 69 | + "))" |
| 70 | + ] |
| 71 | + }, |
| 72 | + { |
| 73 | + "attachments": {}, |
| 74 | + "cell_type": "markdown", |
| 75 | + "id": "12eef53c", |
| 76 | + "metadata": {}, |
| 77 | + "source": [ |
| 78 | + "Same as last time, we will bring the cluster up, wait for it to be ready, and confirm that the specs are as-requested:" |
| 79 | + ] |
| 80 | + }, |
| 81 | + { |
| 82 | + "cell_type": "code", |
| 83 | + "execution_count": null, |
| 84 | + "id": "f0884bbc-c224-4ca0-98a0-02dfa09c2200", |
| 85 | + "metadata": {}, |
| 86 | + "outputs": [], |
| 87 | + "source": [ |
| 88 | + "# Bring up the cluster\n", |
| 89 | + "cluster.up()\n", |
| 90 | + "cluster.wait_ready()" |
| 91 | + ] |
| 92 | + }, |
| 93 | + { |
| 94 | + "attachments": {}, |
| 95 | + "cell_type": "markdown", |
| 96 | + "id": "6abfe904", |
| 97 | + "metadata": {}, |
| 98 | + "source": [ |
| 99 | + "While the resources are being scaled, we can also go into the console and take a look at the InstaScale logs, as well as the new machines/nodes spinning up.\n", |
| 100 | + "\n", |
| 101 | + "Once the cluster is ready, we can confirm the specs:" |
| 102 | + ] |
| 103 | + }, |
| 104 | + { |
| 105 | + "cell_type": "code", |
| 106 | + "execution_count": null, |
| 107 | + "id": "7fd45bc5-03c0-4ae5-9ec5-dd1c30f1a084", |
| 108 | + "metadata": {}, |
| 109 | + "outputs": [], |
| 110 | + "source": [ |
| 111 | + "cluster.details()" |
| 112 | + ] |
| 113 | + }, |
| 114 | + { |
| 115 | + "cell_type": "markdown", |
| 116 | + "id": "5af8cd32", |
| 117 | + "metadata": {}, |
| 118 | + "source": [ |
| 119 | + "Finally, we bring our resource cluster down and release/terminate the associated resources, bringing everything back to the way it was before our cluster was brought up." |
| 120 | + ] |
| 121 | + }, |
| 122 | + { |
| 123 | + "cell_type": "code", |
| 124 | + "execution_count": null, |
| 125 | + "id": "5f36db0f-31f6-4373-9503-dc3c1c4c3f57", |
| 126 | + "metadata": {}, |
| 127 | + "outputs": [], |
| 128 | + "source": [ |
| 129 | + "cluster.down()" |
| 130 | + ] |
| 131 | + }, |
| 132 | + { |
| 133 | + "attachments": {}, |
| 134 | + "cell_type": "markdown", |
| 135 | + "id": "c883caea", |
| 136 | + "metadata": {}, |
| 137 | + "source": [ |
| 138 | + "Once again, we can look at the machines/nodes and see that everything has been successfully scaled down!" |
| 139 | + ] |
| 140 | + }, |
| 141 | + { |
| 142 | + "cell_type": "code", |
| 143 | + "execution_count": null, |
| 144 | + "id": "0d41b90e", |
| 145 | + "metadata": {}, |
| 146 | + "outputs": [], |
| 147 | + "source": [ |
| 148 | + "auth.logout()" |
| 149 | + ] |
| 150 | + } |
| 151 | + ], |
| 152 | + "metadata": { |
| 153 | + "kernelspec": { |
| 154 | + "display_name": "Python 3", |
| 155 | + "language": "python", |
| 156 | + "name": "python3" |
| 157 | + }, |
| 158 | + "language_info": { |
| 159 | + "codemirror_mode": { |
| 160 | + "name": "ipython", |
| 161 | + "version": 3 |
| 162 | + }, |
| 163 | + "file_extension": ".py", |
| 164 | + "mimetype": "text/x-python", |
| 165 | + "name": "python", |
| 166 | + "nbconvert_exporter": "python", |
| 167 | + "pygments_lexer": "ipython3", |
| 168 | + "version": "3.9.13" |
| 169 | + }, |
| 170 | + "vscode": { |
| 171 | + "interpreter": { |
| 172 | + "hash": "f9f85f796d01129d0dd105a088854619f454435301f6ffec2fea96ecbd9be4ac" |
| 173 | + } |
| 174 | + } |
| 175 | + }, |
| 176 | + "nbformat": 4, |
| 177 | + "nbformat_minor": 5 |
| 178 | +} |
0 commit comments