$30 off During Our Annual Pro Sale. View Details »

Kubernetes helm & helmc

Kubernetes helm & helmc

Helm is package management tool for Kubernetes.
This slide describe how to use helm!

Aya (Igarashi) Ozawa

June 20, 2016
Tweet

More Decks by Aya (Igarashi) Ozawa

Other Decks in Technology

Transcript

  1. 1 k8s helm & helmc Kubernetes meetup Tokyo #2

  2. 2 ABOUT ME Software Engineer I’m developing cloud services. AYA

    IGARASHI NTT Communications @Ladicle
  3. 3 AGENDA INTRODUCTION 01 02 03 ࠓ·Ͱͷ؅ཧํ๏ 04 HOW TO

    MANAGE MANIFESTS? ABOUT K8S HELM & HELMC WHICH IS BETTER? HAPPY HELMING ͲΜͳ΋ͷ͔ɺҧ͍͸Կ͔ ͲͪΒΛͲͷΑ͏ͳߏ੒Ͱ࢖͏΂͖͔ ·ͱΊ
  4. 4 How to mange Manifests?

  5. 5 BASH MANAGEMENT of MANIFEST 1 source env.sh 2 printf

    "cat <<++EOS\n%s\n++EOS\n" "$(cat *service.yaml *deployment.yaml)" \ 3 | sh > all-in-one.yaml ؀ڥ͝ͱʹมߋ͍ͨ͠஋Λbashม਺ͱͯ͠ManifestʹຒΊࠐΈɺ ࣮ߦ͍ͨ͠؀ڥͷઃఆϑΝΠϧΛಡΈࠐΜͰ͔ΒγΣϧܳΛ͍ͯͨ͠ ࠓ·Ͱ 1 apiVersion: extensions/v1beta1 2 kind: Deployment 3 metadata: 4 name: rabbitmq${SUFFIX} 5 spec: 6 replicas: ${REPLICA_NUMBER} 7 template: 8 metadata: 9 labels: 04 02 rabbitmq-deployment.yaml labelsҎ߱͸লུ͍ͯ͠Δ install-service-and-deployment.sh env.shͷதͰม਺Λexport
  6. 6 PROBLEMS MANAGEMENT of MANIFEST 01 DUPLICATE DEFINITIONS containersͷenvϑΟʔϧυʹෳ਺ͷϑΝΠϧʹڞ ௨ͷ؀ڥม਺͕ఆٛ͞Ε͍ͯΔͨΊɺमਖ਼࿙Ε͕

    ൃੜ͢Δɻ(࿈૝഑ྻ͕࢖͍͍ͨ….) 02 HARD TO READ γϯϓϧʹߏ଄తͳม਺ΛఆٛͰ͖ͳ͍ͨΊઃఆ ϑΝΠϧ͕ಡΈͮΒ͍ɻ 03 YAML LINT IS NOT ENOUGH ৺ͷฏԺͷͨΊmanifestΛk8s΁Πϯετʔϧ͢Δલ ʹࢼݧΛ࣮ࢪ͔͕ͨͬͨ͠ɺYAML lintͰ͸݁Ռ͕ PASSEDͰ͋ͬͯ΋k8sͰಈ͔ͳ͍͜ͱ͕ଟʑ͋ͬͨɻ PROBLEM BASH
  7. 7 By Helm

  8. 8 What is Helm? ABOUT K8S HELM & HELMC GolangͷTemplate֦ுϥΠϒϥϦͰ͋ΔSprigͷه๏Λ࢖ͬͯManifestϑΝΠϧΛ

    ఆٛ͢Δ͜ͱ͕Ͱ͖Δɻ·ͨɺαϒίϚϯυͱͯ͠จ๏νΣοΫΛߦ͏ lintίϚϯυ͕ఏڙ͞Ε͍ͯΔɻ K8SͷύοέʔδϚωʔδϟ 1 # Githubb্Ͱެ։͞Ε͍ͯΔnginxύοέʔδΛݕࡧ 2 $ helmc search nginx 3 example-nginx - An example nginx + git-sync application 4 nginx - Nginx http service 5 nginx-alpine - Nginx http service 6 7 # Kubernetes΁nginxΛΠϯετʔϧ͢Δ 8 $ helmc install nginx 9 ---> No chart named "nginx" in your workspace. Fetching now. 10 ---> Running `kubectl create -f` ... 11 service "nginx" created 12 replicationcontroller "nginx" created 13 ---> Done
  9. 9 Diff Helm Helmc

  10. 10 ALL Different HELM CLASSIC KUBERNETES HELM Oct 18, 2015ʹDEISʹΑͬͯ࡞ΒΕͨ

    CLIͰChartͷ࡞੒/࡟আ/ߋ৽͕Ͱ͖Δɻ Chartͷόʔδϣϯ͸GitͷSHAsͰ൑ఆ ͞Ε͍ͯΔɻ Nov 1, 2015ʹk8s΁औΓࠐ·ΕͨΫϥΠΞ ϯταʔόܕͷπʔϧɻ12FactorAppͷࢥ ૝Λ΋ͱʹChart + Config = Release ͱ͍͏ ߏ੒Λͱ͍ͬͯΔɻ What is Chart? k8sͷΠϯελϯεΛ࡞੒͢ΔͨΊʹඞཁͳ ςϯϓϨʔτ/஋ͷू߹ମ
  11. 11 02 KUBERNETES GITHUB install uninstall NGINX WORD PRESS MYSQL

    HELMC CHART FILES publish, fetch Create using kubectl Helm Classic ABOUT K8S HELM & HELMC
  12. 12 02 KUBERNETES install chart delete Release TILLER CHART FILES

    Kubernetes Helm ABOUT K8S HELM & HELMC HELM REST/JSON gRPC STORAGE NGINX WORD PRESS MYSQL Create Chart files contain Chart packages Package Chart files NGINX CHART PACKAGE get/update Release TarBall
  13. 13 Which is Better?

  14. 14 Which is better? Kubernetes Helm͸·ͩόʔδϣϯAlpha-1͕ϦϦʔε͞Ε ͨ͹͔ΓͰಈ͔ͳ͍΋ͷ͕ଟ͍ͨΊɻ Which is better?

    Now HELM CLASSIC Helm Classic͸ϝϯςφϯε͞Εͳ͘ͳΔͨΊɺ͋Δఔ౓҆ఆ͔ͯ͠ Β͸Ҡͬͨํ͕Α͍ɻϩʔυϚοϓʹΑΔͱBeta1ʹ͸Chart.yamlͷ ϑΥʔϚοτΛFix͢ΔΒ͍͠ͷͰͦͷࠒʹ͸Ҡಈͯ͠΋Αͦ͞͏ ROAD MAP: https://github.com/kubernetes/helm/issues/694 Feature KUBERNETES HELM
  15. 15 How to use Helmc

  16. 16 How to use Helmc? WHICH IS BETTER? ςϯϓϨʔτͱม਺͸ݟ௨͕͠Α͍Α͏ʹσΟϨΫτϦΛ৽ͨʹ੾͍ͬͯΔɻ ·ͨɺม਺͸؀ڥ͝ͱʹϑΝΠϧΛ෼ׂ͠ڞ௨ͷσϑΥϧτ஋͸௚઀templateʹఆ͍ٛͯ͠Δɻ

    FILE STRUCTURE Variable file format HelmcͰ͸ม਺ϑΝΠϧͷϑΥʔϚοτ͸JSON/ YAML/TOMLͷத͔Βબ୒Ͱ͖Δ͕ɺk8s Helm͸TOML ͷΈͷͨΊɺҠߦͷ͠΍͔͢͞ΒTOML͕͓͢͢Ί deployments-generator.sh ࣍ϖʔδͰઆ໌͢ΔCustomize generator͔Βݺͼͩ ͍ͯ͠ΔManifestͷੜ੒εΫϦϓτ └── rabbitmq ├── Chart.yaml ├── README.md ├── deployemnts-generator.sh ├── manifests ├── templates │ ├── service.yaml │ └── deployment.yaml └── variables └── lab1.toml.tpl └── lab2.toml.tpl
  17. 17 Custom Generator WHICH IS BETTER? deployments-generator.sh (ൈਮ) ( 1

    # helm:generate $HELM_GENERATE_DIR/deployemnts-generator.sh 2 apiVersion: extensions/v1beta1 3 kind: Deployment 1 echo "deploymentType = \"${type}\"" > $tempdir/values.toml 2 3 for type in "age" "hoge"; do 4 helmc template -d $tempdir/values.toml \ 5 -o manifests/${type}-deployment.yaml $HELM_GENERATE_FILE 6 done deployment.yaml (ൈਮ) templateίϚϯυΛ࢖ͬͯManifestΛੜ੒͢Δͱ֤ϑΝΠϧຖʹ࣮ߦ͠ͳ͚Ε͹ͳΒͳ͍͕ɺgenerateί ϚϯυΛ࢖༻͢ΔͱҎԼͷdeployment.yamlͷΑ͏ʹҰߦ໨ʹgenerator͕ࢦఆ͞Ε͍ͯΔ΋ͷΛChartσΟ ϨΫτϦͷத͔Βऩू͠ɺҰׅͯ͠ManifestΛੜ੒͢Δ͜ͱ͕Ͱ͖Δɻ(Jenkinsͱͷ૬ੑΑ͠ʂ)
  18. 18 More Information

  19. 19 More Information HAPPY HELMING 01 02 03 http://slack.kubernetes.io/ KUBERNETES

    SLACK #HELM CHANNEL MEETING ON ZOOM JAPANESE DOCUMENT Contribution ·ͩ·ͩ࢝·ͬͨ͹͔Γͷ໘ന͍ϓϩδΣΫτ খ͞ͳόάFIX͹਺೔ͰRV, MG͞ΕΔ खॱ͸ଞͷk8sϓϩδΣΫτͱಉ͡Ͱ͢ https://engineyard.zoom.us/j/ https://github.com/Ladicle/kubernetes-helm-jp-doc
  20. 20 HAPPY HELMING! Thanks for watching @ladicle