web-dev-qa-db-ja.com

名前空間が見つかりません

展開を実行すると、次のエラーが表示されます。

Error from server (NotFound): error when creating "n3deployment.yaml": namespaces "n2" not found

私のn3deployment.yamlにn2への参照がありませんか?

ステップバイステップ

  1. すべてが空であることを確認してください
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
  1. ファイルを作成する
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
  1. 構成を適用
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という名前空間がありましたが、ご覧のとおり、もう存在していません。

3
A. Gardner

名前空間を追加:n3をデプロイメント仕様に追加

0
P Ekambaram