Merge lp:~mbruzek/charms/trusty/kubernetes-master/v1.0.0 into lp:~kubernetes/charms/trusty/kubernetes-master/trunk
- Trusty Tahr (14.04)
- v1.0.0
- Merge into trunk
Proposed by
Matt Bruzek
Status: | Merged |
---|---|
Merged at revision: | 9 |
Proposed branch: | lp:~mbruzek/charms/trusty/kubernetes-master/v1.0.0 |
Merge into: | lp:~kubernetes/charms/trusty/kubernetes-master/trunk |
Diff against target: |
631 lines (+86/-370) 17 files modified
cli.txt (+0/-80) config.yaml (+1/-1) copyright (+7/-7) docs/1-getting-started.md (+0/-81) docs/contributing.md (+0/-52) files/apiserver.upstart.tmpl (+1/-1) files/create_kubernetes_tar.sh (+0/-59) files/distribution.conf.tmpl (+1/-1) hooks/__init__.py (+2/-0) hooks/hooks.py (+61/-38) hooks/install.py (+2/-1) hooks/kubernetes_installer.py (+2/-0) hooks/setup.py (+2/-0) metadata.yaml (+3/-1) scripts/guestbook.sh (+0/-48) unit_tests/kubernetes_installer_test.py (+2/-0) unit_tests/test_install.py (+2/-0) |
To merge this branch: | bzr merge lp:~mbruzek/charms/trusty/kubernetes-master/v1.0.0 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Butler (community) | Approve | ||
Review via email: mp+265174@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Matt Bruzek (mbruzek) wrote : | # |
Revision history for this message
Charles Butler (lazypower) wrote : | # |
Fix the dual shebang in the install hook and +1 LGTM
review:
Approve
- 9. By Matt Bruzek
-
Code review found double shebang in install.py removing it.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === removed file 'cli.txt' |
2 | --- cli.txt 2015-01-27 17:59:40 +0000 |
3 | +++ cli.txt 1970-01-01 00:00:00 +0000 |
4 | @@ -1,80 +0,0 @@ |
5 | -API Server |
6 | ----------- |
7 | -./apiserver -h |
8 | -Usage of ./apiserver: |
9 | - -address=127.0.0.1: The IP address on to serve on (set to 0.0.0.0 for all interfaces) |
10 | - -allow_privileged=false: If true, allow privileged containers. |
11 | - -alsologtostderr=false: log to standard error as well as files |
12 | - -api_prefix="/api": The prefix for API requests on the server. Default '/api'. |
13 | - -cloud_config="": The path to the cloud provider configuration file. Empty string for no configuration file. |
14 | - -cloud_provider="": The provider for cloud services. Empty string for no provider. |
15 | - -cors_allowed_origins=[]: List of allowed origins for CORS, comma separated. An allowed origin can be a regular expression to support subdomain matching. If this list is empty CORS will not be enabled. |
16 | - -enable_logs_support=true: Enables server endpoint for log collection |
17 | - -etcd_config="": The config file for the etcd client. Mutually exclusive with -etcd_servers. |
18 | - -etcd_servers=[]: List of etcd servers to watch (http://ip:port), comma separated. Mutually exclusive with -etcd_config |
19 | - -event_ttl=48h0m0s: Amount of time to retain events. Default 2 days. |
20 | - -health_check_minions=true: If true, health check minions and filter unhealthy ones. Default true. |
21 | - -log_backtrace_at=:0: when logging hits line file:N, emit a stack trace |
22 | - -log_dir="": If non-empty, write log files in this directory |
23 | - -log_flush_frequency=5s: Maximum number of seconds between log flushes |
24 | - -logtostderr=false: log to standard error instead of files |
25 | - -machines=[]: List of machines to schedule onto, comma separated. |
26 | - -minion_cache_ttl=30s: Duration of time to cache minion information. Default 30 seconds. |
27 | - -minion_port=10250: The port at which kubelet will be listening on the minions. |
28 | - -minion_regexp="": If non empty, and -cloud_provider is specified, a regular expression for matching minion VMs. |
29 | - -node_memory=3221225472: The amount of memory (in bytes) provisioned on each node |
30 | - -node_milli_cpu=1000: The amount of MilliCPU provisioned on each node |
31 | - -port=8080: The port to listen on. Default 8080 |
32 | - -stderrthreshold=0: logs at or above this threshold go to stderr |
33 | - -storage_version="": The version to store resources with. Defaults to server preferred |
34 | - -token_auth_file="": If set, the file that will be used to secure the API server via token authentication. |
35 | - -v=0: log level for V logs |
36 | - -version=false: Print version information and quit |
37 | - -vmodule=: comma-separated list of pattern=N settings for file-filtered logging |
38 | - |
39 | -Controller |
40 | ----------- |
41 | - |
42 | -./controller-manager -h |
43 | -Usage of ./controller-manager: |
44 | - -address=127.0.0.1: The IP address to serve on (set to 0.0.0.0 for all interfaces) |
45 | - -alsologtostderr=false: log to standard error as well as files |
46 | - -api_version="": The API version to use when talking to the server |
47 | - -certificate_authority="": Path to a cert. file for the certificate authority |
48 | - -client_certificate="": Path to a client key file for TLS. |
49 | - -client_key="": Path to a client key file for TLS. |
50 | - -insecure_skip_tls_verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. |
51 | - -log_backtrace_at=:0: when logging hits line file:N, emit a stack trace |
52 | - -log_dir="": If non-empty, write log files in this directory |
53 | - -log_flush_frequency=5s: Maximum number of seconds between log flushes |
54 | - -logtostderr=false: log to standard error instead of files |
55 | - -master="": The address of the Kubernetes API server |
56 | - -port=10252: The port that the controller-manager's http service runs on |
57 | - -stderrthreshold=0: logs at or above this threshold go to stderr |
58 | - -v=0: log level for V logs |
59 | - -version=false: Print version information and quit |
60 | - -vmodule=: comma-separated list of pattern=N settings for file-filtered logging |
61 | - |
62 | - |
63 | -Scheduler |
64 | ---------- |
65 | - |
66 | -./scheduler -h |
67 | -Usage of ./scheduler: |
68 | - -address=127.0.0.1: The IP address to serve on (set to 0.0.0.0 for all interfaces) |
69 | - -alsologtostderr=false: log to standard error as well as files |
70 | - -api_version="": The API version to use when talking to the server |
71 | - -certificate_authority="": Path to a cert. file for the certificate authority |
72 | - -client_certificate="": Path to a client key file for TLS. |
73 | - -client_key="": Path to a client key file for TLS. |
74 | - -insecure_skip_tls_verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure. |
75 | - -log_backtrace_at=:0: when logging hits line file:N, emit a stack trace |
76 | - -log_dir="": If non-empty, write log files in this directory |
77 | - -log_flush_frequency=5s: Maximum number of seconds between log flushes |
78 | - -logtostderr=false: log to standard error instead of files |
79 | - -master="": The address of the Kubernetes API server |
80 | - -port=10251: The port that the scheduler's http service runs on |
81 | - -stderrthreshold=0: logs at or above this threshold go to stderr |
82 | - -v=0: log level for V logs |
83 | - -version=false: Print version information and quit |
84 | - -vmodule=: comma-separated list of pattern=N settings for file-filtered logging |
85 | |
86 | === modified file 'config.yaml' |
87 | --- config.yaml 2015-04-10 21:12:25 +0000 |
88 | +++ config.yaml 2015-07-17 20:13:36 +0000 |
89 | @@ -1,7 +1,7 @@ |
90 | options: |
91 | version: |
92 | type: string |
93 | - default: "v0.8.1" |
94 | + default: "v1.0.0" |
95 | description: | |
96 | The kubernetes release to use in this charm. The binary files are |
97 | compiled from the source identified by this tag in github. Using the |
98 | |
99 | === modified file 'copyright' |
100 | --- copyright 2015-01-27 17:59:40 +0000 |
101 | +++ copyright 2015-07-17 20:13:36 +0000 |
102 | @@ -1,13 +1,13 @@ |
103 | -Copyright 2015 Canonical LTD |
104 | +Copyright 2015 Canonical Ltd. |
105 | |
106 | Licensed under the Apache License, Version 2.0 (the "License"); |
107 | you may not use this file except in compliance with the License. |
108 | You may obtain a copy of the License at |
109 | |
110 | - http://www.apache.org/licenses/LICENSE-2.0 |
111 | + http://www.apache.org/licenses/LICENSE-2.0 |
112 | |
113 | - Unless required by applicable law or agreed to in writing, software |
114 | - distributed under the License is distributed on an "AS IS" BASIS, |
115 | - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
116 | - See the License for the specific language governing permissions and |
117 | - limitations under the License. |
118 | +Unless required by applicable law or agreed to in writing, software |
119 | +distributed under the License is distributed on an "AS IS" BASIS, |
120 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
121 | +See the License for the specific language governing permissions and |
122 | +limitations under the License. |
123 | |
124 | === removed directory 'docs' |
125 | === removed file 'docs/1-getting-started.md' |
126 | --- docs/1-getting-started.md 2015-01-27 17:59:40 +0000 |
127 | +++ docs/1-getting-started.md 1970-01-01 00:00:00 +0000 |
128 | @@ -1,81 +0,0 @@ |
129 | -# Getting Started |
130 | - |
131 | -## Environment Considerations |
132 | - |
133 | -Kubernetes has specific cloud provider integration, and as of the current writing of this document that supported list includes the official Juju supported providers: |
134 | - |
135 | -- [Amazon AWS](https://jujucharms.com/docs/config-aws) |
136 | -- [Azure](https://jujucharms.com/docs/config-azure) |
137 | -- [Vagrant](https://jujucharms.com/docs/config-vagrant) |
138 | - |
139 | -Other providers available for use as a *juju manual environment* can be listed in the [Kubernetes Documentation](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs/getting-started-guides) |
140 | - |
141 | -## Deployment |
142 | - |
143 | -The Kubernetes Charms are currently under heavy development. We encourage you to fork these charms and contribute back to the development effort! See our [contributing](contributing.md) doc for more information on this. |
144 | - |
145 | -#### Deploying the Preview Release charms |
146 | - |
147 | - juju deploy cs:~hazmat/trusty/etcd |
148 | - juju deploy cs:~hazmat/trusty/flannel |
149 | - juju deploy local:trusty/kubernetes-master |
150 | - juju deploy local:trusty/kubernetes |
151 | - |
152 | - juju add-relation etcd flannel |
153 | - juju add-relation etcd kubernetes |
154 | - juju add-relation etcd kubernetes-master |
155 | - juju add-relation kubernetes kubernetes-master |
156 | - |
157 | -#### Deploying the Development Release Charms |
158 | - |
159 | -> These charms are known to be unstable as they are tracking the current efforts of the community at enabling different features against Kubernetes. This includes the specifics for integration per cloud environment, and upgrading to the latest development version. |
160 | - |
161 | - mkdir -p ~/charms/trusty |
162 | - git clone https://github.com/whitmo/kubernetes-master.git ~/charms/trusty/kubernetes-master |
163 | - git clone https://github.com/whitmo/kubernetes.git ~/charms/trusty/kubernetes |
164 | - |
165 | -##### Skipping the manual deployment after git clone |
166 | - |
167 | -> **Note:** This path requires the pre-requisite of juju-deployer. You can obtain juju-deployer via `apt-get install juju-deployer` |
168 | - |
169 | - wget https://github.com/whitmo/bundle-kubernetes/blob/master/develop.yaml kubernetes-devel.yaml |
170 | - juju-deployer kubernetes-devel.yaml |
171 | - |
172 | - |
173 | -## Verifying Deployment with the Kubernetes Agent |
174 | - |
175 | -You'll need the kubernetes command line client to utlize the created cluster. And this can be fetched from the [Releases](https://github.com/GoogleCloudPlatform/kubernetes/releases) page on the Kubernetes project. Make sure you're fetching a client library that matches what the charm is deploying. |
176 | - |
177 | -Grab the tarball and from the extracted release you can just directly use the cli binary at ./kubernetes/platforms/linux/amd64/kubecfg |
178 | - |
179 | -You'll need the address of the kubernetes master as environment variable : |
180 | - |
181 | - juju status kubernetes-master/0 |
182 | - |
183 | -Grab the public-address there and export it as KUBERNETES_MASTER environment variable : |
184 | - |
185 | - export KUBERNETES_MASTER=$(juju status --format=oneline kubernetes-master | cut -d' ' -f3):8080 |
186 | - |
187 | -And now you can run through the kubernetes examples per normal. : |
188 | - |
189 | - kubecfg list minions |
190 | - |
191 | - |
192 | -## Scale Up |
193 | - |
194 | -If the default capacity of the bundle doesn't provide enough capacity for your workload(s) you can scale horizontially by adding a unit to the flannel and kubernetes services respectively. |
195 | - |
196 | - juju add-unit flannel |
197 | - juju add-unit kubernetes --to # (machine id of new flannel unit) |
198 | - |
199 | -## Known Issues / Limitations |
200 | - |
201 | -Kubernetes currently has platform specific functionality. For example load balancers and persistence volumes only work with the google compute provider atm. |
202 | - |
203 | -The Juju integration uses the kubernetes null provider. This means external load balancers and storage can't be directly driven through kubernetes config files. |
204 | - |
205 | -## Where to get help |
206 | - |
207 | -If you run into any issues, file a bug at our [issue tracker](http://github.com/whitmo/kubernetes-charm/issues), email the Juju Mailing List at <juju@lists.ubuntu.com>, or feel free to join us in #juju on irc.freenode.net. |
208 | - |
209 | - |
210 | |
211 | === removed file 'docs/contributing.md' |
212 | --- docs/contributing.md 2015-01-27 17:59:40 +0000 |
213 | +++ docs/contributing.md 1970-01-01 00:00:00 +0000 |
214 | @@ -1,52 +0,0 @@ |
215 | - |
216 | -#### Contributions are welcome, in any form. Whether that be Bugs, BugFixes, Documentation, or Features. |
217 | - |
218 | -### Submitting a bug |
219 | - |
220 | -1. Go to our [issue tracker](http://github.com/whitmo/kubernetes-master-charm/issues) on GitHub |
221 | -2. Search for existing issues using the search field at the top of the page |
222 | -3. File a new issue including the info listed below |
223 | -4. Thanks a ton for helping make the Kubernetes-Master Charm higher quality! |
224 | - |
225 | -##### When filing a new bug, please include: |
226 | - |
227 | -- **Descriptive title** - use keywords so others can find your bug (avoiding duplicates) |
228 | -- **Steps to trigger the problem** - that are specific, and repeatable |
229 | -- **What happens** - when you follow the steps, and what you expected to happen instead. |
230 | -- Include the exact text of any error messages if applicable (or upload screenshots). |
231 | -- Kubernetes-Master Charm version (or if you're pulling directly from Git, your current commit SHA - use git rev-parse HEAD) and the Juju Version output from `juju --version`. |
232 | -- Did this work in a previous charm version? If so, also provide the version that it worked in. |
233 | -- Any errors logged in `juju debug log` Console view |
234 | - |
235 | -### Can I help fix a bug? |
236 | - |
237 | -Yes please! But first... |
238 | - |
239 | -- Make sure no one else is already working on it -- if the bug has a milestone assigned or is tagged 'fix in progress', then it's already under way. Otherwise, post a comment on the bug to let others know you're starting to work on it. |
240 | - |
241 | -We use the Fork & Pull model for distributed development. For a more in-depth overview: consult with the github documentation on [Collaborative Development Models](https://help.github.com/articles/using-pull-requests/#before-you-begin). |
242 | - |
243 | -> ##### Fork & pull |
244 | -> |
245 | -> The fork & pull model lets anyone fork an existing repository and push changes to their personal fork without requiring access be granted to the source repository. The changes must then be pulled into the source repository by the project maintainer. This model reduces the amount of friction for new contributors and is popular with open source projects because it allows people to work independently without upfront coordination. |
246 | - |
247 | -### Submitting a Bug Fix |
248 | - |
249 | -The following checklist will help developers not familiar with the fork and pull process of development. We appreciate your enthusiasm to make the Kubernetes-Master Charm a High Quality experience! To Rapidly get started - follow the 8 steps below. |
250 | - |
251 | -1. [Fork the repository](https://help.github.com/articles/fork-a-repo/) |
252 | -2. Clone your fork `git clone git@github.com/myusername/kubernetes-master-charm.git` |
253 | -3. Checkout your topic branch with `git checkout -b my-awesome-bugfix` |
254 | -4. Hack away at your feature/bugfix |
255 | -5. Validate your bugfix if possible in the amulet test(s) so we dont reintroduce it later. |
256 | -6. Validate your code meets guidelines by passing lint tests `make lint` |
257 | -6. Commit code `git commit -a -m 'i did all this work to fix #32'` |
258 | -7. Push your branch to your forks remote branch `git push origin my-awesome-bugfix` |
259 | -8. Create the [Pull Request](https://help.github.com/articles/using-pull-requests/#initiating-the-pull-request) |
260 | -9. Await Code Review |
261 | -10. Rejoice when Pull Request is accepted |
262 | - |
263 | -### Submitting a Feature |
264 | - |
265 | -The Steps are the same as [Submitting a Bug Fix](#submitting-a-bug-fix). If you want extra credit, make sure you [File an issue](http://github.com/whitmo/kubernetes-master-charm/issues) that covers the Feature you are working on - as kind of a courtesy heads up. And assign the issue to yourself so we know you are working on it. |
266 | - |
267 | |
268 | === modified file 'files/apiserver.upstart.tmpl' |
269 | --- files/apiserver.upstart.tmpl 2015-04-10 21:12:25 +0000 |
270 | +++ files/apiserver.upstart.tmpl 2015-07-17 20:13:36 +0000 |
271 | @@ -11,7 +11,7 @@ |
272 | --address=%(api_bind_address)s \ |
273 | --etcd_servers=%(etcd_servers)s \ |
274 | --logtostderr=true \ |
275 | - --portal_net=10.244.240.0/20 |
276 | + --service-cluster-ip-range=10.244.240.0/20 |
277 | |
278 | |
279 | |
280 | |
281 | === removed file 'files/create_kubernetes_tar.sh' |
282 | --- files/create_kubernetes_tar.sh 2015-01-27 17:59:40 +0000 |
283 | +++ files/create_kubernetes_tar.sh 1970-01-01 00:00:00 +0000 |
284 | @@ -1,59 +0,0 @@ |
285 | -#!/bin/bash |
286 | - |
287 | -set -ex |
288 | - |
289 | -# This script downloads a Kubernetes release and creates a tar file with only |
290 | -# the files that are needed for this charm. |
291 | - |
292 | -# Usage: create_kubernetes_tar.sh VERSION ARCHITECTURE |
293 | - |
294 | -usage() { |
295 | - echo "Build a tar file with only the files needed for the kubernetes charm." |
296 | - echo "The script accepts two arguments version and desired architecture." |
297 | - echo "$0 version architecture" |
298 | -} |
299 | - |
300 | -download_kubernetes() { |
301 | - local VERSION=$1 |
302 | - URL_PREFIX="https://github.com/GoogleCloudPlatform/kubernetes" |
303 | - KUBERNETES_URL="${URL_PREFIX}/releases/download/${VERSION}/kubernetes.tar.gz" |
304 | - # Remove the previous temporary files to remain idempotent. |
305 | - if [ -f /tmp/kubernetes.tar.gz ]; then |
306 | - rm /tmp/kubernetes.tar.gz |
307 | - fi |
308 | - # Download the kubernetes release from the Internet. |
309 | - wget --no-verbose --tries 2 -O /tmp/kubernetes.tar.gz $KUBERNETES_URL |
310 | -} |
311 | - |
312 | -extract_kubernetes() { |
313 | - local ARCH=$1 |
314 | - # Untar the kubernetes release file. |
315 | - tar -xvzf /tmp/kubernetes.tar.gz -C /tmp |
316 | - # Untar the server linux amd64 package. |
317 | - tar -xvzf /tmp/kubernetes/server/kubernetes-server-linux-$ARCH.tar.gz -C /tmp |
318 | -} |
319 | - |
320 | -create_charm_tar() { |
321 | - local OUTPUT_FILE=${1:-"$PWD/kubernetes.tar.gz"} |
322 | - local OUTPUT_DIR=`dirname $OUTPUT_FILE` |
323 | - if [ ! -d $OUTPUT_DIR ]; then |
324 | - mkdir -p $OUTPUT |
325 | - fi |
326 | - |
327 | - # Change to the directory the binaries are. |
328 | - cd /tmp/kubernetes/server/bin/ |
329 | - |
330 | - # Create a tar file with the binaries that are needed for kubernetes master. |
331 | - tar -cvzf $OUTPUT_FILE kube-apiserver kube-controller-manager kubectl kube-scheduler |
332 | -} |
333 | - |
334 | -if [ $# -gt 2 ]; then |
335 | - usage |
336 | - exit 1 |
337 | -fi |
338 | -VERSION=${1:-"v0.8.1"} |
339 | -ARCH=${2:-"amd64"} |
340 | -download_kubernetes $VERSION |
341 | -extract_kubernetes $ARCH |
342 | -TAR_FILE="$PWD/kubernetes-master-$VERSION-$ARCH.tar.gz" |
343 | -create_charm_tar $TAR_FILE |
344 | |
345 | === modified file 'files/distribution.conf.tmpl' |
346 | --- files/distribution.conf.tmpl 2015-04-10 21:12:25 +0000 |
347 | +++ files/distribution.conf.tmpl 2015-07-17 20:13:36 +0000 |
348 | @@ -1,6 +1,6 @@ |
349 | server { |
350 | listen %(api_bind_address)s:80; |
351 | location %(web_uri)s { |
352 | - alias /opt/kubernetes/_output/local/bin/linux/amd64/; |
353 | + alias %(alias)s; |
354 | } |
355 | } |
356 | |
357 | === modified file 'hooks/__init__.py' |
358 | --- hooks/__init__.py 2015-04-10 21:12:25 +0000 |
359 | +++ hooks/__init__.py 2015-07-17 20:13:36 +0000 |
360 | @@ -0,0 +1,2 @@ |
361 | +#!/usr/bin/env python |
362 | + |
363 | |
364 | === modified file 'hooks/hooks.py' |
365 | --- hooks/hooks.py 2015-04-10 21:12:25 +0000 |
366 | +++ hooks/hooks.py 2015-07-17 20:13:36 +0000 |
367 | @@ -1,4 +1,5 @@ |
368 | -#!/usr/bin/python |
369 | +#!/usr/bin/env python |
370 | + |
371 | """ |
372 | The main hook file is called by Juju. |
373 | """ |
374 | @@ -44,46 +45,54 @@ |
375 | config = hookenv.config() |
376 | # Get the version of kubernetes to install. |
377 | version = config['version'] |
378 | - # Get the package architecture, rather than the from the kernel (uname -m). |
379 | - arch = subprocess.check_output(['dpkg', '--print-architecture']).strip() |
380 | - kubernetes_dir = path('/opt/kubernetes') |
381 | - if not kubernetes_dir.exists(): |
382 | - print('The source directory {0} does not exist'.format(kubernetes_dir)) |
383 | - print('Was the kubernetes code cloned during install?') |
384 | - exit(1) |
385 | |
386 | - if version in ['source', 'head', 'master']: |
387 | + if version == 'master': |
388 | + # The 'master' branch of kuberentes is used when master is configured. |
389 | branch = 'master' |
390 | + elif version == 'local': |
391 | + # Check for kubernetes binaries in the local files/output directory. |
392 | + branch = None |
393 | else: |
394 | - # Create a branch to a tag. |
395 | + # Create a branch to a tag to get the release version. |
396 | branch = 'tags/{0}'.format(version) |
397 | |
398 | - # Construct the path to the binaries using the arch. |
399 | - output_path = kubernetes_dir / '_output/local/bin/linux' / arch |
400 | - installer = KubernetesInstaller(arch, version, output_path) |
401 | - |
402 | - # Change to the kubernetes directory (git repository). |
403 | - with kubernetes_dir: |
404 | - # Create a command to get the current branch. |
405 | - git_branch = 'git branch | grep "\*" | cut -d" " -f2' |
406 | - current_branch = subprocess.check_output(git_branch, shell=True).strip() |
407 | - print('Current branch: ', current_branch) |
408 | - # Create the path to a file to indicate if the build was broken. |
409 | - broken_build = charm_dir / '.broken_build' |
410 | - # write out the .broken_build file while this block is executing. |
411 | - with check_sentinel(broken_build) as last_build_failed: |
412 | - print('Last build failed: ', last_build_failed) |
413 | - # Rebuild if the current version is different or last build failed. |
414 | - if current_branch != version or last_build_failed: |
415 | - installer.build(branch) |
416 | - if not output_path.exists(): |
417 | - broken_build.touch() |
418 | - else: |
419 | - print('Notifying minions of verison ' + version) |
420 | - # Notify the minions of a version change. |
421 | - for r in hookenv.relation_ids('minions-api'): |
422 | - hookenv.relation_set(r, version=version) |
423 | - print('Done notifing minions of version ' + version) |
424 | + # Get the package architecture, rather than arch from the kernel (uname -m). |
425 | + arch = subprocess.check_output(['dpkg', '--print-architecture']).strip() |
426 | + |
427 | + if not branch: |
428 | + output_path = charm_dir / 'files/output' |
429 | + installer = KubernetesInstaller(arch, version, output_path) |
430 | + else: |
431 | + |
432 | + # Build the kuberentes binaries from source on the units. |
433 | + kubernetes_dir = path('/opt/kubernetes') |
434 | + |
435 | + # Construct the path to the binaries using the arch. |
436 | + output_path = kubernetes_dir / '_output/local/bin/linux' / arch |
437 | + installer = KubernetesInstaller(arch, version, output_path) |
438 | + |
439 | + if not kubernetes_dir.exists(): |
440 | + print('The source directory {0} does not exist'.format(kubernetes_dir)) |
441 | + print('Was the kubernetes code cloned during install?') |
442 | + exit(1) |
443 | + |
444 | + # Change to the kubernetes directory (git repository). |
445 | + with kubernetes_dir: |
446 | + |
447 | + # Create a command to get the current branch. |
448 | + git_branch = 'git branch | grep "\*" | cut -d" " -f2' |
449 | + current_branch = subprocess.check_output(git_branch, shell=True).strip() |
450 | + print('Current branch: ', current_branch) |
451 | + # Create the path to a file to indicate if the build was broken. |
452 | + broken_build = charm_dir / '.broken_build' |
453 | + # write out the .broken_build file while this block is executing. |
454 | + with check_sentinel(broken_build) as last_build_failed: |
455 | + print('Last build failed: ', last_build_failed) |
456 | + # Rebuild if current version is different or last build failed. |
457 | + if current_branch != version or last_build_failed: |
458 | + installer.build(branch) |
459 | + if not output_path.isdir(): |
460 | + broken_build.touch() |
461 | |
462 | # Create the symoblic links to the right directories. |
463 | installer.install() |
464 | @@ -127,6 +136,12 @@ |
465 | notify_minions() |
466 | |
467 | |
468 | +@hooks.hook('network-relation-changed') |
469 | +def network_relation_changed(): |
470 | + relation_id = hookenv.relation_id() |
471 | + hookenv.relation_set(relation_id, ignore_errors=True) |
472 | + |
473 | + |
474 | def notify_minions(): |
475 | print("Notify minions.") |
476 | config = hookenv.config() |
477 | @@ -136,11 +151,13 @@ |
478 | hostname=hookenv.unit_private_ip(), |
479 | port=8080, |
480 | version=config['version']) |
481 | + print("Notified minions of version " + config['version']) |
482 | |
483 | |
484 | def get_template_data(): |
485 | rels = hookenv.relations() |
486 | config = hookenv.config() |
487 | + version = config['version'] |
488 | template_data = {} |
489 | template_data['etcd_servers'] = ",".join([ |
490 | "http://%s:%s" % (s[0], s[1]) for s in sorted( |
491 | @@ -152,8 +169,14 @@ |
492 | template_data['api_server_address'] = "http://%s:%s" % ( |
493 | hookenv.unit_private_ip(), 8080) |
494 | arch = subprocess.check_output(['dpkg', '--print-architecture']).strip() |
495 | - template_data['web_uri'] = "/kubernetes/%s/local/bin/linux/%s/" % ( |
496 | - config['version'], arch) |
497 | + |
498 | + template_data['web_uri'] = "/kubernetes/%s/local/bin/linux/%s/" % (version, |
499 | + arch) |
500 | + if version == 'local': |
501 | + template_data['alias'] = hookenv.charm_dir() + '/files/output/' |
502 | + else: |
503 | + directory = '/opt/kubernetes/_output/local/bin/linux/%s/' % arch |
504 | + template_data['alias'] = directory |
505 | _encode(template_data) |
506 | return template_data |
507 | |
508 | |
509 | === modified file 'hooks/install.py' |
510 | --- hooks/install.py 2015-04-10 21:12:25 +0000 |
511 | +++ hooks/install.py 2015-07-17 20:13:36 +0000 |
512 | @@ -1,4 +1,5 @@ |
513 | -#!/usr/bin/python |
514 | +#!/usr/bin/env python |
515 | + |
516 | |
517 | import setup |
518 | setup.pre_install() |
519 | |
520 | === modified file 'hooks/kubernetes_installer.py' |
521 | --- hooks/kubernetes_installer.py 2015-04-10 21:12:25 +0000 |
522 | +++ hooks/kubernetes_installer.py 2015-07-17 20:13:36 +0000 |
523 | @@ -1,3 +1,5 @@ |
524 | +#!/usr/bin/env python |
525 | + |
526 | import os |
527 | import shlex |
528 | import subprocess |
529 | |
530 | === modified file 'hooks/setup.py' |
531 | --- hooks/setup.py 2015-04-10 21:12:25 +0000 |
532 | +++ hooks/setup.py 2015-07-17 20:13:36 +0000 |
533 | @@ -1,3 +1,5 @@ |
534 | +#!/usr/bin/env python |
535 | + |
536 | def pre_install(): |
537 | """ |
538 | Do any setup required before the install hook. |
539 | |
540 | === modified file 'metadata.yaml' |
541 | --- metadata.yaml 2015-04-10 21:12:25 +0000 |
542 | +++ metadata.yaml 2015-07-17 20:13:36 +0000 |
543 | @@ -3,7 +3,7 @@ |
544 | description: | |
545 | Provides a kubernetes api endpoint, scheduler for managing containers. |
546 | maintainers: |
547 | - - Matt Bruzek <matt.bruzek@canonical.com> |
548 | + - Matt Bruzek <matthew.bruzek@canonical.com> |
549 | - Whit Morriss <whit.morriss@canonical.com> |
550 | - Charles Butler <charles.butler@canonical.com> |
551 | tags: |
552 | @@ -17,3 +17,5 @@ |
553 | requires: |
554 | etcd: |
555 | interface: etcd |
556 | + network: |
557 | + interface: overlay-network |
558 | |
559 | === removed directory 'scripts' |
560 | === removed file 'scripts/guestbook.sh' |
561 | --- scripts/guestbook.sh 2015-04-10 21:12:25 +0000 |
562 | +++ scripts/guestbook.sh 1970-01-01 00:00:00 +0000 |
563 | @@ -1,48 +0,0 @@ |
564 | -#!/bin/bash |
565 | - |
566 | -# This script sets up the guestbook example application in Kubernetes. |
567 | -# The KUBERENTES_MASTER variable must be set to the URL for kubectl to work. |
568 | -# The first argument is optional and can be used for debugging. |
569 | - |
570 | -set -o errexit # (set -e) |
571 | - |
572 | -DEBUG=false |
573 | -if [[ "$1" == "-d" ]] || [[ "$1" == "--debug" ]]; then |
574 | - DEBUG=true |
575 | - set -o xtrace # (set -x) |
576 | -fi |
577 | -cd /opt/kubernetes/ |
578 | -# Step One Turn up the redis master |
579 | -kubectl create -f examples/guestbook/redis-master.json |
580 | -if [[ "${DEBUG}" == true ]]; then |
581 | - kubectl get pods |
582 | -fi |
583 | -# Step Two: Turn up the master service |
584 | -kubectl create -f examples/guestbook/redis-master-service.json |
585 | -if [[ "${DEBUG}" == true ]]; then |
586 | - kubectl get services |
587 | -fi |
588 | -# Step Three: Turn up the replicated slave pods |
589 | -kubectl create -f examples/guestbook/redis-slave-controller.json |
590 | -if [[ "${DEBUG}" == true ]]; then |
591 | - kubectl get replicationcontrollers |
592 | - kubectl get pods |
593 | -fi |
594 | -# Step Four: Create the redis slave service |
595 | -kubectl create -f examples/guestbook/redis-slave-service.json |
596 | -if [[ "${DEBUG}" == true ]]; then |
597 | - kubectl get services |
598 | -fi |
599 | -# Step Five: Create the frontend pod |
600 | -kubectl create -f examples/guestbook/frontend-controller.json |
601 | -if [[ "${DEBUG}" == true ]]; then |
602 | - kubectl get replicationcontrollers |
603 | - kubectl get pods |
604 | -fi |
605 | - |
606 | -set +x |
607 | - |
608 | -echo "# Now run the following commands on your juju client" |
609 | -echo "juju run --service kubernetes 'open-port 8000'" |
610 | -echo "juju expose kubernetes" |
611 | -echo "# Go to the kubernetes public address on port 8000 to see the guestbook application" |
612 | |
613 | === modified file 'unit_tests/kubernetes_installer_test.py' |
614 | --- unit_tests/kubernetes_installer_test.py 2015-04-10 21:12:25 +0000 |
615 | +++ unit_tests/kubernetes_installer_test.py 2015-07-17 20:13:36 +0000 |
616 | @@ -1,3 +1,5 @@ |
617 | +#!/usr/bin/env python |
618 | + |
619 | from mock import patch |
620 | from path import path |
621 | from path import Path |
622 | |
623 | === modified file 'unit_tests/test_install.py' |
624 | --- unit_tests/test_install.py 2015-04-10 21:12:25 +0000 |
625 | +++ unit_tests/test_install.py 2015-07-17 20:13:36 +0000 |
626 | @@ -1,3 +1,5 @@ |
627 | +#!/usr/bin/env python |
628 | + |
629 | from mock import patch, Mock, MagicMock |
630 | from path import Path |
631 | import pytest |
Vendoring the changes for the v1.0.0 kubernetes release