docker:
- docker ps -a
- docker images
- docker exec -it {ID\NAME} /bin/bash | /bin/sh
- docker run -it {ID\NAME} -p -v
- docker start {ID\NAME}
- docker stop {ID\NAME}
- docker rm {ID\NAME}
- docker rmi {ID\NAME}
- docker save coredns/coredns:1.0.0 | gzip > coredns.tar.gz #将已有的img打包
- docker load -i IMAGE #docker载入本地image打包文件
k8s:
- kubectl get pods -o wide
- kubectl get pod xxx -o yaml #获取yaml配置文件
- kubectl get nodes -o wide
- kubectl describe pod mysql-deploy-766bd7dbcb-7nxvw #查看pod的创建运行记录
- kubectl create -f xxx.yaml #创建资源
- kubectl delete deploy mysql-deploy #删除资源
- kubectl get svc -o wide
- kubectl get rs
- kubectl get deploy/DEPLOY-NAME
- kubectl get all #获取所有类型资源
- kubectl get componentstatuses #获取k8s各组件健康状态,简写为kubectl get cs
- kubectl describe deploy/DEPLOY-NAME
- kubectl status rollout deploy/DEPLOY-NAME
- kubectl label nodes 171 disktype=ssd #添加标签
- kubectl label nodes 171 disktype- #删除标签
- kubectl label nodes 171 disktype=hdd --overwrite #修改标签
- kubectl logs POD_NAME #查看pod的日志,排错用
- kubectl delete pod NAME --grace-period=0 --force #强制删除资源
- kubectl replace -f xxx.yaml #更改定义资源的yaml配置文件
- kubectl scale --replicas=3 deployment/xxxx #横向扩展deploy的rs数量
- kubectl cordon NODENAME #将node设置为检修状态,不再向此node调度新的pod
- kubectl drain NODENAME #将node设置为(排水)不可用状态,并且驱逐其上的pod转移至其他正常node上。这一步会进行两个步骤:1.将node设为cordon状态2.驱逐node上的pod
- kubectl drain node2 --delete-local-data --force --ignore-daemonsets #忽略ds,否则存在ds的话无法正常执行
- kubectl uncordon NODENAME #取消检修状态、排水状态
- kubectl proxy --address=0.0.0.0 --port=8001 --accept-hosts=^.* & #kubectl监听端口代理apiserver的服务,允许调用客户端免去认证步骤
###指定pod运行载体node选择器
1.给node打上标签:kubectl label nodes 171 disktype=ssd
2.给yaml配置文件内针对的spec.nodeselector配置上选择器,如下:
spec:
nodeSelector:
disktype: ssd
- kubectl get nodes k8s.node1 --show-labels #查看node标签,一般配合nodeselector使用
###强制pod选择node:
Pod.spec.nodeName:XXX
#check the subnets assigned to each node:
- kubectl get nodes -o json | jq '.items[] | .spec'
#get resources from k8s api,ensure the kubectl proxy enabled
- curl http://192.168.9.28:8001/api/v1/namespaces/default/services/smtzddev
/{hostname}/ /{namespace}/{resource kind}/{resource name}
####kubectl patch修改pod配置,只支持直接修改如下提示的四个字段。
- kubectl patch pod amazondev-59956bd9bb-v9rmd -p '{"spec":{"nodeSelector":{"disktype":"ssd"}}}'
the Pod "amazondev-59956bd9bb-v9rmd" is invalid: spec: Forbidden: pod updates may not change fields other than `spec.containers[*].image`, `spec.initContainers[*].image`, `spec.activeDeadlineSeconds` or `spec.tolerations` (only additions to existing tolerations)
docker、k8s常用命令查询手册
猜你喜欢
转载自blog.csdn.net/ywq935/article/details/80108857
今日推荐
周排行