问题:运行docker-for-mac&kubernetes,命令kubectl get pods -namespace=kube-system
未列出预期的Pod。
使用kubernetes和docker-for-mac进行实验。完成初始设置后,我希望以下命令的输出列出多个Pod(例如etcd pod和kube-proxy pod等)
╰─$ kubectl get pods -namespace=kube-system
No resources found.
我可以验证实际的容器本身是否在docker container ls
的输出下运行
╰─$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d7bfc959bb33 docker/kube-compose-controller "/compose-controller…" 46 seconds ago Up 46 seconds k8s_compose_compose-74649b4db6-xn46f_docker_f4dd8d7f-eeee-11e8-8e78-025000000001_0
2f01b7e2855f k8s.gcr.io/pause-amd64:3.1 "/pause" 53 seconds ago Up 52 seconds k8s_POD_compose-74649b4db6-xn46f_docker_f4dd8d7f-eeee-11e8-8e78-025000000001_0
a54f5f5e0186 docker/kube-compose-api-server "/api-server --kubec…" 54 seconds ago Up 54 seconds k8s_compose_compose-api-5d6dcc4cbc-4r52t_docker_f00a7746-eeee-11e8-8e78-025000000001_0
1242642473b3 k8s.gcr.io/pause-amd64:3.1 "/pause" About a minute ago Up About a minute k8s_POD_compose-api-5d6dcc4cbc-4r52t_docker_f00a7746-eeee-11e8-8e78-025000000001_0
ee49f5c45980 0dab2435c100 "/dashboard --insecu…" About a minute ago Up About a minute k8s_kubernetes-dashboard_kubernetes-dashboard-7b9c7bc8c9-nslnw_kube-system_559631df-eeec-11e8-982b-025000000001_1
4cb9888194b9 6f7f2dc7fab5 "/sidecar --v=2 --lo…" About a minute ago Up About a minute k8s_sidecar_kube-dns-86f4d74b45-5zssv_kube-system_2255e3e7-eeea-11e8-982b-025000000001_0
3ef054ac39a2 c2ce1ffb51ed "/dnsmasq-nanny -v=2…" About a minute ago Up About a minute k8s_dnsmasq_kube-dns-86f4d74b45-5zssv_kube-system_2255e3e7-eeea-11e8-982b-025000000001_0
6511e32e5255 80cc5ea4b547 "/kube-dns --domain=…" About a minute ago Up About a minute k8s_kubedns_kube-dns-86f4d74b45-5zssv_kube-system_2255e3e7-eeea-11e8-982b-025000000001_1
98908ce56c77 k8s.gcr.io/pause-amd64:3.1 "/pause" About a minute ago Up About a minute k8s_POD_kube-dns-86f4d74b45-5zssv_kube-system_2255e3e7-eeea-11e8-982b-025000000001_1
747fd0b06213 k8s.gcr.io/pause-amd64:3.1 "/pause" About a minute ago Up About a minute k8s_POD_kubernetes-dashboard-7b9c7bc8c9-nslnw_kube-system_559631df-eeec-11e8-982b-025000000001_1
980b20ab8907 4261d315109d "/usr/local/bin/kube…" About a minute ago Up About a minute k8s_kube-proxy_kube-proxy-8tn9v_kube-system_221cf931-eeea-11e8-982b-025000000001_1
8592205bbda8 k8s.gcr.io/pause-amd64:3.1 "/pause" About a minute ago Up About a minute k8s_POD_kube-proxy-8tn9v_kube-system_221cf931-eeea-11e8-982b-025000000001_1
dad3aea73e73 e03746fe22c3 "kube-apiserver --ad…" About a minute ago Up About a minute k8s_kube-apiserver_kube-apiserver-docker-for-desktop_kube-system_456522cd0020e6485653eab412bf0586_2
4271813e4543 353b8f1d102e "kube-scheduler --le…" About a minute ago Up About a minute k8s_kube-scheduler_kube-scheduler-docker-for-desktop_kube-system_8c33750d637b5de93e891805153e7560_1
9770f8a8b22c 40c8d10b2d11 "kube-controller-man…" About a minute ago Up About a minute k8s_kube-controller-manager_kube-controller-manager-docker-for-desktop_kube-system_f11db718cff79a1337ad4547ab74b891_2
dbd19772566f 52920ad46f5b "etcd --listen-clien…" About a minute ago Up About a minute k8s_etcd_etcd-docker-for-desktop_kube-system_d9b7a25d513fbfc6827c78cfa47d6daf_2
f1a19e2a8eac k8s.gcr.io/pause-amd64:3.1 "/pause" About a minute ago Up About a minute k8s_POD_kube-scheduler-docker-for-desktop_kube-system_8c33750d637b5de93e891805153e7560_2
9f388bea2f02 k8s.gcr.io/pause-amd64:3.1 "/pause" About a minute ago Up About a minute k8s_POD_kube-controller-manager-docker-for-desktop_kube-system_f11db718cff79a1337ad4547ab74b891_2
98ca4df129b4 k8s.gcr.io/pause-amd64:3.1 "/pause" About a minute ago Up About a minute k8s_POD_kube-apiserver-docker-for-desktop_kube-system_456522cd0020e6485653eab412bf0586_2
2bc4fd6d216c k8s.gcr.io/pause-amd64:3.1 "/pause" About a minute ago Up About a minute k8s_POD_etcd-docker-for-desktop_kube-system_d9b7a25d513fbfc6827c78cfa47d6daf_2
为了验证,kubectl指向我的本地kubernetes服务器
╰─$ kubectl config current-context
docker-for-desktop
MSC信息
╰─$ kubectl cluster-info
Kubernetes master is running at https://localhost:6443
KubeDNS is running at https://localhost:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
╰─$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
docker-for-desktop Ready master 49m v1.10.3
答案 0 :(得分:2)
您使用的命令不正确,应该使用:
kubectl get pods --namespace=kube-system
或
kubectl get pods -n kube-system
它将向您显示豆荚。