1

Preliminary remark: The word replica means repetition or copy for me, but:

When someone speaks of "one replica", does that mean one instance or two instances in total? Interestingly, I have come across the use of the former case and this makes me a little insecure. Based on the second case, would one speak of "zero replicas" if there is only one app or instance in total?

Sorry if that question seems a bit vague. Example time. My app or instance has 8 different containers in 8 different pods.

+------------+--------------+--------------+
| #container |    case 1    |    case 2    |
+------------+--------------+--------------+
| 8 x 1      | "1 replica"  | "0 replicas" |
| 8 x 2      | "2 replicas" | "1 replica"  |
| 8 x 3      | "3 replicas" | "2 replicas" |
| ...        | ...          | ...          |
+------------+--------------+--------------+

The question whether the word replica refers to a single container/pod or to the whole app is not important here (it is equivalent), because I will replicate each different container/pod of the 8 containers/pods with the same number. I would like to know if you would rather use case 1 or case 2 (in discussions among colleagues), or if the numbering is one-based or zero-based. Please mark the question as opinion-based, if necessary.

uav
  • 494
  • 3
  • 16

1 Answers1

1

Your question depends on many scenario factors. It's hard to say as you did not provide whole scenario. However you put Kubernetes tag so I can answer regarding Kubernetes.

If you are referring to Replica in Kubernetes it means how many pods of the same application should run in cluster.

It's described in Kubernetes docs that, when you create Deployment, it creates ReplicaSet which is responsible for number of existing pods (number of replicas).

If you will deploy and scale replicas value in Deployment it will automatically apply changes to ReplicaSet.

$ kubectl run nginx --image=nginx --replicas=3
kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.
deployment.apps/nginx created
$ kubectl get pods
NAME                     READY   STATUS    RESTARTS   AGE
nginx-7db9fccd9b-4gzfd   1/1     Running   0          9s
nginx-7db9fccd9b-7msm2   1/1     Running   0          9s
nginx-7db9fccd9b-mfj9s   1/1     Running   0          9s

$ kubectl scale deployment nginx --replicas=1
deployment.extensions/nginx scaled
$ kubectl get pods
NAME                     READY   STATUS    RESTARTS   AGE
nginx-7db9fccd9b-7msm2   1/1     Running   0          78s

In Kubernetes, if you will set replica value to 0, you will not have any running pod in this specific Deployment.

$ kubectl scale deploy nginx --replicas=0
deployment.extensions/nginx scaled
sekreta@cloudshell:~ (composite-rune-239911)$ kubectl get deploy
NAME    READY   UP-TO-DATE   AVAILABLE   AGE
nginx   0/0     0            0           6m48s

So if you are asking about meaning of Replica regarding Kubernetes concept, proper is case 1.

PjoterS
  • 615
  • 3
  • 11
  • Thanks. Yes, at first I only talked about containers, because in my pods there is only one container at a time (1-to-1 relationship) and the terms container and pods should be used synonymously in this case. Let me count your answer so that my colleague is right and I am wrong with my assessment that using the word "replica" is similar to using the word "copy". – uav Apr 02 '20 at 12:57