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
===========================================
To get details about CRDs
kubectl get crd
kubectl api-reference | grep "output of previous command"
If the APIGROUP column is empty in output of "kubectl api-reference" command, then its default value is v1 that denote stable object.
K8s Hands-on - 1
One can find many useful articles about basic kubectl commands and minikube. Katacoda is one of the best website, for online hands-on with k8s. Here, I just shared my experience with katacoda and on-premise minikube cluster.
First, one need set few alias at .bashrc file.
alias k=kubectl
alias kg=kubectl get
alias m=minikube
Minikube
By default, minikube runs with 2 CPUs and 2GB RAM. It makes the system slow. minikube needs minimum 2 CPU. With trial and error i found, 1.5 GB is sufficient to run minikube.
minikube start --memory 1536
Now few commands
kubectl config view
kubectl cluster-info
kubectl get nodes
kubectl desscribe node
minikube ip
minikube dashboard
minikube addons enable heapster
minikube addons list
minikube service list
minikube status
Service related commands
One can use svc in place of service for kubectl command, not for minikube commands
kubectl get svc
command lists services only from default namespace, while
minikube service list
command list services from all namespace.
One can add "-n kube-system" for kubectl command.
kubectl get svc -n kube-system
One can also add "--all-namespaces" for kubectl command
kubectl get svc --all-namespaces
Virtual Box
/home folder of host OS is mounted as /hosthome folder inside VirtualBox
To login to virtual box
minikube ssh
OR
ssh to minikube's IP address with docker/tcuser
Note: None of the above methods work at Katacoda for first scenario "Launching single Node cluster" under "Introduction to Kubernets" hands-on.
Here are comparision of IP address and various interface within virtual box and outside virtual box
Deployment
I found, below 3 basic images to begin with
kubectl create deployment x --image=katacoda/docker-http-server
kubectl create deployment k --image=k8s.gcr.io/echoserver:1.10
kubectl create deployment i --image=nginx
The dployment should be exposed with below commans
For http-server and nginx
kubectl expose deployment x--port=80 --type=NodePort
kubectl expose deployment i --port=80 --type=NodePort
For echo-server
kubectl expose deployment k--port=8080 --type=NodePort
The deployment can be removed with
kubectl delete svc
Access Service
1.
As per katacoda, the service can be tested with curl command as below
export PORT=$(kubectl get svc first-deployment -o go-template='{{range.spec.ports}}{{if .nodePort}}{{.nodePort}}{{"\n"}}{{end}}{{end}}')
echo "Accessing host01:$PORT"
curl host01:$PORT
There are alternate ways also
2.
curl $(minikube service x --url)
3. The below command invoke browser with required URL
minikube service x
4. Using proxy
kubectl proxy
Open URL in browser
http://127.0.0.1:8001/api/v1/namespaces/default/pods/POD_NAME/proxy/
POD
To get details about pod in JSON format
1.
kubectl get pods -o json
2.
kubectl proxy
Open URL in browser
http://127.0.0.1:8001/api/v1/namespaces/default/pods/
To login to pod
kubectl exec -it $POD_NAME bash
To get enviornment variables
kubectl exec $POD_NMAE env
To display custom columns
kubectl get pod -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name,podIP:.status.podIP,NAMESPACE:.metadata.namespace --all-namespaces
kubectl config set-context --current --namespace="namespace name"
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
First, one need set few alias at .bashrc file.
alias k=kubectl
alias kg=kubectl get
alias m=minikube
Minikube
By default, minikube runs with 2 CPUs and 2GB RAM. It makes the system slow. minikube needs minimum 2 CPU. With trial and error i found, 1.5 GB is sufficient to run minikube.
minikube start --memory 1536
Now few commands
kubectl config view
kubectl cluster-info
kubectl get nodes
kubectl desscribe node
minikube ip
minikube dashboard
minikube addons enable heapster
minikube addons list
minikube service list
minikube status
Service related commands
One can use svc in place of service for kubectl command, not for minikube commands
kubectl get svc
command lists services only from default namespace, while
minikube service list
command list services from all namespace.
One can add "-n kube-system" for kubectl command.
kubectl get svc -n kube-system
One can also add "--all-namespaces" for kubectl command
kubectl get svc --all-namespaces
Virtual Box
/home folder of host OS is mounted as /hosthome folder inside VirtualBox
To login to virtual box
minikube ssh
OR
ssh to minikube's IP address with docker/tcuser
Note: None of the above methods work at Katacoda for first scenario "Launching single Node cluster" under "Introduction to Kubernets" hands-on.
Here are comparision of IP address and various interface within virtual box and outside virtual box
| IP Address | Interface | Interface | IP Address | Remarks |
|---|---|---|---|---|
| Outside VBox | Outside VBox | Inside VBox | Inside VBox | |
| 172.17.0.1 | docker0 | docker0 | 172.17.0.1 | Pod network |
| 192.168.99.1 | vboxnet0 | eth1 | 192.168.99.102 | Minikube IP address |
| eth0 | 10.0.2.15 | Node Internal IP | ||
| 127.0.0.1 | lo | lo | 127.0.0.1 | Local interface |
Deployment
I found, below 3 basic images to begin with
kubectl create deployment x --image=katacoda/docker-http-server
kubectl create deployment k --image=k8s.gcr.io/echoserver:1.10
kubectl create deployment i --image=nginx
The dployment should be exposed with below commans
For http-server and nginx
kubectl expose deployment x
For echo-server
kubectl expose deployment k
kubectl delete svc
kubectl delete deployment
As per katacoda, the service can be tested with curl command as below
export PORT=$(kubectl get svc first-deployment -o go-template='{{range.spec.ports}}{{if .nodePort}}{{.nodePort}}{{"\n"}}{{end}}{{end}}')
echo "Accessing host01:$PORT"
curl host01:$PORT
There are alternate ways also
2.
curl $(minikube service x --url)
3. The below command invoke browser with required URL
minikube service x
4. Using proxy
kubectl proxy
Open URL in browser
http://127.0.0.1:8001/api/v1/namespaces/default/pods/POD_NAME/proxy/
POD
To get details about pod in JSON format
1.
kubectl get pods
2.
kubectl proxy
Open URL in browser
http://127.0.0.1:8001/api/v1/namespaces/default/pods/
To login to pod
kubectl exec -it $POD_NAME bash
To get enviornment variables
kubectl exec $POD_NMAE env
To display custom columns
kubectl get pod -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name,podIP:.status.podIP,NAMESPACE:.metadata.namespace --all-namespaces
kubectl config set-context --current --namespace="namespace name"
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
Dockercon 2019 SFO Recap & Announcements
Posted by
Manish Panchmatia
on Thursday, June 20, 2019
Labels:
Bangalore,
DevOps,
Meetup,
microservice,
security,
software
/
Comments: (0)
Full article...>>
This blog is just about key takeaway points from a Meetup Event : https://www.meetup.com/Docker-Bangalore/events/261474778/
and
https://github.com/collabnix/dockerbangalore/tree/master/slides/15th-June-2019-Dockercon19-Recap
=================================================
1. Dockercon 19 Recap & Announcement by
=================================================
2. Hardening and Securing your Kubernetes Platform – Munish Kumar Gupta
cAdvisor, is agent running at worker node, which collect usage information. It is not secure. As part of hardening, it is disabled.
One should refer : Docker file best practicies https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
Important resources about security : Center for Internet Security (CIS)
https://en.wikipedia.org/wiki/Center_for_Internet_Security
https://www.cisecurity.org/
If master node comes down, then also the application will be keep running. Yes, during deployment if master node come down then deployment got impacted.
We should sepeate network for control plane (between master node, worker nodes) and user plane (for pod to pod communication among microservices)
We should have pod restart policy and health check API in plact at pod.
Munish kept camera icon on right top cornet to indicate picture time. Instead of taking notes, one can take picture of that important slide.
Generally at VISA deployment the VMs are run with 30 to 40 % of capacity. Containers run with higher capacity.
https://github.com/collabnix/dockerbangalore/blob/master/slides/15th-June-2019-Dockercon19-Recap/-
=================================================
3. Next Gen Payments Platform For Evolving Digital Economy – Sachin Karjatkar & Prabhu Kadapenthangal Venkatesan
=================================================
4. Sentiment Analysis using Stanford NLP , Docker , Helidon Microservice - Saiyam Pathak
DockerHub can pull DOCKERFILE from github and build Docker container image with appropriate config settings at DockerHub website.
Saiyam's suggested to use his github repository for K8s autoscaller components. https://github.com/saiyam1814/autoscaler
It is based on K8s git hub repository https://github.com/kubernetes/autoscaler
Helidon is a collection of Java libraries for writing microservices that run on a fast web core powered by Netty. https://helidon.io
Torando is a Python web framework and asynchronous networking library, https://www.tornadoweb.org
https://stanfordnlp.github.io/CoreNLP/
https://nlp.stanford.edu/sentiment/
https://github.com/stanfordnlp/CoreNLP
Nginx is a web server which can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache.
Want to port forward a resource:
kubectl port-forward TYPE/NAME [LOCAL_PORT:]REMOTE_PORT
kubectl port-forward deployment/saiyam 8081:8080
=================================================
5. Running Docker containers on IoT - Sangam Biradar
Docker repository for Raspberry Pi https://hub.docker.com/u/arm32v7
https://www.slideshare.net/sangambiradar370/docker-on-iot-dockercon19-sfo-recap-announcements-bangalore
and
https://github.com/collabnix/dockerbangalore/tree/master/slides/15th-June-2019-Dockercon19-Recap
=================================================
1. Dockercon 19 Recap & Announcement by
Ajeet Singh Raina https://www.linkedin.com/in/ajeetsraina/
Blog : http://collabnix.com/
YouTube channel : https://www.youtube.com/channel/UCuXpQ3jNcNJBDKHBpWjb_fw
Importanat playlists
* Docker workshop https://www.youtube.com/watch?v=Q1jSDyZ4Org&list=PLImC3BtIMDrfsjF7eRYTnIufAccOtD1GI
Docker Labs : https://github.com/collabnix/dockerlabs DockerLabs brings you tutorials that help you get hands-on experience using Docker & Kubernetes.
Ajeet discussed about Docker desktop enterprise and its feature application designer. Version Packs is used for backward compatibility. https://blog.docker.com/2019/05/a-first-look-at-docker-desktop-enterprise/
He also talks about Docker Kubernetes Services, CLI plugin https://blog.docker.com/2019/05/kubernetes-lifecycle-management-with-docker-kubernetes-service-dks/
"docker buildx" is useful to build Docker container image for various on-premises and cloud platform in one shot. At present, available only in enterprise version.
One interesting webinar : "How Docker Simplifies Kubernetes for the Masses"
=================================================
2. Hardening and Securing your Kubernetes Platform – Munish Kumar Gupta
cAdvisor, is agent running at worker node, which collect usage information. It is not secure. As part of hardening, it is disabled.
One should refer : Docker file best practicies https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
Important resources about security : Center for Internet Security (CIS)
https://en.wikipedia.org/wiki/Center_for_Internet_Security
https://www.cisecurity.org/
If master node comes down, then also the application will be keep running. Yes, during deployment if master node come down then deployment got impacted.
We should sepeate network for control plane (between master node, worker nodes) and user plane (for pod to pod communication among microservices)
We should have pod restart policy and health check API in plact at pod.
Munish kept camera icon on right top cornet to indicate picture time. Instead of taking notes, one can take picture of that important slide.
Generally at VISA deployment the VMs are run with 30 to 40 % of capacity. Containers run with higher capacity.
https://github.com/collabnix/dockerbangalore/blob/master/slides/15th-June-2019-Dockercon19-Recap/-
=================================================
3. Next Gen Payments Platform For Evolving Digital Economy – Sachin Karjatkar & Prabhu Kadapenthangal Venkatesan
=================================================
4. Sentiment Analysis using Stanford NLP , Docker , Helidon Microservice - Saiyam Pathak
DockerHub can pull DOCKERFILE from github and build Docker container image with appropriate config settings at DockerHub website.
Saiyam's suggested to use his github repository for K8s autoscaller components. https://github.com/saiyam1814/autoscaler
It is based on K8s git hub repository https://github.com/kubernetes/autoscaler
Helidon is a collection of Java libraries for writing microservices that run on a fast web core powered by Netty. https://helidon.io
Torando is a Python web framework and asynchronous networking library, https://www.tornadoweb.org
https://stanfordnlp.github.io/CoreNLP/
https://nlp.stanford.edu/sentiment/
https://github.com/stanfordnlp/CoreNLP
Nginx is a web server which can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache.
Want to port forward a resource:
kubectl port-forward TYPE/NAME [LOCAL_PORT:]REMOTE_PORT
kubectl port-forward deployment/saiyam 8081:8080
=================================================
5. Running Docker containers on IoT - Sangam Biradar
Docker repository for Raspberry Pi https://hub.docker.com/u/arm32v7
https://www.slideshare.net/sangambiradar370/docker-on-iot-dockercon19-sfo-recap-announcements-bangalore
Consonants of Bhagavad Gita Text
Posted by
Manish Panchmatia
on Tuesday, June 18, 2019
Labels:
Art of Living,
Gita,
India,
Music,
Poem,
Sanskrit,
software,
Spiritual Science
/
Comments: (0)
Full article...>>
Consonants
of Bhagavad Gita Text
Context
Sanskrit
language’s alphabet is very scientific. All the consonants are divided in
different classes. The different sounds made by birds is represented by class क
consonants (क, ख, ग, घ, ङ) , amphibians (e.g. frog)
sounds in class ट
(ट, ठ, ड, ढ, ण ),
mammals (e.g. sheep, goat, cows etc.) sounds
by class प
(प, फ, ब, भ, म ) and
all the divine prayers, mantras always contain at least one consonant from
unclassified category (य, र, ऱ, ल, ळ, ऴ, व, श, ष, स, ह,) . Thus,
the alphabet sequence of Sanskrit (and most of the Indian languages) indicates
evolution.
Here, an attempt is made to understand, the usage
of consonants in holy Hindu scripture Shrimad Bhagavad Gita, using Python code.
Method
·
Shrimad
Bhagavad Gita text file is loaded in Python code. This input file is UTF-8
format Unicode text.
· From
the input files, 37 consonants are identified. Their Unicode is 0xE0A495 for क, to 0xE0A4BA for ह.
·
The dictionary data structure is used, to associate
all the consonants with different consonant classes and with different
speakers. For source code, please refer https://github.com/mpanchmatia/BhagavadGitaAlphabet
Some important findings
·
Shrimad
Bhagavad Gita contains total 30271 consonants. The Devanagari (Hindi) script
has total 37 unique Unicodes for consonants.
· Out
of these 30271 constantans, majority of consonants 40.22 % used in Shrimad Bhagavad Gita are
belongs to unclassified category. The least contribution 2.15 % is from class ट. Here is the detail breakup.
Consonant class
|
Consonants
|
Count
|
Percentage
|
Class
क
|
क, ख, ग, घ, ङ
|
2116
|
6.99
%
|
Class
च
|
च, छ, ज, झ, ञ
|
1746
|
5.77
%
|
Class
ट
|
ट, ठ, ड, ढ, ण
|
650
|
2.15
%
|
Class
त
|
त, थ, द, ध, न, ऩ
|
8611
|
28.45
%
|
Class
प
|
प, फ, ब, भ, म
|
4973
|
16.43
%
|
Unclassified
|
य, र, ऱ, ल, ळ, ऴ, व, श, ष, स, ह,
|
12175
|
40.22
%
|
Total
|
30271
|
30271
|
100
%
|
· The least one is झ pronounced only for once by the lord Krishna.
· The most frequent consonants uttered is त, 3931 times and
· Out of these 30271 constantans, majority of consonants 80.37% of consonants are uttered by the lord Krishna and 13.39 % of constantans are uttered by Arjuna. Here is the detail breakup.
· The most frequent consonants uttered is त, 3931 times and
· Out of these 30271 constantans, majority of consonants 80.37% of consonants are uttered by the lord Krishna and 13.39 % of constantans are uttered by Arjuna. Here is the detail breakup.
Speaker
|
Number of consonants
|
Percentage of
consonants
|
Arjuna
|
4052
|
13.39
%
|
the
lord Krishna
|
24330
|
80.37
%
|
Sanjay
|
1730
|
5.72
%
|
Dhritarashtra
|
42
|
0.14
%
|
None
|
117
|
0.39
%
|
Total
|
30271
|
100
%
|
Please refer https://github.com/mpanchmatia/BhagavadGitaAlphabet/blob/master/output.txt for deatil break-up of all consonants uttered by all characters.
Future
Scope
·
The scope of consonants analysis can be further
extended, like, identify patterns that can be corelated to energy movement in
the body and impact on brain from neuroscience perspective.
·
The analysis can be done to other ancient Sanskrit
text, epic, hymns etc.
·
One can target famous text from other languages
also and perform comparative analysis.
Container Orchestration
Posted by
Manish Panchmatia
on Friday, June 14, 2019
Labels:
k8s,
microservice,
software
/
Comments: (0)
Full article...>>
What is Container Orchestration ?
- Fault tolerant
- Scaling
- Optimally use resources
- Discovery
- Access from outside world
- Update/rollback with 0 downtime
What Container Orchestrators do?
- cluster = multiple host together
- schedule container(pod) to run on host/node
- network among pod on different nodes
- bind container with storage
- services = group of containers
- keep resource usage in check and optimize if needed
- secure access to app running inside continer
Deployment options
on-premise v/s cloud
bare-matel v/s VM
Container Orchestrators
- Kubernetes
- Docker Swarm
- Mesos Marathon
- Docker Compose : Single machine. Not for large scale. With one command, "docker compose up" it will bring up : containers, volumes, networks
- Hashicorp Nomad
- Amazon ECS (Amazon EC2 container service)
1. Task == Pod
2. It has its own repository.
3. Task can be part of CloudFormation stack. Task, Queue, EC2 Volume all together in
4. CloudFormation to start and to cleanup
5. To get started https://aws.amazon.com/ecs/
- AWS Fargate https://aws.amazon.com/fargate
- Google Kubernetes Engine (^L = clear = cls at Google Cloud Shell)
- Microsoft Azure Kubernetes Services (AKS)
- Cloud Foundry
- Rackspace
- Oracle Cloud Infrastructure
- Rancher
K8s Features
- schedule pod based on resource usage and constrain with HA
- self-healing
- scaling
- service discovery + load balancing.
- auto rollout and rollback
- secrets and config mgt
- storage orchstration with SDS
- batch execution
- RBAC
- Fault tolerant
- Scaling
- Optimally use resources
- Discovery
- Access from outside world
- Update/rollback with 0 downtime
What Container Orchestrators do?
- cluster = multiple host together
- schedule container(pod) to run on host/node
- network among pod on different nodes
- bind container with storage
- services = group of containers
- keep resource usage in check and optimize if needed
- secure access to app running inside continer
Deployment options
on-premise v/s cloud
bare-matel v/s VM
Container Orchestrators
- Kubernetes
- Docker Swarm
- Mesos Marathon
- Docker Compose : Single machine. Not for large scale. With one command, "docker compose up" it will bring up : containers, volumes, networks
- Hashicorp Nomad
- Amazon ECS (Amazon EC2 container service)
1. Task == Pod
2. It has its own repository.
3. Task can be part of CloudFormation stack. Task, Queue, EC2 Volume all together in
4. CloudFormation to start and to cleanup
5. To get started https://aws.amazon.com/ecs/
- AWS Fargate https://aws.amazon.com/fargate
- Google Kubernetes Engine (^L = clear = cls at Google Cloud Shell)
- Microsoft Azure Kubernetes Services (AKS)
- Cloud Foundry
- Rackspace
- Oracle Cloud Infrastructure
- Rancher
K8s Features
- schedule pod based on resource usage and constrain with HA
- self-healing
- scaling
- service discovery + load balancing.
- auto rollout and rollback
- secrets and config mgt
- storage orchstration with SDS
- batch execution
- RBAC








