Merge lp:~mbruzek/charms/trusty/kubernetes/trunk into lp:~kubernetes/charms/trusty/kubernetes/trunk

Proposed by Matt Bruzek
Status: Merged
Merged at revision: 12
Proposed branch: lp:~mbruzek/charms/trusty/kubernetes/trunk
Merge into: lp:~kubernetes/charms/trusty/kubernetes/trunk
Diff against target: 412 lines (+162/-49)
13 files modified
Makefile (+2/-1)
README.md (+43/-21)
copyright (+1/-1)
files/kubelet.upstart.tmpl (+3/-3)
hooks/hooks.py (+19/-4)
hooks/install (+13/-12)
hooks/kubernetes_installer.py (+16/-2)
hooks/lib/__init__.py (+16/-0)
hooks/lib/registrator.py (+18/-4)
hooks/start (+1/-1)
python_requirements.txt (+1/-0)
unit_tests/lib/test_registrator.py (+15/-0)
unit_tests/test_hooks.py (+14/-0)
To merge this branch: bzr merge lp:~mbruzek/charms/trusty/kubernetes/trunk
Reviewer Review Type Date Requested Status
Charles Butler (community) Approve
Review via email: mp+273993@code.launchpad.net

Description of the change

Synched this charm with the content on github. Then ran the lint and CI tests against the code.

Had to clean up quite a few failures to get here, but this charm passes all tests in CI and is synchronized with the content in github.

http://reports.vapour.ws/charm-test-details/charm-bundle-test-parent-1122

To post a comment you must log in.
15. By Matt Bruzek

Changing the flake8 rules to not conflict with the verify-boilerplate k8s tool.

Revision history for this message
Charles Butler (lazypower) wrote :

+1 lGTM

Thanks for the hard work Matt. One minor nitpick left inline, but not a blocker.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2015-09-24 20:09:00 +0000
3+++ Makefile 2015-10-09 16:18:47 +0000
4@@ -6,7 +6,7 @@
5 .venv/bin/pip install -q -r requirements.txt
6
7 lint: virtualenv
8- @.venv/bin/flake8 hooks --exclude=charmhelpers
9+ @.venv/bin/flake8 hooks --exclude=charmhelpers --ignore=W391
10 @.venv/bin/charm proof
11
12 test: virtualenv
13@@ -27,3 +27,4 @@
14 clean:
15 rm -rf .venv
16 find -name *.pyc -delete
17+ rm -rf unit_tests/.cache
18
19=== modified file 'README.md'
20--- README.md 2015-04-10 21:47:06 +0000
21+++ README.md 2015-10-09 16:18:47 +0000
22@@ -1,6 +1,6 @@
23-# Kubernetes Minion Charm
24+# Kubernetes Node Charm
25
26-[Kubernetes](https://github.com/googlecloudplatform/kubernetes) is an open
27+[Kubernetes](https://github.com/kubernetes/kubernetes) is an open
28 source system for managing containerized applications across multiple hosts.
29 Kubernetes uses [Docker](http://www.docker.io/) to package, instantiate and run
30 containerized applications.
31@@ -28,8 +28,9 @@
32 main management contact point providing many management services for the worker
33 nodes.
34
35-### Kubernetes minion
36-The servers that perform the work are known as minions. Minions must be able to
37+### Kubernetes node
38+The servers that perform the work are known as nodes (previously minions).
39+Nodes must be able to
40 communicate with the master and run the workloads that are assigned to them.
41
42
43@@ -55,22 +56,39 @@
44
45 #### Deploying the recommended configuration
46
47-A bundle can be used to deploy Kubernetes onto any cloud it can be
48-orchestrated directly in the Juju Graphical User Interface, when using
49-`juju quickstart`:
50-
51- juju quickstart https://raw.githubusercontent.com/whitmo/bundle-kubernetes/master/bundles.yaml
52-
53-
54-For more information on the recommended bundle deployment, see the
55-[Kubernetes bundle documentation](https://github.com/whitmo/bundle-kubernetes)
56+Use the 'juju quickstart' command to deploy a Kubernetes cluster to any cloud
57+supported by Juju.
58+
59+The charm store version of the Kubernetes bundle can be deployed as follows:
60+
61+ juju quickstart u/kubernetes/kubernetes-cluster
62+
63+> Note: The charm store bundle may be locked to a specific Kubernetes release.
64+
65+Alternately you could deploy a Kubernetes bundle straight from github or a file:
66+
67+ juju quickstart https://raw.githubusercontent.com/kubernetes/kubernetes/master/cluster/juju/bundles/local.yaml
68+
69+The command above does few things for you:
70+
71+- Starts a curses based gui for managing your cloud or MAAS credentials
72+- Looks for a bootstrapped deployment environment, and bootstraps if
73+ required. This will launch a bootstrap node in your chosen
74+ deployment environment (machine 0).
75+- Deploys the Juju GUI to your environment onto the bootstrap node.
76+- Provisions 4 machines, and deploys the Kubernetes services on top of
77+ them (Kubernetes-master, two Kubernetes nodes using flannel, and etcd).
78+- Orchestrates the relations among the services, and exits.
79+
80+Now you should have a running Kubernetes. Run `juju status
81+--format=oneline` to see the address of your kubernetes-master unit.
82
83
84 #### Post Deployment
85
86 To interact with the kubernetes environment, either build or
87-[download](https://github.com/GoogleCloudPlatform/kubernetes/releases) the
88-[kubectl](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/kubectl.md)
89+[download](https://github.com/kubernetes/kubernetes/releases) the
90+[kubectl](https://github.com/kubernetes/kubernetes/blob/master/docs/user-guide/kubectl/kubectl.md)
91 binary (available in the releases binary tarball) and point it to the master with :
92
93
94@@ -79,7 +97,8 @@
95 $ export KUBERNETES_MASTER="104.131.108.99"
96
97 # Configuration
98-For you convenience this charm supports changing the version of kubernetes binaries.
99+For you convenience this charm supports changing the version of the Kubernetes
100+release through a configuration option.
101 This can be done through the Juju GUI or on the command line:
102
103 juju set kubernetes version=”v0.10.0”
104@@ -89,12 +108,15 @@
105 command.
106
107 Congratulations you know have deployed a Kubernetes environment! Use the
108-[kubectl](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/kubectl.md)
109+[kubectl](https://github.com/kubernetes/kubernetes/blob/master/docs/user-guide/kubectl/kubectl.md)
110 to interact with the environment.
111
112 # Kubernetes information
113
114-- [Kubernetes github project](https://github.com/GoogleCloudPlatform/kubernetes)
115-- [Kubernetes issue tracker](https://github.com/GoogleCloudPlatform/kubernetes/issues)
116-- [Kubernetes Documenation](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs)
117-- [Kubernetes releases](https://github.com/GoogleCloudPlatform/kubernetes/releases)
118+- [Kubernetes github project](https://github.com/kubernetes/kubernetes)
119+- [Kubernetes issue tracker](https://github.com/kubernetes/kubernetes/issues)
120+- [Kubernetes Documenation](https://github.com/kubernetes/kubernetes/tree/master/docs)
121+- [Kubernetes releases](https://github.com/kubernetes/kubernetes/releases)
122+
123+
124+[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/juju/charms/trusty/kubernetes/README.md?pixel)]()
125
126=== modified file 'copyright'
127--- copyright 2015-07-17 20:00:22 +0000
128+++ copyright 2015-10-09 16:18:47 +0000
129@@ -1,4 +1,4 @@
130-Copyright 2015 Canonical Ltd.
131+Copyright 2015 Google Inc. All rights reserved.
132
133 Licensed under the Apache License, Version 2.0 (the "License");
134 you may not use this file except in compliance with the License.
135
136=== modified file 'files/kubelet.upstart.tmpl'
137--- files/kubelet.upstart.tmpl 2015-07-17 20:00:22 +0000
138+++ files/kubelet.upstart.tmpl 2015-10-09 16:18:47 +0000
139@@ -9,7 +9,7 @@
140
141 exec /usr/local/bin/kubelet \
142 --address=%(kubelet_bind_addr)s \
143- --api_servers=%(kubeapi_server)s \
144- --hostname_override=%(kubelet_bind_addr)s \
145- --cadvisor_port=4193 \
146+ --api-servers=%(kubeapi_server)s \
147+ --hostname-override=%(kubelet_bind_addr)s \
148+ --cadvisor-port=4193 \
149 --logtostderr=true
150
151=== modified file 'hooks/hooks.py'
152--- hooks/hooks.py 2015-10-01 00:35:41 +0000
153+++ hooks/hooks.py 2015-10-09 16:18:47 +0000
154@@ -1,5 +1,19 @@
155 #!/usr/bin/env python
156
157+# Copyright 2015 The Kubernetes Authors All rights reserved.
158+#
159+# Licensed under the Apache License, Version 2.0 (the "License");
160+# you may not use this file except in compliance with the License.
161+# You may obtain a copy of the License at
162+#
163+# http://www.apache.org/licenses/LICENSE-2.0
164+#
165+# Unless required by applicable law or agreed to in writing, software
166+# distributed under the License is distributed on an "AS IS" BASIS,
167+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
168+# See the License for the specific language governing permissions and
169+# limitations under the License.
170+
171 """
172 The main hook file that is called by Juju.
173 """
174@@ -11,7 +25,7 @@
175
176 from charmhelpers.core import hookenv, host
177 from kubernetes_installer import KubernetesInstaller
178-from path import path
179+from path import Path
180
181 from lib.registrator import Registrator
182
183@@ -26,10 +40,10 @@
184 from the kubernetes-master charm and installs it locally on this machine.
185 """
186 hookenv.log('Starting api-relation-changed')
187- charm_dir = path(hookenv.charm_dir())
188+ charm_dir = Path(hookenv.charm_dir())
189 # Get the package architecture, rather than the from the kernel (uname -m).
190 arch = subprocess.check_output(['dpkg', '--print-architecture']).strip()
191- kubernetes_bin_dir = path('/opt/kubernetes/bin')
192+ kubernetes_bin_dir = Path('/opt/kubernetes/bin')
193 # Get the version of kubernetes to install.
194 version = subprocess.check_output(['relation-get', 'version']).strip()
195 print('Relation version: ', version)
196@@ -187,8 +201,9 @@
197 mem = info.strip().split(':')[1].strip().split()[0]
198 cpus = os.sysconf('SC_NPROCESSORS_ONLN')
199
200+ # https://github.com/kubernetes/kubernetes/blob/master/docs/admin/node.md
201 registration_request = Registrator()
202- registration_request.data['Kind'] = 'Minion'
203+ registration_request.data['kind'] = 'Node'
204 registration_request.data['id'] = private_address
205 registration_request.data['name'] = private_address
206 registration_request.data['metadata']['name'] = private_address
207
208=== modified file 'hooks/install'
209--- hooks/install 2015-04-10 20:43:29 +0000
210+++ hooks/install 2015-10-09 16:18:47 +0000
211@@ -13,20 +13,21 @@
212 python-pip \
213 wget
214
215-pip install path.py
216+pip install -r $CHARM_DIR/python_requirements.txt
217
218 # Create the necessary kubernetes group.
219-groupadd kubernetes
220-useradd -d /var/lib/kubernetes \
221- -g kubernetes \
222- -s /sbin/nologin \
223- --system \
224- kubernetes
225+groupadd --force kubernetes
226+
227+if grep -q "^kubernetes:" /etc/passwd; then
228+ echo "The kubernetes user already exists!"
229+else
230+ # Create the user when kubernetes does not exist.
231+ useradd -d /var/lib/kubernetes \
232+ -g kubernetes \
233+ -s /sbin/nologin \
234+ --system \
235+ kubernetes
236+fi
237
238 install -d -m 0744 -o kubernetes -g kubernetes /var/lib/kubernetes
239 install -d -m 0744 -o kubernetes -g kubernetes /etc/kubernetes/manifests
240-
241-# wait for the world, depends on where we installed it from distro
242-#sudo service docker.io stop
243-# or upstream archive
244-#sudo service docker stop
245
246=== modified file 'hooks/kubernetes_installer.py'
247--- hooks/kubernetes_installer.py 2015-07-17 20:00:22 +0000
248+++ hooks/kubernetes_installer.py 2015-10-09 16:18:47 +0000
249@@ -1,7 +1,21 @@
250 #!/usr/bin/env python
251
252+# Copyright 2015 The Kubernetes Authors All rights reserved.
253+#
254+# Licensed under the Apache License, Version 2.0 (the "License");
255+# you may not use this file except in compliance with the License.
256+# You may obtain a copy of the License at
257+#
258+# http://www.apache.org/licenses/LICENSE-2.0
259+#
260+# Unless required by applicable law or agreed to in writing, software
261+# distributed under the License is distributed on an "AS IS" BASIS,
262+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
263+# See the License for the specific language governing permissions and
264+# limitations under the License.
265+
266 import subprocess
267-from path import path
268+from path import Path
269
270
271 class KubernetesInstaller():
272@@ -35,7 +49,7 @@
273 print(output)
274 destination.chmod(0o755)
275
276- def install(self, install_dir=path('/usr/local/bin')):
277+ def install(self, install_dir=Path('/usr/local/bin')):
278 """ Create links to the binary files to the install directory. """
279
280 if not install_dir.isdir():
281
282=== modified file 'hooks/lib/__init__.py'
283--- hooks/lib/__init__.py 2015-09-24 20:09:00 +0000
284+++ hooks/lib/__init__.py 2015-10-09 16:18:47 +0000
285@@ -0,0 +1,16 @@
286+#!/usr/bin/env python
287+
288+# Copyright 2015 The Kubernetes Authors All rights reserved.
289+#
290+# Licensed under the Apache License, Version 2.0 (the "License");
291+# you may not use this file except in compliance with the License.
292+# You may obtain a copy of the License at
293+#
294+# http://www.apache.org/licenses/LICENSE-2.0
295+#
296+# Unless required by applicable law or agreed to in writing, software
297+# distributed under the License is distributed on an "AS IS" BASIS,
298+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
299+# See the License for the specific language governing permissions and
300+# limitations under the License.
301+
302
303=== modified file 'hooks/lib/registrator.py'
304--- hooks/lib/registrator.py 2015-10-01 00:35:41 +0000
305+++ hooks/lib/registrator.py 2015-10-09 16:18:47 +0000
306@@ -1,5 +1,19 @@
307 #!/usr/bin/env python
308
309+# Copyright 2015 The Kubernetes Authors All rights reserved.
310+#
311+# Licensed under the Apache License, Version 2.0 (the "License");
312+# you may not use this file except in compliance with the License.
313+# You may obtain a copy of the License at
314+#
315+# http://www.apache.org/licenses/LICENSE-2.0
316+#
317+# Unless required by applicable law or agreed to in writing, software
318+# distributed under the License is distributed on an "AS IS" BASIS,
319+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
320+# See the License for the specific language governing permissions and
321+# limitations under the License.
322+
323 import httplib
324 import json
325 import time
326@@ -10,7 +24,7 @@
327 def __init__(self):
328 self.ds = {
329 "creationTimestamp": "",
330- "kind": "Minion",
331+ "kind": "Node",
332 "name": "", # private_address
333 "metadata": {
334 "name": "", # private_address,
335@@ -69,9 +83,9 @@
336 return True
337 elif response.status in (500,) and result.get(
338 'message', '').startswith('The requested resource does not exist'): # noqa
339- # There's something fishy in the kube api here (0.4 dev), on first
340- # registration of a new minion, we always seem to get this error.
341- # https://github.com/GoogleCloudPlatform/kubernetes/issues/1995
342+ # There is something fishy in the kube api here (0.4 dev), first
343+ # time to register a new node, we always seem to get this error.
344+ # http://issue.k8s.io/1995
345 time.sleep(1)
346 print("Retrying registration...")
347 raise ValueError("Registration returned 500, retry")
348
349=== modified file 'hooks/start'
350--- hooks/start 2015-01-27 17:31:57 +0000
351+++ hooks/start 2015-10-09 16:18:47 +0000
352@@ -3,7 +3,7 @@
353 set -ex
354
355 # Start is guaranteed to be called once when after the unit is installed
356-# *AND* once everytime a machine is rebooted.
357+# *AND* once every time a machine is rebooted.
358
359 if [ ! -f $CHARM_DIR/.unit-state ]
360 then
361
362=== added file 'python_requirements.txt'
363--- python_requirements.txt 1970-01-01 00:00:00 +0000
364+++ python_requirements.txt 2015-10-09 16:18:47 +0000
365@@ -0,0 +1,1 @@
366+path.py
367
368=== modified file 'unit_tests/lib/test_registrator.py'
369--- unit_tests/lib/test_registrator.py 2015-10-01 03:09:07 +0000
370+++ unit_tests/lib/test_registrator.py 2015-10-09 16:18:47 +0000
371@@ -1,4 +1,19 @@
372 #!/usr/bin/env python
373+
374+# Copyright 2015 The Kubernetes Authors All rights reserved.
375+#
376+# Licensed under the Apache License, Version 2.0 (the "License");
377+# you may not use this file except in compliance with the License.
378+# You may obtain a copy of the License at
379+#
380+# http://www.apache.org/licenses/LICENSE-2.0
381+#
382+# Unless required by applicable law or agreed to in writing, software
383+# distributed under the License is distributed on an "AS IS" BASIS,
384+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
385+# See the License for the specific language governing permissions and
386+# limitations under the License.
387+
388 import json
389 from mock import MagicMock, patch
390 from path import Path
391
392=== modified file 'unit_tests/test_hooks.py'
393--- unit_tests/test_hooks.py 2015-07-17 20:00:22 +0000
394+++ unit_tests/test_hooks.py 2015-10-09 16:18:47 +0000
395@@ -1,5 +1,19 @@
396 #!/usr/bin/env python
397
398+# Copyright 2015 The Kubernetes Authors All rights reserved.
399+#
400+# Licensed under the Apache License, Version 2.0 (the "License");
401+# you may not use this file except in compliance with the License.
402+# You may obtain a copy of the License at
403+#
404+# http://www.apache.org/licenses/LICENSE-2.0
405+#
406+# Unless required by applicable law or agreed to in writing, software
407+# distributed under the License is distributed on an "AS IS" BASIS,
408+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
409+# See the License for the specific language governing permissions and
410+# limitations under the License.
411+
412 # import pytest
413
414

Subscribers

People subscribed via source and target branches