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
=== modified file 'Makefile'
--- Makefile 2015-09-24 20:09:00 +0000
+++ Makefile 2015-10-09 16:18:47 +0000
@@ -6,7 +6,7 @@
6 .venv/bin/pip install -q -r requirements.txt6 .venv/bin/pip install -q -r requirements.txt
77
8lint: virtualenv8lint: virtualenv
9 @.venv/bin/flake8 hooks --exclude=charmhelpers9 @.venv/bin/flake8 hooks --exclude=charmhelpers --ignore=W391
10 @.venv/bin/charm proof10 @.venv/bin/charm proof
1111
12test: virtualenv 12test: virtualenv
@@ -27,3 +27,4 @@
27clean:27clean:
28 rm -rf .venv28 rm -rf .venv
29 find -name *.pyc -delete29 find -name *.pyc -delete
30 rm -rf unit_tests/.cache
3031
=== modified file 'README.md'
--- README.md 2015-04-10 21:47:06 +0000
+++ README.md 2015-10-09 16:18:47 +0000
@@ -1,6 +1,6 @@
1# Kubernetes Minion Charm1# Kubernetes Node Charm
22
3[Kubernetes](https://github.com/googlecloudplatform/kubernetes) is an open3[Kubernetes](https://github.com/kubernetes/kubernetes) is an open
4source system for managing containerized applications across multiple hosts.4source system for managing containerized applications across multiple hosts.
5Kubernetes uses [Docker](http://www.docker.io/) to package, instantiate and run5Kubernetes uses [Docker](http://www.docker.io/) to package, instantiate and run
6containerized applications.6containerized applications.
@@ -28,8 +28,9 @@
28main management contact point providing many management services for the worker28main management contact point providing many management services for the worker
29nodes.29nodes.
3030
31### Kubernetes minion31### Kubernetes node
32The servers that perform the work are known as minions. Minions must be able to32The servers that perform the work are known as nodes (previously minions).
33Nodes must be able to
33communicate with the master and run the workloads that are assigned to them.34communicate with the master and run the workloads that are assigned to them.
3435
3536
@@ -55,22 +56,39 @@
5556
56#### Deploying the recommended configuration57#### Deploying the recommended configuration
5758
58A bundle can be used to deploy Kubernetes onto any cloud it can be59Use the 'juju quickstart' command to deploy a Kubernetes cluster to any cloud
59orchestrated directly in the Juju Graphical User Interface, when using60supported by Juju.
60`juju quickstart`:61
6162The charm store version of the Kubernetes bundle can be deployed as follows:
62 juju quickstart https://raw.githubusercontent.com/whitmo/bundle-kubernetes/master/bundles.yaml63
6364 juju quickstart u/kubernetes/kubernetes-cluster
6465
65For more information on the recommended bundle deployment, see the66> Note: The charm store bundle may be locked to a specific Kubernetes release.
66[Kubernetes bundle documentation](https://github.com/whitmo/bundle-kubernetes)67
68Alternately you could deploy a Kubernetes bundle straight from github or a file:
69
70 juju quickstart https://raw.githubusercontent.com/kubernetes/kubernetes/master/cluster/juju/bundles/local.yaml
71
72The command above does few things for you:
73
74- Starts a curses based gui for managing your cloud or MAAS credentials
75- Looks for a bootstrapped deployment environment, and bootstraps if
76 required. This will launch a bootstrap node in your chosen
77 deployment environment (machine 0).
78- Deploys the Juju GUI to your environment onto the bootstrap node.
79- Provisions 4 machines, and deploys the Kubernetes services on top of
80 them (Kubernetes-master, two Kubernetes nodes using flannel, and etcd).
81- Orchestrates the relations among the services, and exits.
82
83Now you should have a running Kubernetes. Run `juju status
84--format=oneline` to see the address of your kubernetes-master unit.
6785
6886
69#### Post Deployment87#### Post Deployment
7088
71To interact with the kubernetes environment, either build or89To interact with the kubernetes environment, either build or
72[download](https://github.com/GoogleCloudPlatform/kubernetes/releases) the90[download](https://github.com/kubernetes/kubernetes/releases) the
73[kubectl](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/kubectl.md)91[kubectl](https://github.com/kubernetes/kubernetes/blob/master/docs/user-guide/kubectl/kubectl.md)
74binary (available in the releases binary tarball) and point it to the master with :92binary (available in the releases binary tarball) and point it to the master with :
7593
7694
@@ -79,7 +97,8 @@
79 $ export KUBERNETES_MASTER="104.131.108.99"97 $ export KUBERNETES_MASTER="104.131.108.99"
8098
81# Configuration99# Configuration
82For you convenience this charm supports changing the version of kubernetes binaries.100For you convenience this charm supports changing the version of the Kubernetes
101release through a configuration option.
83This can be done through the Juju GUI or on the command line:102This can be done through the Juju GUI or on the command line:
84103
85 juju set kubernetes version=”v0.10.0”104 juju set kubernetes version=”v0.10.0”
@@ -89,12 +108,15 @@
89command.108command.
90109
91Congratulations you know have deployed a Kubernetes environment! Use the110Congratulations you know have deployed a Kubernetes environment! Use the
92[kubectl](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/kubectl.md)111[kubectl](https://github.com/kubernetes/kubernetes/blob/master/docs/user-guide/kubectl/kubectl.md)
93to interact with the environment.112to interact with the environment.
94113
95# Kubernetes information114# Kubernetes information
96115
97- [Kubernetes github project](https://github.com/GoogleCloudPlatform/kubernetes)116- [Kubernetes github project](https://github.com/kubernetes/kubernetes)
98- [Kubernetes issue tracker](https://github.com/GoogleCloudPlatform/kubernetes/issues)117- [Kubernetes issue tracker](https://github.com/kubernetes/kubernetes/issues)
99- [Kubernetes Documenation](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs)118- [Kubernetes Documenation](https://github.com/kubernetes/kubernetes/tree/master/docs)
100- [Kubernetes releases](https://github.com/GoogleCloudPlatform/kubernetes/releases)119- [Kubernetes releases](https://github.com/kubernetes/kubernetes/releases)
120
121
122[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/cluster/juju/charms/trusty/kubernetes/README.md?pixel)]()
101123
=== modified file 'copyright'
--- copyright 2015-07-17 20:00:22 +0000
+++ copyright 2015-10-09 16:18:47 +0000
@@ -1,4 +1,4 @@
1Copyright 2015 Canonical Ltd. 1Copyright 2015 Google Inc. All rights reserved.
22
3Licensed under the Apache License, Version 2.0 (the "License");3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.4you may not use this file except in compliance with the License.
55
=== modified file 'files/kubelet.upstart.tmpl'
--- files/kubelet.upstart.tmpl 2015-07-17 20:00:22 +0000
+++ files/kubelet.upstart.tmpl 2015-10-09 16:18:47 +0000
@@ -9,7 +9,7 @@
99
10exec /usr/local/bin/kubelet \10exec /usr/local/bin/kubelet \
11 --address=%(kubelet_bind_addr)s \11 --address=%(kubelet_bind_addr)s \
12 --api_servers=%(kubeapi_server)s \12 --api-servers=%(kubeapi_server)s \
13 --hostname_override=%(kubelet_bind_addr)s \13 --hostname-override=%(kubelet_bind_addr)s \
14 --cadvisor_port=4193 \14 --cadvisor-port=4193 \
15 --logtostderr=true15 --logtostderr=true
1616
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2015-10-01 00:35:41 +0000
+++ hooks/hooks.py 2015-10-09 16:18:47 +0000
@@ -1,5 +1,19 @@
1#!/usr/bin/env python1#!/usr/bin/env python
22
3# Copyright 2015 The Kubernetes Authors All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
3"""17"""
4The main hook file that is called by Juju.18The main hook file that is called by Juju.
5"""19"""
@@ -11,7 +25,7 @@
1125
12from charmhelpers.core import hookenv, host26from charmhelpers.core import hookenv, host
13from kubernetes_installer import KubernetesInstaller27from kubernetes_installer import KubernetesInstaller
14from path import path28from path import Path
1529
16from lib.registrator import Registrator30from lib.registrator import Registrator
1731
@@ -26,10 +40,10 @@
26 from the kubernetes-master charm and installs it locally on this machine.40 from the kubernetes-master charm and installs it locally on this machine.
27 """41 """
28 hookenv.log('Starting api-relation-changed')42 hookenv.log('Starting api-relation-changed')
29 charm_dir = path(hookenv.charm_dir())43 charm_dir = Path(hookenv.charm_dir())
30 # Get the package architecture, rather than the from the kernel (uname -m).44 # Get the package architecture, rather than the from the kernel (uname -m).
31 arch = subprocess.check_output(['dpkg', '--print-architecture']).strip()45 arch = subprocess.check_output(['dpkg', '--print-architecture']).strip()
32 kubernetes_bin_dir = path('/opt/kubernetes/bin')46 kubernetes_bin_dir = Path('/opt/kubernetes/bin')
33 # Get the version of kubernetes to install.47 # Get the version of kubernetes to install.
34 version = subprocess.check_output(['relation-get', 'version']).strip()48 version = subprocess.check_output(['relation-get', 'version']).strip()
35 print('Relation version: ', version)49 print('Relation version: ', version)
@@ -187,8 +201,9 @@
187 mem = info.strip().split(':')[1].strip().split()[0]201 mem = info.strip().split(':')[1].strip().split()[0]
188 cpus = os.sysconf('SC_NPROCESSORS_ONLN')202 cpus = os.sysconf('SC_NPROCESSORS_ONLN')
189203
204 # https://github.com/kubernetes/kubernetes/blob/master/docs/admin/node.md
190 registration_request = Registrator()205 registration_request = Registrator()
191 registration_request.data['Kind'] = 'Minion'206 registration_request.data['kind'] = 'Node'
192 registration_request.data['id'] = private_address207 registration_request.data['id'] = private_address
193 registration_request.data['name'] = private_address208 registration_request.data['name'] = private_address
194 registration_request.data['metadata']['name'] = private_address209 registration_request.data['metadata']['name'] = private_address
195210
=== modified file 'hooks/install'
--- hooks/install 2015-04-10 20:43:29 +0000
+++ hooks/install 2015-10-09 16:18:47 +0000
@@ -13,20 +13,21 @@
13 python-pip \13 python-pip \
14 wget14 wget
1515
16pip install path.py16pip install -r $CHARM_DIR/python_requirements.txt
1717
18# Create the necessary kubernetes group.18# Create the necessary kubernetes group.
19groupadd kubernetes19groupadd --force kubernetes
20useradd -d /var/lib/kubernetes \20
21 -g kubernetes \21if grep -q "^kubernetes:" /etc/passwd; then
22 -s /sbin/nologin \22 echo "The kubernetes user already exists!"
23 --system \23else
24 kubernetes24 # Create the user when kubernetes does not exist.
25 useradd -d /var/lib/kubernetes \
26 -g kubernetes \
27 -s /sbin/nologin \
28 --system \
29 kubernetes
30fi
2531
26install -d -m 0744 -o kubernetes -g kubernetes /var/lib/kubernetes32install -d -m 0744 -o kubernetes -g kubernetes /var/lib/kubernetes
27install -d -m 0744 -o kubernetes -g kubernetes /etc/kubernetes/manifests33install -d -m 0744 -o kubernetes -g kubernetes /etc/kubernetes/manifests
28
29# wait for the world, depends on where we installed it from distro
30#sudo service docker.io stop
31# or upstream archive
32#sudo service docker stop
3334
=== modified file 'hooks/kubernetes_installer.py'
--- hooks/kubernetes_installer.py 2015-07-17 20:00:22 +0000
+++ hooks/kubernetes_installer.py 2015-10-09 16:18:47 +0000
@@ -1,7 +1,21 @@
1#!/usr/bin/env python1#!/usr/bin/env python
22
3# Copyright 2015 The Kubernetes Authors All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
3import subprocess17import subprocess
4from path import path18from path import Path
519
620
7class KubernetesInstaller():21class KubernetesInstaller():
@@ -35,7 +49,7 @@
35 print(output)49 print(output)
36 destination.chmod(0o755)50 destination.chmod(0o755)
3751
38 def install(self, install_dir=path('/usr/local/bin')):52 def install(self, install_dir=Path('/usr/local/bin')):
39 """ Create links to the binary files to the install directory. """53 """ Create links to the binary files to the install directory. """
4054
41 if not install_dir.isdir():55 if not install_dir.isdir():
4256
=== modified file 'hooks/lib/__init__.py'
--- hooks/lib/__init__.py 2015-09-24 20:09:00 +0000
+++ hooks/lib/__init__.py 2015-10-09 16:18:47 +0000
@@ -0,0 +1,16 @@
1#!/usr/bin/env python
2
3# Copyright 2015 The Kubernetes Authors All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
017
=== modified file 'hooks/lib/registrator.py'
--- hooks/lib/registrator.py 2015-10-01 00:35:41 +0000
+++ hooks/lib/registrator.py 2015-10-09 16:18:47 +0000
@@ -1,5 +1,19 @@
1#!/usr/bin/env python1#!/usr/bin/env python
22
3# Copyright 2015 The Kubernetes Authors All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
3import httplib17import httplib
4import json18import json
5import time19import time
@@ -10,7 +24,7 @@
10 def __init__(self):24 def __init__(self):
11 self.ds = {25 self.ds = {
12 "creationTimestamp": "",26 "creationTimestamp": "",
13 "kind": "Minion",27 "kind": "Node",
14 "name": "", # private_address28 "name": "", # private_address
15 "metadata": {29 "metadata": {
16 "name": "", # private_address,30 "name": "", # private_address,
@@ -69,9 +83,9 @@
69 return True83 return True
70 elif response.status in (500,) and result.get(84 elif response.status in (500,) and result.get(
71 'message', '').startswith('The requested resource does not exist'): # noqa85 'message', '').startswith('The requested resource does not exist'): # noqa
72 # There's something fishy in the kube api here (0.4 dev), on first86 # There is something fishy in the kube api here (0.4 dev), first
73 # registration of a new minion, we always seem to get this error.87 # time to register a new node, we always seem to get this error.
74 # https://github.com/GoogleCloudPlatform/kubernetes/issues/199588 # http://issue.k8s.io/1995
75 time.sleep(1)89 time.sleep(1)
76 print("Retrying registration...")90 print("Retrying registration...")
77 raise ValueError("Registration returned 500, retry")91 raise ValueError("Registration returned 500, retry")
7892
=== modified file 'hooks/start'
--- hooks/start 2015-01-27 17:31:57 +0000
+++ hooks/start 2015-10-09 16:18:47 +0000
@@ -3,7 +3,7 @@
3set -ex3set -ex
44
5# Start is guaranteed to be called once when after the unit is installed5# Start is guaranteed to be called once when after the unit is installed
6# *AND* once everytime a machine is rebooted.6# *AND* once every time a machine is rebooted.
77
8if [ ! -f $CHARM_DIR/.unit-state ]8if [ ! -f $CHARM_DIR/.unit-state ]
9then9then
1010
=== added file 'python_requirements.txt'
--- python_requirements.txt 1970-01-01 00:00:00 +0000
+++ python_requirements.txt 2015-10-09 16:18:47 +0000
@@ -0,0 +1,1 @@
1path.py
02
=== modified file 'unit_tests/lib/test_registrator.py'
--- unit_tests/lib/test_registrator.py 2015-10-01 03:09:07 +0000
+++ unit_tests/lib/test_registrator.py 2015-10-09 16:18:47 +0000
@@ -1,4 +1,19 @@
1#!/usr/bin/env python1#!/usr/bin/env python
2
3# Copyright 2015 The Kubernetes Authors All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
2import json17import json
3from mock import MagicMock, patch18from mock import MagicMock, patch
4from path import Path19from path import Path
520
=== modified file 'unit_tests/test_hooks.py'
--- unit_tests/test_hooks.py 2015-07-17 20:00:22 +0000
+++ unit_tests/test_hooks.py 2015-10-09 16:18:47 +0000
@@ -1,5 +1,19 @@
1#!/usr/bin/env python1#!/usr/bin/env python
22
3# Copyright 2015 The Kubernetes Authors All rights reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
3# import pytest17# import pytest
418
519

Subscribers

People subscribed via source and target branches