Lädt...

🔧 Learning Kubernetes: ReplicationController vs ReplicaSet


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

As I dive deeper into Kubernetes, I’ve been exploring the concepts of ReplicationControllers and ReplicaSets—two core constructs used to ensure high availability and scalability of pods in a Kubernetes cluster.

In this post, I’ll share what I learned, along with sample YAML definitions and key commands. Hopefully, it helps anyone else navigating this space too!

What is a ReplicationController?

A ReplicationController (RC) ensures that a specified number of pod replicas are running at any given time. While it’s considered a bit old-school now (ReplicaSet and Deployments have largely replaced it), it’s still a fundamental concept worth understanding.

Here’s a sample YAML to create a ReplicationController:

apiVersion: v1
kind: ReplicationController
metadata: 
  name: myrc
spec: 
  replicas: 5
  template:
    metadata:
      labels: 
        app: web
    spec:
      containers:
      - name: c1
        image: nginx

Basic ReplicationController Commands

List all RCs:

kubectl get rc or kubectl get replicationcontroller

Delete an RC:

kubectl delete rc <rc-name>

Scale the RC:

kubectl scale --replicas=<number> rc/<rc-name>

What is ReplicaSet?

A ReplicaSet (RS) is the next-gen version of RC, introduced with better support for label selectors, including set-based ones. It ensures that a specified number of pod replicas are maintained and is mostly used under the hood by Deployments.

Example 1: Equality-Based Selector:

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: mywebapp
spec:
  replicas: 5
  selector:
    matchLabels: 
      app: web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: c1
        image: nginx

Example 2: Set-Based Selector:

apiVersion: apps/v1
kind: ReplicaSet
metadata: 
  name: webdata
spec:
  replicas: 4
  selector:
    matchExpressions:
    - key: app
      operator: In
      values:
        - nginx
        - web
  template:
    metadata:
      labels:
        app: web
    spec:
      containers:
      - name: c1
        image: nginx

Basic Replica Set Commands:

List all ReplicaSets

kubectl get rs

This shows all the ReplicaSets in your current namespace.

Describe a ReplicaSet

kubectl describe rs <replicaset-name>

Provides detailed information including events, pod template, and selector.

Delete a ReplicaSet

kubectl delete rs <replicaset-name>

Deletes the ReplicaSet

Scale a ReplicaSet

kubectl scale rs/<replicaset-name> --replicas=3

Adjusts the number of desired pod replicas.

Edit a ReplicaSet

kubectl edit rs <replicaset-name>

Opens the ReplicaSet manifest in your default editor so you can make changes on the fly.

Apply from a YAML file

kubectl apply -f webrs.yml

Creates or updates a ReplicaSet from a manifest file.

View pods managed by a ReplicaSet

kubectl get pods -l app=web

Use label selectors to filter pods created by the ReplicaSet.

Key difference between ReplicationController and ReplicaSet:

Feature ReplicationController (RC) ReplicaSet (RS)
API Version v1 apps/v1
Label Selector Support Equality-based only Equality & set-based
Usage Legacy / older systems Modern replacement for RC
Used by Deployment No Yes
Flexibility Less flexible More flexible
Community Support Deprecated Actively supported

After getting comfortable with Replication Controllers and Replica Sets, I’ve realized they’re just the beginning. Now, I’m excited to dive into Deployments—the real game-changer for managing apps in Kubernetes!

...

🔧 Learning Kubernetes: ReplicationController vs ReplicaSet


📈 75.83 Punkte
🔧 Programmierung

🔧 Understanding the Differences Between ReplicationController, ReplicaSet, and Deployment in Kubernetes


📈 70.28 Punkte
🔧 Programmierung

🐧 Kubernetes ReplicaSet: Automatische Anpassung von Pods


📈 34.2 Punkte
🐧 Server

🔧 Kubernetes Workshop1 : Step4 : replicaset คืออะไร


📈 34.2 Punkte
🔧 Programmierung

🔧 Kubernetes Workshop1 : Step5 : การจัดการ replicaset


📈 34.2 Punkte
🔧 Programmierung

🐧 Understanding ReplicaSet in Kubernetes With Hands-on Example


📈 34.2 Punkte
🐧 Linux Tipps

🔧 Kubernetes ReplicaSet


📈 34.2 Punkte
🔧 Programmierung

🔧 Kubernetes: ReplicaSet


📈 34.2 Punkte
🔧 Programmierung

🔧 Deploying MongoDB ReplicaSet with Docker (Public VPS IP and User Authentication Required)


📈 26.98 Punkte
🔧 Programmierung

🔧 CKA Full Course 2024: Day 8/40 Deployment, Replication Controller and ReplicaSet Explained


📈 26.98 Punkte
🔧 Programmierung

🔧 Testcontainers MongoDB ReplicaSet


📈 26.98 Punkte
🔧 Programmierung

🔧 Replicaset vs Daemonset


📈 26.98 Punkte
🔧 Programmierung

🐧 MongoDB Replicaset: Daten kopieren und sichern


📈 26.98 Punkte
🐧 Server

🔧 Kubernetes Unlocked: From Kubernetes Zero to Kubernetes Hero!


📈 21.67 Punkte
🔧 Programmierung

📰 Learning ML or Learning About Learning ML?


📈 16.65 Punkte
🔧 AI Nachrichten

📰 Learning ML or Learning About Learning ML?


📈 16.65 Punkte
🔧 AI Nachrichten

🔧 🌟 Supervised Learning vs. Unsupervised Learning: A Complete Guide for Machine Learning Beginners


📈 16.65 Punkte
🔧 Programmierung

🐧 Is learning Linux the same as learning Bash? And if not, what does learning Linux consist of?


📈 16.65 Punkte
🐧 Linux Tipps

🔧 Kubernetes Observability: Lessons Learned From Running Kubernetes in Production


📈 14.44 Punkte
🔧 Programmierung

📰 heise-Angebot: Mastering Kubernetes 2022: In einem Tag zum Kubernetes-Profi werden


📈 14.44 Punkte
📰 IT Nachrichten

🔧 Asas Kubernetes - Hari 4. Bagaimana pentadbir Kubernetes mengawalselia sumber komponen.


📈 14.44 Punkte
🔧 Programmierung

🔧 Understanding Kubernetes: part 51 – Kubernetes 1.30 Changelog


📈 14.44 Punkte
🔧 Programmierung

🔧 🔭 OpenTelemetry in Action on Kubernetes: Part 3 - Deploying the Application on Kubernetes


📈 14.44 Punkte
🔧 Programmierung

🔧 Kubernetes Client and Server Version | Kubernetes Troubleshooting


📈 14.44 Punkte
🔧 Programmierung

🕵️ Kubernetes: XSS on kubernetes-csi.github.io (mdBook)


📈 14.44 Punkte
🕵️ Sicherheitslücken

🔧 Kubernetes Deployment with Ansible: A Comprehensive Guide to Bootstraping Kubernetes Clusters


📈 14.44 Punkte
🔧 Programmierung

🔧 Introducing Kubernetes MCP: Safe, Read-Only Kubernetes Operations with AI


📈 14.44 Punkte
🔧 Programmierung

🔧 Understanding Kubernetes: part 52 – Kubernetes 1.31 Changelog


📈 14.44 Punkte
🔧 Programmierung

🕵️ Medium CVE-2020-8554: Kubernetes Kubernetes


📈 14.44 Punkte
🕵️ Sicherheitslücken

🔧 Kubernetes Interview Questions: Kubernetes Architecture: Node


📈 14.44 Punkte
🔧 Programmierung

🐧 Changes to Kubernetes Slack (Kubernetes Contributors blog)


📈 14.44 Punkte
🐧 Linux Tipps