新增说明及示例文件

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,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