kubectl scale命令用于程序在負(fù)載加重或縮小時(shí)進(jìn)行pod擴(kuò)容或縮小,我們通過一些實(shí)際例子來觀察scale命令到底能達(dá)到什么效果。
在遷西等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站 網(wǎng)站設(shè)計(jì)制作按需求定制開發(fā),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),全網(wǎng)營銷推廣,成都外貿(mào)網(wǎng)站制作,遷西網(wǎng)站建設(shè)費(fèi)用合理。
命令行創(chuàng)建一個(gè)deployment:
kubectl run jerry-nginx --image=nginx:1.12.2
kubectl get deploy查看剛剛創(chuàng)建的deployment:
自動(dòng)被deployment創(chuàng)建的pod:
kubectl get pod:
使用下列命令查看生成的deployment明細(xì):
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
另一個(gè)有用的命令:
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: <none>
Host Port: <none>
Environment: <none>
Mounts: <none>
Volumes: <none>
Conditions:
Type Status Reason
Available True MinimumReplicasAvailable
Progressing True NewReplicaSetAvailable
OldReplicaSets: <none>
NewReplicaSet: jerry-nginx-69fd9f6c4 (1/1 replicas created)
Events:
Type Reason Age From Message
Normal ScalingReplicaSet 9m41s deployment-controller Scaled up replica set jerry-nginx-69fd9f6c4 to 1
現(xiàn)在我們使用下面的命令對(duì)deployment進(jìn)行水平擴(kuò)展:
kubectl scale deployment jerry-nginx --replicas=3
kubectl get pods -l run=jerry-nginx
下圖這個(gè)Age為15分鐘之前的是第一次創(chuàng)建deployment時(shí)生成的,其他兩個(gè)Age為1分鐘之前的是執(zhí)行了scale命令后自動(dòng)創(chuàng)建的。
選中一個(gè)才創(chuàng)建的pod,查看其事件記錄:
kubectl describe pod jerry-nginx-69fd9f6c4-8dpvb
kubectl get replicaset
得到自動(dòng)創(chuàng)建的replication set:
desired = 3意思就是我們水平擴(kuò)展時(shí)指定的參數(shù)3.
即使手動(dòng)刪除一個(gè)pod實(shí)例,replication set又會(huì)很快自動(dòng)創(chuàng)建一個(gè)新的:
自動(dòng)創(chuàng)建的新pod:
要獲取更多Jerry的原創(chuàng)文章,請(qǐng)關(guān)注公眾號(hào)"汪子熙":
新聞名稱:通過一個(gè)實(shí)際例子理解Kubernetes里pod的自動(dòng)scale-水平自動(dòng)伸縮
本文來源:http://jinyejixie.com/article34/gdjpse.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)、做網(wǎng)站、企業(yè)網(wǎng)站制作、小程序開發(fā)、網(wǎng)站策劃、品牌網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)