Kubernetes in 33 points — Bird’s eye view

Quick Summary of Kubernetes (K8S) in Action

Kubernetes — Feature Summary

TL;DR;

History

What is Kubernetes -K8S?

K8S Architecture — Bird’s eye view

Master Node [Control Plane]— consists of following components:

Worker Nodes — runs apps with following components:

Nodes?

Pods vs containers?

Why need a ReplicationController/ReplicaSet?

K8S Concepts, commands and more:

1. Run a docker image from docker rgistr

2. Create Docker Image with following Dockerfile

3. Check All running containers or inspect

4. Local K8S setup

5. Install kubectl client to interact with k8s cluster

6. Run an image in k8s cluster using below

6. Display all POD details OR a specific POD

7. See cluster dashboard

8. POD, service or any object in k8s can be created via json or YAML file as well. For Pod we created above, you can explore the object definition file in YAML using:

9. To create a POD using YAML file

10. Check logs of a Pod OR specific container in a POD

11. Sending Request/connect to a specific POD via port forward

12. You can add/edit multiple labels to PODS which later help in listing certain Pods only based on label-selectors

13. Node selectors can be used to selector machine where the POD is preferred to be deployed

apiVersion: v1
kind: Pod
metadata:
name: apu-pod
labels:
env:staging
spec:
nodeSelector:
gpu: "true"
containers:
- image: apuravchauhan/kubia
name: apurav

14. You can logically and horizontally segregate all resources by creating namespaces

15. Liveness probes can be configured that help k8s restart app in case of node failure or app crash. Readiness probes can be used to tell k8s when app is ready to serve traffic after startup

16. Creating Pods indirectly via Replication Controller/ReplicationSets yaml file. As see we can define replicas


apiVersion: v1
kind: ReplicationController
metadata:
name: kubia
spec:
replicas: 3
selector:
app: kubia
template:
metadata:
labels:
app: kubia
spec:
containers:
- name: kubia
image: apuravchauhan/kubia
ports:
- containerPort: 8080

17. Scale up replicationcontroller

18. You can run exactly one pod on each node with DaemonSet

19. You can run pods that perform a single completable task using Job Resource

20. As a client you communicate with a group of a specific type of Pods via service resource. Below is an example YAML that can create a service using

apiVersion: v1
kind: Service
metadata:
name: orderloadbalancer
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: orderservice

21. When exposing multiple service group/ load balancers to external world, you can use something called Ingress Resource to define multiple rules and mappings based on paths

22. Pods can be decoupled from underlying storage technology by mounting different storage volumes in k8s like direct gitrepo, aws, gce, nfs, worker’s node fs etc

23. Special types of volumes exist to store configurations and secrets that can be mounted on worker nodes.

apiVersion: v1
kind: Pod
metadata:
name: gitrepo-volume-pod
spec:
containers:
- image: nginx:alpine
name: web-server
volumeMounts:
- name: html
mountPath: /usr/share/nginx/html

volumes:
- name: html

gitRepo:
repository: https://github.com/luksa/kubia-website-example.git
revision: master
directory: .

24. To further decouple the Pods from underlying storage, we can use an abstraction called PersistentVolumeClaim

25. For managing production build updates and patch, use Deployment resource to handle rolling updates gracefully. Other deployment strategies are also available. Deployment resources maintains history of deployments and can even rollback the last deployment.

apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: kubia
spec:
replicas: 3
template:
metadata:
name: kubia
labels:
app: kubia
spec:
containers:
- image: luksa/kubia:v1
name: nodejs

26. Use Statefulset resource to maintain the app state in case a Pod/container goes down. StatefulSet helps maintain the disk state and other identity details when a new POD is created.

27. Make sure your k8s is secured including API server using proper authentication/ role based access. Same for cluster network

28. Post-start and pre-stop hooks can be registered with Pods

29. LimitRange resources can be used to define computational limits for PODs

apiVersion: v1
kind: LimitRange
metadata:
name: example
spec:
limits:
- type: Pod
min:
cpu: 50m
memory: 5Mi
max:
cpu: 1
memory: 1Gi
- type: Container
defaultRequest:
cpu: 100m
memory: 10Mi
.
.
.
.
.

30. You can use ResourceQuota objects to limit the amount of resources available to all the pods in a namespace.

31. Use HorizontalPodAutoscaler resource for autoscaling. Just point it to a Deployment, ReplicaSet, or ReplicationController and specify the target CPU utilisation for the pods

32. A package manager called Helm makes deploying existing apps without requiring you to build resource manifests for them.

33. You can extend K8S server with your own custom objects and APIs

Summarising the K8S resources

Core resources of K8S

Director Of Engineering @Paytm | Entrepreneur | Strategic leader

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store