第9章:Kubernetes Pod控制器控制器应用进阶四

Deployment

kubectl explain deploy.spec.strategy
KIND: Deployment
VERSION: apps/v1

RESOURCE: strategy

DESCRIPTION:
The deployment strategy to use to replace existing pods with new ones.

 DeploymentStrategy describes how to replace existing pods with new ones.

FIELDS:
rollingUpdate
Rolling update config params. Present only if DeploymentStrategyType =
RollingUpdate.

type
Type of deployment. Can be “Recreate” or “RollingUpdate”. Default is
RollingUpdate.

最多可以多几个
maxSurge
The maximum number of pods that can be scheduled above the desired number
of pods. Value can be an absolute number (ex: 5) or a percentage of desired
pods (ex: 10%). This can not be 0 if MaxUnavailable is 0. Absolute number
is calculated from percentage by rounding up. Defaults to 25%. Example:
when this is set to 30%, the new ReplicaSet can be scaled up immediately
when the rolling update starts, such that the total number of old and new
pods do not exceed 130% of desired pods. Once old pods have been killed,
new ReplicaSet can be scaled up further, ensuring that total number of pods
running at any time during the update is at most 130% of desired pods.

最少不能少于几个(最多有几个不可用)
maxUnavailable
The maximum number of pods that can be unavailable during the update. Value
can be an absolute number (ex: 5) or a percentage of desired pods (ex:
10%). Absolute number is calculated from percentage by rounding down. This
can not be 0 if MaxSurge is 0. Defaults to 25%. Example: when this is set
to 30%, the old ReplicaSet can be scaled down to 70% of desired pods
immediately when the rolling update starts. Once new pods are ready, old
ReplicaSet can be scaled down further, followed by scaling up the new
ReplicaSet, ensuring that the total number of pods available at all times
during the update is at least 70% of desired pods.

注意:maxSurge和maxUnavailable不能同时为零,至少有一个大于零。

kubectl rollout history deployment 某deploy的具体名称
使用该命令可以查看某具体deploy的版本历史信息;

kubectl rollout undo deployment 某deploy的具体名称 --to-reversion=1
使用该命令可以使得某具体的deploy回滚到版本1,不加–to-reversion=1,也就是不指明具体版本,则默认回滚到上一个版本;

kubectl patch deployment 某deploy的具体名称 -p ‘{“spec”:{“replcas”: 5}}
使用该命令可以使得某具体deploy的副本数更新为5个;

kubectl set image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 … CONTAINER_NAME_N=CONTAINER_IMAGE_N
[options]
替换镜像,使用举例:
kubectl set image deployment 某deploy的具体名称 某容器的名字=想要替换的容器镜像地址和版本

Daemonset
kubectl apply -f ds-name.yaml
该命令用于创建一个名为ds-name的工作负载;

kubectl expose deployment redis --port=6379
该命令用于为redis的工作负载暴露服务端口为6379;

kubectl get pods
该命令用于查看当前命名空间下的pods情况;

kubectl get pods -w
该命令用于watch(盯着)当前命名空间下的pods情况;

kubectl exec -it 某个pod的name --/bin/sh
该命令用于进入到某个pod内部;

注意:daemonSet.strategy的rollingUpdate没有maxSurge,只有maxUnavailable;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Davidwatt

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值