Pod using yaml
Creating a Pod using a Yaml based file.
Kubernetes uses yaml files as input to create object such as Pods, replicas, deployments, services
pod-definition.yml
apiVersion:
kind:
metadata:
name: myapp-app
labels:
app: myapp
type: front-end
spec:
containers:
-name: nginx-container
image: nginx
---
kubectl create -f pod-definition.yml
kubectl apply -f pod-definition.yml
Both these commands work the same way when you are creating a new object
----
kubectl get pods
kubectl describe pod myapp-app
--
create a new pod using nginx image
kubectl run nginx --image=nginx
kubectl get pods -o wide
--
deleting a pod
kubectl delete pod webapp
--
dry run creating a pod yaml file , this will create a yaml file output. in this case the image is a wrong image > redis123
kubectl run redis --image redis123 --dry-run -o yaml
--dry-run=client (this is the new one --dry-run is deprecated)
kubectl run redis --image redis123 --dry-run=client -o yaml
we can direct this to another file
kubectl run redis --image redis123 --dry-run=client -o yaml > redis.yaml
create the pod now
kubectl create -f redis.yaml
verify that is created
kubectl get pods
-- Correcting the wrong image file to redis image
you can do this using kubectl edit command or open up the yaml file using a text editor and change it
-- Now appy the changes
kubectl apply -f redis.yaml
-- Replication Sets
Replication controller spans across multiple nodes in a cluster
---
Upscaling the ReplicaSet
edit the replica-set-definitions.yaml
edit the replicas and
kubectl replace -f replica-set-definitions.yaml
second method to do this
kubectl scale --replicas=6 -f replica-set-definitions.yaml
or you can use the replicaset name
kubectl scale --replicas=6 replicaset myapp-replicaset
kubectl get replicasets
kubectl delete replicaset myapp-replicaset
kubectl explain replicaset
kubectl edit rs new-replicaset
kubectl scale rs new-replicaset --replicas=5
kubectl edit rs new-replicasets
Comments
Post a Comment