logo
  • Blog
  • The Cloud
  • DevOps
  • Trending
    • Blockchain
    • Bitcoin
  • How To
  • Kubernetes

 

  • Introduction to Kubernetes
  • Kubernetes Introduction
  • Container Introduction
  • Kubernetes Setup
  • Local Setup with Minikube
  • Minikube Demo
  • Kubernetes using the Docker client
  • Minikube vs Docker Client vs Kops vs Kubeadm
  • Introduction to Kops
  • Demo: Preparing Kops install
  • Demo: DNS Troubleshooting
  • Demo: Cluster setup on AWS using kops
  • Building Docker containers
  • Demo: Building docker containers
  • Docker Image Registry
  • Demo: Pushing Docker Image
  • Running first app on Kubernetes
  • Demo: Userful commands
  • Service with LoadBalancer
  • Demo: Service with AWS ELB LoadBalancer
  • Kubernetes Basic
  • Node Architecture
  • Replication Controller
  • Demo Replication Controller
  • Deployments
  • Demo: Deployments
  • Services
  • Demo: Services
  • Labels
  • Demo: NodeSelector using Labels
  • Healthchecks
  • Demo: Healthcheck
  • Readiness Probe
  • Demo: Liveness and Readiness probe
  • Pod State
  • Pod Lifecycle
  • Demo: Pod Lifecycle
  • Secrets
  • Demo: Credentials using Volumes
  • Demo: Running WordPress on K8s
  • WebUI
  • Demo: Web UI in Kops
  • Demo: WebUI
  • Advanced Topic
  • Service Discovery
  • Demo: Service Discovery
  • ConfigMap
  • Demo: ConfigMap
  • Ingress Controller
  • Demo: Ingress Controller
  • External DNS
  • Demo: External DNS
  • Volumes
  • Demo: Volumes
  • Volumes Autoprovisioning
  • Demo: WordPress with Volumes
  • Pod Presets
  • Demo: Pod Presets
  • StatefulSets
  • Demo: StatefulSets
  • Daemon Sets
  • Resource Usage Monitoring
  • Demo: Resource Usage Monitoring
  • Autoscaling
  • Demo: Autoscaling
  • Affinity / Anti-Affinity
  • Demo: Affinity / Anti-Affinity
  • Interpod Affinity and Anti-Affinity
  • Demo: Interpod Affinity
  • Demo Interpod Anti-Affinity
  • Taints and Tolerations
  • Demo: Taints and Tolerations
  • Custom Resource Definitions (CRDs)
  • Operators
  • Demo: postgresql-operator
  • Kubernetes Administration
  • The Kubernetes Master Services
  • Resource Quotas
  • Namespaces
  • Demo: Namespace quotas
  • User Managements
  • Demo: Adding Users
  • RBAC
  • Demo: RBAC
  • Networking
  • Node Maintenance
  • Demo: Node Maintenance
  • High Availability
  • Demo: High Availability
  • TLS on ELB using Annotations
  • Demo: TLS on ELB
  • Packaging and Deploying on Kubernetes
  • Introduction to Helm
  • Demo: Helm
  • Creating your own Helm Charts
  • Demo: Creating your own Helm Charts
  • Demo: Nodejs app Helm Chart
  • Demo: Setting up a Helm Repository on S3
  • Demo: Building and Deploying Helm Charts with Jenkins
  • Serverless on Kubernetes
  • Introduction to Serverless
  • Introduction to Kubeless
  • Demo: Creating Functions with Kubeless
  • Demo: Triggering Kubeless Functions with Kafka
  • Microservices
  • Introduction to Istio
  • Demo: Istio Installation
  • Demo: An Istio enables app
  • Demo: Advances routing with Istio
  • Installing Kubernetes using kubeadm
  • Introduction to kubeadm
  • Demo: kubeadm (Part 1)
  • Demo: kubeadm (Part 2)
  • On-Prem or Cloud Agnostic Kubernetes
  • Managing TLS Certs with Cert-Manager
  • Demo: Cert-Manager (Part 1)
  • Demo: Cert-Manager (Part 2)

Replication Controller

In this tutorial, you will learn about scaling of the pods.

If your application is stateless then you can horizontally scale it. Stateless means your application does not have a state, it does not write any local file or keeps any local sessions.

All traditional databases like MySQL, Postgres are stateful, they have database files that can not be split over multiple instances.

Most of the web application can be made stateless. To make web application stateless, you must do Session management outside the container. If you are getting hits to your applicationa and you want to keep record of your visitors then you need to keep these information outside of the containers, you can not store your data within the container. You can use memcached, redis, or database to store you data or information in it.

Any file that need to be saved cannot be saved locally on the container, because if you will stop your container and start it again, you will loose your data, so that you need to save any file outside of the container.

We will see an example of stateless container, if the same app would run multiple times, it does not change the state.

For learning more on cloud native or container apps best practice you can have a look at 12factor.net

Still you want to run stateful apps? then you will be learning, how to use volumes with pods to store the state of the app. Those stateful apps cannot horizontally scale, but you can run them in a single container and vertically scale (allocate more CPU/Memory/Desk).

How to scale apps in Kubernetes?

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 the time.

A pod created with the replica controller will automatically be replaced if they fail, get delete, or get terminated.

Using the replication controller also ensures to always run 1 pod always running even after node reboot.

Replication controller can be run with just 1 replica or multiple replicas. It ensures that pod must be keep running even after node get crashes.

Replication Controller example

apiVersion: v1
kind: ReplicationController
metadata:
  name: helloworld-controller
spec:
  replicas: 2
  selector:
    app: helloworld
  template:
    metadata:
      labels:
        app: helloworld
    spec:
      containers:
      - name: k8s-demo
        image: vermanotes/k8s-demo
        ports:
        - containerPort: 3000

Scale Pod Replicas through kubectl

Use following `kubectl scale` command to increase or descrease the number of replicas of a Replication Controller.

`$ kubectl scale –replicas=4 rc/helloworld-controller`

  • Previous page
  • Next page

 344 total views,  2 views today

Replication Controller was last modified: March 2nd, 2020 by Sushil Verma
Share on Facebook
Facebook
0Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin
Email this to someone
email

Latest Blogs

  • Linux: Viewing Log Messages
  • AWS CodeBuild: Getting Started
  • AWS CodeCommit: Set up Notifications
  • AWS CodeCommit: Securing The Repository and Branches
  • Managing Systemd units in Linux

Tags

Amazon EC2 AWS bash_shell bitcoin blockchain Cloud computing CodeCommit DevOps digital currency Kubernetes Linux trending ubuntu

For Improving Education

Categories

  • Amazon EC2
  • Amazon Web Services
  • AWS
  • AWS CodeCommit
  • Bash shell
  • Best Practices
  • Bitcoin
  • Blockchain
  • Chaincode
  • CLI
  • Cloud Computing
  • Cloud Security
  • CodeBuild
  • CodeCommit
  • CryptoCurrency
  • Cryptography
  • DevOps
  • Digital Currency
  • EC2 Lambda
  • Hyperledger
  • IBM Bluemix
  • IBM Garage
  • Kubernetes
  • Linux
  • Monitoring
  • OpenStack
  • Platform as a Service
  • TDD
  • Trending
  • Ubuntu
  • Virtual Server
Home | Site Map | Privacy Policy | Site Terms | Terms of use @2013, Times of Cloud.
The content is copyrighted to 'Times of Cloud' and may not be reproduced on other websites.