增加一些k8s的应用

This commit is contained in:
2022-07-04 18:22:30 +08:00
parent eadf98e33c
commit 994a5d4b1c
3 changed files with 67 additions and 1 deletions

View File

@@ -3,8 +3,11 @@ kind: Deployment #该配置的类型,我们使用的是 Deployment
metadata: #译名为元数据,即 Deployment 的一些基本属性和信息
name: nginx-deployment #Deployment 的名称
namespace: nginx
labels: #标签可以灵活定位一个或多个资源其中key和value均可自定义可以定义多组目前不需要理解
labels: #标签可以灵活定位一个或多个资源其中key和value均可自定义可以定义多组目前不需要理解 Job、Deployment、ReplicaSet 和 DaemonSet 同时支持基于等式的选择方式和基于集合的选择方式
app: nginx #为该Deployment设置key为appvalue为nginx的标签
annotations: #注释
key1: value1
key2: value2
spec: #这是关于该Deployment的描述可以理解为你期待该Deployment在k8s中如何使用
replicas: 3 #使用该Deployment创建一个应用程序实例
selector: #标签选择器,与上面的标签共同作用,目前不需要理解
@@ -18,3 +21,33 @@ spec: #这是关于该Deployment的描述可以理解为你期待该D
containers: #生成container与docker中的container是同一种 containers
- name: nginx #container的名称
image: nginx:1.23.0 #使用镜像nginx:1.7.9创建container该container默认80端口可访问
ports:
- containerPort: 80
volumeMounts:
- name: workdir
mountPath: /usr/share/nginx/html
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
preStop:
exec:
command: ["/bin/sh", "-c", "nginx -s quit; while killall -o nginx; do sleep 1; done"]
limits:
# These containers are run during pod initialization
initContainers:
- name: install
image: busybox
command:
- wget
- "-O"
- "/work-dir/index.html"
- https://kuboard.cn
volumeMounts:
- name: workdir
mountPath: "/work-dir"
dnsPolicy: Default
volumes:
- name: workdir
emptyDir: {}