When you deploy a pod to a Kubernetes cluster, you create pod replays to scale an application or service. The most productive way to handle those plays is to use a ReplicaSet, which ensures that the specified playback pods are still running in the desired state. Without a ReplicaSet, you would need to create multiple manifests for a certain number of pods required for a single application or service.
For those who have been Kubernetes for some time, ReplicaSet is considered the next-generation replacement of the replication controller.
I need to show you how to create a ReplicaSet on a running Kubernetes cluster. We’ll use the NGINX pod shown as an example (since you’re already familiar with the implementation of that pod).
SEE: Recruitment Kit: Database Administrator (TechRepublic Premium)
To create a ReplicaSet, you want a Kubernetes cluster to run. If you haven’t already deployed that cluster, read my article: How to Deploy a Kubernetes Cluster to an Ubuntu Server. If you have deployed your cluster to a third-party service, such as AWS, this consultant deserves to work without much change.
As expected, I’ll demonstrate it with a Kubernetes cluster running on 3 Ubuntu Server instances.
As with almost everything related to Kubernetes, we describe our ReplicaSet a YAML record. Create the record with the command:
Let’s look at the contents of the log. The first two lines describe which API edition to use (v1) and what the YAML (ReplicaSet) record will be implemented. These lines are:
The following segment defines the pod metadata, which indicates what we’re looking for with the pod. In our example, we create an NGINX pod proxy to serve as an interface. This segment looks like:
In the next segment, we set the replicaSet specifications. We start by implementing five replicas, then use matchLabels to tell Kubernetes which pods the implementation will apply to (in our case, nginx-proxy). We’ll also call the boxes and outline the symbol to be used for the pod (nginx). This segment looks like:
When you gather all this YAML, it’s like:
Save and file.
Now that you have your YAML record together, we’ll deploy it to create five replicas of the NGINX pod. To do this, run the command:
You can use the command:
The command indicates that the ReplicaSet was created. You can check it with the command:
You will see the new ReplicaSet running (Figure A).
Figure A
Our ReplicaSet has been implemented effectively.
Suppose you have to build ReplicaSet from five to ten. It’s very simple. Open your YAML record and replace the line:
To:
Save and file. Rerun the command:
You will see replicaset.apps / nginx-proxy configured informed. To verify the change, run the command:
Now you see that ReplicaSet is in the new desired state (Figure B).
Figure B
We’ve reduced our replicas from five to ten.
You can also prestige individual pods with the command:
You will see all 10 pods running (Figure C).
Figure C
Our 10 NGINX proxy pods are running.
And that’s how simple it is to implement a ReplicaSet Kubernetes. To learn more about this feature, be sure to read the official Kubernetes documentation.
How a Database Administrator: A Cheat Sheet (TechRepublic)
10 things that corporations stay in their own knowledge centers (download TechRepublic)
How to create a Kubernetes name (TechRepublic)
How Large-Scale Knowledge Centers Are Reshaping All IT (ZDNet)
Best Cloud Services for Small Businesses (CNET)
DevOps: more policies to read (TechRepublic on Flipboard)
Jack Wallen is an award for TechRepublic and Linux.com. He is an avid promoter of open source and voice of the Android expert. To learn more about Jack Wallen, visit his online page jackwallen.com.