- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
How Two different Containers communicate with each-other within the Same Pod:
> Create a new AWS Instance named “Minikube” on T2-Medium & access it via PUTTY as we do, then do the rest lab:
ubuntu
sudo su
apt update && apt -y install [docker.io](<http://docker.io>)
→ Now Install docker
curl -LO [<https://storage.googleapis.com/kubern>...](<https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbTZrdHFlT2pZQlB4OXhLWHRhUDEyX2NBbzZ2QXxBQ3Jtc0tsaC1lQVZsY0JXbnVzRGxvWjBjV1Rna2NBZlN3a2JPei1uRlloNzRaV3RQUXRrWVpJaE55ZFZ6S3BCaGFXOUx3ejYtXzJDcjdlSWc4MGJVYzBMNjlIanE3OXVZbjQyLVBQTURlRDF2a0pwbmJVV2hrbw&q=https%3A%2F%2Fstorage.googleapis.com%2Fkubernetes-release%2Frelease%2F%24%28curl&v=hV8zi3vdQqk>) -s [<https://storage.googleapis.com/kubern>...](<https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqbXJxa2IwTm5majRfdUdtV3N4VUcyMmF5WFVVUXxBQ3Jtc0trZ1lnRVBZVjk1Sm5QLWo4aVFEaXhfRkZmTzc5OGx3eHpIYWV6bTZtNHNxUkszU2lfUTdnSnk4TG1pSmRxdmRSb2RlQmlTdGZoVWRrcHJieVd4X3ltQkdJOUcyUkNnZEtLd0daQ194WnM5UWQtek10dw&q=https%3A%2F%2Fstorage.googleapis.com%2Fkubernetes-release%2Frelease%2Fstable.txt%29%2Fbin%2Flinux%2Famd64%2Fkubectl&v=hV8zi3vdQqk>) && chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin/kubectl
→ Now Install Kubectl
which kubectl
kubectl version
curl -Lo minikube [<https://storage.googleapis.com/miniku>...](<https://www.youtube.com/redirect?event=video_description&redir_token=QUFFLUhqazBQTF9JUWpSRVgtVFNLYlMwYWl3UFAwaG9VQXxBQ3Jtc0tscHpZX1Y2Vm15NHpGdC1OajlkcmxJNExIMVV5ak9pNTllTG1xcmc0eDY0WmRYblg2MWFiNDZXSkxWWmJSNEFxVTYycGZZN3BMYjhuTjh5c05XZDVxLTBJQkNqRWZwejg2NXhKdjhUZ3NMQUJGWU5saw&q=https%3A%2F%2Fstorage.googleapis.com%2Fminikube%2Freleases%2Flatest%2Fminikube-linux-amd64&v=hV8zi3vdQqk>) && chmod +x minikube && sudo mv minikube /usr/local/bin/
→ Now Install Minikube
apt install conntrack
minikube start --vm-driver=none
→ This command starts Minikube [ Always run this to start Minikube ]
minikube status
vi pod1.yml
# KUBERNETES NETWORKING
kind: Pod
apiVersion: v1
metadata:
name: testpod
spec:
containers:
- name: c00
image: ubuntu
command: ["/bin/bash", "-c", "while true; do echo Hello-Bhupinder; sleep 5 ; done"]
- name: c01
image: httpd # Apache Webserver
ports:
- containerPort: 80
kubectl apply -f pod1.yml
→ Applies the configuration from “pod1.yml” to create or update a pod named “testpod”
kubectl get pods
→ Lists all pods
kubectl exec testpod -it -c c00 -- /bin/bash
→ By this command, you will redirect inside that particular Container & you can run commands their inside the Container
apt update && apt install curl
→ It will install Curl Package inside that Containercurl [localhost:80](<http://localhost:80>)
→ check if the “Port:80” means Apache Server ****is working on that particular Container or notexit
→ Exit from the Containers Terminal and change the directory to the Podkubectl delete -f pod1.yml
→ It will delete the testpod created by the above YAML file
How Two different Pods Communicate with each-other within the same Node:
> It will be the Sequence of above labs
vi pod2.yml
# KUBERNETES NETWORKING
kind: Pod
apiVersion: v1
metadata:
name: testpod1
spec:
containers:
- name: c01
image: nginx # nginx Webserver
ports:
- containerPort: 80
vi pod3.yml
# KUBERNETES NETWORKING
kind: Pod
apiVersion: v1
metadata:
name: testpod4
spec:
containers:
- name: c03
image: httpd # Apache Webserver
ports:
- containerPort: 80
kubectl apply -f pod2.yml
→ Applies the configuration from “pod2.yml” to create or update a pod named “testpod1”
kubectl apply -f pod3.yml
→ Applies the configuration from “pod3.yml” to create or update a pod named “testpod4”
kubectl get pods
→ It will show how many Pods are available
kubectl get pods -o wide
→ By using this command, you will get every details about all of Your Pod
curl ip_address_of_that_pod:80
→ To check if the “Port:80” means Web Server is working on that particular Pod or not
These are of 3 types →
Cluster IP
Node Port
Load Balancer