/images/avatar.png

Kubernetes Deployment

You must know Deployment is going to create ReplicaSet automatically. YAML - deployment-definition.yml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 apiVersion: apps/v1 kind: Deployment metadata: # -> Deployment name: myapp-deployment labels: app: myapp type: front-end spec: # -> Deployment template: metadata: # -> POD name: myapp-pod labels: app: myapp type: front-end spec: # -> POD containers: - name: nginx-continer image: nginx replicas: 3 selector: matchLabels: type: front-end Create a Deployment 1 kubectl create -f deployment-definition.

Kubernetes ReplicaSet

You must know selector is to find the matched labels for managing the PODs in the ReplicaSet. YAML - rs-definition.yml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 apiVersion: apps/v1 kind: ReplicaSet metadata: # -> ReplicaSet name: myapp-replicaset labels: app: myapp type: front-end spec: # -> ReplicaSet template: metadata: # -> POD name: myapp-pod labels: app: myapp type: front-end spec: # -> POD containers: - name: nginx-continer image: nginx replicas: 3 selector: # -> `selector` is not required by Replication Controller matchLabels: type: front-end Create a ReplicaSet 1 kubectl create -f rs-definition.

Kubernetes Commands

Command Tip! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # Create a POD with nginx image kubectl run nginx --image=nginx # Generate POD Manifest YAML file without create(--dry-run) kubectl run nginx --image=nginx --dry-run=client -o yaml > nginx-pod.yml # Create a Deployment kubectl create deployment --image=nginx nginx # Generate Deployment Manifest YAML file without create(--dry-run) kubectl create deployment --image=nginx nginx --dry-run=client -o yaml > nginx-deployment.

Kubernetes YAML

Basic YAML Structure in Kubernetes Basic YAML Structure 1 2 3 4 5 6 apiVersion: kind: metadata: spec: Version Information Kind Version POD v1 Service v1 ReplicaSet apps/v1 Deployment apps/v1 POD YAML pod-definition.yml 1 2 3 4 5 6 7 8 9 10 11 apiVersion: v1 kind: Pod metadata: name: myapp-pod labels: app: myapp type: front-end spec: containers: - name: nginx-continer image: nginx Create a POD with YAML file 1 kubectl create -f pod-definition.

Kubernetes POD

You must know POD is a unit of service. If kubernetes needs to scale out, it replicates POD unit. It’s not to scale out container in a POD. Manage Containers with Docker 1 2 3 4 5 6 7 8 9 10 11 12 13 # app1 docker run python-app # app2 docker run python-app # app3 docker run python-app # app4 docker run python-app docker run helper -link app1 docker run helper -link app2 docker run helper -link app3 docker run helper -link app4 Manage Containers with POD pod-definition.

Kubernetes Core Concepts

Cluster Architecture Master Node Manage Plan Schedule Monitor Nodes Worker Nodes Host Application as Containers Kubernetes Architecture Master Node kube-apiserver Controller-Manager Node-Manager Replication-Manager Worker Nodes kubelet is manager of a node Kube Proxy kube-api server Execute Process Authenticate User Validate Request Retrieve data Update ETCD Scheduler Kubelet api-server options 1 cat /etc/kubernetes/manifests/kube-apiserver.yaml 1 cat /etc/systemd/system/kube-apiserver.service 1 ps -aux | grep kube-apiserver ETCD ETCD is a distributed reliable key-value store that is Simple, Secure & Fast