File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Dockerfile
2+ FROM golang:1.16-buster AS builder
3+ RUN mkdir /src
4+ ADD . /src
5+ WORKDIR /src
6+
7+ RUN go env -w GO111MODULE=auto
8+ RUN go build -o main .
9+
10+ FROM gcr.io/distroless/base-debian10
11+
12+ WORKDIR /
13+
14+ COPY --from=builder /src/main /main
15+ EXPOSE 3000
16+ ENTRYPOINT ["/main" ]
Original file line number Diff line number Diff line change 1+ apiVersion : apps/v1
2+ kind : Deployment
3+ metadata :
4+ name : hellok8s-deployment
5+ spec :
6+ strategy :
7+ rollingUpdate :
8+ maxSurge : 1
9+ maxUnavailable : 1
10+ replicas : 3
11+ selector :
12+ matchLabels :
13+ app : hellok8s
14+ template :
15+ metadata :
16+ labels :
17+ app : hellok8s
18+ spec :
19+ containers :
20+ - image : guangzhengli/hellok8s:bad
21+ name : hellok8s-container
22+ readinessProbe :
23+ httpGet :
24+ path : /healthz
25+ port : 3000
26+ initialDelaySeconds : 1
27+ successThreshold : 5
Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "io"
5+ "net/http"
6+ )
7+
8+ func hello (w http.ResponseWriter , r * http.Request ) {
9+ io .WriteString (w , "[v2] Hello, Kubernetes!" )
10+ }
11+
12+ func main () {
13+ http .HandleFunc ("/healthz" , func (w http.ResponseWriter , r * http.Request ) {
14+ w .WriteHeader (500 )
15+ })
16+
17+ http .HandleFunc ("/" , hello )
18+ http .ListenAndServe (":3000" , nil )
19+ }
You can’t perform that action at this time.
0 commit comments