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

Skaffoldを使ってKubernetes してみた/skaffold_k8s

Skaffoldを使ってKubernetes してみた/skaffold_k8s

PHPカンファレンス福岡2018での発表に用いた資料です。

KOYAMA Tetsuji

June 16, 2018
Tweet

More Decks by KOYAMA Tetsuji

Other Decks in Programming

Transcript

  1. w (4VJUF (NBJM (PPHMFΧϨϯμʔͳͲ ʹػೳ௥Ճ͠ ͯൢച w ಋೖ ࣾҎ্ w

    IUUQTSBLVNPDPN w ࡢ೥(PPHMF$MPVE1MBUGPSN ($1 ͷύʔτφʔʹ
  2. LTIJTUPSZ w ೥(PPHMFͷࣾ಺πʔϧͱͯ͠։ൃ։࢝ w (PPHMFͷ#PSH͔Βڧ͍ӨڹΛड͚ͨ1SPKFDU4FWFO w 4FWFO͸4UBS5SFL7PZBHFSͷ4FWFOPG/JOF͔Β w ϩΰͷຊεϙʔΫͷ଩ͷ༝དྷ w

    ʹWϦϦʔε w ͦͷޙ$/$'ʹҠ؅ #Z4PVSDF 81/'$$ 'BJSVTF  IUUQTFOXJLJQFEJBPSHXJOEFYQIQ DVSJE
  3. w "[VSF$POUBJOFS4FSWJDF "$4  w ࠷ॳ͸"QBDIF.FTPTϕʔε w ෳ਺ͷΦʔέετϨʔγϣϯπʔϧΛαϙʔτ w "[VSF$POUBJOFS4FSWJDF

    ",4  w ,VCFSOFUFTϕʔε w "[VSF,VCFSOFUFT4FSWJDF ",4 ʹվ໊ LTPO"[VSF
  4. apiVersion: v1 kind: Pod metadata: name: nginx spec: containers: -

    name: nginx image: nginx:1.7.9 ports: - containerPort: 80 nginx-pod.yml
  5. w Ϋϥελ w 1PE w 4FSWJDF w 3FQMJDB4FU w %BFNPO4FU

    w +PC w %FQMPZNFOU w $POpH.BQ LTߏ੒ཁૉ
  6. w Ϋϥελ w 1PE w 4FSWJDF w 3FQMJDB4FU w %BFNPO4FU

    w +PC w %FQMPZNFOU w $POpH.BQ LTߏ੒ཁૉ
  7. w ։ൃ࣌ w ϏϧυϩʔΧϧͷEPDLFSCVJME w ొ࿥ͳ͠ w σϓϩΠNJOJLVCFʹLVCFDUM w ຊ൪࣌

    ($1ͷ৔߹  w Ϗϧυ(PPHMF$POUBJOFS#VJMEFSʹ౤͛Δ w ొ࿥(PPHMF$POUBJOFS3FHJTUSZʹొ࿥͢Δ w σϓϩΠ(,&ʹLVCFDUM ྆ऀͷҧ͍
  8. w #B[FM w IUUQTCB[FMCVJME w )FMN w IUUQTIFMNTI w LBOJLP

    w IUUQTHJUIVCDPN(PPHMF$POUBJOFS5PPMTLBOJLP w LVTUPNJ[F w IUUQTHJUIVCDPNLVCFSOFUFTTJHTLVTUPNJ[F w ෳ਺ΠϝʔδͷରԠ NJDSPTFSWJDF ֤छπʔϧରԠ
  9. w TLB⒎PME͸HP੡ w ֤ϓϥοτϑΥʔϜ༻όΠφϦΛ഑͍ͬͯΔͷͰࣗ෼Ͱ Ϗϧυ͢Δඞཁ͸ͳ͍ w .BDͳΒ TLB⒎PMEίϚϯυ curl -Lo

    skaffold https://storage.googleapis.com/skaffold/ releases/latest/skaffold-darwin-amd64 && chmod +x skaffold && sudo mv skaffold /usr/local/bin
  10. NBJOHP package main import ( "fmt" "time" ) func main()

    { for { fmt.Println("Hello world!") time.Sleep(time.Second * 1) } }
  11. %PDLFSpMF FROM golang:1.10.1-alpine3.7 as builder COPY main.go . RUN go

    build -o /app main.go FROM alpine:3.7 CMD ["./app"] COPY --from=builder /app .
  12. TLB⒎PMEZNM apiVersion: skaffold/v1alpha2 kind: Config build: artifacts: - imageName: gcr.io/myproj-koyhoge/skaffold-gcb

    deploy: kubectl: manifests: - k8s-* profiles: - name: gcb build: googleCloudBuild: projectId: myproj-koyhoge
  13. LTQPEZNM apiVersion: v1 kind: Pod metadata: name: getting-started spec: containers:

    - name: getting-started image: gcr.io/myproj-koyhoge/skaffold-gcb