jskubectl get pod
jskubectl get pod
jskubectl get pod -o wide -A
jskubectl get pod -o wide -n 命名空间的名称
jskubectl get pod -w -n 命名空间的名称
jskubectl run pod的名称 --image=nginx
jskubectl describe pod nginx
该问题是拉取镜像失败了,需要重新配置一下containerd容器镜像拉取地址
jsvim /etc/containerd/config.toml
jsdisabled_plugins = ["restart"]
[plugins.linux]
shim_debug = true
[plugins.cri.registry.mirrors."docker.io"]
endpoint = [
"https://docker.m.daocloud.io",
"https://docker.1panel.live",
"https://hub.rat.dev",
"https://registry-1.docker.io" # 官方源保底
]
[plugins.cri]
sandbox_image = "registry.aliyuncs.com/google_containers/pause:3.2"
js#重启容器 systemctl restart containerd
然后测试一下拉取还是报错,看来是crictl问题
需要创建/修改 crictl 配置文件
jsmkdir -p /etc/crictl
cat <<EOF | sudo tee /etc/crictl/config.yaml
runtime-endpoint: unix:///run/containerd/containerd.sock
image-endpoint: unix:///run/containerd/containerd.sock
timeout: 10
debug: true
EOF
再次查看NG镜像已经拉取成功
jsvi k8s.yml
ymlapiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.21
imagePullPolicy: IfNotPresent
restartPolicy: Always
jskubectl apply -f k8s.yml
jskubectl delete pod <pod的名称>
kubectl delete -f k8s.yml
jskubectl exec -it nginx -- bash
如果一个pod有多个容器,列如:nginx-container + log-collector
js# 进入名为 nginx-container 的容器 kubectl exec -it nginx -c nginx-container -- bash # 进入名为 log-collector 的容器 kubectl exec -it nginx -c log-collector -- bash
js#查看该pod所有容器的日志 kubectl logs -f <pod名称> #查看该pod指定容器的日志 kubectl logs -f <pod名称> -c log-collector
js#查看pod的标签 kubectl get pod --show-labels
jskubectl label pod nginx-redis01 name=songxuan
jskubectl label --overwrite pod nginx-redis01 name=xuan
jskubectl label pod nginx-redis01 name-
本文作者:松轩(^U^)
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!