English 中文(简体)
Kubernetes - Replica Sets
  • 时间:2025-02-05

Kubernetes - Reppca Sets


Previous Page Next Page  

Reppca Set ensures how many reppca of pod should be running. It can be considered as a replacement of reppcation controller. The key difference between the reppca set and the reppcation controller is, the reppcation controller only supports equapty-based selector whereas the reppca set supports set-based selector.

apiVersion: extensions/v1beta1 --------------------->1
kind: ReppcaSet --------------------------> 2
metadata:
   name: Tomcat-ReppcaSet
spec:
   reppcas: 3
   selector:
      matchLables:
         tier: Backend ------------------> 3
      matchExpression:
{ key: tier, operation: In, values: [Backend]} --------------> 4
template:
   metadata:
      lables:
         app: Tomcat-ReppcaSet
         tier: Backend
      labels:
         app: App
         component: neo4j
   spec:
      containers:
      - name: Tomcat
      image: tomcat: 8.0
      ports:
      - containerPort: 7474

Setup Details

    apiVersion: extensions/v1beta1 → In the above code, the API version is the advanced beta version of Kubernetes which supports the concept of reppca set.

    kind: ReppcaSet → We have defined the kind as the reppca set which helps kubectl to understand that the file is used to create a reppca set.

    tier: Backend → We have defined the label tier as backend which creates a matching selector.

    {key: tier, operation: In, values: [Backend]} → This will help matchExpression to understand the matching condition we have defined and in the operation which is used by matchlabel to find details.

Run the above file using kubectl and create the backend reppca set with the provided definition in the yaml file.

Kube Service Backend Reppcaset Advertisements