From 1a1ae19371cda865c17844d60589eb5c6e013a67 Mon Sep 17 00:00:00 2001 From: MoShitrit Date: Wed, 29 Apr 2020 19:04:34 -0400 Subject: [PATCH 1/2] Update documentation to stop using deprecated versions. --- examples/notebooks/create_deployment.ipynb | 326 +++++++++------------ examples/notebooks/intro_notebook.ipynb | 8 +- 2 files changed, 136 insertions(+), 198 deletions(-) diff --git a/examples/notebooks/create_deployment.ipynb b/examples/notebooks/create_deployment.ipynb index b4e1229dd7..5e23925c1d 100644 --- a/examples/notebooks/create_deployment.ipynb +++ b/examples/notebooks/create_deployment.ipynb @@ -2,345 +2,283 @@ "cells": [ { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, "source": [ "How to create a Deployment\n", "==========================\n", "\n", "In this notebook, we show you how to create a Deployment with 3 ReplicaSets. These ReplicaSets are owned by the Deployment and are managed by the Deployment controller. We would also learn how to carry out RollingUpdate and RollBack to new and older versions of the deployment." - ] + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ "from kubernetes import client, config" - ] + ], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, "source": [ "### Load config from default location" - ] + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ "config.load_kube_config()\n", - "apps_api = client.AppsV1beta1Api()" - ] + "apps_api = client.AppsV1Api()" + ], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, "source": [ "### Create Deployment object" - ] + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ - "deployment = client.AppsV1beta1Deployment()" - ] + "deployment = client.V1Deployment()" + ], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, "source": [ "### Fill required Deployment fields (apiVersion, kind, and metadata)" - ] + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ - "deployment.api_version = \"apps/v1beta1\"\n", + "deployment.api_version = \"apps/v1\"\n", "deployment.kind = \"Deployment\"\n", "deployment.metadata = client.V1ObjectMeta(name=\"nginx-deployment\")" - ] + ], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, "source": [ "### A Deployment also needs a .spec section" - ] + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ - "spec = client.AppsV1beta1DeploymentSpec()\n", + "spec = client.V1DeploymentSpec()\n", "spec.replicas = 3" - ] + ], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, "source": [ "### Add Pod template in .spec.template section" - ] + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ "spec.template = client.V1PodTemplateSpec()\n", "spec.template.metadata = client.V1ObjectMeta(labels={\"app\": \"nginx\"})\n", "spec.template.spec = client.V1PodSpec()" - ] + ], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, "source": [ "### Pod template container description" - ] + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ "container = client.V1Container()\n", "container.name=\"nginx\"\n", "container.image=\"nginx:1.7.9\"\n", "container. ports = [client.V1ContainerPort(container_port=80)]" - ] + ], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ "spec.template.spec.containers = [container]\n", "deployment.spec = spec" - ] + ], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, "source": [ "### Create Deployment" - ] + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ "apps_api.create_namespaced_deployment(namespace=\"default\", body=deployment)" - ] + ], + "metadata": { + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, "source": [ - "### Update container image " - ] + "### Update container image" + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ "deployment.spec.template.spec.containers[0].image = \"nginx:1.9.1\"" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, - "source": [ - "### Apply update (RollingUpdate)" - ] - }, - { - "cell_type": "code", - "execution_count": null, + ], "metadata": { "collapsed": false, - "deletable": true, - "editable": true - }, - "outputs": [], - "source": [ - "apps_api.replace_namespaced_deployment(name=\"nginx-deployment\", namespace=\"default\", body=deployment)" - ] + "pycharm": { + "name": "#%%\n" + } + } }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, "source": [ - "### Create DeploymentRollback object\n", - "This object is used to rollback to a previous version of the deployment." - ] + "### Apply update (RollingUpdate)" + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ - "rollback = client.AppsV1beta1DeploymentRollback()\n", - "rollback.api_version = \"apps/v1beta1\"\n", - "rollback.kind = \"DeploymentRollback\"\n", - "rollback.rollback_to = client.AppsV1beta1RollbackConfig()\n", - "rollback.rollback_to.revision = 0\n", - "rollback.name = \"nginx-deployment\"" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, - "source": [ - "### Execute RollBack" - ] - }, - { - "cell_type": "code", - "execution_count": null, + "apps_api.replace_namespaced_deployment(name=\"nginx-deployment\", namespace=\"default\", body=deployment)\n" + ], "metadata": { "collapsed": false, - "deletable": true, - "editable": true - }, - "outputs": [], - "source": [ - "extension.create_namespaced_deployment_rollback_rollback(name=\"nginx-deployment\", namespace=\"default\", body=rollback)" - ] + "pycharm": { + "name": "#%%\n" + } + } }, { "cell_type": "markdown", - "metadata": { - "deletable": true, - "editable": true - }, "source": [ "### Delete Deployment" - ] + ], + "metadata": { + "collapsed": false + } }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false, - "deletable": true, - "editable": true - }, "outputs": [], "source": [ - "extension.delete_namespaced_deployment(name=\"nginx-deployment\", namespace=\"default\", body=client.V1DeleteOptions(propagation_policy=\"Foreground\", grace_period_seconds=5))" - ] - }, - { - "cell_type": "code", - "execution_count": null, + "apps_api.delete_namespaced_deployment(name=\"nginx-deployment\", namespace=\"default\", body=client.V1DeleteOptions(propagation_policy=\"Foreground\", grace_period_seconds=5))" + ], "metadata": { - "collapsed": true, - "deletable": true, - "editable": true - }, - "outputs": [], - "source": [] + "collapsed": false, + "pycharm": { + "name": "#%%\n" + } + } } ], "metadata": { @@ -364,4 +302,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file diff --git a/examples/notebooks/intro_notebook.ipynb b/examples/notebooks/intro_notebook.ipynb index b4e3b8e8e9..df0099be73 100644 --- a/examples/notebooks/intro_notebook.ipynb +++ b/examples/notebooks/intro_notebook.ipynb @@ -89,9 +89,9 @@ }, "outputs": [], "source": [ - "api_instance = client.AppsV1beta1Api()\n", - "dep = client.AppsV1beta1Deployment()\n", - "spec = client.AppsV1beta1DeploymentSpec()" + "api_instance = client.AppsV1Api()\n", + "dep = client.V1Deployment()\n", + "spec = client.V1DeploymentSpec()" ] }, { @@ -306,4 +306,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} +} \ No newline at end of file From 6e62c3dd97cdec2def2d8369a0b6e70a4489be43 Mon Sep 17 00:00:00 2001 From: MoShitrit Date: Mon, 11 May 2020 19:48:54 -0400 Subject: [PATCH 2/2] Reverting some changed that were made by IDE --- examples/notebooks/create_deployment.ipynb | 258 ++++++++++----------- examples/notebooks/intro_notebook.ipynb | 2 +- 2 files changed, 128 insertions(+), 132 deletions(-) diff --git a/examples/notebooks/create_deployment.ipynb b/examples/notebooks/create_deployment.ipynb index 5e23925c1d..f62ac6887b 100644 --- a/examples/notebooks/create_deployment.ipynb +++ b/examples/notebooks/create_deployment.ipynb @@ -2,283 +2,279 @@ "cells": [ { "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true + }, "source": [ "How to create a Deployment\n", "==========================\n", "\n", "In this notebook, we show you how to create a Deployment with 3 ReplicaSets. These ReplicaSets are owned by the Deployment and are managed by the Deployment controller. We would also learn how to carry out RollingUpdate and RollBack to new and older versions of the deployment." - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": true, + "deletable": true, + "editable": true + }, "outputs": [], "source": [ "from kubernetes import client, config" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true + }, "source": [ "### Load config from default location" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": true, + "deletable": true, + "editable": true + }, "outputs": [], "source": [ "config.load_kube_config()\n", "apps_api = client.AppsV1Api()" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true + }, "source": [ "### Create Deployment object" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": true, + "deletable": true, + "editable": true + }, "outputs": [], "source": [ "deployment = client.V1Deployment()" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true + }, "source": [ "### Fill required Deployment fields (apiVersion, kind, and metadata)" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": true, + "deletable": true, + "editable": true + }, "outputs": [], "source": [ "deployment.api_version = \"apps/v1\"\n", "deployment.kind = \"Deployment\"\n", "deployment.metadata = client.V1ObjectMeta(name=\"nginx-deployment\")" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true + }, "source": [ "### A Deployment also needs a .spec section" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": true, + "deletable": true, + "editable": true + }, "outputs": [], "source": [ "spec = client.V1DeploymentSpec()\n", "spec.replicas = 3" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true + }, "source": [ "### Add Pod template in .spec.template section" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": true, + "deletable": true, + "editable": true + }, "outputs": [], "source": [ "spec.template = client.V1PodTemplateSpec()\n", "spec.template.metadata = client.V1ObjectMeta(labels={\"app\": \"nginx\"})\n", "spec.template.spec = client.V1PodSpec()" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true + }, "source": [ "### Pod template container description" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": true, + "deletable": true, + "editable": true + }, "outputs": [], "source": [ "container = client.V1Container()\n", "container.name=\"nginx\"\n", "container.image=\"nginx:1.7.9\"\n", "container. ports = [client.V1ContainerPort(container_port=80)]" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": false, + "deletable": true, + "editable": true + }, "outputs": [], "source": [ "spec.template.spec.containers = [container]\n", "deployment.spec = spec" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true + }, "source": [ "### Create Deployment" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": false, + "deletable": true, + "editable": true + }, "outputs": [], "source": [ "apps_api.create_namespaced_deployment(namespace=\"default\", body=deployment)" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "markdown", - "source": [ - "### Update container image" - ], "metadata": { - "collapsed": false - } + "deletable": true, + "editable": true + }, + "source": [ + "### Update container image " + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": true, + "deletable": true, + "editable": true + }, "outputs": [], "source": [ "deployment.spec.template.spec.containers[0].image = \"nginx:1.9.1\"" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] }, { "cell_type": "markdown", + "metadata": { + "deletable": true, + "editable": true + }, "source": [ "### Apply update (RollingUpdate)" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, - "outputs": [], - "source": [ - "apps_api.replace_namespaced_deployment(name=\"nginx-deployment\", namespace=\"default\", body=deployment)\n" - ], "metadata": { "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + "deletable": true, + "editable": true + }, + "outputs": [], + "source": [ + "apps_api.replace_namespaced_deployment(name=\"nginx-deployment\", namespace=\"default\", body=deployment)" + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "### Delete Deployment" - ], - "metadata": { - "collapsed": false - } + ] }, { "cell_type": "code", "execution_count": null, + "metadata": { + "collapsed": false, + "deletable": true, + "editable": true + }, "outputs": [], "source": [ "apps_api.delete_namespaced_deployment(name=\"nginx-deployment\", namespace=\"default\", body=client.V1DeleteOptions(propagation_policy=\"Foreground\", grace_period_seconds=5))" - ], - "metadata": { - "collapsed": false, - "pycharm": { - "name": "#%%\n" - } - } + ] } ], "metadata": { @@ -302,4 +298,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} \ No newline at end of file +} diff --git a/examples/notebooks/intro_notebook.ipynb b/examples/notebooks/intro_notebook.ipynb index df0099be73..26de9c195c 100644 --- a/examples/notebooks/intro_notebook.ipynb +++ b/examples/notebooks/intro_notebook.ipynb @@ -306,4 +306,4 @@ }, "nbformat": 4, "nbformat_minor": 2 -} \ No newline at end of file +}