增加一些k8s的应用
This commit is contained in:
@@ -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为app,value为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: {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user