DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Kubernetes — Replication, and Self-Healing
  • GitOps: Flux vs Argo CD
  • The Open Source Way to Rightsize Kubernetes With One Click
  • Advanced Kubernetes Deployment Strategies

Trending

  • How To Optimize Feature Sets With Genetic Algorithms
  • Top 7 Best Practices DevSecOps Team Must Implement in the CI/CD Process
  • Leveraging FastAPI for Building Secure and High-Performance Banking APIs
  • Harnessing the Power of In-Memory Databases: Unleashing Real-Time Data Processing
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Scaling a Kubernetes Cluster

Scaling a Kubernetes Cluster

Learn about using the Replication Controller to scale a Kubernetes cluster.

Arun Gupta user avatar by
Arun Gupta
·
Jul. 22, 15 · Tutorial
Like (1)
Save
Tweet
Share
2.72K Views

Join the DZone community and get the full member experience.

Join For Free

Automatic Restarting of Pods inside Replication Controller of Kubernetes Cluster shows how Kubernetes reschedule pods in the cluster if one or more of existing Pods disappear for some reason. This is a common usage pattern and one of the key features of Kubernetes.

Another common usage pattern of Replication Controller is scaling:

The replication controller makes it easy to scale the number of replicas up or down, either manually or by an auto-scaling control agent, by simply updating the replicas field.

Replication Controller#Scaling

This blog will show how a Kubernetes cluster can be easily scaled up and down.

All the code used in this blog is available at kubernetes-java-sample.

Start Replication Controller and Verify

  1. Start a Replication Controller as:

  2. ./cluster/kubectl.sh create -f ~/workspaces/kubernetes-java-sample/wildfly-rc.yaml 
    replicationcontrollers/wildfly-rc
  3. Get status of the Pods:

  4. ./cluster/kubectl.sh get -w po
    NAME      READY     STATUS    RESTARTS   AGE
    NAME               READY     STATUS    RESTARTS   AGE
    wildfly-rc-bgtkg   0/1       Pending   0          1s
    wildfly-rc-l8fqv   0/1       Pending   0         1s
    wildfly-rc-bgtkg   0/1       Pending   0         1s
    wildfly-rc-l8fqv   0/1       Pending   0         1s
    wildfly-rc-bgtkg   0/1       Pending   0         1s
    wildfly-rc-l8fqv   0/1       Pending   0         1s
    wildfly-rc-bgtkg   0/1       Running   0         1m
    wildfly-rc-l8fqv   0/1       Running   0         1m
    wildfly-rc-bgtkg   1/1       Running   0         1m
    wildfly-rc-l8fqv   1/1       Running   0         1m

    Make sure to wait for the status to change to Running. Note down name of the Pods as wildfly-rc-bgtkg” and wildfly-rc-bgtkg”.

  5. Get status of the Replication Controller:
  6. ./cluster/kubectl.sh get rc
    CONTROLLER   CONTAINER(S)     IMAGE(S)        SELECTOR       REPLICAS
    wildfly-rc   wildfly-rc-pod   jboss/wildfly   name=wildfly   2

    If multiple Replication Controllers are running then you can query for this specific one using the label:

    ./cluster/kubectl.sh get rc -l name=wildfly
    CONTROLLER   CONTAINER(S)     IMAGE(S)        SELECTOR       REPLICAS
    wildfly-rc   wildfly-rc-pod   jboss/wildfly   name=wildfly   2

Scaling Kubernetes Cluster Up

Replication Controller allows dynamic scaling up and down of Pods.

  1. Scale up the number of Pods:
  2. ./cluster/kubectl.sh scale --replicas=3 rc wildfly-rc
    scaled
  3. Status of the Pods can be seen in another shell:

  4. ./cluster/kubectl.sh get -w po
    NAME               READY     STATUS    RESTARTS   AGE
    wildfly-rc-k6pk2   1/1       Running   0          47s
    wildfly-rc-wez29   1/1       Running   0          47s
    NAME               READY     STATUS    RESTARTS   AGE
    wildfly-rc-aqaqn   0/1       Pending   0          0s
    wildfly-rc-aqaqn   0/1       Pending   0         0s
    wildfly-rc-aqaqn   0/1       Pending   0         0s
    wildfly-rc-aqaqn   0/1       Running   0         2s
    wildfly-rc-aqaqn   1/1       Running   0         11s

    Notice a new Pod with the name wildfly-rc-aqaqn is created.

Scale Kubernetes Cluster Down

  1. Scale down the number of Pods:
  2. ./cluster/kubectl.sh scale --replicas=1 rc wildfly-rc
    scaled
  3. Status of the Pods using -w is not correctly updated (#11338). But status of the Pods can be seen correctly as:
  4. ./cluster/kubectl.sh get po
    NAME               READY     STATUS    RESTARTS   AGE
    wildfly-rc-k6pk2   1/1       Running   0          9m

    Notice only one Pod is now running.

Kubernetes dynamically scales the Pods up and down using the scale --replicas command.

All code used in this blog is available at kubernetes-java-sample.

Kubernetes cluster Scaling (geometry) pods Replication (computing)

Published at DZone with permission of Arun Gupta, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Kubernetes — Replication, and Self-Healing
  • GitOps: Flux vs Argo CD
  • The Open Source Way to Rightsize Kubernetes With One Click
  • Advanced Kubernetes Deployment Strategies

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: