Upgrade to Pro — share decks privately, control downloads, hide ads and more …

プロダクションレディ Pods / Production-Ready Pods

Kazuki Suda
December 20, 2017

プロダクションレディ Pods / Production-Ready Pods

市ヶ谷Geek★Night #16 Kubernetes Christmas! / https://ichigayageek.connpass.com/event/74057/

Kazuki Suda

December 20, 2017
Tweet

More Decks by Kazuki Suda

Other Decks in Technology

Transcript

  1. apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: -

    name: nginx image: nginx:1.13.7 ports: - containerPort: 80 Ӝ 醱侧ך؝ٝذشה醱侧ךنُٔ٦ي Ӝ رفٗ؎ך剑㼭⽃⡘ Ӝ *1QFS1PE 1PET
  2. NVMUJTUBHFCVJMET 6TFNVMUJTUBHFCVJMET]%PDLFS%PDVNFOUBUJPO FROM golang:1.7.3 WORKDIR /go/src/github.com/alexellis/href-counter/ RUN go get -d

    -v golang.org/x/net/html COPY app.go . RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app . FROM alpine:latest RUN apk --no-cache add ca-certificates WORKDIR /root/ COPY --from=0 /go/src/github.com/alexellis/href-counter/app . CMD ["./app"]
  3. SFTPVSDFSFRVFTUT Ӝ ؝ٝذشך㹋遤ח䗳銲剑⡚ꣲ䗳銲זٔا٦أ Ӝ أ؛آُ٦ׁٕ׸׋؝ٝذشךٔا٦أ銲実ך
 さ鎘ָظ٦سך㺁ꆀ״׶׮㼰זְֿה׾⥂鏾ׅ׷ apiVersion: v1 kind: Pod

    metadata: name: kuard spec: containers: - image: gcr.io/kuar-demo/kuard- name: kuard resources: requests: cpu: "500m" memory: "128Mi" ports: - containerPort: 8080 name: http protocol: TCP
  4. apiVersion: v1 kind: Pod metadata: name: kuard spec: containers: -

    image: gcr.io/kuar-demo/kuar name: kuard resources: requests: cpu: "500m" memory: "128Mi" limits: cpu: "1000m" memory: "256Mi" ports: - containerPort: 8080 name: http protocol: TCP Ӝ ؝ٝذشךٔا٦أ⢪欽ꆀך♳ꣲ׾䭷㹀ׅ׷ $16♳ꣲ׾馄ִג⢪欽׃זְ NFNPSZ♳ꣲ׾馄ִ׷ה00.ח״׶فٗإأָ媷ׁ׸׷ SFTPVSDFMJNJUT
  5. -JWFOFTTQSPCF Ӝ ؝ٝذشⰻفٗإأך娤崞湊鋔 Ӝ 㣟侁ׅ׷ה؝ٝذش׾䓼ⵖ涸חⱄ饯⹛ׅ׷ name: kuard spec: containers: -

    image: gcr.io/kuar-demo/kuard-amd64:1 name: kuard ports: - containerPort: 8080 name: http protocol: TCP livenessProbe: httpGet: path: /healthy port: 8080 initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 10 failureThreshold: 3 readinessProbe: httpGet: path: /ready port: 8080 initialDelaySeconds: 30 timeoutSeconds: 1 periodSeconds: 10 failureThreshold: 3
  6. 3FBEJOFTT1SPCF Ӝ ؝ٝذشⰻفٗإأָؙٔؒأزח 䘔瘶דֹ׷ַ Ӝ 㣟侁ׅ׷ה4FSWJDFT׾鸐ׄג
 زٓؿ؍حؙ׾「⥋׃זְ 6OSFBEZ name: kuard

    spec: containers: - image: gcr.io/kuar-demo/kuard-amd64:1 name: kuard ports: - containerPort: 8080 name: http protocol: TCP livenessProbe: httpGet: path: /healthy port: 8080 initialDelaySeconds: 5 timeoutSeconds: 1 periodSeconds: 10 failureThreshold: 3 readinessProbe: httpGet: path: /ready port: 8080 initialDelaySeconds: 30 timeoutSeconds: 1 periodSeconds: 10 failureThreshold: 3
  7. 4FSWJDFT Ӝ ⟎䟝*1הه٦ز Ӝ ٓكٕإؙٖةח״׷
 1PEךؚٕ٦ؾؚٝ Ӝ ؟٦ؽأة؎ف $MVTUFS*1 /PEF1PSU

    -PBE#BMBODFS  1PE app web 1PE app web 3FQMJDB4FU 4FSWJDF VIP: 10.0.0.249 Selector: app=web
  8. apiVersion: v1 kind: Service metadata: name: kuard spec: type: ClusterIP

    selector: app: kuard ports: - protocol: TCP port: 8080 targetPort: 8080 4FSWJDFT Ӝ ⟎䟝*1הه٦ز Ӝ ٓكٕإؙٖةח״׷
 1PEךؚٕ٦ؾؚٝ Ӝ ؟٦ؽأة؎ف $MVTUFS*1 /PEF1PSU -PBE#BMBODFS 
  9. http.HandleFunc("/ready", func(w http.ResponseWriter, r *http.Request) { message := "" //

    Check database if err := db.Ping(); err != nil { message += fmt.Sprintf("database: %s\n", err) } if len(message) > 0 { // Send 503 http.Error(w, message, http.StatusServiceUnavailable) } else { w.Write([]byte("OK")) } }) http.ListenAndServe(":8080", nil)
  10. apiVersion: apps/v1 kind: Deployment metadata: name: kuard spec: selector: matchLabels:

    app: kuard template: metadata: labels: app: kuard spec: terminationGracePeriodSeconds: 60 containers: - image: gcr.io/kuar-demo/kuard-amd64:1 name: kuard ports: - containerPort: 8080 name: http protocol: TCP livenessProbe: UFSNJOBUJPO(SBDF1FSJPE4FDPOET Ӝ 1PE׾(SBDFGVMח穄✪ׇׁ׷׋׭䗳銲ז猱侧 Ӝ 鏣㹀׃׋猱侧ָ穗麓ׅ׷ה؝ٝذشח4*(,*--ָ鷏⥋ׁ׸׷
  11. apiVersion: apps/v1 kind: Deployment metadata: labels: app: nginx name: nginx

    spec: selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - image: nginx:1.13.7 name: nginx lifecycle: preStop: exec: command: ["nginx", "-s", "quit"] Ӝ 1PEך穄✪ؿؑ؎ؤך剑ⴱח㹋遤ׁ׸׷ 0QUJPOBM  ـٗحؙ׃זֽ׸לז׵זְ ず劍 ֿהח岣䠐 Ӝ QSF4UPQؿحؙ㹋遤䖓ח4*(5&3.ָ鷏⥋ׁ׸׷ QSF4UPQؿحؙ
  12. 倜鋉؝طؙءّٝ 䱸竲幥؝طؙءّٝ QSF4UPQⳢ椚 4*(5&3.Ⳣ椚 1PEך穄✪Ꟛ㨣 0QUJPOBM 
 QSF4UPQؿحؙ 4FSWJDFTךة٦؜حزַ׵㢩׸׷ LVCFQSPYZָJQUBCMFTٕ٦ٕ׾刿倜׃ծ倜鋉䱸竲ָזֻז׷

    ֿ׸⟃꣬倜鋉䱸竲כזֻז׷ QSF4UPQؿحַؙ4*(5&3.ד (SBDFGVMחؙٗ٦ؤׅ׷䗳銲ָ֮׷ (SBDF1FSJPE4FDPOET䖓
 穄✪׃גְזְ㜥さ رؿٕؓز猱 
 4*(,*-- 
 4*(5&3. ,VCFSOFUFT鑫鍑1PETך穄✪2JJUB
  13. תה׭ Ӝ #VJMEJOH$POUBJOFST كأزفؙٓذ؍أח䖞ֲ Ӝ 1PE4DIFEVMJOH 䗳銲剑⡚ꣲ䗳銲זٔا٦أ׾鏣㹀ׅ׷ SFTPVSDFSFRVFTUT  Ӝ

    1PE3VOOJOH قٕأثؑحؙ׾鏣㹀ׅ׷ -JWFOFTT3FBEJOFTTQSPCF  ٔا٦أ⢪欽ꆀח♳ꣲ׾鏣㹀ׅ׷ SFTPVSDFMJNJUT  Ӝ 1PE5FSNJOBUJOH (SBDFGVMTIVUEPXOׇׁ׷ QSF4UPQؿحؙ4*(5&3.عٝسؚٔٝ