DevOps Concepts

Why Cloud native?

  • Competitive advantage 
  • advanced Flexibility
  • Loosely coupled applications

Approaches to build software:

Traditional approach: Bimodal – Mode 1

  • GUI driven
  • Ticket based
  • Every server the application is deployed on is unique and hand-crafted
  • Scaling refers to the scaling up the servers
  • Proprietary making it more expensive

New approach: Cloud native/ Bimodal – Mode 2

  • API driven
  • Self service -> if anything breaks its self detected and fixed
  • Automated 
  • On-demand
  • Scale-out
  • Smart apps -> handles failures, fail safe
  • Built with 85% Open source softwares
  • Agile DevOps -> bring dev and operations together to collaborate to get additional value to the org

What is cloud native?

  • how the app is created and deployed, and not where
  • Automate and integrate concepts of devOps and CI/CD

Docker

What is Docker?

  • Docker is a set of platform as a service products that uses OS-level virtualization to deliver software in packages called containers.
  • Docker is the de facto standard to build and share containerized apps – from desktop, to the cloud.
  • Docker helps package Software into Standardized Units for Development, Shipment and Deployment.
  • A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

Docker Commands

docker container run –detach –publish 8080:80 –name nginx nginx

  • Detach flag is to run the process in the background
  • 8080:80 -> route the traffic to port 8080 from port 80
  • Nginx -> open source resource to load websites/ pictures etc

docker container stop 3a9

To stop the containers running -> use first 3 letters from the container names

docker system prune

To prune the system -> removes the stopped containers

export DOCKER_USER=<username>

docker login -u $DOCKER_USER

To login to docker hub

docker image build -t $DOCKER_USER/python-hello-world:v1 .

  • Build an image with a tag “tagname=python-hello-world:v1” 
  • It looks for the image to pull from the DockerHub under user DOCKER_USER

docker run -d -p 5000:5000 smayekar/python-hello-world:v1

To run the built image on port 5000 -> 5000 is the default port for Flask application

docker image ls

List all the images

docker push smayekar/python-hello-world:v2

Push the image with a specific tag

Kubernetes

  • Docker creates the containers – process running in isolation. 
  • K8s is a platform for container orchestration to the public internet 
  • K8s is a database (etcd) with watchers and controllers that react to changes in the DB

Kubenetes commands

kubectl run guestbook –image=ibmcom/guestbook:v1

Running a deployment guestbook pulling from the image “guestbook:v1”

kubectl get pods

Check if the pod is created and running

kubectl expose deployment guestbook –type=”NodePort” –port=3000

Exposing the service from the deployment “guestbook” by specifying the port

kubectl get service guestbook

Get the service “guestbook” details

kubectl scale –replicas=10 deployment guestbook && kubectl rollout status deployment guestbook

Scale up 10 replicas of the deployment

kubectl set image deployment/guestbook guestbook=ibmcom/guestbook:v2 && kubectl rollout status deployment guestbook

Update all the pods to version v2 now

kubectl get replicasets

To get all the replica sets – it will show all the pods with previous version – its just that they won’t be in use currently

kubectl rollout undo deployment guestbook && kubectl rollout status deployment guestbook

  • Undo deployment to the previous used version
  • Rollout status -> keeps giving the status of the replicas

kubectl delete deployment guestbook

Cleanup -> delete the deployment guestbook

kubectl delete service guestbook

To delete the service

kubectl create -f guestbook-deployment.yaml

To create a deployment from a deployment.yaml file

kubectl get pods -l app=guestbook

To filter the pods details by app name

kubectl apply -f guestbook-deployment.yaml

If you made changes to the deployment.yaml and you need them to be applied to your deployment pod and replicas, use apply

kubectl create -f guestbook-service.yaml

Creates the service guestbook from the service.yaml

kubectl describe service guestbook

Describes the service guestbook

kubectl get services

Get all the services

kubectl config view

To view what cluster we connected to

Difference between create and apply on kubectl:

If the resource you plan to create already exists and you ran a create, you will get error. With apply, if the resource does not exist, it will create it and if it already existed, it will update it.

Helm

Helm is the first application package manager running atop Kubernetes. It allows describing the application structure through convenient helm-charts and managing it with simple commands.

Helm Commands

helm list

Lists all helm deployments

helm version

Get Helm version

helm history guestbook-demo

List the history of a particular deployment

helm repo list

List the repositories

kubectl get all –namespace helm-demo

Get all the resources under a particular namespace

helm delete –purge guestbook-demo

Purge all the resources under a particular helm chart

helm install -> to install a new helm chart

helm upgrade -> to upgrade a helm chart

Leave a comment

Design a site like this with WordPress.com
Get started