Kubernet Learning- Sujit
Limited Time Offer!
For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!
– What is POD – in 10 lines with 1 YAML example
- A Kubernetes pod is a collection of one or more Linux containers, and is the smallest unit of a Kubernetes application.
- pod can be composed of multiple, tightly coupled containers or just a single container.
- Within the kubernets system, containers in the same pod will share the same compute resources.
- Kubernetes does not run containers directly, instead running pods to ensure that each container within them shares the same resources and local network.
- Pods also contain shared networking and storage resources for their containers.
- A Pod is meant to run a single instance of your application on your cluster
- To create pod from yaml file we can use command kubectl create -f pod.yaml
- To inspect a Pod running on your cluster we can use command kubectl get pod
- To describe pod we can use kubectl describe pods sujit
- To edit pod we can use command kubectl edit pods sujit
apiVersion: v1
kind: Pod
metadata:
name: sujit
labels:
app: helloworld
spec:
containers:
-name: devopsschool1
image: scmgalaxy/nginx-devopsschoolv1
ports:
-name: nginx-port
containerPort: 80
– What is ReplicationController – in 4 lines with 1 YAML example
1.A ReplicationController ensures that a specified number of pod replicas are running at any one time
2.A ReplicationController makes sure that a pod is always up and available.
3. It is responsible for managing the pod lifecycle.
4. It is used in time when one wants to make sure that the specified number of pod or at least one pod is running.
5.It has the capability to bring up or down the specified no of pod.
apiVersion: v1
kind: ReplicationController
metadata:
name: replicationcontroller-example
spec:
replicas: 3
template:
metadata:
labels:
app: nginx
spec:
containers:
– name: nginx
image: scmgalaxy/nginx-devopsschoolv1
– What is ReplicaSets – in 4 lines with 1 YAML example
- Replica Set ensures how many replica of pod should be running and helps with load-balancing in case of an increase in resource usage.
- It can be considered as a replacement of replication controller.
- A ReplicaSet is a process that runs multiple instances of a Pod
- Its purpose is to maintain the specified number of Pod instances running in a cluster at any given time to prevent users from losing access to their application when a Pod fails or is inaccessible.
- ReplicaSet helps bring up a new instance of a Pod when the existing one fails.
apiVersion: v1
kind: ReplicaSet
metadata:
name: my-replicaset
spec:
replicas: 2
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
– name: my-container
image: nginx
– What is Deployment – in 10 lines with 1 YAML example
- A deployment allows us to describe an application’s life cycle, such as which images to use for the app, the number of pods there should be, and the way in which they should be updated.
2. The Kubernetes deployment object lets us:
- Deploy a replica set or pod
- Update pods and replica sets
- Rollback to previous deployment versions
- Scale a deployment
- Pause or continue a deployment.
3. Kubernetes Deployment is the process of providing declarative updates to Pods and Replica sets.
4.It allows users to declare the desired state in the yaml file, and the controller will change the current state to the declared state.
5. Deployments represent a set of multiple, identical Pods with no unique identities.
6.A Deployment runs multiple replicas of your application and automatically replaces any instances that fail or become unresponsive
7. Deployments help ensure that one or more instances of your application are available to serve user requests.
8. Deployments are managed by the Kubernetes Deployment controller.
9. To create deployment we can use comand kubectl create deployment my-dep –image=scmgalaxy/nginx-devopsschoolv1 -n=sujit
10.To get deployment we can use kubectl get deploy -n=sujit
11. To edit deployment kubectl edit deploy my-dep -n=sujit
12. To delete deployment kubectl delete pod my-dep-747b4ffb56-2ftv5 my-dep-747b4ffb56-8nvwk my-dep-747b4ffb56-bgnhk my-dep-747b4ffb56-hxsqd my-dep-747b4ffb56-lqqm8 my-dep-747b4ffb56-ppkhg my-dep-747b4ffb56-rt977 -n=sujit
apiVersion: v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
– name: nginx
image: nginx:1.14.2
ports:
– containerPort: 80