mirror of https://github.com/k3s-io/k3s
Merge pull request #21314 from luebken/fix-guestbook-go-build
Auto commit by PR queue botpull/6/head
commit
fa48e2497b
|
@ -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
|
||||
...
|
||||
```
|
||||
|
||||
|
|
|
@ -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 .
|
||||
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
||||
|
||||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||||
|
|
|
@ -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}" -
|
|
@ -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
|
|
@ -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}"
|
|
@ -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."
|
|
@ -22,7 +22,7 @@
|
|||
"containers":[
|
||||
{
|
||||
"name":"guestbook",
|
||||
"image":"kubernetes/guestbook:v2",
|
||||
"image":"gcr.io/google_containers/guestbook:v3",
|
||||
"ports":[
|
||||
{
|
||||
"name":"http-server",
|
||||
|
|
Loading…
Reference in New Issue