K8s Hands-on - 2



Dashboard

Reference file for dashboard.yaml https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
Similar file, is present at Katacoda course

Each worker node has Kubelet. cAdvisor (port 4194) is part of Kubelet binary. It collects following data for node, pods and containers. 
- CPU usage
- Memory usage
- File system
- Network usage

Heapster collect / aggregate all the above data from cAdvisor over REST API. Heapster store this data to InfluxDB. Grafana access the data from InfluxDB and visulaise 

Heapster cal also store data in Google Cloud Monitoring service. Then Google Cloud Monitoring Console can access this data and visualize it. 

====================================

Horizontal scaling is possible with below command

kubectl scale --replicas=3 deployment x
====================================

Few more useful alias

alias kc='kubectl create'
alias kd='kubectl delete'
alias ka='kubectl apply'

Deployment can be store mannually as YAML file and created back again using that YAML file. 

kg deployment x -o yaml
k delete svc x
k delete deployment x

k create -f x.yaml
kubectl expose deployment x --port=80 --type=NodePort


Same applies for service

kg svc x -o yaml
kd svc x
kc -f x_svc.xml

Remove undwanted lines and change replicas value. 
ka -f x.yaml

==========================================
Guestbook example

kc -f redis_m_controller.yaml 
kg rc

Same example https://kubernetes.io/docs/tutorials/stateless-application/guestbook/ So related YAML files are also similar. E.g.

redis-master-controller.yaml is same as 
https://k8s.io/examples/application/guestbook/redis-master-deployment.yaml

redis-master-.yaml is same as 
https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/application/guestbook/redis-master-service.yaml

Same for redis-slave and PHP frontend. 
===========================================
To see log from any pod


k logs -f POD_NAME

To see log from any container


k logs POD_NAME -c CONTAINER_NAME

1 comments:

Manish Panchmatia said...

https://github.com/ahmetb/kubectl-aliases

https://ahmet.im/blog/kubectl-aliases/

Post a Comment