Kubernetes for the Absolute Beginners - Hands-on | Udemy
Pods
The Kubernetes pod definition file contains 4 top-level fields:
- apiVersion
- the version of Kubernetes version used
- kind
- the kind of service that is created
- ex) Pod, Service, ReplicaSet, Deployment
- the kind of service that is created
- metadata
- data of the object such as name and labels
- under label property, we can set whatever key-value pair we want
- data of the object such as name and labels
- spec
- where containers are defined along with their image and name
kubectl apply -f [name of the file].yaml: creates pod according to the YAML file in the argument
Replication Controllers and ReplicaSets
Replication Controller: allows running of multiple pods of the same image for high availability
- ensures a specified number of pods are running at a time
- can span across multiple nodes to scale the application
- in the spec section of the YAML file
- template: The YAML file of the pod is copied
- replicas: the number of replicas is specified
ReplicaSets: newer technology that is replacing replication controllers
- apiVersion needs to be specified as apps/v1
- spec section is almost the same except that there is one more field to it
- selector: monitors pods with specified labels unlike replication controllers
- so if pods of the same labels are already running when ReplicaSets are created, it does not create a new one until one fails
- selector: monitors pods with specified labels unlike replication controllers
Scaling ReplicaSet:
- change the replica filed of the YAML file and run kubectl replace -f [filename]
- use kubectl scale --replicas=[number of replicas] -f [filename] command
Deployment
Rolling Updates: Upgrading instances one by one to maintain availability
- two ReplicaSets
Deployment: wraps around ReplicaSet to update the instance seamlessly and control changes
- The definition file is almost the same as ReplicaSet except that the section for kind is changed to Deployment.
kubectl get all: lists all the objects created in the Kubernetes such as pods, ReplicaSets, deployments
Rollout is triggered when a new deployment is created.
- the revision number increases when there is a newer version
- this allows us to keep track of the revision history
kubectl rollout status [deployment name]: see the current status of the rollout
kubectl rollout history [deployment name]: see the history of the deployment
Deployment strategy:
- (Bad) Destroying all the instances and creating updated new instance
- (Good) Taking down one instance and bringing up a new instance for availability (Rolling Update)
kubectl apply -f [YAML file name]: updates the current running instance to a newer version
kubectl rollout undo [deployment name]: goes back to older format by destroying the current instance
'DevOps > Kubernetes' 카테고리의 다른 글
[Kubernetes 배우기] Section 7. Services (0) | 2024.01.09 |
---|---|
[Kubernetes 배우기] Section 6. Networking in Kubernetes (0) | 2024.01.09 |
[Kubernetes 배우기] Section 4. YAML Introduction (0) | 2024.01.09 |
[Kubernetes 배우기] Section 3. Kubernetes Concepts (0) | 2024.01.09 |
[Kubernetes 배우기] Section 2. Kubernetes Overview (0) | 2024.01.09 |