-
Notifications
You must be signed in to change notification settings - Fork 770
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a tutorial for kruise controllers (#25)
* add a tutorial for kruise controllers * update readme * update readme * update readme * update command
- Loading branch information
Showing
23 changed files
with
915 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: apps.kruise.io/v1alpha1 | ||
kind: BroadcastJob | ||
metadata: | ||
name: download-image | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: guestbook | ||
image: openkruise/guestbook:v2 | ||
command: ["echo", "started"] # a dummy command to do nothing | ||
restartPolicy: Never | ||
completionPolicy: | ||
type: Always | ||
ttlSecondsAfterFinished: 60 # the job will be deleted after 60 seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: guestbook | ||
labels: | ||
app: guestbook | ||
spec: | ||
ports: | ||
- port: 3000 | ||
targetPort: http-server | ||
name: main-port | ||
- port: 4000 | ||
targetPort: sidecar-server | ||
name: sidecar-port | ||
selector: | ||
app: guestbook | ||
type: LoadBalancer |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: apps.kruise.io/v1alpha1 | ||
kind: SidecarSet | ||
metadata: | ||
name: guestbook-sidecar | ||
spec: | ||
selector: # select the pods to be injected with sidecar containers | ||
matchLabels: | ||
app: guestbook | ||
containers: | ||
- name: guestbook-sidecar | ||
image: openkruise/guestbook:sidecar | ||
imagePullPolicy: Always | ||
ports: | ||
- name: sidecar-server | ||
containerPort: 4000 # different from main guestbook containerPort which is 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: apps.kruise.io/v1alpha1 | ||
kind: StatefulSet | ||
metadata: | ||
name: guestbook-v1 | ||
labels: | ||
app: guestbook | ||
version: "1.0" | ||
spec: | ||
replicas: 20 | ||
serviceName: guestbook | ||
selector: | ||
matchLabels: | ||
app: guestbook | ||
template: | ||
metadata: | ||
labels: | ||
app: guestbook | ||
version: "1.0" | ||
spec: | ||
readinessGates: | ||
# A new condition that ensures the pod remains at NotReady state while the in-place update is happening | ||
- conditionType: InPlaceUpdateReady | ||
containers: | ||
- name: guestbook | ||
image: openkruise/guestbook:v2 | ||
ports: | ||
- name: http-server | ||
containerPort: 3000 | ||
podManagementPolicy: Parallel # allow parallel updates, works together with maxUnavailable | ||
updateStrategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
# Do in-place update if possible, currently only image update is supported for in-place update | ||
podUpdatePolicy: InPlaceIfPossible | ||
# Allow parallel updates with max number of unavailable instances equals to 2 | ||
maxUnavailable: 3 | ||
partition: 15 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apiVersion: apps.kruise.io/v1alpha1 | ||
kind: StatefulSet | ||
metadata: | ||
name: guestbook-v1 | ||
labels: | ||
app: guestbook | ||
version: "1.0" | ||
spec: | ||
replicas: 20 | ||
serviceName: guestbook | ||
selector: | ||
matchLabels: | ||
app: guestbook | ||
template: | ||
metadata: | ||
labels: | ||
app: guestbook | ||
version: "1.0" | ||
spec: | ||
readinessGates: | ||
# A new condition that ensures the pod remains at NotReady state while the in-place update is happening | ||
- conditionType: InPlaceUpdateReady | ||
containers: | ||
- name: guestbook | ||
image: openkruise/guestbook:v1 | ||
ports: | ||
- name: http-server | ||
containerPort: 3000 | ||
podManagementPolicy: Parallel # allow parallel updates, works together with maxUnavailable | ||
updateStrategy: | ||
type: RollingUpdate | ||
rollingUpdate: | ||
# Do in-place update if possible, currently only image update is supported for in-place update | ||
podUpdatePolicy: InPlaceIfPossible | ||
# Allow parallel updates with max number of unavailable instances equals to 2 | ||
maxUnavailable: 3 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
guestbook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM golang as builder | ||
RUN go get github.com/codegangsta/negroni | ||
RUN go get github.com/gorilla/mux github.com/xyproto/simpleredis | ||
COPY main.go . | ||
RUN go build main.go | ||
|
||
FROM busybox:ubuntu-14.04 | ||
|
||
COPY --from=builder /go//main /app/guestbook | ||
|
||
ADD public/index.html /app/public/index.html | ||
ADD public/script.js /app/public/script.js | ||
ADD public/style.css /app/public/style.css | ||
ADD public/jquery.min.js /app/public/jquery.min.js | ||
|
||
WORKDIR /app | ||
CMD ["./guestbook"] | ||
EXPOSE 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Build the guestbook example | ||
# Usage: | ||
# [VERSION=v1] [REGISTRY="docker.io/ibmcom"] make build | ||
|
||
VERSION?=v1 | ||
REGISTRY?=openkruise | ||
|
||
all: build | ||
|
||
release: clean build push clean | ||
|
||
# Builds a docker image that builds the app and packages it into a | ||
# minimal docker image | ||
build: | ||
docker build --pull -t "${REGISTRY}/guestbook:${VERSION}" . | ||
|
||
# push the image to an registry | ||
push: build | ||
docker push ${REGISTRY}/guestbook:${VERSION} | ||
|
||
# remove previous images and containers | ||
clean: | ||
rm -f guestbook/guestbook | ||
docker rmi -f "${REGISTRY}/guestbook:${VERSION}" || true | ||
|
||
.PHONY: release clean build push |
Oops, something went wrong.