kubernetes commands
Running application in deployment:
$kubectl create -f redis-deploy.yaml
error: unable to recognize "redis-deploy.yaml": no matches for kind "Deployment" in version "apps/v1beta1
Then we check the required version for the deployment and we modify the yam file redis-deploy.yaml .
$kubectl explain deployment
KIND: Deployment
VERSION: apps/v1
Then we rerun the command:
$kubectl create -f redis-deploy.yaml
deployment.apps/redis created
Namespaces:
\W $kubectl create -f busybox.yaml
pod/busybox2 created
\W $kubectl create -f busybox.yaml
Error from server (AlreadyExists): error when creating "busybox.yaml": pods "busybox2" already exists
If we try to create the same pod, we will get an error but if we create a pod in a different namespace by modifying the namespace in the yaml file. The pod will be created
We see that we have 2 busybox2 created in different Namespaces.$kubectl create ns myspace namespace/myspace created
$vim busybox.yaml$kubectl create -f busybox.yaml pod/busybox2 created
$kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default busybox2 1/1 Running 0 5m49s
default redis-6fb5b985bc-9jl56 1/1 Running 0 2d22h
kube-system coredns-74ff55c5b-bgtzz 1/1 Running 0 4d15h
kube-system etcd-minikube 1/1 Running 0 4d15h
kube-system kube-apiserver-minikube 1/1 Running 0 4d15h
kube-system kube-controller-manager-minikube 1/1 Running 0 4d15h
kube-system kube-proxy-n9f56 1/1 Running 0 4d15h
kube-system kube-scheduler-minikube 1/1 Running 0 4d15h
kube-system storage-provisioner 1/1 Running 2 4d15h
myspace busybox2
Application scalability:
1- We change the number of replicas of the deployment redis to 3 using the command kubectl edit deployments redis
$kubectl get deployments.apps
NAME READY UP-TO-DATE AVAILABLE AGE
redis 1/1 1 1 2d22h
\W $
\W $kubectl edit deployments redis
deployment.apps/redis edited
\W $kubectl get deployments.apps
NAME READY UP-TO-DATE AVAILABLE AGE
redis 3/3 3 3 2d22h
2. Usign scale command:
$kubectl scale --replicas=4 deployment redis
deployment.apps/redis scaled
$kubectl get deployments.apps
NAME READY UP-TO-DATE AVAILABLE AGE
redis 4/4 4 4 2d22h
List the pods with IP adresse value
kubectl get pods -o wide
verybusy 2/2 Running 0 12s 172.17.0.4 minikube
Add a comment