Try This Consideration:- You have 3 nodes ( 1 master and 2 worker nodes) Cluster. Create a Pod called nginx-pod1 with image nginx (it runs...
Try This
Consideration:- You have 3 nodes ( 1 master and 2 worker nodes) Cluster.
- Create a Pod called nginx-pod1 with image nginx (it runs on Port 80)
- Create another Pod called tomcat-pod1 with image tomcat (it runs on Port 8080)
- Access these pods on worker nodes (use curl command ). Are you able to Access ? If not then checkout the reason.
- Go inside tomcat pod ( use kubectl exec ....command) and try to access nginx service Pod by using nginx-pod1 IP address and pod name. Are you able to access the nginx website ? if no then figure out the reason.
- Go inside nginx pod (use kubectl exec ....command) and try to access tomcat service with IP address and pod name ot tomcat-pod1. Are you able to access the nginx website? if no then figure out the reason.
- Change docker image of nginx-pod1 from nginx to tomcat. Is it possible for running a pod?
- Check the restart value of nginx-pod1.
- check all the events of tomcat-pod1 and also find out in which namespace tomcat-pod1 is created.
- Display the tomcat-pod1 properties in json format.
- Delete all the pods.
1. Create a Pod called nginx-pod1 with image nginx (it runs on Port 80)
ReplyDeletekubectl run nginx-pod1 --image=nginx
OR
#nginx-pod1.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod1
spec:
containers:
- name: c1
image: nginx
2. Create another Pod called tomcat-pod1 with image tomcat (it runs on Port 8080)
kubectl run tomcat-pod1 --image=tomcat
OR
#tomcat-pod1.yaml
apiVersion: v1
kind: Pod
metadata:
name: tomcat-pod1
spec:
containers:
- name: c1
image: tomcat
3. Access these pods on worker nodes (use curl command ). Are you able to Access ? If not then checkout the reason.
kubectl get pods -o wide
curl
(yes able to, for nginx is ok but for tomcat need to put port number (8080))
4. Go inside tomcat pod ( use kubectl exec ....command) and try to access nginx service Pod by using nginx-pod1 IP address and pod name. Are you able to access the nginx website ? if no then figure out the reason.
kubectl exec -it tomcat-pod1 -- bash
curl
(can access as they are in the same CIDR range (calico network layer))
5. Go inside nginx pod (use kubectl exec ....command) and try to access tomcat service with IP address and pod name ot tomcat-pod1. Are you able to access the nginx website? if no then figure out the reason.
kubectl exec -it nginx-pod1 -- bash
curl
(can access as they are in the same CIDR range (calico network layer))
6. Change docker image of nginx-pod1 from nginx to tomcat. Is it possible to do on a running pod?
No.
Error from server (AlreadyExists): pods "nginx-pod1" already exists
7. Check the restart value of nginx-pod1
kubectl get pod nginx-pod1 -o wide
8. Check all the events of tomcat-pod1 and also find out in which namespace tomcat-pod1 is created.
kubectl describe pod tomcat-pod1
Name: tomcat-pod1
Namespace: default
9. Display the tomcat-pod1 properties in json format.
kubectl get pod tomcat-pod1 -o json
10. Delete all the pods.
kubectl delete pod --all
1. Create a Pod called nginx-pod1 with image nginx (it runs on Port 80)
ReplyDeleteroot@kmaster:/home/vagrant# kubectl run nginx-pod1 --image=nginx
pod/nginx-pod1 created
2. Create another Pod called tomcat-pod1 with image tomcat (it runs on Port 8080)
root@kmaster:/home/vagrant# kubectl run tomcat-pod1 --image=tomcat
pod/tomcat-pod1 created
3. Access these pods on worker nodes (use curl command ). Are you able to Access ? If not then checkout the reason. Can access.
vagrant@kworker1:~$ curl 192.168.41.137:8080
4. Go inside tomcat pod ( use kubectl exec ....command) and try to access nginx service Pod by using nginx-pod1 IP address and pod name.
Are you able to access the nginx website ? if no then figure out the reason. Can access.
root@kmaster:/home/vagrant# kubectl exec -it tomcat-pod1 -- bash
root@tomcat-pod1:/usr/local/tomcat# curl 192.168.77.132
5. Go inside nginx pod (use kubectl exec ....command) and try to access tomcat service with IP address and pod name ot tomcat-pod1.
Are you able to access the nginx website? if no then figure out the reason. can access.
root@kmaster:/home/vagrant# kubectl exec -it nginx-pod1 -- bash
root@nginx-pod1:/# curl 192.168.41.137:8080
6. Change docker image of nginx-pod1 from nginx to tomcat. Is it possible for running a pod? No.
root@kmaster:/home/vagrant# vi eg.yml
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod1
spec:
containers:
- name: nginxc
image: tomcat
root@kmaster:/home/vagrant# kubectl create -f eg.yml
Error from server (AlreadyExists): error when creating "eg.yml": pods "nginx-pod1" already exists
7. Check the restart value of nginx-pod1.
root@kmaster:/home/vagrant# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-pod1 1/1 Running 0 24m 192.168.77.132 kworker2
tomcat-pod1 1/1 Running 0 23m 192.168.41.137 kworker1
8. check all the events of tomcat-pod1 and also find out in which namespace tomcat-pod1 is created.
root@kmaster:/home/vagrant# kubectl describe pod tomcat-pod1
Name: tomcat-pod1
Namespace: default
9. Display the tomcat-pod1 properties in json format.
root@kmaster:/home/vagrant# kubectl get pod tomcat-pod1 -o json
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"annotations": {
...........
10.Delete all the pods.
root@kmaster:/home/vagrant# kubectl delete pod --all
pod "nginx-pod1" deleted
pod "tomcat-pod1" deleted
root@kmaster:/home/vagrant# kubectl get pods
No resources found in default namespace.
Mikraj
Delete1.
ReplyDeletevi nginx-pod1
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
2.
vi tomcat-pod1
apiVersion: v1
kind: Pod
metadata:
name: tomcat
spec:
containers:
- name: tomcat
image: tomcat
ports:
- containerPort: 8080
3. Able to access both pods in kworker2
4. kubectl exec -it tomcat -- bash
curl 190.168.77.136:8080
5. kubectl exec -it nginx -- bash
curl 190.168.77.135:80
6. Yes, image updated
7. Restart value is 0
8. Namespace: default
9. kubectl get pod tomcat -o json
10. kubectl delete pod --all
1. kubectl run nginx-pod1 --image=nginx
ReplyDelete2. kubectl run tomcat-pod1 --image=tomcat
3. Use kubectl get pods -o wide to obtain IPs of the two pods.
NGINX pod runs on port 80 and can be accessed directly with IP,
TOMCAT pod runs on port 8080 and thus the port has to be appended
after IP in the curl command, e.g. curl <>:8080.
Both pods can be accessed from both worker nodes.
4. Able to
5. Able to.
6. No.
Error from server (AlreadyExists): pods "nginx-pod1" already exists
7. kubectl get pods -o wide
0.
8. kubectl describe pod tomcat-pod1
Name: tomcat-pod1
Namespace: default
9. kubectl get pod tomcat-pod1 -o json
10. kubectl delete pod --all
6. kubectl edit pod nginx-pod1
DeleteChange image to tomcat
7. kubectl get pods -o wide
1.
Create a Pod called nginx-pod1 with image nginx (it runs on Port 80)
ReplyDeletekubectl run nginxpod1 --image=nginx
Create another Pod called tomcat-pod1 with image tomcat (it runs on Port 8080)
kubectl run tomcatpod1 --image=tomcat
Access these pods on worker nodes (use curl command ). Are you able to Access ? If not then checkout the reason.
vagrant@kworker1:~$ curl 192.168.77.137
vagrant@kworker1:~$ curl 190.168.77.136:8080
Go inside tomcat pod ( use kubectl exec ....command) and try to access nginx service Pod by using nginx-pod1 IP address and pod name. Are you able to access the nginx website ? if no then figure out the reason.
kubectl exec -it tomcatpod1 -- bash
curl 192.168.77.137
Go inside nginx pod (use kubectl exec ....command) and try to access tomcat service with IP address and pod name ot tomcat-pod1. Are you able to access the nginx website? if no then figure out the reason.
kubectl exec -it nginxpod1 -- bash
curl 190.168.77.136:8080
Change docker image of nginx-pod1 from nginx to tomcat. Is it possible for running a pod?
No, because nginx image is running
Check the restart value of nginx-pod1.
kubectl get pod nginxpod1 -o wide
check all the events of tomcat-pod1 and also find out in which namespace tomcat-pod1 is created.
kubectl describe pod tomcatpod1
Name: tomcatpod1
Namespace: default
Display the tomcat-pod1 properties in json format.
kubectl get pod tomcatpod1 -o json
Delete all the pods.
kubectl delete pod --all
exec it:
ReplyDeletekubectl exec -it nginx-pod -- bash
from tomcat:
curl 192.168.77.133:80 -works
from nginx:
curl 192.168.77.134:8080-works
exec it:
Deletekubectl exec -it nginx-pod -- bash
from tomcat:
curl 192.168.77.133:80 -works
from nginx:
curl 192.168.77.134:8080-works
amend the nginx.yaml file to change the container to tomcat from nginx, then run this command : kubectl apply -f nginx.yaml
after update of yaml file, restart value of nginx-pod becomes "1"
Deletedisplay as json
Deletekubectl get pod tomcat-pod1 -o json
delete all pods
kubectl delete --all pods
This comment has been removed by the author.
ReplyDelete1. Create a Pod called nginx-pod1 with image nginx (it runs on Port 80)
ReplyDelete-> kubectl run nginx-pod1 --image=nginx
2. Create another Pod called tomcat-pod1 with image tomcat (it runs on Port 8080)
-> kubectl run tomcat-pod1 --image=tomcat
3. Access these pods on worker nodes (use curl command ). Are you able to Access? If not then checkout the reason.
On master server -> kubectl get pods -o wide (to view IP address)
On worker nodes -> curl 190.168.41.129 (nginx pod) YES, both worker nodes have access
On worker nodes -> curl 190.168.77.129 (tomcat pod) NO, port 80: Connection refused
4. Go inside tomcat pod ( use kubectl exec ....command) and try to access nginx service Pod by using nginx-pod1 IP address and pod name. Are you able to access the nginx website ? if no then figure out the reason.
On master server -> kubectl exec -it tomcat-pod1 -- bash
-> curl 190.168.41.129 (YES)
5. Go inside nginx pod (use kubectl exec ....command) and try to access tomcat service with IP address and pod name of tomcat-pod1. Are you able to access the nginx website? if no then figure out the reason.
-> exit
-> kubectl exec -it nginx-pod1 -- bash
-> curl 190.168.77.129:8080 (YES)
6. Change docker image of nginx-pod1 from nginx to tomcat. Is it possible for running a pod?
-> exit -> kubectl edit pod nginx-pod1 (change image: nginx to tomcat in the editor)
NO
7. Check the restart value of nginx-pod1. -> kubectl get pods -o wide (0 RESTARTS)
8. check all the events of tomcat-pod1 and also find out in which namespace tomcat-pod1 is created.
-> kubectl describe pod tomcat-pod1 (Namespace: default)
9. Display the tomcat-pod1 properties in json format. -
> kubectl get pod tomcat-pod1 -o json
10. Delete all the pods.
-> kubectl delete pod --all