赞
踩
pod的托管机制
组成:
①label selector(标签选择器,用于确定ReplicationController作用域中的pod)
②replica count(副本个数,指定运行pod的期望数量)
③pod template(pod模板)
将pod移出ReplicationController的作用域:修改pod标签label
kubectl label pod <pod name> <label=xxx> --overwrite
ReplicationControllerd的进阶版,ReplicaSet的标签选择能力更强(如仅标签名就可匹配),并将逐渐替换掉ReplicationController
apiVersion: apps/v1 kind: ReplicaSet metadata: name: kubia spec: replicas: 3 selector: matchLabels: app: kubia template: metadata: labels: app: kubia spec: containers: - name: kubia image: luksa/kubia
selector:
matchLabels:
- key: app
operator: In
values:
- kubia
①In: pod的label值必须与指定values相同
②NotIn:pod的label值必须与任何指定values不相同
③Exists:pod必须包含一个指定的label名(不关心值),此时matchLabels不要指定values值
④DoesNotExists:pod不得包含指定的label名,此时matchLabels不要指定values值
用于设置在集群每个节点上运行一个pod实例
spec:
nodeSelector:
disk:ssd
containers:
- name: main
image: luksa/ssd-monitor
设置任务可结束的pod
apiVersion: batch/v1 kind: Job metadata: name: batch-job spec: completions: 5 parallelism: 3 template: metadata: labels: app: batch-job spec: restartPolicy: OnFailure containers: - name: main image: luksa/batch-job
该Job类型运行一个luksa/batch-job的镜像,执行一个120s的进程后退出
可以设置定时任务(cron时间表),如每15分钟执行一次,每个周日执行一次等
apiVersion: batch/v1beta1 kind: CronJob metadata: name: batch-job-every-five-minutes spec: schedule: "0,5,15,20,25,30 * * * *" jobTemplate: spec: template: metadata: labels: app: periodic-batch-job spec: restartPolicy: OnFailure containers: - name: main image: luksa/batch-job
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。