为什么在microk8s创建的集群中看不到pod资源?

为什么在microk8s创建的集群中看不到pod资源?

安装microk8s

sudo snap install microk8s --classic --channel=1.17/stable

别名

alias kubectl='microk8s.kubectl'

当前docker容器:

docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
b07100cc21cc        first-app:v1        "nginx -g 'daemon of…"   11 minutes ago      Up 11 minutes       0.0.0.0:8000->80/tcp   good_sala

文件结构:

  kubernetes/         # Kubernetes manifests to deploy the application
    deployment.yaml
    service.yaml

在deployment.yaml中:

apiVersion: apps/v1 
kind: Deployment
metadata:
  name: first-app
spec:
  selector:
    matchLabels:
      app: first-app
  replicas: 2
  template:
    metadata:
      labels:
        app: first-app
    spec:
      containers:
      - name: first-app
        image: first-app:v1
        ports:
        - containerPort: 80

在 service.yaml 中:

kind: Service
apiVersion: v1
metadata:
  name: first-app
spec:
  selector:
    app: first-app
  type: NodePort
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80

部署:

kubectl -n default create -f kubernetes
deployment.apps/first-app created
service/first-app created

检查吊舱:

kubectl -n default get pod
No resources found in default namespace.

检查服务:

kubectl -n default get service | grep first-app
first-app     NodePort    10.152.183.215   <none>        80:30366/TCP   7m52s

为何找不到任何 pod?

如果我将同样的东西部署到 minikube,它就可以工作。

相关内容