Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
318 views
in Technique[技术] by (71.8m points)

kubernetes - Kubernetes:如何扩展我的豆荚(Kubernetes: how to scale my pods)

I'm new to Kubernetes.

(我是Kubernetes的新手。)

I try to scale my pods.

(我尝试缩放我的豆荚。)

First I started 3 pods:

(首先,我启动了3个Pod:)

./cluster/kubectl.sh run my-nginx --image=nginx --replicas=3 --port=80

There were starting 3 pods.

(开始有3个豆荚。)

First I tried to scale up/down by using a replicationcontroller but this did not exist.

(首先,我尝试使用复制控制器来按比例放大/缩小,但这并不存在。)

It seems to be a replicaSet now.

(现在好像是一个resetSet。)

./cluster/kubectl.sh get rs
NAME                  DESIRED   CURRENT   AGE
my-nginx-2494149703   3         3         9h

I tried to change the amount of replicas described in my replicaset:

(我尝试更改副本集中描述的副本数量:)

./cluster/kubectl.sh scale --replicas=5 rs/my-nginx-2494149703
replicaset "my-nginx-2494149703" scaled

But I still see my 3 original pods

(但我仍然看到我的3个原始豆荚)

./cluster/kubectl.sh get pods
NAME                        READY     STATUS    RESTARTS   AGE
my-nginx-2494149703-04xrd   1/1       Running   0          9h
my-nginx-2494149703-h3krk   1/1       Running   0          9h
my-nginx-2494149703-hnayu   1/1       Running   0          9h

I would expect to see 5 pods.

(我希望看到5个豆荚。)

./cluster/kubectl.sh describe rs/my-nginx-2494149703
Name:       my-nginx-2494149703
Namespace:  default
Image(s):   nginx
Selector:   pod-template-hash=2494149703,run=my-nginx
Labels:     pod-template-hash=2494149703
        run=my-nginx
Replicas:   3 current / 3 desired
Pods Status:    3 Running / 0 Waiting / 0 Succeeded / 0 Failed

Why isn't it scaling up?

(为什么不扩大规模?)

Do I also have to change something in the deployment?

(我是否还需要更改部署中的某些内容?)

I see something like this when I describe my rs after scaling up: (Here I try to scale from one running pod to 3 running pods).

(在放大后描述我的rs时,我会看到类似的内容:(在这里,我尝试从一个正在运行的Pod缩放到三个正在运行的Pod)。)

But it remains one running pod.

(但是它仍然是一个运行的吊舱。)

The other 2 are started and killed immediatly

(其他2个立即启动并被杀死)

  34s       34s     1   {replicaset-controller }            Normal      SuccessfulCreate    Created pod: my-nginx-1908062973-lylsz
  34s       34s     1   {replicaset-controller }            Normal      SuccessfulCreate    Created pod: my-nginx-1908062973-5rv8u
  34s       34s     1   {replicaset-controller }            Normal      SuccessfulDelete    Deleted pod: my-nginx-1908062973-lylsz
  34s       34s     1   {replicaset-controller }            Normal      SuccessfulDelete    Deleted pod: my-nginx-1908062973-5rv8u
  ask by DenCowboy translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

TL;DR: You need to scale your deployment instead of the replica set directly.

(TL; DR:您需要扩展部署,而不是直接扩展副本集。)

If you try to scale the replica set, then it will (for a very short time) have a new count of 5. But the deployment controller will see that the current count of the replica set is 5 and since it knows that it is supposed to be 3, it will reset it back to 3. By manually modifying the replica set that was created for you, you are fighting with the system controller (which is untiring and will pretty much always outlast you).

(如果您尝试缩放副本集,那么它(在很短的时间内)的新计数将为5。但是,部署控制器将看到副本集的当前计数为5,因为它知道应该这样做。设置为3,它将重置为3。通过手动修改为您创建的副本集,您正在与系统控制器(这很累,并且几乎总是比您更久)作战。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...