1. pod
apiVersion: v1
kind: Pod
metadata:
name: test-my-nginx
namespace: xxx
labels:
app: test-nginx
spec:
containers:
- name: test-nginx
image: nginx:1.19.3-alpine
ports:
- containerPort: 80
2. deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deployment
namespace: xxx
spec:
selector:
matchLabels:
app: test-nginx
replicas: 2
template:
metadata:
labels:
app: test-nginx
spec:
containers:
- name: test-nginx
image: nginx:1.19.3-alpine
ports:
- containerPort: 80
3. ReplicationController
和deployment的区别:如果该标签的pod数量多于期望值,则会被停掉,如果少于期望值,则会自动创建。
apiVersion: v1
kind: ReplicationController
metadata:
name: test-rc
namespace: xxx
labels:
app: test-nginx
spec:
selector:
app: test-nginx
replicas: 2
template:
metadata:
labels:
app: test-nginx
spec:
containers:
- name: test-nginx
image: nginx:1.19.3-alpine
ports:
- containerPort: 80
4. service
apiVersion: v1
kind: Service
metadata:
name: test-my-service
namespace: xxx
spec:
type: NodePort
ports:
- port: 80
nodePort: 30001
name: nginx-port
selector:
app: test-nginx
868

被折叠的 条评论
为什么被折叠?



