Skip to content

Commit fd7fa0f

Browse files
committed
Merge remote-tracking branch 'upstream/master' into registry-change
# Conflicts: # guestbook-go/guestbook-controller.json # guestbook-go/redis-master-controller.json # guestbook-go/redis-replica-controller.json Signed-off-by: ajayk <[email protected]>
2 parents 33dfad2 + 2452dfc commit fd7fa0f

16 files changed

+176
-201
lines changed

dev/cd/after-push-to-branch

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o nounset
5+
set -o pipefail
6+
7+
# cd to the repo root
8+
REPO_ROOT=$(git rev-parse --show-toplevel)
9+
cd "${REPO_ROOT}"
10+
11+
if [ -z "${GIT_REF:-}" ]; then
12+
echo "GIT_REF must be set"
13+
exit 1
14+
fi
15+
16+
if [[ -z "${REGISTRY_BASE:-}" ]]; then
17+
echo "REGISTRY_BASE must be set"
18+
exit 1
19+
fi
20+
21+
if [[ ! "${GIT_REF}" =~ ^refs/heads/.* ]]; then
22+
echo "GIT_REF=${GIT_REF} is not of the expected format refs/heads/*"
23+
exit 1
24+
fi
25+
26+
BRANCH=${GIT_REF/refs\/heads\//}
27+
echo "BRANCH is ${BRANCH}"
28+
29+
GIT_REVISION=$(git rev-parse --short HEAD)
30+
echo "GIT_REVISION is ${GIT_REVISION}"
31+
32+
export IMAGE_TAG="g${GIT_REVISION}"
33+
echo "IMAGE_TAG is ${IMAGE_TAG}"
34+
35+
pushd ${REPO_ROOT}/guestbook-go
36+
VERSION=${IMAGE_TAG} REGISTRY=${REGISTRY_BASE} make push
37+
popd

dev/cloudbuild/cloudbuild.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
timeout: 900s
2+
steps:
3+
- name: 'gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20230111-cd1b3caf9c'
4+
entrypoint: dev/cd/after-push-to-branch
5+
env:
6+
- GIT_REF=$_GIT_TAG
7+
- PULL_BASE_REF=$_PULL_BASE_REF
8+
- REGISTRY_BASE=gcr.io/k8s-staging-examples
9+
substitutions:
10+
# _GIT_TAG will be filled with a git-based tag for the image, of the form vYYYYMMDD-hash, and
11+
# can be used as a substitution
12+
_GIT_TAG: '12345'
13+
_PULL_BASE_REF: 'master'

guestbook-go/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ release: clean build push clean
2323

2424
# builds a docker image that builds the app and packages it into a minimal docker image
2525
build:
26-
docker build -t ${REGISTRY}/guestbook:${VERSION} .
26+
docker buildx build --load -t ${REGISTRY}/guestbook:${VERSION} .
2727

2828
# push the image to an registry
2929
push:
30-
gcloud docker -- push ${REGISTRY}/guestbook:${VERSION}
30+
docker buildx build --push -t ${REGISTRY}/guestbook:${VERSION} .
3131

3232
# remove previous images and containers
3333
clean:

guestbook-go/README.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ This example assumes that you have a working cluster. See the [Getting Started G
2424

2525
### Step One: Create the Redis master pod<a id="step-one"></a>
2626

27-
Use the `examples/guestbook-go/redis-master-controller.json` file to create a [replication controller](https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/) and Redis master [pod](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/). The pod runs a Redis key-value server in a container. Using a replication controller is the preferred way to launch long-running pods, even for 1 replica, so that the pod benefits from the self-healing mechanism in Kubernetes (keeps the pods alive).
27+
Use the `examples/guestbook-go/redis-master-controller.yaml` file to create a [replication controller](https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/) and Redis master [pod](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/). The pod runs a Redis key-value server in a container. Using a replication controller is the preferred way to launch long-running pods, even for 1 replica, so that the pod benefits from the self-healing mechanism in Kubernetes (keeps the pods alive).
2828

29-
1. Use the [redis-master-controller.json](redis-master-controller.json) file to create the Redis master replication controller in your Kubernetes cluster by running the `kubectl create -f` *`filename`* command:
29+
1. Use the [redis-master-controller.yaml](redis-master-controller.yaml) file to create the Redis master replication controller in your Kubernetes cluster by running the `kubectl create -f` *`filename`* command:
3030

3131
```console
32-
$ kubectl create -f examples/guestbook-go/redis-master-controller.json
32+
$ kubectl create -f examples/guestbook-go/redis-master-controller.yaml
3333
3434
```
3535

@@ -73,10 +73,10 @@ A Kubernetes [service](https://kubernetes.io/docs/concepts/services-networking/s
7373

7474
Services find the pods to load balance based on pod labels. The pod that you created in Step One has the label `app=redis` and `role=master`. The selector field of the service determines which pods will receive the traffic sent to the service.
7575

76-
1. Use the [redis-master-service.json](redis-master-service.json) file to create the service in your Kubernetes cluster by running the `kubectl create -f` *`filename`* command:
76+
1. Use the [redis-master-service.yaml](redis-master-service.yaml) file to create the service in your Kubernetes cluster by running the `kubectl create -f` *`filename`* command:
7777

7878
```console
79-
$ kubectl create -f examples/guestbook-go/redis-master-service.json
79+
$ kubectl create -f examples/guestbook-go/redis-master-service.yaml
8080
8181
```
8282

@@ -96,10 +96,10 @@ Services find the pods to load balance based on pod labels. The pod that you cre
9696

9797
The Redis master we created earlier is a single pod (REPLICAS = 1), while the Redis read replicas we are creating here are 'replicated' pods. In Kubernetes, a replication controller is responsible for managing the multiple instances of a replicated pod.
9898

99-
1. Use the file [redis-replica-controller.json](redis-replica-controller.json) to create the replication controller by running the `kubectl create -f` *`filename`* command:
99+
1. Use the file [redis-replica-controller.yaml](redis-replica-controller.yaml) to create the replication controller by running the `kubectl create -f` *`filename`* command:
100100

101101
```console
102-
$ kubectl create -f examples/guestbook-go/redis-replica-controller.json
102+
$ kubectl create -f examples/guestbook-go/redis-replica-controller.yaml
103103
104104
```
105105

@@ -139,10 +139,10 @@ The Redis master we created earlier is a single pod (REPLICAS = 1), while the Re
139139

140140
Just like the master, we want to have a service to proxy connections to the read replicas. In this case, in addition to discovery, the Redis replica service provides transparent load balancing to clients.
141141

142-
1. Use the [redis-replica-service.json](redis-replica-service.json) file to create the Redis replica service by running the `kubectl create -f` *`filename`* command:
142+
1. Use the [redis-replica-service.yaml](redis-replica-service.yaml) file to create the Redis replica service by running the `kubectl create -f` *`filename`* command:
143143

144144
```console
145-
$ kubectl create -f examples/guestbook-go/redis-replica-service.json
145+
$ kubectl create -f examples/guestbook-go/redis-replica-service.yaml
146146
147147
```
148148

@@ -164,14 +164,14 @@ Tip: It is helpful to set labels on your services themselves--as we've done here
164164

165165
This is a simple Go `net/http` ([negroni](https://github.com/codegangsta/negroni) based) server that is configured to talk to either the replica or master services depending on whether the request is a read or a write. The pods we are creating expose a simple JSON interface and serves a jQuery-Ajax based UI. Like the Redis replica pods, these pods are also managed by a replication controller.
166166

167-
1. Use the [guestbook-controller.json](guestbook-controller.json) file to create the guestbook replication controller by running the `kubectl create -f` *`filename`* command:
167+
1. Use the [guestbook-controller.yaml](guestbook-controller.yaml) file to create the guestbook replication controller by running the `kubectl create -f` *`filename`* command:
168168

169169
```console
170-
$ kubectl create -f examples/guestbook-go/guestbook-controller.json
170+
$ kubectl create -f examples/guestbook-go/guestbook-controller.yaml
171171
172172
```
173173

174-
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.
174+
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.yaml.
175175

176176
2. To verify that the guestbook replication controller is running, run the `kubectl get rc` command:
177177

@@ -204,10 +204,10 @@ This is a simple Go `net/http` ([negroni](https://github.com/codegangsta/negroni
204204

205205
Just like the others, we create a service to group the guestbook pods but this time, to make the guestbook front end externally visible, we specify `"type": "LoadBalancer"`.
206206

207-
1. Use the [guestbook-service.json](guestbook-service.json) file to create the guestbook service by running the `kubectl create -f` *`filename`* command:
207+
1. Use the [guestbook-service.yaml](guestbook-service.yaml) file to create the guestbook service by running the `kubectl create -f` *`filename`* command:
208208

209209
```console
210-
$ kubectl create -f examples/guestbook-go/guestbook-service.json
210+
$ kubectl create -f examples/guestbook-go/guestbook-service.yaml
211211
```
212212

213213

guestbook-go/guestbook-controller.json

-37
This file was deleted.
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
kind: ReplicationController
2+
apiVersion: v1
3+
metadata:
4+
name: guestbook
5+
labels:
6+
app: guestbook
7+
spec:
8+
replicas: 3
9+
selector:
10+
app: guestbook
11+
template:
12+
metadata:
13+
labels:
14+
app: guestbook
15+
spec:
16+
containers:
17+
- name: guestbook
18+
image: k8s.gcr.io/guestbook:v3
19+
ports:
20+
- name: http-server
21+
containerPort: 3000

guestbook-go/guestbook-service.json

-22
This file was deleted.

guestbook-go/guestbook-service.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: guestbook
5+
labels:
6+
app: guestbook
7+
spec:
8+
ports:
9+
- port: 3000
10+
targetPort: http-server
11+
selector:
12+
app: guestbook
13+
type: LoadBalancer

guestbook-go/redis-master-controller.json

-40
This file was deleted.
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
kind: ReplicationController
2+
apiVersion: v1
3+
metadata:
4+
name: redis-master
5+
labels:
6+
app: redis
7+
role: master
8+
spec:
9+
replicas: 1
10+
selector:
11+
app: redis
12+
role: master
13+
template:
14+
metadata:
15+
labels:
16+
app: redis
17+
role: master
18+
spec:
19+
containers:
20+
- name: redis-master
21+
image: k8s.gcr.io/redis:e2e
22+
ports:
23+
- name: redis-server
24+
containerPort: 6379

guestbook-go/redis-master-service.json

-23
This file was deleted.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
name: redis-master
5+
labels:
6+
app: redis
7+
role: master
8+
spec:
9+
ports:
10+
- port: 6379
11+
targetPort: redis-server
12+
selector:
13+
app: redis
14+
role: master

guestbook-go/redis-replica-controller.json

-40
This file was deleted.

0 commit comments

Comments
 (0)