我正在尝试将kubernetes集群中的这个yaml部署到我的一个节点中
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-1
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80但是,当我尝试使用命令部署它时,我收到以下错误消息
pi@k8s-master-rasp4:~ $ kubectl apply -f despliegue-nginx.yaml -l kubernetes.io/hostname=k8s-worker-1
error: no objects passed to apply有人知道问题出在哪里吗?
谢谢
发布于 2021-02-26 19:55:56
不允许将标签选择器(-l)与kubectl apply...一起使用。
使用nodeSelector将pods分配给特定节点:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment-1
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
nodeSelector:
kubernetes.io/hostname: k8s-worker-1 # <-- updated here!
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80https://stackoverflow.com/questions/66385294
复制相似问题