Enjoying k8s cluster with Minikube and Helm

4cb5b950cfd0eabf5d6b828c951d4549?s=47 loftkun
April 08, 2019

Enjoying k8s cluster with Minikube and Helm

- My kubernetes environment and tools
 - kubectl 
 - Minikube
 - Helm
- Already tried Charts 
 - Istio
 - Prometheus/Alertmanager/PushGateway
 - Gitlab
- Create Original Chart 

4cb5b950cfd0eabf5d6b828c951d4549?s=128

loftkun

April 08, 2019
Tweet

Transcript

  1. 2.

    @loftkun •   •  *(,! $ • /'.

    • %% ==( 10" )==> WEBSRE • )0+-k8s#&
  2. 5.

    Agenda • My k8s environment and tools • kubectl •

    Minikube • Helm • Already tried Charts • Create Original Chart
  3. 7.
  4. 8.

    kubectl • +   ('"()  • ))&( 

    )* %# !*'$)( !*'$)( '"(( • &) "* $ $ (# ( '*) $ )% )" • GIB@J.()"7632L •  $ $%,  *( (  (%')*) %' ""$#(&( • ""$#(&( AGCHJ= 5/;:-7632L • 0<6849>6?DGEKF1:-L
  5. 9.

          $ kubectl –h Advanced

    Commands: diff Diff live version against would-be applied version apply Apply a configuration to a resource by filename or stdin patch Update field(s) of a resource using strategic merge patch replace Replace a resource by filename or stdin wait Experimental: Wait for a specific condition on one or many resources. convert Convert config files between different API versions kustomize Build a kustomization target from a directory or a remote url.
  6. 10.
  7. 11.

    New features • v1.0.0 is released at 3/27 ! •

            • supports Kubernetes 1.14 by default • https://kubernetes.io/blog/2019/03/28/running-kubernetes-locally-on-linux-with- minikube-now-with-kubernetes-1.14-support/    
  8. 12.

    single-node ? • Minikube  single-node Kubernetes cluster  

    • V1.0.0README.md   • https://github.com/kubernetes/minikube/commit/ec5ac30
  9. 13.

    Become multi-node support !? • Roadmap (2019)   •

    https://github.com/kubernetes/minikube/blob/master/docs/contributors/roadmap.md • #4 Support all Kubernetes features • Add multi-node support • minikube multi-node cluster    
  10. 14.

    Setup is Simple ! (on ubuntu 17.10) # download curl

    -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube sudo cp minikube /usr/local/bin && rm minikube
  11. 15.

    Setup is Simple ! (on ubuntu 17.10) # download curl

    -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube sudo cp minikube /usr/local/bin && rm minikube # config as you like minikube config set cpus 12 minikube config set memory 40960
  12. 16.

    Setup is Simple ! (on ubuntu 17.10) # download curl

    -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube sudo cp minikube /usr/local/bin && rm minikube # config as you like minikube config set cpus 12 minikube config set memory 40960 # start cluster minikube start
  13. 17.

             $

    kubectl get no NAME STATUS ROLES AGE VERSION minikube Ready master 10m v1.14.0
  14. 18.

    $ kubectl get no NAME STATUS ROLES AGE VERSION minikube

    Ready master 10m v1.14.0 $ kubectl get svc -A NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE default kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 10m kube-system kube-dns ClusterIP 10.96.0.10 <none> 53/UDP,53/TCP,9153/TCP 10m kube-system monitoring-grafana NodePort 10.107.133.92 <none> 80:30002/TCP 10m kube-system monitoring-influxdb ClusterIP 10.109.201.109 <none> 8083/TCP,8086/TCP 10m         
  15. 19.

    Be careful ! • Minikube (VM)(&<3?2) "'0;24 % • Default

    • CPU21-9:<2GB5.2020GB) " • Spinnaker ( 9:<10GB  ) ,57=/*%'9:< • 9:<) ") "  • minikube config set 18>6#) ", • !+*&'0;24 !@ • minikube delete $minikube start  
  16. 20.

    Tips of Minikube •  minikubeCPU  default2 • https://qiita.com/loftkun/items/41ecde082778254de79a

    •  minikube default2GB • https://qiita.com/loftkun/items/7400d5ae0e7b1fb7d26e • Spinnaker + Kayenta  • https://qiita.com/loftkun/items/2fd1d598d04084495e2c
  17. 21.
  18. 22.

    Overview • v2.13.0 is released at 2/27 ! • https://github.com/helm/helm/releases

    •  ! #  • "! • 10.2/+ !*%&)'-(%,$3 •  !! 
  19. 24.

    Setup is Simple ! (on ubuntu 17.10) # download &

    install cli $ curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash
  20. 25.

    Setup is Simple ! (on ubuntu 17.10) # download &

    install cli $ curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash # deploy tiller $ helm init
  21. 26.

    Deploy a Chart (e.g. MongoDB) $ helm install stable/mongodb ¥

    --name my-mongo ¥ --namespace my-mongo ¥ --set mongodbRootPassword=pass,mongodbUsername=user1,mongodbPassword=pass1,mongodbDatabase=testdb
  22. 27.

    Deploy a Chart (e.g. MongoDB) $ helm install stable/mongodb ¥

    --name my-mongo ¥ --namespace my-mongo ¥ --set mongodbRootPassword=pass,mongodbUsername=user1,mongodbPassword=pass1,mongodbDatabase=testdb $ kubectl get svc -n my-mongo NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE my-mongo-mongodb ClusterIP 10.97.82.12 <none> 27017/TCP 37s
  23. 28.

    Deploy a Chart (e.g. MongoDB) $ helm install stable/mongodb ¥

    --name my-mongo ¥ --namespace my-mongo ¥ --set mongodbRootPassword=pass,mongodbUsername=user1,mongodbPassword=pass1,mongodbDatabase=testdb $ kubectl get svc -n my-mongo NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE my-mongo-mongodb ClusterIP 10.97.82.12 <none> 27017/TCP 37s $ kubectl get po -n my-mongo NAME READY STATUS RESTARTS AGE my-mongo-mongodb-5ccffd7cb4-tkrd8 1/1 Running 0 40s $
  24. 30.

    • Grafana • Gitlab-ce • Minio • MongoDB • MySQL

    • Prometheus • includes alertmanager, pushgateway • Spinnaker Already tried Charts • Istio • Kafka • GitLab • Cloud native images • https://docs.gitlab.com/ee/inst all/docker.html#cloud-native- images • loftkun ( ) • abematv-comment-receiver charts/incubator charts/stable 3rd party repo
  25. 31.

    • Grafana • Gitlab-ce • Minio • MongoDB • MySQL

    • Prometheus • includes alertmanager, pushgateway • Spinnaker Already tried Charts • Istio • Kafka • GitLab • Cloud native images • https://docs.gitlab.com/ee/inst all/docker.html#cloud-native- images • loftkun ( my original chart ) • abematv-comment-receiver charts/incubator charts/stable 3rd party repo Today's Pickup
  26. 33.

    Be Careful ! •  #$  "% !(* •

    Istio.io ')& •     
  27. 34.

         •    

         • $ helm fetch stable/spinnaker • $ helm template spinnaker-1.1.7.tgz > spinnaker-1.1.7.yaml
  28. 35.

         •   ! 

    $    • $ helm fetch stable/spinnaker • $ helm template spinnaker-1.1.7.tgz > spinnaker-1.1.7.yaml • $  # "  ! $ • $ istioctl kube-inject -f ./spinnaker.yaml > ./spinnaker-injected.yaml
  29. 36.

      • $%!  )    

    • $ helm fetch stable/spinnaker • $ helm template spinnaker-1.1.7.tgz > spinnaker-1.1.7.yaml •  ) '$&$% ) • $ istioctl kube-inject -f ./spinnaker.yaml > ./spinnaker-injected.yaml • "#(% )+,-* • $ kubectl apply -f ./spinnaker-injected.yaml
  30. 37.
  31. 38.

    Consepts • Proxy ( Envoy ) • Pod  

      •  Automatic  Manual 
  32. 39.

    Consepts • Pilot • SideCar •  ! yaml •

    Route • blue/green deploy • canary release •     •   •   •      • 
  33. 41.

    charts/stable/prometheus • 1Chart #% • Prometheus / Alertmanager / PushGateway

    • &" !$ • Prometheus ------> Alertmanager • Prometheus ------> scrape targets • PushGateway • Node, Service, Pod,   
  34. 43.

    Cloud native images •  % $&# • $$!# 

    # $    #$  " $  % $& # • *0'1 %##*0+).-1, • /(, • "$# #$ $    •  % $&#  
  35. 45.

    Create New Chart $ helm create abematv-comment-receiver $ tree abematv-comment-receiver/

    abematv-comment-receiver/ ├── charts ├── Chart.yaml ├── templates │ ├── deployment.yaml │ ├── _helpers.tpl │ ├── ingress.yaml │ ├── NOTES.txt │ ├── service.yaml │ └── tests │ └── test-connection.yaml └── values.yaml     
  36. 46.

    Fix Chart Info ( e.g. image repo, tag ) $

    vim abematv-comment-receiver/values.yaml $ cat abematv-comment-receiver/values.yaml image: repository: loftkun/abematv-comment-receiver tag: latest $ helm lint abematv-comment-receiver/ ==> Linting abematv-comment-receiver/ 1 chart(s) linted, no failures $      
  37. 47.

    Deploy ! $ helm install ./abematv-comment-receiver ¥ --name abmtest ¥

    --namespace abmtest $ kubectl get po -n abmtest NAME READY STATUS RESTARTS AGE abmtest-abematv-comment-receiver 1/1 Running 0 43s $ kubectl logs –f ${podname} -n abmtest {"id":"wnBd8uUPeey6BwP8PkkWWS","message":"10" !#$  ","createdAtMs":1554630315263}         
  38. 48.

    loftkun/abematv-comment-receiver • ")16-  %$&03%,05' $ •  #)6+. 

    "5(!$ • )16- : *26/4( https://abema.tv/now-on-air/shogi ) $ kubectl logs abmtest-abematv-comment-receiver-7775747d65-h8zs2 -n abmtest {"id":"XEfQoBeq3LU5Tq4kXTJZ5R","message":"360 ;?75","createdAtMs":1554630249431} {"id":"hn3gbIw0245r908JfrgOcN","message":"'/) <9!'"4-  ,( 81%.","createdAtMs":1554630274691} {"id":"hn3gbIw0245r908JfrgOmx","message":" > 2by","createdAtMs":1554630307015} {"id":"wnBd8uUPeey6BwP8PkkWWS","message":"10*+ :! # $=&","createdAtMs":1554630315263}
  39. 50.

    Tips of Helm • Helm  • https://qiita.com/loftkun/items/853bbaabd4bf0fa96e9c • Pushgateway->Prometheus->Alertmanager->Webhook

    • https://qiita.com/loftkun/items/28cdf77ea9269e255a53 •   GitLab   • https://qiita.com/loftkun/items/c3945a2595e4f9c7ba09
  40. 52.

    Appendix : other trying environments • &+"- )-$** • "+=4C;0B?>D1?/A

    • '#) ') *#+'( • 0:2@ '#)83 8< 5;07 • #* $,*+) < #,+$ ?9;0B6E • !++(*...'#)'%()',+*'#)*#+'( • '#) E'%('* '& ,)&+*=E • !++(* "+!,'%'#)'%('*'&#,)&+*