在minikube hyper-v机器中,我使用sawtooth config file进行了锯齿0的部署。
现在,当我检查正在运行的Pod时,似乎有一些默认的Pod,但是在尝试与kubernetes shell容器连接时。
C:\Users\Debo>kubectl get --all-namespaces
You must specify the type of resource to get. Use "kubectl api-resources" for a complete list of supported resources.
error: Required resource not specified.
Use "kubectl explain <resource>" for a detailed description of that resource (e.g. kubectl explain pods).
See 'kubectl get -h' for help and examples
C:\Users\Debo>kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
default sawtooth-0-65d547498c-mfrsb 7/7 Running 1 120m
kube-system coredns-6955765f44-b684l 1/1 Running 0 122m
kube-system coredns-6955765f44-tc4vg 1/1 Running 0 122m
kube-system etcd-minikube 1/1 Running 0 121m
kube-system kube-addon-manager-minikube 1/1 Running 0 121m
kube-system kube-apiserver-minikube 1/1 Running 0 121m
kube-system kube-controller-manager-minikube 1/1 Running 0 121m
kube-system kube-proxy-t7nhs 1/1 Running 0 122m
kube-system kube-scheduler-minikube 1/1 Running 0 121m
kube-system storage-provisioner 1/1 Running 0 122m
kubernetes-dashboard dashboard-metrics-scraper-7b64584c5c-b8t7s 1/1 Running 0 122m
kubernetes-dashboard kubernetes-dashboard-79d9cd965-pn94z 1/1 Running 0 122m
C:\Users\Debo>kubectl get pods
NAME READY STATUS RESTARTS AGE
sawtooth-0-65d547498c-mfrsb 7/7 Running 1 120m
C:\Users\Debo>kubectl exec -it $(kubectl get pods | awk "/sawtooth-0/ {print $1}") --container sawtooth-shell -- bash
awk: /sawtooth-0/ {print $1})
awk: ^ syntax error
errcount: 1
Error from server (NotFound): pods "$(kubectl" not found
C:\Users\Debo>
答案 0 :(得分:0)
如果我了解您的用例,则您尝试从名称空间中给定Pod列表中筛选出sawtooth-0 Pod,然后打开一个在其中您知道容器名称的运行容器的交互式会话。
因此,要解决上述问题,我将有问题的锯齿配置文件作为附件,并启动了它的两个实例锯齿0和锯齿1以及几个虚拟吊舱,然后在Windows Power Shell上使用此命令过滤并连接到容器上锯齿0吊舱。
假设您需要在Windows Powershell上运行kubectl,完成以下所有操作
PS C:\Users\winuser> kubectl get pods
NAME READY STATUS RESTARTS AGE
busybox 1/1 Running 0 4m18s
nginx 1/1 Running 0 10m
sawtooth-0-7f584587cf-8jfwk 7/7 Running 0 19m
sawtooth-1-6ccd4494-kq24n 7/7 Running 0 18m
连接到锯齿0
PS C:\Users\winuser> kubectl exec -it $(kubectl get pods --no-headers -o custom-columns=":metadata.name" | findstr -i sawtooth-0) --container sawtooth-shell -- bash
root@sawtooth-0-7f584587cf-8jfwk:/# whoami
root
root@sawtooth-0-7f584587cf-8jfwk:/# date
Thu Jan 16 11:57:22 UTC 2020
root@sawtooth-0-7f584587cf-8jfwk:/# exit
exit
command terminated with exit code 130
连接到锯齿1
PS C:\Users\winuser> kubectl exec -it $(kubectl get pods --no-headers -o custom-columns=":metadata.name" | findstr -i sawtooth-1) --container sawtooth-shell -- bash
root@sawtooth-1-6ccd4494-kq24n:/# date
Thu Jan 16 12:17:33 UTC 2020