【发布时间】:2019-11-20 15:31:12
【问题描述】:
我在运行部署时看到以下错误:
Error from server (NotFound): error when creating "n3deployment.yaml": namespaces "n2" not found
我的 n3deployment.yaml 没有引用 n2?
一步一步
- 确保一切都是空的
c:\temp\k8s>kubectl get pods
No resources found.
c:\temp\k8s>kubectl get svc
No resources found.
c:\temp\k8s>kubectl get deployments
No resources found.
c:\temp\k8s>kubectl get namespaces
NAME STATUS AGE
default Active 20h
docker Active 20h
kube-public Active 20h
kube-system Active 20h
- 创建文件
n3namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: n3
n3service.yaml
apiVersion: v1
kind: Service
metadata:
name: my-app-n3
namespace: n3
labels:
app: my-app-n3
spec:
type: LoadBalancer
ports:
- name: http
port: 80
targetPort: http
protocol: TCP
selector:
app: my-app-n3
n3deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app-n3
labels:
app: my-app-n3
spec:
replicas: 1
selector:
matchLabels:
app: my-app-n3
template:
metadata:
labels:
app: my-app-n3
spec:
containers:
- name: waiter
image: waiter:v1
ports:
- containerPort: 80
- 应用配置
c:\temp\k8s>kubectl apply -f n3namespace.yaml
namespace "n3" created
c:\temp\k8s>kubectl apply -f n3service.yaml
service "my-app-n3" created
c:\temp\k8s>kubectl apply -f n3deployment.yaml
Error from server (NotFound): error when creating "n3deployment.yaml": namespaces "n2" not found
我以前有一个名为 n2 的命名空间,但如您所见,它不再存在。
【问题讨论】:
标签: kubernetes namespaces minikube