新增说明及示例文件

This commit is contained in:
2023-12-15 16:39:01 +08:00
committed by huty
parent 823b19c3f0
commit 3445c145aa
71 changed files with 4048 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
# CronJob 说明,官方文档: https://v1-22.docs.kubernetes.io/zh/docs/concepts/workloads/controllers/cron-jobs
# API 版本
apiVersion: batch/v1
# 资源类型
kind: CronJob
# 元数据
metadata:
## 名称
name: 此 CronJob 的名称
## 命名空间
namespace: 此 CronJob 所属命名空间
## 标签
labels:
标签名1: 标签值1
标签名2: 标签值2
# 内容
spec:
## 此 CronJob 的执行周期【语法见https://v1-22.docs.kubernetes.io/zh/docs/concepts/workloads/controllers/cron-jobs/#cron-%E6%97%B6%E9%97%B4%E8%A1%A8%E8%AF%AD%E6%B3%95】
schedule: 此 CronJob 的执行周期
## 此 CronJob 执行的 Job
jobTemplate:
### Job 的内容
spec:
#### 指定 Job 的 Pod 模板(内容参考 Pod 的 Yaml
template:
##### Pod 的内容
spec:
###### Pod 的容器
containers:
####### 容器1
######## 容器1的名称
- name: 容器1的名称
######## 容器1使用的镜像
image: 容器1使用的镜像
######## 镜像拉取规则
imagePullPolicy: IfNotPresent
######## 执行的命令
command:
- 命令1
- 命令2
###### 容器重启策略【Never不重启OnFailure失败时重启】
restartPolicy: 容器重启策略【Never不重启OnFailure失败时重启】

View File

@@ -0,0 +1,24 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: example-hello
namespace: demo
labels:
name: example-hello
app: hello
type: cronjob
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure

View File

@@ -0,0 +1,95 @@
# DaemonSet 说明,官方文档: https://v1-22.docs.kubernetes.io/zh/docs/concepts/workloads/controllers/daemonset
# API 版本
apiVersion: apps/v1
# 资源类型
kind: DaemonSet
# 元数据
metadata:
## 名称
name: 此 DaemonSet 的名称
## 命名空间
namespace: 此 DaemonSet 所属命名空间
## 标签
labels:
标签名1: 标签值1
标签名2: 标签值2
# 内容
spec:
## 指定 Pod 选择器( 此 DaemonSet 需要管理哪些 Pod
selector:
### 指定标签选择器
matchLabels:
标签名1: 标签值1
标签名2: 标签值2
## 指定 Pod 模板
template:
### Pod 的元数据
metadata:
#### Pod 的标签(需要和上面 matchLabels 中配置的标签一致)
labels:
标签名1: 标签值1
标签名2: 标签值2
### Pod 的内容
spec:
#### Pod 的容忍度(需要在哪些节点上部署 Pod
tolerations:
##### Pod 的容忍度 1
###### 容忍度 1 的 key
- key: 容忍度 1 的 key
###### 容忍度 1 的表达式【Equal等于Exists存在】
operator: 容忍度 1 的表达式
###### 容忍度 1 的值
value: 容忍度 1 的值
###### 容忍度 1 的效果
effect: 容忍度 1 的效果
#### Pod 的终止宽限期(秒)
terminationGracePeriodSeconds: Pod 的终止宽限期(秒)
#### Pod 的容器
containers:
##### 容器1
###### 容器1的名称
- name: 容器1的名称
###### 容器1使用的镜像
image: 容器1使用的镜像
###### 容器1的资源
resources:
####### 限制资源
limits:
######## 限制的内存
memory: 限制的内存
####### 请求资源
requests:
######## 请求的 CPU
cpu: 请求的 CPU
######## 请求的内存
memory: 请求的内存
###### 容器1使用的持久卷
volumeMounts:
####### 持久卷1
######## 持久卷1的名称
- name: 持久卷1的名称
######## 持久卷1的挂载路径容器内
mountPath: 持久卷1的挂载路径容器内
####### 持久卷2
######## 持久卷2的名称
- name: 持久卷2的名称
######## 持久卷2的挂载路径容器内
mountPath: 持久卷2的挂载路径容器内
######## 容器内是否只读
readOnly: true
#### 持久卷
volumes:
##### 持久卷1
###### 持久卷1的名称
- name: 持久卷1的名称
###### 持久卷1的路径宿主机目录
hostPath:
####### 持久卷1的路径宿主机目录
path: 持久卷1的路径宿主机目录
##### 持久卷2
###### 持久卷2的名称
- name: 持久卷2的名称
###### 持久卷2的路径宿主机目录
hostPath:
####### 持久卷2的路径宿主机目录
path: 持久卷2的路径宿主机目录

View File

@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: example-elasticsearch-fluentd
namespace: demo
labels:
name: elasticsearch-fluentd
app: elasticsearch-fluentd
type: daemonset
spec:
selector:
matchLabels:
name: elasticsearch-fluentd
app: elasticsearch-fluentd
type: pod
template:
metadata:
labels:
name: elasticsearch-fluentd
app: elasticsearch-fluentd
type: pod
spec:
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
terminationGracePeriodSeconds: 30
containers:
- name: fluentd-elasticsearch
image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: varlog
mountPath: /var/log
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
volumes:
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers

View File

@@ -0,0 +1,45 @@
# Deployment 说明,官方文档: https://v1-22.docs.kubernetes.io/zh/docs/concepts/workloads/controllers/deployment
# API 版本
apiVersion: apps/v1
# 资源类型
kind: Deployment
# 元数据
metadata:
## 名称
name: 此 Deployment 的名称
## 命名空间
namespace: 此 Deployment 所属命名空间
## 标签
labels:
标签名1: 标签值1
标签名2: 标签值2
# 内容
spec:
## 指定副本数
replicas: 期望副本数
## 指定 Pod 选择器( 此 Deployment 需要管理哪些 Pod
selector:
### 指定标签选择器
matchLabels:
标签名1: 标签值1
标签名2: 标签值2
## 指定 Pod 模板
template:
### Pod 的元数据
metadata:
#### Pod 的标签(需要和上面 matchLabels 中配置的标签一致)
labels:
标签名1: 标签值1
标签名2: 标签值2
### Pod 的内容
spec:
#### Pod 的容器
containers:
##### 容器1
###### 容器1的名称
- name: 容器1的名称
###### 容器1使用的镜像
image: 容器1使用的镜像
###### 容器1使用的端口号
ports:
- containerPort: 80

View File

@@ -0,0 +1,28 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: example-nginx
namespace: demo
labels:
name: nginx
app: nginx
type: deployment
spec:
replicas: 3
selector:
matchLabels:
name: nginx
app: nginx
type: pod
template:
metadata:
labels:
name: nginx
app: nginx
type: pod
spec:
containers:
- name: nginx
image: nginx:1.23.3
ports:
- containerPort: 80

View File

@@ -0,0 +1,45 @@
# Deployments 说明,官方文档: https://v1-22.docs.kubernetes.io/zh/docs/concepts/workloads/controllers/deployment
# API 版本
apiVersion: apps/v1
# 资源类型
kind: Deployments
# 元数据
metadata:
## 名称
name: 此 Deployments 的名称
## 命名空间
namespace: 此 Deployments 所属命名空间
## 标签
labels:
标签名1: 标签值1
标签名2: 标签值2
# 内容
spec:
## 指定副本数
replicas: 期望副本数
## 指定 Pod 选择器( 此 Deployments 需要管理哪些 Pods
selector:
### 指定标签选择器
matchLabels:
标签名1: 标签值1
标签名2: 标签值2
## 指定 Pod 模板
template:
### Pod 的元数据
metadata:
#### Pod 的标签(需要和上面 matchLabels 中配置的标签一致)
labels:
标签名1: 标签值1
标签名2: 标签值2
### Pod 的内容
spec:
#### Pod 的容器
containers:
##### 容器1
###### 容器1的名称
- name: 容器1的名称
###### 容器1使用的镜像
image: 容器1使用的镜像
###### 容器1使用的端口号
ports:
- containerPort: 80

View File

@@ -0,0 +1,28 @@
apiVersion: apps/v1
kind: Deployments
metadata:
name: example-nginx
namespace: demo
labels:
name: nginx
app: nginx
type: deployments
spec:
replicas: 3
selector:
matchLabels:
name: nginx
app: nginx
type: pod
template:
metadata:
labels:
name: nginx
app: nginx
type: pod
spec:
containers:
- name: nginx
image: nginx:1.23.3
ports:
- containerPort: 80

View File

@@ -0,0 +1,48 @@
# Job 说明,官方文档: https://v1-22.docs.kubernetes.io/zh/docs/concepts/workloads/controllers/job
# API 版本
apiVersion: batch/v1
# 资源类型
kind: Job
# 元数据
metadata:
## 名称
name: 此 Job 的名称
## 命名空间
namespace: 此 Job 所属命名空间
## 标签
labels:
标签名1: 标签值1
标签名2: 标签值2
# 内容
spec:
## 是否挂起此 Jobtrue挂起false不挂起立即执行
suspend: 是否挂起此 Job
## 指定 Pod 模板(内容参考 Pod 的 Yaml
template:
### Pod 的内容
spec:
#### Pod 的容器
containers:
##### 容器1
###### 容器1的名称
- name: 容器1的名称
###### 容器1使用的镜像
image: 容器1使用的镜像
###### 容器1运行的命令
command:
- 命令1
- 命令2
#### 容器重启策略【Never不重启OnFailure失败时重启】
restartPolicy: 容器重启策略【Never不重启OnFailure失败时重启】
## 失败重试次数(重试次数到达此值后,此 Job 标记为失败)
backoffLimit: 失败重试次数
## Job 活跃期限Job 运行时间达到此值后,此 Job 标记为失败,优先级高于 backoffLimit
activeDeadlineSeconds: Job 活跃期限(秒)
## Pod 完成模式【NonIndexed当成功完成的 Pod 个数达到 .spec.completions 所设值时认为 Job 已经完成IndexedJob 的 Pod 会获得对应的完成索引,取值为 0 到 .spec.completions-1当每个索引都对应一个完成完成的 Pod 时Job 被认为是已完成的】
completionMode: Pod 完成模式
## Pod 完成量(当成功的 Pod 个数达到次数时,该 Job 视为完成)
completions: Pod 完成量
## Pod 工作队列
parallelism: Pod 工作队列
## Job 完成(状态为 Complete 或 Failed后自动清除时间
ttlSecondsAfterFinished: Job 完成(状态为 Complete 或 Failed后自动清除时间

View File

@@ -0,0 +1,18 @@
apiVersion: batch/v1
kind: Job
metadata:
name: example-pi
namespace: demo
labels:
name: example-pi
app: pi
type: job
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 4

View File

@@ -0,0 +1,40 @@
# Jobs 说明,官方文档: https://v1-22.docs.kubernetes.io/zh/docs/concepts/workloads/controllers/job
# API 版本
apiVersion: apps/v1
# 资源类型
kind: Jobs
# 元数据
metadata:
## 名称
name: 此 Jobs 的名称
## 命名空间
namespace: 此 Jobs 所属命名空间
## 标签
labels:
标签名1: 标签值1
标签名2: 标签值2
# 内容
spec:
## 指定 Pod 模板(内容参考 Pod 的 Yaml
template:
### Pod 的内容
spec:
#### Pod 的容器
containers:
##### 容器1
###### 容器1的名称
- name: 容器1的名称
###### 容器1使用的镜像
image: 容器1使用的镜像
###### 容器1运行的命令
command:
- 命令1
- 命令2
#### 容器重启策略【Never不重启OnFailure失败时重启】
restartPolicy: 容器重启策略【Never不重启OnFailure失败时重启】
## 失败重试次数
backoffLimit: 4
## Pod 完成量(当成功的 Pod 个数达到次数时,该 Job 视为完成)
completions: Pod 完成量
## Pod 工作队列
parallelism: Pod 工作队列

View File

@@ -0,0 +1,18 @@
apiVersion: apps/v1
kind: Jobs
metadata:
name: example-pi
namespace: demo
labels:
name: example-pi
app: pi
type: job
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
restartPolicy: Never
backoffLimit: 4

View File

@@ -0,0 +1,33 @@
# Pod 说明官方文档https://v1-22.docs.kubernetes.io/zh/docs/concepts/workloads/pods
# API 版本
apiVersion: v1
# 资源类型
kind: Pod
# 元数据
metadata:
## 名称
name: 此 Pod 的名称
## 命名空间
namespace: 此 Pod 所属命名空间
## 标签
labels:
标签名1: 标签值1
标签名2: 标签值2
# 内容
spec:
## 容器
containers:
### 容器1
#### 容器名称
- name: 该容器的名称
#### 容器镜像
image: 改容器使用的镜像
#### 容器端口号
ports:
##### 端口号1
###### 名称
- name: 该端口号的名称
###### 端口号
containerPort: 端口号
###### 端口类型
protocol: 该端口号的类型

View File

@@ -0,0 +1,17 @@
apiVersion: v1
kind: Pod
metadata:
name: example-nginx
namespace: demo
labels:
name: nginx
app: nginx
type: pod
spec:
containers:
- name: web
image: nginx:1.23.3
ports:
- name: web
containerPort: 80
protocol: TCP

View File

@@ -0,0 +1,33 @@
# Pods 说明官方文档https://v1-22.docs.kubernetes.io/zh/docs/concepts/workloads/pods
# API 版本
apiVersion: v1
# 资源类型
kind: Pods
# 元数据
metadata:
## 名称
name: 此 Pods 的名称
## 命名空间
namespace: 此 Pods 所属命名空间
## 标签
labels:
标签名1: 标签值1
标签名2: 标签值2
# 内容
spec:
## 容器
containers:
### 容器1
#### 容器名称
- name: 该容器的名称
#### 容器镜像
image: 改容器使用的镜像
#### 容器端口号
ports:
##### 端口号1
###### 名称
- name: 该端口号的名称
###### 端口号
containerPort: 端口号
###### 端口类型
protocol: 该端口号的类型

View File

@@ -0,0 +1,17 @@
apiVersion: v1
kind: Pods
metadata:
name: example-nginx
namespace: demo
labels:
name: nginx
app: nginx
type: pod
spec:
containers:
- name: web
image: nginx:1.23.3
ports:
- name: web
containerPort: 80
protocol: TCP

View File

@@ -0,0 +1,83 @@
# StatefulSet 说明,官方文档: https://v1-22.docs.kubernetes.io/zh/docs/concepts/workloads/controllers/statefulset
# API 版本
apiVersion: apps/v1
# 资源类型
kind: StatefulSet
# 元数据
metadata:
## 名称
name: 此 StatefulSet 的名称
## 命名空间
namespace: 此 StatefulSet 所属命名空间
## 标签
labels:
标签名1: 标签值1
标签名2: 标签值2
# 内容
spec:
## 服务名称
serviceName: 服务名称(此 StatefulSet 对应的 Service 的 name
## 指定副本数
replicas: 期望副本数
## 指定更新策略
updateStrategy:
type: 更新策略【OnDelete不自动更新 PodRollingUpdate自动滚动更新默认
## 最短就绪秒数
minReadySeconds: 短就绪秒数( Pod 就绪后默认可用的等待时间,默认为 0即 Pod 就绪后即为可用状态)
## 指定 Pod 选择器( 此 StatefulSet 需要管理哪些 Pod
selector:
### 指定标签选择器
matchLabels:
标签名1: 标签值1
标签名2: 标签值2
## 指定 Pod 模板(内容参考 Pod 的 Yaml
template:
### Pod 的元数据
metadata:
#### Pod 的标签(需要和上面 matchLabels 中配置的标签一致)
labels:
标签名1: 标签值1
标签名2: 标签值2
### Pod 的内容
spec:
#### Pod 的终止宽限期(秒)
terminationGracePeriodSeconds: Pod 的终止宽限期(秒)
#### Pod 的容器
containers:
##### 容器1
###### 容器1的名称
- name: 容器1的名称
###### 容器1使用的镜像
image: 容器1使用的镜像
###### 容器1使用的端口号
ports:
####### 端口号1
######## 端口号1的名称
- name: 端口号1的名称
######## 端口号1的端口号
containerPort: 端口号1的端口号
###### 容器1使用的持久卷
volumeMounts:
######## 持久卷1
######## 持久卷1的名称
- name: 持久卷1的名称
######## 持久卷1的挂载路径容器内
mountPath: 持久卷1的挂载路径容器内
## 指定 PersistentVolumeClaims 模板(内容参考 PersistentVolumeClaims 的 Yaml
volumeClaimTemplates:
### PersistentVolumeClaims 1
#### PersistentVolumeClaims 1 的元数据
- metadata:
##### PersistentVolumeClaims 1 的名称
name: PersistentVolumeClaims 1 的名称
#### PersistentVolumeClaims 1 的内容
spec:
##### 访问模式
accessModes:
- PersistentVolumeClaims 1 的访问模式
##### Storage Class 名称
storageClassName: PersistentVolumeClaims 1 使用的 StorageClass 的名称
##### 资源
resources:
requests:
storage: PersistentVolumeClaim 1 使用的空间大小

View File

@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: example-nginx-slim
namespace: demo
labels:
name: nginx
app: nginx
type: statefulset
spec:
serviceName: example-nginx-slim
replicas: 3
updateStrategy:
type: RollingUpdate
minReadySeconds: 0
selector:
matchLabels:
name: nginx
app: nginx
type: pod
template:
metadata:
labels:
name: nginx
app: nginx
type: pod
spec:
terminationGracePeriodSeconds: 10
containers:
- name: nginx
image: nginx:1.23.3-alpine-slim
ports:
- name: http
containerPort: 80
- name: https
containerPort: 443
volumeMounts:
- name: html
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: html
spec:
accessModes:
- ReadWriteOnce
storageClassName: example-storage-class-nginx-html
resources:
requests:
storage: 1Gi

View File

@@ -0,0 +1,83 @@
# StatefulSets 说明,官方文档: https://v1-22.docs.kubernetes.io/zh/docs/concepts/workloads/controllers/statefulset
# API 版本
apiVersion: apps/v1
# 资源类型
kind: StatefulSets
# 元数据
metadata:
## 名称
name: 此 StatefulSets 的名称
## 命名空间
namespace: 此 StatefulSets 所属命名空间
## 标签
labels:
标签名1: 标签值1
标签名2: 标签值2
# 内容
spec:
## 服务名称
serviceName: 服务名称(此 StatefulSets 对应的 Service 的 name
## 指定副本数
replicas: 期望副本数
## 指定更新策略
updateStrategy:
type: 更新策略【OnDelete不自动更新 PodRollingUpdate自动滚动更新默认
## 最短就绪秒数
minReadySeconds: 短就绪秒数( Pod 就绪后默认可用的等待时间,默认为 0即 Pod 就绪后即为可用状态)
## 指定 Pod 选择器( 此 StatefulSets 需要管理哪些 Pods
selector:
### 指定标签选择器
matchLabels:
标签名1: 标签值1
标签名2: 标签值2
## 指定 Pod 模板(内容参考 Pod 的 Yaml
template:
### Pod 的元数据
metadata:
#### Pod 的标签(需要和上面 matchLabels 中配置的标签一致)
labels:
标签名1: 标签值1
标签名2: 标签值2
### Pod 的内容
spec:
#### Pod 的终止宽限期(秒)
terminationGracePeriodSeconds: Pod 的终止宽限期(秒)
#### Pod 的容器
containers:
##### 容器1
###### 容器1的名称
- name: 容器1的名称
###### 容器1使用的镜像
image: 容器1使用的镜像
###### 容器1使用的端口号
ports:
####### 端口号1
######## 端口号1的名称
- name: 端口号1的名称
######## 端口号1的端口号
containerPort: 端口号1的端口号
###### 容器1使用的持久卷
volumeMounts:
######## 持久卷1
######## 持久卷1的名称
- name: 持久卷1的名称
######## 持久卷1的挂载路径容器内
mountPath: 持久卷1的挂载路径容器内
## 指定 PersistentVolumeClaims 模板(内容参考 PersistentVolumeClaims 的 Yaml
volumeClaimTemplates:
### PersistentVolumeClaims 1
#### PersistentVolumeClaims 1 的元数据
- metadata:
##### PersistentVolumeClaims 1 的名称
name: PersistentVolumeClaims 1 的名称
#### PersistentVolumeClaims 1 的内容
spec:
##### 访问模式
accessModes:
- PersistentVolumeClaims 1 的访问模式
##### Storage Class 名称
storageClassName: PersistentVolumeClaims 1 使用的 StorageClass 的名称
##### 资源
resources:
requests:
storage: PersistentVolumeClaim 1 使用的空间大小

View File

@@ -0,0 +1,49 @@
apiVersion: apps/v1
kind: StatefulSets
metadata:
name: example-nginx-slim
namespace: demo
labels:
name: nginx
app: nginx
type: statefulsets
spec:
serviceName: example-nginx-slim
replicas: 3
updateStrategy:
type: RollingUpdate
minReadySeconds: 0
selector:
matchLabels:
name: nginx
app: nginx
type: pod
template:
metadata:
labels:
name: nginx
app: nginx
type: pod
spec:
terminationGracePeriodSeconds: 10
containers:
- name: nginx
image: nginx:1.23.3-alpine-slim
ports:
- name: http
containerPort: 80
- name: https
containerPort: 443
volumeMounts:
- name: html
mountPath: /usr/share/nginx/html
volumeClaimTemplates:
- metadata:
name: html
spec:
accessModes:
- ReadWriteOnce
storageClassName: example-storage-class-nginx-html
resources:
requests:
storage: 1Gi