1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# 编写yaml
apiVersion: v1
kind: Namespace # 创建namespace,或不创建使用现有的namespace
metadata:
name: nginx-test
labels:
name: label-nginx
---
apiVersion: v1
kind: Pod
metadata:
namespace: nginx-test
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
imagePullPolicy: Never
ports:
- containerPort: 80
apiVersion: apps/v1
kind: Deployment # 创建deployment
metadata:
namespace: nginx-test
name: nginx-deploy
spec:
selector:
matchLabels:
app: nginx
replicas: 2
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
imagePullPolicy: Never
ports:
- containerPort: 80
|