Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove code execution output from create_pod notebook #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 82 additions & 150 deletions examples/notebooks/create_pod.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"How to start a Pod\n",
"==================\n",
Expand All @@ -15,9 +18,11 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"collapsed": true
"collapsed": true,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
Expand All @@ -26,16 +31,21 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"If you are using a proxy, you can use the _client Configuration_ to setup the host that the client should use. Otherwise read the kubeconfig file."
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {
"collapsed": true
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
Expand All @@ -44,16 +54,21 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"Pods are a stable resource in the V1 API group. Instantiate a client for that API group endpoint."
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {
"collapsed": true
"collapsed": true,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
Expand All @@ -62,9 +77,11 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true,
"scrolled": false
},
"outputs": [],
Expand All @@ -76,16 +93,21 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"In this example, we only start one container in the Pod. The container is an instnace of the _V1Container_ class. "
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"collapsed": true
"collapsed": true,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
Expand All @@ -97,16 +119,21 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"The specification of the Pod is made of a single container in its list."
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {
"collapsed": true
"collapsed": true,
"deletable": true,
"editable": true
},
"outputs": [],
"source": [
Expand All @@ -116,26 +143,23 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"Get existing list of Pods, before the creation of the new Pod."
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"172.17.0.6 default jupyter\n"
]
}
],
"outputs": [],
"source": [
"ret = v1.list_namespaced_pod(namespace=\"default\")\n",
"for i in ret.items:\n",
Expand All @@ -144,119 +168,46 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"You are now ready to create the Pod."
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [
{
"data": {
"text/plain": [
"{'metadata': {'annotations': None,\n",
" 'cluster_name': None,\n",
" 'creation_timestamp': u'2017-04-01T23:30:48Z',\n",
" 'deletion_grace_period_seconds': None,\n",
" 'deletion_timestamp': None,\n",
" 'finalizers': None,\n",
" 'generate_name': None,\n",
" 'generation': None,\n",
" 'labels': None,\n",
" 'name': 'busybox',\n",
" 'namespace': 'default',\n",
" 'owner_references': None,\n",
" 'resource_version': '26551',\n",
" 'self_link': '/api/v1/namespaces/default/pods/busybox',\n",
" 'uid': '3c6a0821-1733-11e7-877c-0800277d3a21'},\n",
" 'spec': {'active_deadline_seconds': None,\n",
" 'containers': [{'args': ['sleep', '3600'],\n",
" 'command': None,\n",
" 'env': None,\n",
" 'image': 'busybox',\n",
" 'image_pull_policy': 'Always',\n",
" 'lifecycle': None,\n",
" 'liveness_probe': None,\n",
" 'name': 'busybox',\n",
" 'ports': None,\n",
" 'readiness_probe': None,\n",
" 'resources': {'limits': None, 'requests': None},\n",
" 'security_context': None,\n",
" 'stdin': None,\n",
" 'stdin_once': None,\n",
" 'termination_message_path': '/dev/termination-log',\n",
" 'tty': None,\n",
" 'volume_mounts': [{'mount_path': '/var/run/secrets/kubernetes.io/serviceaccount',\n",
" 'name': 'default-token-x47xb',\n",
" 'read_only': True,\n",
" 'sub_path': None}],\n",
" 'working_dir': None}],\n",
" 'dns_policy': 'ClusterFirst',\n",
" 'host_ipc': None,\n",
" 'host_network': None,\n",
" 'host_pid': None,\n",
" 'hostname': None,\n",
" 'image_pull_secrets': None,\n",
" 'node_name': None,\n",
" 'node_selector': None,\n",
" 'restart_policy': 'Always',\n",
" 'security_context': {'fs_group': None,\n",
" 'run_as_non_root': None,\n",
" 'run_as_user': None,\n",
" 'se_linux_options': None,\n",
" 'supplemental_groups': None},\n",
" 'service_account': 'default',\n",
" 'service_account_name': 'default',\n",
" 'subdomain': None,\n",
" 'termination_grace_period_seconds': 30,\n",
" 'volumes': [{'name': 'default-token-x47xb'}]},\n",
" 'status': {'conditions': None,\n",
" 'container_statuses': None,\n",
" 'host_ip': None,\n",
" 'message': None,\n",
" 'phase': 'Pending',\n",
" 'pod_ip': None,\n",
" 'reason': None,\n",
" 'start_time': None}}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"v1.create_namespaced_pod(namespace=\"default\",body=pod)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"Get list of Pods, after the creation of the new Pod. Note the newly created pod with name \"busybox\""
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": false,
"deletable": true,
"editable": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"None default busybox\n",
"172.17.0.6 default jupyter\n"
]
}
],
"outputs": [],
"source": [
"ret = v1.list_namespaced_pod(namespace=\"default\")\n",
"for i in ret.items:\n",
Expand All @@ -265,7 +216,10 @@
},
{
"cell_type": "markdown",
"metadata": {},
"metadata": {
"deletable": true,
"editable": true
},
"source": [
"Delete the Pod\n",
"--------------\n",
Expand All @@ -275,29 +229,14 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {
"collapsed": false,
"deletable": true,
"editable": true,
"scrolled": false
},
"outputs": [
{
"data": {
"text/plain": [
"{'code': None,\n",
" 'details': None,\n",
" 'message': None,\n",
" 'metadata': {'resource_version': '26556',\n",
" 'self_link': '/api/v1/namespaces/default/pods/busybox'},\n",
" 'reason': None,\n",
" 'status': \"{u'phase': u'Pending', u'conditions': [{u'status': u'True', u'lastProbeTime': None, u'type': u'Initialized', u'lastTransitionTime': u'2017-04-01T23:30:48Z'}, {u'status': u'False', u'lastTransitionTime': u'2017-04-01T23:30:48Z', u'reason': u'ContainersNotReady', u'lastProbeTime': None, u'message': u'containers with unready status: [busybox]', u'type': u'Ready'}, {u'status': u'True', u'lastProbeTime': None, u'type': u'PodScheduled', u'lastTransitionTime': u'2017-04-01T23:30:48Z'}], u'containerStatuses': [{u'restartCount': 0, u'name': u'busybox', u'image': u'busybox', u'imageID': u'', u'state': {u'waiting': {u'reason': u'ContainerCreating'}}, u'ready': False, u'lastState': {}}], u'startTime': u'2017-04-01T23:30:48Z', u'hostIP': u'192.168.99.100'}\"}"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"v1.delete_namespaced_pod(name=\"busybox\", namespace=\"default\", body=client.V1DeleteOptions())"
]
Expand All @@ -306,16 +245,9 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
"collapsed": true,
"deletable": true,
"editable": true
},
"outputs": [],
"source": []
Expand All @@ -337,7 +269,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.12"
"version": "2.7.13"
}
},
"nbformat": 4,
Expand Down