Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Understand the automatic scale-horizontal automatic scaling of pod in Kubernetes through a practical example

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The kubectl scale command is used to expand or shrink the pod when the load is increased or reduced. We use some practical examples to see what effect the scale command can achieve.

Create a deployment on the command line:

Kubectl run jerry-nginx-image=nginx:1.12.2

Kubectl get deploy view the deployment you just created:

Pod automatically created by deployment:

Kubectl get pod:

Use the following command to view the generated deployment details:

Kubectl get deployment jerry-nginx-o yaml

ApiVersion: extensions/v1beta1

Kind: Deployment

Metadata:

Annotations:

Deployment.kubernetes.io/revision: "1"

CreationTimestamp: 2018-11-29T08:29:06Z

Generation: 1

Labels:

Run: jerry-nginx

Name: jerry-nginx

Namespace: part-0110

ResourceVersion: "7203445"

SelfLink: / apis/extensions/v1beta1/namespaces/part-0110/deployments/jerry-nginx

Uid: d5c64f72-f3b0-11e8-b308-a20cb743f347

Spec:

ProgressDeadlineSeconds: 600

Replicas: 1

RevisionHistoryLimit: 2

Selector:

MatchLabels:

Run: jerry-nginx

Strategy:

RollingUpdate:

MaxSurge: 25%

MaxUnavailable: 25%

Type: RollingUpdate

Template:

Metadata:

CreationTimestamp: null

Labels:

Run: jerry-nginx

Spec:

Containers:

-image: nginx:1.12.2

ImagePullPolicy: IfNotPresent

Name: jerry-nginx

Resources: {}

TerminationMessagePath: / dev/termination-log

TerminationMessagePolicy: File

DnsPolicy: ClusterFirst

RestartPolicy: Always

SchedulerName: default-scheduler

SecurityContext: {}

TerminationGracePeriodSeconds: 30

Status:

AvailableReplicas: 1

Conditions:

LastTransitionTime: 2018-11-29T08:29:07Z

LastUpdateTime: 2018-11-29T08:29:07Z

Message: Deployment has minimum availability.

Reason: MinimumReplicasAvailable

Status: "True"

Type: Available

LastTransitionTime: 2018-11-29T08:29:06Z

LastUpdateTime: 2018-11-29T08:29:07Z

Message: ReplicaSet "jerry-nginx-69fd9f6c4" has successfully progressed.

Reason: NewReplicaSetAvailable

Status: "True"

Type: Progressing

ObservedGeneration: 1

ReadyReplicas: 1

Replicas: 1

UpdatedReplicas: 1

Another useful command:

Kubectl describe deployment jerry-nginx

Name: jerry-nginx

Namespace: part-0110

CreationTimestamp: Thu, 29 Nov 2018 16:29:06 + 0800

Labels: run=jerry-nginx

Annotations: deployment.kubernetes.io/revision: 1

Selector: run=jerry-nginx

Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable

StrategyType: RollingUpdate

MinReadySeconds: 0

RollingUpdateStrategy: 25% max unavailable, 25% max surge

Pod Template:

Labels: run=jerry-nginx

Containers:

Jerry-nginx:

Image: nginx:1.12.2

Port:

Host Port:

Environment:

Mounts:

Volumes:

Conditions:

Type Status Reason

Available True MinimumReplicasAvailable

Progressing True NewReplicaSetAvailable

OldReplicaSets:

NewReplicaSet: jerry-nginx-69fd9f6c4 (1 replicas created)

Events:

Type Reason Age From Message

Normal ScalingReplicaSet 9m41s deployment-controller Scaled up replica set jerry-nginx-69fd9f6c4 to 1

Now let's scale deployment horizontally using the following command:

Kubectl scale deployment jerry-nginx-replicas=3

Kubectl get pods-l run=jerry-nginx

The Age shown below was generated when the deployment was first created 15 minutes ago, and the other two Age were created automatically after the scale command was executed 1 minute ago.

Select a newly created pod to view its event record:

Kubectl describe pod jerry-nginx-69fd9f6c4-8dpvb

Kubectl get replicaset

Get the automatically created replication set:

Desired = 3 means the parameter 3 that we specify when we scale horizontally.

Even if you manually delete an instance of pod, replication set will soon automatically create a new one:

Automatically created new pod:

For more original Jerry articles, please follow the official account "Wang Zixi":

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report