目前刚开始写一个月,一共写了18篇原创文章,文章目录如下:
istio多集群探秘,部署了50次多集群后我得出的结论
istio多集群链路追踪,附实操视频
istio防故障利器,你知道几个,istio新手不要读,太难!
istio业务权限控制,原来可以这么玩
istio实现非侵入压缩,微服务之间如何实现压缩
不懂envoyfilter也敢说精通istio系列-http-rbac-不要只会用AuthorizationPolicy配置权限
不懂envoyfilter也敢说精通istio系列-02-http-corsFilter-不要只会vs
不懂envoyfilter也敢说精通istio系列-03-http-csrf filter-再也不用再代码里写csrf逻辑了
不懂envoyfilter也敢说精通istio系列http-jwt_authn-不要只会RequestAuthorization
不懂envoyfilter也敢说精通istio系列-05-fault-filter-故障注入不止是vs
不懂envoyfilter也敢说精通istio系列-06-http-match-配置路由不只是vs
不懂envoyfilter也敢说精通istio系列-07-负载均衡配置不止是dr
不懂envoyfilter也敢说精通istio系列-08-连接池和断路器
不懂envoyfilter也敢说精通istio系列-09-http-route filter
不懂envoyfilter也敢说精通istio系列-network filter-redis proxy
不懂envoyfilter也敢说精通istio系列-network filter-HttpConnectionManager
不懂envoyfilter也敢说精通istio系列-ratelimit-istio ratelimit完全手册
————————————————
•Job负责批量处理短暂的一次性任务 (short lived one-off tasks),即仅执行一次的任务,它保证批处理任务的一个或多个Pod成功结束.
•Never
•OnFailure
•如果RestartPolicy指定Never,则job会在pod出现故障时创建新的pod,且故障pod不会消失。.status.failed加1。
•如果RestartPolicy指定OnFailure,则job会在pod出现故障时其内部重启容器,而不是创建pod。.status.failed不变。
[root@master01 job]# cat busybox-never-job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: job
spec:
template:
spec:
restartPolicy: Never
containers:
- name: job
image: busybox
command: ["echooo","Hello World"]
[root@master01 job]# cat busybox-onfailure-job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: job
spec:
template:
spec:
restartPolicy: OnFailure
containers:
- name: job
image: busybox
command: ["echooo","Hello World"]
[root@master01 job]# cat busybox-completions-job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: job
spec:
completions: 2
template:
spec:
restartPolicy: OnFailure
containers:
- name: job
image: busybox
command:
- "sh"
args:
- "-c"
- "sleep 30 && echo helloword"
[root@master01 job]# cat busybox-parallelism-job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: job
spec:
parallelism: 2
template:
spec:
restartPolicy: OnFailure
containers:
- name: job
image: busybox
command:
- "sh"
args:
- "-c"
- "sleep 30 && echo helloword"
[root@master01 job]# cat busybox-completions-parallelism-job.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: job
spec:
parallelism: 2
completions: 2
template:
spec:
restartPolicy: OnFailure
containers:
- name: job
image: busybox
command:
- "sh"
args:
- "-c"
- "sleep 30 && echo helloword"
[root@master01 job]# cat busybox-activeDeadlineSeconds.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: job
spec:
activeDeadlineSeconds: 20
completions: 2
template:
spec:
restartPolicy: OnFailure
containers:
- name: job
image: busybox
command:
- "sh"
args:
- "-c"
- "sleep 30 && echo helloword"
•This field is alpha-level and is only honored by servers that enable the TTLAfterFinished feature.
•1.12版本之后,k8s提出了通过TTL自动删除Job的特性,当前仅对job生效,对 Complete 和 Failed 状态的Job都会自动删除
使用batch/v1时,用户需要将jod的spec.manualSelector设置为true,才可以定制selector。默认为false
[root@master01 job]# cat busybox-selector.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: job
spec:
manualSelector: true
selector:
matchLabels:
app: busybox
template:
metadata:
labels:
app: busybox
spec:
restartPolicy: Never
containers:
- name: job
image: busybox
command: ["echo","Hello World"]
•.spec.backoffLimit用于设置Job的容错次数,默认值为6。当Job运行的Pod失败次数到达.spec.backoffLimit次时,Job Controller不再新建Pod,直接停止运行这个Job,将其运行结果标记为Failure。另外,Pod运行失败后再次运行的时间间隔呈递增状态,例如10s,20s,40s
[root@master01 job]# cat busybox-backoffLimit.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: job
spec:
backoffLimit: 1
template:
spec:
restartPolicy: Never
containers:
- name: job
image: busybox
command: ["echooo","Hello World"]
•kubectl create job my-job --image=busybox – date
•kubectl create job my-job --image=busybox
•kubectl create job test-job --from=cronjob/a-cronjob
CronJob:
•CronJob即定时任务,就类似于Linux系统的crontab,在指定的时间周期运行指定的任务。
[root@master01 cronjob]# cat schedule-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob1
spec:
schedule: "*/1 * * * *"
jobTemplate:
metadata:
name: job
spec:
template:
metadata:
name: pod
spec:
restartPolicy: OnFailure
containers:
- name: busybox
image: busybox
command: ["echo","hello"]
imagePullPolicy: IfNotPresent
backoffLimit:
[root@master01 cronjob]# cat backoffLimit-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob1
spec:
schedule: "*/1 * * * *"
jobTemplate:
metadata:
name: job
spec:
backoffLimit: 1
template:
metadata:
name: pod
spec:
restartPolicy: OnFailure
containers:
- name: busybox
image: busybox
command: ["echooo","hello"]
imagePullPolicy: IfNotPresent
•.spec.suspend 字段也是可选的。如果设置为 true,后续所有执行都将被挂起。它对已经开始执行的 Job 不起作用。默认值为 false。
•kubectl patch cronjob cronjob1 -p '{"spec":{"suspend":false}}'
[root@master01 cronjob]# cat suspend-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob1
spec:
schedule: "*/1 * * * *"
suspend: true
jobTemplate:
metadata:
name: job
spec:
template:
metadata:
name: pod
spec:
restartPolicy: OnFailure
containers:
- name: busybox
image: busybox
command: ["echo","hello"]
imagePullPolicy: IfNotPresent
[root@master01 cronjob]# cat completion-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob1
spec:
schedule: "*/1 * * * *"
jobTemplate:
metadata:
name: job
spec:
completions: 2
template:
metadata:
name: pod
spec:
restartPolicy: OnFailure
containers:
- name: busybox
image: busybox
command: ["echo","hello"]
imagePullPolicy: IfNotPresent
[root@master01 cronjob]# cat parallelism-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob1
spec:
schedule: "*/1 * * * *"
jobTemplate:
metadata:
name: job
spec:
completions: 2
parallelism: 2
template:
metadata:
name: pod
spec:
restartPolicy: OnFailure
containers:
- name: busybox
image: busybox
command: ["echo","hello"]
imagePullPolicy: IfNotPresent
spec.concurrencyPolicy 字段也是可选的。它指定了如何处理被 Cron Job 创建的 Job 的并发执行。只允许指定下面策略中的一种:
注意,当前策略只能应用于同一个 Cron Job 创建的 Job。如果存在多个 Cron Job,它们创建的 Job 之间总是允许并发运行。
[root@master01 cronjob]# cat concurrencyPolicy-allow-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob1
spec:
concurrencyPolicy: Allow
schedule: "*/1 * * * *"
jobTemplate:
metadata:
name: job
spec:
completions: 2
parallelism: 2
template:
metadata:
name: pod
spec:
restartPolicy: OnFailure
containers:
- name: busybox
image: busybox
command: ["echo","hello"]
imagePullPolicy: IfNotPresent
[root@master01 cronjob]# cat concurrencyPolicy-forbid-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob1
spec:
concurrencyPolicy: Forbid
schedule: "*/1 * * * *"
jobTemplate:
metadata:
name: job
spec:
completions: 2
parallelism: 2
template:
metadata:
name: pod
spec:
restartPolicy: OnFailure
containers:
- name: busybox
image: busybox
command:
- "sh"
args:
- "-c"
- "sleep 70"
imagePullPolicy: IfNotPresent
[root@master01 cronjob]# cat concurrencyPolicy-replace-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob1
spec:
concurrencyPolicy: Replace
schedule: "*/1 * * * *"
jobTemplate:
metadata:
name: job
spec:
completions: 2
parallelism: 2
template:
metadata:
name: pod
spec:
restartPolicy: OnFailure
containers:
- name: busybox
image: busybox
command:
- "sh"
args:
- "-c"
- "sleep 70"
imagePullPolicy: IfNotPresent
.spec.startingDeadlineSeconds 字段是可选的。它表示启动 Job 的期限(秒级别),如果因为任何原因而错过了被调度的时间,那么错过执行时间的 Job 将被认为是失败的。如果没有指定,则没有期限
[root@master01 cronjob]# cat activeDeadlineSeconds-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob1
spec:
schedule: "*/1 * * * *"
jobTemplate:
metadata:
name: job
spec:
activeDeadlineSeconds: 10
template:
metadata:
name: pod
spec:
restartPolicy: OnFailure
containers:
- name: busybox
image: busybox
command:
- "sh"
args:
- "-c"
- "sleep 30"
imagePullPolicy: IfNotPresent
•.spec.successfulJobsHistoryLimit 和 .spec.failedJobsHistoryLimit 这两个字段是可选的。它们指定了可以保留完成和失败 Job 数量的限制。
[root@master01 cronjob]# cat failedJobsHistoryLimit-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob1
spec:
failedJobsHistoryLimit: 2
schedule: "*/1 * * * *"
jobTemplate:
metadata:
name: job
spec:
completions: 1
backoffLimit: 0
template:
metadata:
name: pod
spec:
restartPolicy: OnFailure
containers:
- name: busybox
image: busybox
command: ["echoioo","hello"]
imagePullPolicy: IfNotPresent
[root@master01 cronjob]# cat successfulJobsHistoryLimit-cronjob.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cronjob1
spec:
successfulJobsHistoryLimit: 1
schedule: "*/1 * * * *"
jobTemplate:
metadata:
name: job
spec:
completions: 2
template:
metadata:
name: pod
spec:
restartPolicy: OnFailure
containers:
- name: busybox
image: busybox
command: ["echo","hello"]
imagePullPolicy: IfNotPresent