Devops end to end deployment using circle ci and kubernetes
Er Virendra Giri
DevOps Engineer | Automating Continuous Delivery, Infrastructure, and Collaboration| AWS | Docker | Kubernetes | Jenkins | Python | Linux| CloudWatch
Completion steps →
Step 1 → Upload code to github
Here we are not going to see how we setup if you have any issue in pushing your code to github you could checkout my previous blogs in git in my profile
2. Now push the exact to your github account and move forward to Circle ci step
Step 2 → setup circle ci and connect with github repository
Sign into your circle ci account and if you don’t have an account just sign up by the following steps
3. Choose the following options
4. Now you have to choose github and you redirect to your github accout select the repository where your code present and then click on authorize
5. now you have tocreate a project for which you have to require a key pairs
Now you are connected to your github repository
Step 3 →upload the .circleci/config.yml file to build pipeline
领英推荐
version: 2.1
executors:
docker-publisher:
environment:
IMAGE_NAME: virugoswami/building-on-ci
docker:
- image: circleci/buildpack-deps:stretch
jobs:
build:
executor: docker-publisher
steps:
- checkout
- setup_remote_docker
- run:
name: Build Docker image
command: |
docker build -t $IMAGE_NAME:latest .
- run:
name: Archive Docker image
command: docker save -o image.tar $IMAGE_NAME
- persist_to_workspace:
root: .
paths:
- ./image.tar
publish-latest:
executor: docker-publisher
steps:
- attach_workspace:
at: /tmp/workspace
- setup_remote_docker
- run:
name: Load archived Docker image
command: docker load -i /tmp/workspace/image.tar
- run:
name: Publish Docker Image to Docker Hub
command: |
echo "$DOCKERHUB_PASSWWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker push $IMAGE_NAME:latest
workflows:
version: 2
build-master:
jobs:
- build:
filters:
branches:
only: master
- publish-latest:
requires:
- build
filters:
branches:
only: master
2. Add the environment variable by click on project setting option you will find Environment varible option
$DOCKERHUB_USERNAME →your dockerhub username
$DOCKERHUB_USERNAME → your dockerhub password
now it will automatically starts building your docker image and push it to your dockerhub account
Step 4 setup ec2 on aws and take ssh of it
commands to run on your terminal
a. ssh -i <your key pair name > ec2-user@<public ip>
c. apt update
Step 5 setup Minikube for kubernetes
command to run on your terminal
Now we have to write the sample.yaml file for pod deployment →
Below is the example file just replace the image name that is present in dockerhub repo
once you created a file then you have to run a command to craete a pod from file
you will see your pod is created and running having a private ip which you could use in checking
you will see your aplication is running inside a minikube cluster change now you are free to make changes in yaml file such as creating replicas etc.
Immediately Joiner| Java Full Stack | Production Support | Teacher by passion #JavaFullStackDeveloper #ReactDeveloper #JavaDeveloper #productionsupport #ITSMmanagement
7 个月Sensitive Data management