Deploying the custom docker image as POD/container in kubernetes and creating LB to access the services

 

Deploying the custom docker image as POD/container in kubernetes and creating LB to access the services

 

$kubectl run nginx-webapp --image=abushad/nginx-webapp --dry-run -o yaml > webapp.yaml


$kubectl apply -f webapp.yaml


$kubectl get pods -o wide


$kubectl run ubuntu --image=ubuntu -- sleep 600


$kubectl exec -it ubuntu /bin/bash


#apt-get update

#apt-get install curl

#curl http://ip


$kubectl expose pod nginx-webapp --port=80 --target-port=80 --dry-run -o yaml > webapp-service.yaml


$cat webapp-service.yaml

apiVersion: v1

kind: Service

metadata:

  creationTimestamp: null

  labels:

    run: nginx-webapp

  name: nginx-services         ###This is optional

spec:

  type: LoadBalancer

  ports:

  - port: 80

    protocol: TCP

    targetPort: 80

  selector:

    run: nginx

status:

  loadBalancer: {}

 

Check in EC2 -- Loadbalacer , a new loadbalancer will now get created , wait for some time

and we will be able to access the html page from the pod using the loadbalancer dns name

 




Comments

Popular posts from this blog

Install and configure AWS CLI and kubectl in a EC2 Client machine for AWS EKS

Building a custom docker container image and pushing it to Docker Hub – Docker Compose