|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "markdown",
|
5 |
| - "metadata": {}, |
| 5 | + "metadata": { |
| 6 | + "deletable": true, |
| 7 | + "editable": true |
| 8 | + }, |
6 | 9 | "source": [
|
7 | 10 | "How to start a Pod\n",
|
8 | 11 | "==================\n",
|
|
15 | 18 | },
|
16 | 19 | {
|
17 | 20 | "cell_type": "code",
|
18 |
| - "execution_count": 1, |
| 21 | + "execution_count": null, |
19 | 22 | "metadata": {
|
20 |
| - "collapsed": true |
| 23 | + "collapsed": true, |
| 24 | + "deletable": true, |
| 25 | + "editable": true |
21 | 26 | },
|
22 | 27 | "outputs": [],
|
23 | 28 | "source": [
|
|
26 | 31 | },
|
27 | 32 | {
|
28 | 33 | "cell_type": "markdown",
|
29 |
| - "metadata": {}, |
| 34 | + "metadata": { |
| 35 | + "deletable": true, |
| 36 | + "editable": true |
| 37 | + }, |
30 | 38 | "source": [
|
31 | 39 | "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."
|
32 | 40 | ]
|
33 | 41 | },
|
34 | 42 | {
|
35 | 43 | "cell_type": "code",
|
36 |
| - "execution_count": 2, |
| 44 | + "execution_count": null, |
37 | 45 | "metadata": {
|
38 |
| - "collapsed": true |
| 46 | + "collapsed": false, |
| 47 | + "deletable": true, |
| 48 | + "editable": true |
39 | 49 | },
|
40 | 50 | "outputs": [],
|
41 | 51 | "source": [
|
|
44 | 54 | },
|
45 | 55 | {
|
46 | 56 | "cell_type": "markdown",
|
47 |
| - "metadata": {}, |
| 57 | + "metadata": { |
| 58 | + "deletable": true, |
| 59 | + "editable": true |
| 60 | + }, |
48 | 61 | "source": [
|
49 | 62 | "Pods are a stable resource in the V1 API group. Instantiate a client for that API group endpoint."
|
50 | 63 | ]
|
51 | 64 | },
|
52 | 65 | {
|
53 | 66 | "cell_type": "code",
|
54 |
| - "execution_count": 3, |
| 67 | + "execution_count": null, |
55 | 68 | "metadata": {
|
56 |
| - "collapsed": true |
| 69 | + "collapsed": true, |
| 70 | + "deletable": true, |
| 71 | + "editable": true |
57 | 72 | },
|
58 | 73 | "outputs": [],
|
59 | 74 | "source": [
|
|
62 | 77 | },
|
63 | 78 | {
|
64 | 79 | "cell_type": "code",
|
65 |
| - "execution_count": 4, |
| 80 | + "execution_count": null, |
66 | 81 | "metadata": {
|
67 | 82 | "collapsed": false,
|
| 83 | + "deletable": true, |
| 84 | + "editable": true, |
68 | 85 | "scrolled": false
|
69 | 86 | },
|
70 | 87 | "outputs": [],
|
|
76 | 93 | },
|
77 | 94 | {
|
78 | 95 | "cell_type": "markdown",
|
79 |
| - "metadata": {}, |
| 96 | + "metadata": { |
| 97 | + "deletable": true, |
| 98 | + "editable": true |
| 99 | + }, |
80 | 100 | "source": [
|
81 | 101 | "In this example, we only start one container in the Pod. The container is an instnace of the _V1Container_ class. "
|
82 | 102 | ]
|
83 | 103 | },
|
84 | 104 | {
|
85 | 105 | "cell_type": "code",
|
86 |
| - "execution_count": 5, |
| 106 | + "execution_count": null, |
87 | 107 | "metadata": {
|
88 |
| - "collapsed": true |
| 108 | + "collapsed": true, |
| 109 | + "deletable": true, |
| 110 | + "editable": true |
89 | 111 | },
|
90 | 112 | "outputs": [],
|
91 | 113 | "source": [
|
|
97 | 119 | },
|
98 | 120 | {
|
99 | 121 | "cell_type": "markdown",
|
100 |
| - "metadata": {}, |
| 122 | + "metadata": { |
| 123 | + "deletable": true, |
| 124 | + "editable": true |
| 125 | + }, |
101 | 126 | "source": [
|
102 | 127 | "The specification of the Pod is made of a single container in its list."
|
103 | 128 | ]
|
104 | 129 | },
|
105 | 130 | {
|
106 | 131 | "cell_type": "code",
|
107 |
| - "execution_count": 6, |
| 132 | + "execution_count": null, |
108 | 133 | "metadata": {
|
109 |
| - "collapsed": true |
| 134 | + "collapsed": true, |
| 135 | + "deletable": true, |
| 136 | + "editable": true |
110 | 137 | },
|
111 | 138 | "outputs": [],
|
112 | 139 | "source": [
|
|
116 | 143 | },
|
117 | 144 | {
|
118 | 145 | "cell_type": "markdown",
|
119 |
| - "metadata": {}, |
| 146 | + "metadata": { |
| 147 | + "deletable": true, |
| 148 | + "editable": true |
| 149 | + }, |
120 | 150 | "source": [
|
121 | 151 | "Get existing list of Pods, before the creation of the new Pod."
|
122 | 152 | ]
|
123 | 153 | },
|
124 | 154 | {
|
125 | 155 | "cell_type": "code",
|
126 |
| - "execution_count": 7, |
| 156 | + "execution_count": null, |
127 | 157 | "metadata": {
|
128 |
| - "collapsed": false |
| 158 | + "collapsed": false, |
| 159 | + "deletable": true, |
| 160 | + "editable": true |
129 | 161 | },
|
130 |
| - "outputs": [ |
131 |
| - { |
132 |
| - "name": "stdout", |
133 |
| - "output_type": "stream", |
134 |
| - "text": [ |
135 |
| - "172.17.0.6 default jupyter\n" |
136 |
| - ] |
137 |
| - } |
138 |
| - ], |
| 162 | + "outputs": [], |
139 | 163 | "source": [
|
140 | 164 | "ret = v1.list_namespaced_pod(namespace=\"default\")\n",
|
141 | 165 | "for i in ret.items:\n",
|
|
144 | 168 | },
|
145 | 169 | {
|
146 | 170 | "cell_type": "markdown",
|
147 |
| - "metadata": {}, |
| 171 | + "metadata": { |
| 172 | + "deletable": true, |
| 173 | + "editable": true |
| 174 | + }, |
148 | 175 | "source": [
|
149 | 176 | "You are now ready to create the Pod."
|
150 | 177 | ]
|
151 | 178 | },
|
152 | 179 | {
|
153 | 180 | "cell_type": "code",
|
154 |
| - "execution_count": 8, |
| 181 | + "execution_count": null, |
155 | 182 | "metadata": {
|
156 |
| - "collapsed": false |
| 183 | + "collapsed": false, |
| 184 | + "deletable": true, |
| 185 | + "editable": true |
157 | 186 | },
|
158 |
| - "outputs": [ |
159 |
| - { |
160 |
| - "data": { |
161 |
| - "text/plain": [ |
162 |
| - "{'metadata': {'annotations': None,\n", |
163 |
| - " 'cluster_name': None,\n", |
164 |
| - " 'creation_timestamp': u'2017-04-01T23:30:48Z',\n", |
165 |
| - " 'deletion_grace_period_seconds': None,\n", |
166 |
| - " 'deletion_timestamp': None,\n", |
167 |
| - " 'finalizers': None,\n", |
168 |
| - " 'generate_name': None,\n", |
169 |
| - " 'generation': None,\n", |
170 |
| - " 'labels': None,\n", |
171 |
| - " 'name': 'busybox',\n", |
172 |
| - " 'namespace': 'default',\n", |
173 |
| - " 'owner_references': None,\n", |
174 |
| - " 'resource_version': '26551',\n", |
175 |
| - " 'self_link': '/api/v1/namespaces/default/pods/busybox',\n", |
176 |
| - " 'uid': '3c6a0821-1733-11e7-877c-0800277d3a21'},\n", |
177 |
| - " 'spec': {'active_deadline_seconds': None,\n", |
178 |
| - " 'containers': [{'args': ['sleep', '3600'],\n", |
179 |
| - " 'command': None,\n", |
180 |
| - " 'env': None,\n", |
181 |
| - " 'image': 'busybox',\n", |
182 |
| - " 'image_pull_policy': 'Always',\n", |
183 |
| - " 'lifecycle': None,\n", |
184 |
| - " 'liveness_probe': None,\n", |
185 |
| - " 'name': 'busybox',\n", |
186 |
| - " 'ports': None,\n", |
187 |
| - " 'readiness_probe': None,\n", |
188 |
| - " 'resources': {'limits': None, 'requests': None},\n", |
189 |
| - " 'security_context': None,\n", |
190 |
| - " 'stdin': None,\n", |
191 |
| - " 'stdin_once': None,\n", |
192 |
| - " 'termination_message_path': '/dev/termination-log',\n", |
193 |
| - " 'tty': None,\n", |
194 |
| - " 'volume_mounts': [{'mount_path': '/var/run/secrets/kubernetes.io/serviceaccount',\n", |
195 |
| - " 'name': 'default-token-x47xb',\n", |
196 |
| - " 'read_only': True,\n", |
197 |
| - " 'sub_path': None}],\n", |
198 |
| - " 'working_dir': None}],\n", |
199 |
| - " 'dns_policy': 'ClusterFirst',\n", |
200 |
| - " 'host_ipc': None,\n", |
201 |
| - " 'host_network': None,\n", |
202 |
| - " 'host_pid': None,\n", |
203 |
| - " 'hostname': None,\n", |
204 |
| - " 'image_pull_secrets': None,\n", |
205 |
| - " 'node_name': None,\n", |
206 |
| - " 'node_selector': None,\n", |
207 |
| - " 'restart_policy': 'Always',\n", |
208 |
| - " 'security_context': {'fs_group': None,\n", |
209 |
| - " 'run_as_non_root': None,\n", |
210 |
| - " 'run_as_user': None,\n", |
211 |
| - " 'se_linux_options': None,\n", |
212 |
| - " 'supplemental_groups': None},\n", |
213 |
| - " 'service_account': 'default',\n", |
214 |
| - " 'service_account_name': 'default',\n", |
215 |
| - " 'subdomain': None,\n", |
216 |
| - " 'termination_grace_period_seconds': 30,\n", |
217 |
| - " 'volumes': [{'name': 'default-token-x47xb'}]},\n", |
218 |
| - " 'status': {'conditions': None,\n", |
219 |
| - " 'container_statuses': None,\n", |
220 |
| - " 'host_ip': None,\n", |
221 |
| - " 'message': None,\n", |
222 |
| - " 'phase': 'Pending',\n", |
223 |
| - " 'pod_ip': None,\n", |
224 |
| - " 'reason': None,\n", |
225 |
| - " 'start_time': None}}" |
226 |
| - ] |
227 |
| - }, |
228 |
| - "execution_count": 8, |
229 |
| - "metadata": {}, |
230 |
| - "output_type": "execute_result" |
231 |
| - } |
232 |
| - ], |
| 187 | + "outputs": [], |
233 | 188 | "source": [
|
234 | 189 | "v1.create_namespaced_pod(namespace=\"default\",body=pod)"
|
235 | 190 | ]
|
236 | 191 | },
|
237 | 192 | {
|
238 | 193 | "cell_type": "markdown",
|
239 |
| - "metadata": {}, |
| 194 | + "metadata": { |
| 195 | + "deletable": true, |
| 196 | + "editable": true |
| 197 | + }, |
240 | 198 | "source": [
|
241 | 199 | "Get list of Pods, after the creation of the new Pod. Note the newly created pod with name \"busybox\""
|
242 | 200 | ]
|
243 | 201 | },
|
244 | 202 | {
|
245 | 203 | "cell_type": "code",
|
246 |
| - "execution_count": 9, |
| 204 | + "execution_count": null, |
247 | 205 | "metadata": {
|
248 |
| - "collapsed": false |
| 206 | + "collapsed": false, |
| 207 | + "deletable": true, |
| 208 | + "editable": true |
249 | 209 | },
|
250 |
| - "outputs": [ |
251 |
| - { |
252 |
| - "name": "stdout", |
253 |
| - "output_type": "stream", |
254 |
| - "text": [ |
255 |
| - "None default busybox\n", |
256 |
| - "172.17.0.6 default jupyter\n" |
257 |
| - ] |
258 |
| - } |
259 |
| - ], |
| 210 | + "outputs": [], |
260 | 211 | "source": [
|
261 | 212 | "ret = v1.list_namespaced_pod(namespace=\"default\")\n",
|
262 | 213 | "for i in ret.items:\n",
|
|
265 | 216 | },
|
266 | 217 | {
|
267 | 218 | "cell_type": "markdown",
|
268 |
| - "metadata": {}, |
| 219 | + "metadata": { |
| 220 | + "deletable": true, |
| 221 | + "editable": true |
| 222 | + }, |
269 | 223 | "source": [
|
270 | 224 | "Delete the Pod\n",
|
271 | 225 | "--------------\n",
|
|
275 | 229 | },
|
276 | 230 | {
|
277 | 231 | "cell_type": "code",
|
278 |
| - "execution_count": 10, |
| 232 | + "execution_count": null, |
279 | 233 | "metadata": {
|
280 | 234 | "collapsed": false,
|
| 235 | + "deletable": true, |
| 236 | + "editable": true, |
281 | 237 | "scrolled": false
|
282 | 238 | },
|
283 |
| - "outputs": [ |
284 |
| - { |
285 |
| - "data": { |
286 |
| - "text/plain": [ |
287 |
| - "{'code': None,\n", |
288 |
| - " 'details': None,\n", |
289 |
| - " 'message': None,\n", |
290 |
| - " 'metadata': {'resource_version': '26556',\n", |
291 |
| - " 'self_link': '/api/v1/namespaces/default/pods/busybox'},\n", |
292 |
| - " 'reason': None,\n", |
293 |
| - " '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'}\"}" |
294 |
| - ] |
295 |
| - }, |
296 |
| - "execution_count": 10, |
297 |
| - "metadata": {}, |
298 |
| - "output_type": "execute_result" |
299 |
| - } |
300 |
| - ], |
| 239 | + "outputs": [], |
301 | 240 | "source": [
|
302 | 241 | "v1.delete_namespaced_pod(name=\"busybox\", namespace=\"default\", body=client.V1DeleteOptions())"
|
303 | 242 | ]
|
|
306 | 245 | "cell_type": "code",
|
307 | 246 | "execution_count": null,
|
308 | 247 | "metadata": {
|
309 |
| - "collapsed": true |
310 |
| - }, |
311 |
| - "outputs": [], |
312 |
| - "source": [] |
313 |
| - }, |
314 |
| - { |
315 |
| - "cell_type": "code", |
316 |
| - "execution_count": null, |
317 |
| - "metadata": { |
318 |
| - "collapsed": true |
| 248 | + "collapsed": true, |
| 249 | + "deletable": true, |
| 250 | + "editable": true |
319 | 251 | },
|
320 | 252 | "outputs": [],
|
321 | 253 | "source": []
|
|
337 | 269 | "name": "python",
|
338 | 270 | "nbconvert_exporter": "python",
|
339 | 271 | "pygments_lexer": "ipython2",
|
340 |
| - "version": "2.7.12" |
| 272 | + "version": "2.7.13" |
341 | 273 | }
|
342 | 274 | },
|
343 | 275 | "nbformat": 4,
|
|
0 commit comments