Running Kubernetes
Mustafa Kirimli
High Level Architecture of K8s Cluster
Components
Components are running on
typical K8s cluster we will look
Worker Nodes
● Kubelet
● Kube Proxy
Master Nodes
● Etcd
● Api Server
● Kube Scheduler
● Controller Manager
Where to Run K8s Cluster
● EKS (Amazon Elastic Container Service for Kubernetes)
● GKE (Google Kubernetes Engine)
● AKS (Azure Kubernetes Service)
● Self Hosted (EC2/GCE/VM/On-Premise)
● Local Machine
kops
Kops can help you to
create/upgrade/maintain
Kubernetes cluster (master and
worker nodes)
Underlying infrastructure
configuration, instance group
creation, Kubernetes component
management are the some of the
features of the kops
Managing Kubernetes cluster
itself
kops rolling-update cluster k8s-cluster.example.com
--instance-group nodes --yes
CA (Cluster
Autoscaler)
Scaling Kubernetes cluster
vertically
Cluster autoscaler can
automatically listen your changes
doing on instance groups and
applies it.
It also checks are there any pod in
a “Pending”. If so it changes
underlying infra settings (ASG on
AWS) to add more machine to
cluster.
kubectl apply -f ./cluster_autoscaler.yml
HPA (Horizontal
Pod Autoscaler)
Scaling Kubernetes cluster
horizontally
Horizontal pod autoscaler is
checking metric server and
compares threshold given to
specific deployment, if threshold
exceed it changed deployment’s
replica settings to have scaling.
Daemonset
Concept
Running an application across
your cluster
Daemonsets are running across
your cluster (one copy on each
node).
You can have control on daemonset
with node selectors, taints and
tolerations to limit where to deploy.
Pod &
Container
Running set of containers in a
group/pod
Pods are smallest and simplest unit
in the Kubernetes objects*
Containers running in a pod can
have shared storage and
communicating each other through
localhost.
kubectl logs -f -n alpha web -c nginx --since 10s
Service &
Ingress
Way of exposing your
application internally and
externally
Services are exposing (L4) your
deployment/pods within cluster
(also can expose externally if you
do not want to use ingress)
Ingress can expose (L7) your
service externally to have control on
request values such as; hostname,
path, header etc.
Cronjob & Job
Running scheduled job on
Kubernetes
Cronjob is the scheduled task on
Kubernetes. It is giving you same
extra control over crontab.
Job is the a task either created by
cronjob or manually.
Following is the how cronjob works;
cronjob -> job(s) -> pod -> container(s)
kubectl create job --from="cronjob/rds-backup"
"rds-backup" -n alpha
Helm
Re-using Kubernetes yaml
templates/managing packages
Helm is the way of re-using,
managing versions of the your
Kubernetes object and controlling
your deployment.
With helm you can have a set of
Kubernetes object (deployment,
service, ingress, cronjob) under a
package which can be used on
different environments with passing
parameters.
helm init
Network Flow of Kubernetes

Running kubernetes

  • 1.
  • 2.
  • 3.
    Components Components are runningon typical K8s cluster we will look Worker Nodes ● Kubelet ● Kube Proxy Master Nodes ● Etcd ● Api Server ● Kube Scheduler ● Controller Manager
  • 4.
    Where to RunK8s Cluster ● EKS (Amazon Elastic Container Service for Kubernetes) ● GKE (Google Kubernetes Engine) ● AKS (Azure Kubernetes Service) ● Self Hosted (EC2/GCE/VM/On-Premise) ● Local Machine
  • 5.
    kops Kops can helpyou to create/upgrade/maintain Kubernetes cluster (master and worker nodes) Underlying infrastructure configuration, instance group creation, Kubernetes component management are the some of the features of the kops Managing Kubernetes cluster itself kops rolling-update cluster k8s-cluster.example.com --instance-group nodes --yes
  • 6.
    CA (Cluster Autoscaler) Scaling Kubernetescluster vertically Cluster autoscaler can automatically listen your changes doing on instance groups and applies it. It also checks are there any pod in a “Pending”. If so it changes underlying infra settings (ASG on AWS) to add more machine to cluster. kubectl apply -f ./cluster_autoscaler.yml
  • 7.
    HPA (Horizontal Pod Autoscaler) ScalingKubernetes cluster horizontally Horizontal pod autoscaler is checking metric server and compares threshold given to specific deployment, if threshold exceed it changed deployment’s replica settings to have scaling.
  • 8.
    Daemonset Concept Running an applicationacross your cluster Daemonsets are running across your cluster (one copy on each node). You can have control on daemonset with node selectors, taints and tolerations to limit where to deploy.
  • 9.
    Pod & Container Running setof containers in a group/pod Pods are smallest and simplest unit in the Kubernetes objects* Containers running in a pod can have shared storage and communicating each other through localhost. kubectl logs -f -n alpha web -c nginx --since 10s
  • 10.
    Service & Ingress Way ofexposing your application internally and externally Services are exposing (L4) your deployment/pods within cluster (also can expose externally if you do not want to use ingress) Ingress can expose (L7) your service externally to have control on request values such as; hostname, path, header etc.
  • 11.
    Cronjob & Job Runningscheduled job on Kubernetes Cronjob is the scheduled task on Kubernetes. It is giving you same extra control over crontab. Job is the a task either created by cronjob or manually. Following is the how cronjob works; cronjob -> job(s) -> pod -> container(s) kubectl create job --from="cronjob/rds-backup" "rds-backup" -n alpha
  • 12.
    Helm Re-using Kubernetes yaml templates/managingpackages Helm is the way of re-using, managing versions of the your Kubernetes object and controlling your deployment. With helm you can have a set of Kubernetes object (deployment, service, ingress, cronjob) under a package which can be used on different environments with passing parameters. helm init
  • 13.
    Network Flow ofKubernetes