Node Architecture and Scaling Pods Kubernetes | DevOps | VisualPath

Node Architecture

Scaling Pods

Scaling
• If your application is stateless you can horizontally scale it.
• Stateless means your application does not store files/data on the local file system.
• All Databases are stateful. They store database files locally.
• Most Web applications can be made stateless.
• Session Management needs to be done outside the container
• Any file that needs to be saved can’t be saved locally on the computer
• Scaling in Kubernetes can be done using the Replication Controller.
• The replication controller will ensure a specified number of pod replicas will run at all time
• A pod created with the replica controller will automatically be replaced if they fil, get deleted or are terminated.
• Using the replication controller is also recommended if you just want to make sure 1 pod is always running, even after reboots.
• Replicating our pod two times.
 • Check pod & RC (replication controller) with kubectl get & kubectl describe command.
 • Delete one pod to see scaling
 • Scale Up/Down the replication controller.
 • Scale Up/Down with the replication controller’s definition file

Deployments

Replication Set
• A replica set is the next generation Replication Controller.
• It supports a new selector that can do selection based on filtering according to a set of values.
• e.g “environment” either “dev” or “qa”
• not only based on equality like the Replication Controller -> e.g “environment” == “dev”
• This Replica Set rather than the Replication Controller is used by the Deployment object.
Deployments
• A deployment declaration in Kubernetes allows you to do app deployments and updates.
• When using the deployment object, you define the state of your application.
• Kubernetes will then make the clusters matches your desired state.
• Just using the replication controller or replication set might be cumbersome to deploy apps.
• The Deployment Object is easier to use and gives you more possibilities.
• With a deployment object, you can:
• Create a deployment (e.g deploying an app)
• Update a deployment (e.g deploying the latest version)
• Do rolling updates (zero downtime deployments)
• Roll back to a previous version
• Pause/Resume a deployment (e.g to roll-out to only a certain percentage)
• Sample Deployment Definition
• Useful Commands
• Deployment:
• Create deployment
• Get info on deployment, Replication set (rs), pod, rollout status 
• Build k8s-demo image with next version, V2.
• Copy docker-demo directory content into another directory.
• Edit index.js file, update string in res.send to something like “version 2”.
• Build the image with tag V2.
• Push the latest image to dockerhub registry.
• Verify from dockerhub


 
 • Expose the existing deployment with NodePort.
 • NodePort is 32400 as per above output. • Allow this port in Security group of master node so that we can connect to this service.
• Verify Master node IP and exposed port.
 • Upgrade the image version to V2 from Deployment.
 • Verify from browser & curl.

 • Deployment Rollout History.
 • Rollback previous version.
 • Increasing rollout history limit from just two to many.

• Rollout with version number.
 
For more information about Visualpath, visit www.visualpath.in and follow the company on Facebook and Twitter.
For DevOps training contact us at +91 9704455959 / info@visualpath.in

Comments