Share
Embed
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
loftkun
April 08, 2019
Transcript
53 slides
-
@loftkun • • *(,! $ • /'.
• %% ==( 10" )==> WEBSRE • )0+-k8s#& -
• " • •
! -
Agenda • My k8s environment and tools • kubectl •
Minikube • Helm • Already tried Charts • Create Original Chart -
kubectl • + ('"() • ))&(
)* %# !*'$)( !*'$)( '"(( • &) "* $ $ (# ( '*) $ )% )" • GIB@J.()"7632L • $ $%, *( ( (%')*) %' ""$#(&( • ""$#(&( AGCHJ= 5/;:-7632L • 0<6849>6?DGEKF1:-L -
$ 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. -
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/ -
single-node ? • Minikube single-node Kubernetes cluster
• V1.0.0README.md • https://github.com/kubernetes/minikube/commit/ec5ac30 -
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 -
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 -
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 -
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 -
$
kubectl get no NAME STATUS ROLES AGE VERSION minikube Ready master 10m v1.14.0 -
$ 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 -
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 -
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 -
Overview • v2.13.0 is released at 2/27 ! • https://github.com/helm/helm/releases
• ! # • "! • 10.2/+ !*%&)'-(%,$3 • !! -
Setup is Simple ! (on ubuntu 17.10) # download &
install cli $ curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash -
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 -
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 -
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 -
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 $ -
• 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 -
• 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 -
Be Careful ! • #$ "% !(* •
Istio.io ')& • -
•
• $ helm fetch stable/spinnaker • $ helm template spinnaker-1.1.7.tgz > spinnaker-1.1.7.yaml -
• !
$ • $ 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 -
• $%! )
• $ 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 -
Consepts • Proxy ( Envoy ) • Pod
• Automatic Manual -
Consepts • Pilot • SideCar • ! yaml •
Route • blue/green deploy • canary release • • • • • -
charts/stable/prometheus • 1Chart #% • Prometheus / Alertmanager / PushGateway
• &" !$ • Prometheus ------> Alertmanager • Prometheus ------> scrape targets • PushGateway • Node, Service, Pod, -
Cloud native images • % $&# • $$!#
# $ #$ " $ % $& # • *0'1 %##*0+).-1, • /(, • "$# #$ $ • % $&# -
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 -
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 $ -
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} -
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} -
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 -
Appendix : other trying environments • &+"- )-$** • "+=4C;0B?>D1?/A
• '#) ') *#+'( • 0:2@ '#)83 8< 5;07 • #* $,*+) < #,+$ ?9;0B6E • !++(*...'#)'%()',+*'#)*#+'( • '#) E'%('* '& ,)&+*=E • !++(* "+!,'%'#)'%('*'&#,)&+*