
Devops Session 4
containerization- it is software base virtualization which does not require VM for every application
Docker- It is software layer on the top of base OS so that we can container on the top of docker
Setup to setup docker
1 sudo apt-get update
2. sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
3. sudo mkdir -m 0755 -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
4. echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
5. sudo apt-get update
6. sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo apt-get update
7. sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
To run the container we require image files (dockerhub)
Commands to run docker
1. docker pull httpd - it will use to download the docker image (httpd)
2. docker image list - it will use to see the image which is downloaded
3. docker ps - it is used to see the running container
4. To run container we used - docker run -d -it httpd -p 80:80
-d -- run in background
-p -- port
-it -- interative
5. docker logs - to see the list of logs
6. docker rm xyz - it use to delete docker container (whicg is not running)
7. docker start xyz - start container
8. docker stop xyz - stop container
9. docker restart xyz - restart container
10. docker kill xyz - delete running container
DevOps Session 5
Run multiple sites in different containers
1. Download sample html code
2. copy it in aws instance
3. create resume folder and extract website data into it
4. Create Dockerfile and insert content
From httpd:latest
COPY . /usr/local/apache2/htdocs/
5. docker build -t resume_image .
6. docker run -p 80:80 -d -it resume_image
7. Create hotel folder and extract website into it
8. Create Dockerfile and insert content
From httpd:latest
COPY . /usr/local/apache2/htdocs/
9. docker build -t hotel_image .
10.docker run -p 8080:80 -d -it hotel_image
Commands in docker file
1. FROM - it will use to refer the another image from docker hub
2. COPY - copy the content from local machine to the container
3. ADD - add the content from local machine to the container but it will extract tar files and download content if url is present
4. WORKDIR - it will select the directory in which we want to work
5. CMD - when you want to run any command
6. RUN - it will help to build your container
7. ENTRYPOINT - it will execute command on startup
8. CMD - it will execute command on startup
DevOps Session 6
#!/bin/bash
echo "1. Run hotel website"
echo "2. Delete hotel website"
read var
case $var in
1)
docker build -t hotel_image $HOME
docker run --name hotel -p 80:80 -d -it hotel_image
break;;
2)
docker kill hotel
docker rm hotel
docker rmi hotel_image
break;;
*)
echo "enter correct choice"
esac
docker run -d -p 8000:8000 -p 9443:9443 --name portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:2.9.3
DevOps session 7
Cluster - It is not posssible to depend on single system so we setup multiple systems in such a way that if first is down then second will work without downtime
Docker swarm - it is cluster service odf docker
Steps to create cluster
1. docker swarm init --advertise-addr ip_add_1st
2. docker swarm join --token SWMTKN-1-6adyuvs4e2mxrlxs4p8so1amheyfj2uzgkp3ar69pg3k6scvfa-dgxoe1vhevkcau2ufxshyp17f 172.31.46.142:2377
3. docker node ls
4.docker service create -p 80:80 --name sample --replicas=6 httpd:latest
5. Launch portrainer to check on gui
6. docker service scale sample=10
DevOps Session 8
Docker compose
It is use to handle multiple containers in once
Steps to run docker compose
1. Install Docker file and docker-compose
2. Create 2 different folders and create 2 docker files
3. Create dcker compose file (docker-compose.yml)
version: '3.3'
services:
hotel:
restart: always
build:
dockerfile: Dockerfile
context: ./hotel
ports:
- '80:80'
resume:
restart: always
build:
dockerfile: Dockerfile
context: ./resume
ports:
- '8080:80'
version: '3.3'
services:
hotel:
restart: always
build:
dockerfile: Dockerfile
context: ./hotel
ports:
- '80:80'
resume:
restart: always
build:
dockerfile: Dockerfile
context: ./resume
ports:
- '8080:80'
portainer:
image: portainer/portainer-ce:latest
ports:
- '9443:9443'
- '8000:8000'
volumes:
- portainer_data:/data
- /var/run/docker.sock:/var/run/docker.sock
restart: unless-stopped
volumes:
portainer_data:
This course is for anybody who wants to get started with DevOps:
As there are many tools & technologies in DevOps, it has become difficult for people to choose the right technologies.
This course starts from very basics of command line, hands on demonstrations of many tools & technologies.
Also most importantly it will show you how various technologies in DevOps work together by setting up your own projects.
Also this course help you to be atleast preparation of CKA examination.
Learn about components of Kubernetes
To be VERY safe, you simply work through the workbooks, which give you almost 60 practical tasks that you have to carry out. This should consolidate your knowledge even further and the exams will be child's play for you.
At the end of each major topic, you can go through a small quiz with 180 multiple choice questions like those asked in the exams.
As you can see, with this course you really have everything you need to pass the two exams and soon be able to call yourself Kubernetes administrator.
Step 1
Docker Intro
Understanding and Implementing Containers
Volumes, Network, logs etc
Building Images for Vprofile project
Docker compose to run vprofile multi containers
Kubernetes Intro
Kubernetes setup for production Env
Kubernetes objects
Pods, Services, Controllers, Deployment
Replication, Autoscaling, Resource quotas, secret, configmap, namespace.