diff --git a/examples/guestbook-go/README.md b/examples/guestbook-go/README.md index 1a5d58504fd..88c1b521b7c 100644 --- a/examples/guestbook-go/README.md +++ b/examples/guestbook-go/README.md @@ -95,8 +95,8 @@ Use the `examples/guestbook-go/redis-master-controller.json` file to create a [r me@workstation$ gcloud compute ssh --zone us-central1-b kubernetes-minion-bz1p me@kubernetes-minion-3:~$ sudo docker ps - CONTAINER ID IMAGE COMMAND CREATED STATUS - d5c458dabe50 gurpartap/redis:latest "/usr/local/bin/redi 5 minutes ago Up 5 minutes + CONTAINER ID IMAGE COMMAND CREATED STATUS + d5c458dabe50 redis "/entrypoint.sh redis" 5 minutes ago Up 5 minutes ``` Note: The initial `docker pull` can take a few minutes, depending on network conditions. @@ -141,9 +141,9 @@ The Redis master we created earlier is a single pod (REPLICAS = 1), while the Re ```console $ kubectl get rc - CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS - redis-master redis-master gurpartap/redis app=redis,role=master 1 - redis-slave redis-slave gurpartap/redis app=redis,role=slave 2 + CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS + redis-master redis-master redis app=redis,role=master 1 + redis-slave redis-slave kubernetes/redis-slave:v2 app=redis,role=slave 2 ... ``` @@ -205,14 +205,16 @@ This is a simple Go `net/http` ([negroni](https://github.com/codegangsta/negroni replicationcontrollers/guestbook ``` + Tip: If you want to modify the guestbook code open the `_src` of this example and read the README.md and the Makefile. If you have pushed your custom image be sure to update the `image` accordingly in the guestbook-controller.json. + 2. To verify that the guestbook replication controller is running, run the `kubectl get rc` command: ```console $ kubectl get rc - CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS - guestbook guestbook kubernetes/guestbook:v2 app=guestbook 3 - redis-master redis-master gurpartap/redis app=redis,role=master 1 - redis-slave redis-slave gurpartap/redis app=redis,role=slave 2 + CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS + guestbook guestbook gcr.io/google_containers/guestbook:v3 app=guestbook 3 + redis-master redis-master redis app=redis,role=master 1 + redis-slave redis-slave kubernetes/redis-slave:v2 app=redis,role=slave 2 ... ``` diff --git a/examples/guestbook-go/_src/Dockerfile b/examples/guestbook-go/_src/Dockerfile index adbe6c2237e..b1bb5ea0ef4 100644 --- a/examples/guestbook-go/_src/Dockerfile +++ b/examples/guestbook-go/_src/Dockerfile @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM google/golang:latest +FROM golang:1.6.0 -ADD . /gopath/src/github.com/GoogleCloudPlatform/kubernetes/examples/guestbook-go/_src +ADD . /go/src/github.com/GoogleCloudPlatform/kubernetes/examples/guestbook-go/_src -WORKDIR /gopath/src/github.com/GoogleCloudPlatform/kubernetes/examples/guestbook-go/ +WORKDIR /go/src/github.com/GoogleCloudPlatform/kubernetes/examples/guestbook-go/ RUN cd _src/ && go get && go build -o ../bin/guestbook RUN cp _src/guestbook/Dockerfile . diff --git a/examples/guestbook-go/_src/Makefile b/examples/guestbook-go/_src/Makefile new file mode 100644 index 00000000000..9c89fbcd95f --- /dev/null +++ b/examples/guestbook-go/_src/Makefile @@ -0,0 +1,39 @@ +# Copyright 2016 The Kubernetes Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Build the guestbook-go example + +# Usage: +# [VERSION=v3] [REGISTRY="gcr.io/google_containers"] make build +VERSION?=v3 +REGISTRY?=gcr.io/google_containers + +release: clean build push clean + +# builds a docker image that builds the app and packages it into a minimal docker image +build: + docker build --rm --force-rm -t ${REGISTRY}/guestbook-builder . + docker run --rm ${REGISTRY}/guestbook-builder | docker build -t "${REGISTRY}/guestbook:${VERSION}" - + +# push the image to an registry +push: + gcloud docker push ${REGISTRY}/guestbook:${VERSION} + +# remove previous images and containers +clean: + docker rm -f ${REGISTRY}/guestbook-builder 2> /dev/null || true + docker rmi -f ${REGISTRY}/guestbook-builder || true + docker rmi -f "${REGISTRY}/guestbook:${VERSION}" || true + +.PHONY: release clean build push diff --git a/examples/guestbook-go/_src/README.md b/examples/guestbook-go/_src/README.md index d0fd7fd22e0..d3f99392230 100644 --- a/examples/guestbook-go/_src/README.md +++ b/examples/guestbook-go/_src/README.md @@ -36,36 +36,22 @@ Documentation for other releases can be found at This process employs building two docker images, one compiles the source and the other hosts the compiled binaries. -Releasing the image requires that you have access to the docker registry user account which will host the image. +Releasing the image requires that you have access to the docker registry user account which will host the image. You can specify the registry including the user account by setting the environment variable `REGISTRY`. To build and release the guestbook image: cd examples/guestbook-go/_src - ./script/release.sh + make release -#### Step by step +To build and release the guestbook image with a different registry and version: -If you may want to, you can build and push the image step by step. + VERSION=v4 REGISTRY="docker.io/luebken" make build -###### Start fresh before building +If you want to, you can build and push the image step by step: - ./script/clean.sh 2> /dev/null - -###### Build - -Builds a docker image that builds the app and packages it into a minimal docker image - - ./script/build.sh - -###### Push - -Accepts an optional tag (defaults to "latest") - - ./script/push.sh [TAG] - -###### Clean up - - ./script/clean.sh + make clean + make build + make push diff --git a/examples/guestbook-go/_src/script/build.sh b/examples/guestbook-go/_src/script/build.sh deleted file mode 100755 index 9aee8a1a8ea..00000000000 --- a/examples/guestbook-go/_src/script/build.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Copyright 2014 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Usage: ./script/build.sh - -set -o errexit -set -o nounset -set -o pipefail - -guestbook_version=${1:-latest} -docker build --rm --force-rm -t kubernetes/guestbook-builder . -docker run --rm kubernetes/guestbook-builder | docker build -t "kubernetes/guestbook:${guestbook_version}" - diff --git a/examples/guestbook-go/_src/script/clean.sh b/examples/guestbook-go/_src/script/clean.sh deleted file mode 100755 index 026b8ad9ec9..00000000000 --- a/examples/guestbook-go/_src/script/clean.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -# Copyright 2014 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Usage: ./script/clean.sh - -set -o errexit -set -o nounset -set -o pipefail - -guestbook_version=${1:-latest} -docker rm -f guestbook-builder 2> /dev/null || true -docker rmi -f kubernetes/guestbook-builder || true -docker rmi -f "kubernetes/guestbook:${guestbook_version}" || true diff --git a/examples/guestbook-go/_src/script/push.sh b/examples/guestbook-go/_src/script/push.sh deleted file mode 100755 index 2d359ccc0bf..00000000000 --- a/examples/guestbook-go/_src/script/push.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -# Copyright 2014 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Usage: ./script/push.sh [TAG] - -set -o errexit -set -o nounset -set -o pipefail - -guestbook_version=${1:-latest} -docker push "kubernetes/guestbook:${guestbook_version}" diff --git a/examples/guestbook-go/_src/script/release.sh b/examples/guestbook-go/_src/script/release.sh deleted file mode 100755 index 34af8fb414f..00000000000 --- a/examples/guestbook-go/_src/script/release.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -# Copyright 2014 The Kubernetes Authors All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Usage: ./script/release.sh [TAG] - -set -o errexit -set -o nounset -set -o pipefail - -base_dir=$(dirname "$0") -base_dir=$(cd "${base_dir}" && pwd) - -guestbook_version=${1:-latest} - -echo " ---> Cleaning up before building..." -"${base_dir}/clean.sh" "${guestbook_version}" 2> /dev/null - -echo " ---> Building..." -"${base_dir}/build.sh" "${guestbook_version}" - -echo " ---> Pushing kubernetes/guestbook:${guestbook_version}..." -"${base_dir}/push.sh" "${guestbook_version}" - -echo " ---> Cleaning up..." -"${base_dir}/clean.sh" "${guestbook_version}" - -echo " ---> Done." diff --git a/examples/guestbook-go/guestbook-controller.json b/examples/guestbook-go/guestbook-controller.json index 2fe5d99c71d..82c0e9134fd 100644 --- a/examples/guestbook-go/guestbook-controller.json +++ b/examples/guestbook-go/guestbook-controller.json @@ -22,7 +22,7 @@ "containers":[ { "name":"guestbook", - "image":"kubernetes/guestbook:v2", + "image":"gcr.io/google_containers/guestbook:v3", "ports":[ { "name":"http-server",