常用命令
可以执行这个命令:kubectl exec -it qqwei-0602-rdb-vehicle-0 -- bash -C ""
中文文档:http://docs.kubernetes.org.cn/643.html
kubectl get pod -o wide 查看每个pod被调度到那个node上面
kubectl get all
kubectl get service
kubectl get pod ——查看所有pod
kubectl get deployments
kubectl delete pod -- 重启pod:
执行以后, pod的名字发生变化, 所以需要设置一个全局变量, 供后面使用
lixiao-0514-rdb-server-serialized-service-699786cc4b-ht492 0/1 Running 0 15s
lixiao-0514-rdb-server-serialized-service-699786cc4b-f4dj5 0/1 Init:2/4 0 5s
lixiao-0514-rdb-server-serialized-service-699786cc4b-ht492 1/1 Running 0 90s
kubectl get replicaset | grep ${serviceName}
kubectl get statefulset | grep ${serviceName}
删除服务:
kubectl scale --replicas=1 deployment.apps/rf-ting-rdb-server-serialized-service
kubectl scale --replicas=1 statefulset.apps/ting-test-rdb-vehicle
kubectl scale --replicas=1 deployment.apps/ting-test-rdb-server-visual-2dimage-service
重启服务:
kubectl -n roaddb rollout restart deployment <deployment name>:
通过Deployment对象,你可以轻松的做到以下事情:
创建ReplicaSet和Pod
滚动升级(不停止旧服务的状态下升级)和回滚应用(将应用回滚到之前的版本)
平滑地扩容和缩容
暂停和继续Deployment
rollout命令的更多用法:
history(查看历史版本)
pause(暂停Deployment)
resume(恢复暂停的Deployment)
status(查看资源状态)
undo(回滚版本)
Delete a pod using the type and name specified in pod.json.
kubectl delete -f ./pod.json
kubectl scale --replicas=5 statefulset xxx-rdb-vehicle
kubectl get svc ——查看pod对应的ip和port
kubectl exec -ti custom-2944-nfs-rdb-server-****(pod name) -- ls /opt/ygomi/roadDB ——直接从本地远程登录到pod,
如果不指定container,会进入pod默认的container
kubectl exec -it lixiao-0513-rdb-vehicle-4 -- /etc/init.d/road_probe status
kubectl exec -it lixiao-0513-rdb-vehicle-4 -- bash -c "echo '' > /x/x/x"
kubectl logs -f my-test-rdb-server-serialized-service-6ddffd7c4b-stcdb ——本地通过kubectl log查看pod服务日志。
kubectl cp <local-file> <pod-name>:<container-path>
(kubectl cp local-file my-test-2-rdb-server-rtv-storage-547cf958d-f8hwm:/opt/ygomi/roadDB/file_storage)
cd local_path;tar cf - ./* | kubectl exec -i ${pServerPod} -- tar xf - -C ${podPath}
kubectl exec ting-test-rdb-server-rtv-storage-0 -- bash -c "cd /opt/ygomi/roadDB/file_storage/rtv/;tar cvPf - RDB-20685_minimal_e2e" | tar xvf - -C ~/Documents/ting/test/
部署包:
helm repo add rdb-release-repo https://harbor.roaddb.net/chartrepo/rdb-release
helm repo add rdb-release https://harbor.roaddb.net/chartrepo/rdb-custom-charts
kubectl config set-context --current --namespace=roaddb
kubectl config set-context --current --namespace=fws-testing-2
查看库地址:
helm repo ls
更新版本库:
helm repo update
查看当前是否已安装roaddb版本
helm list
helm uninstall ting-test(这个名称是部署roaddb时,自定义的名称,代表这一次的部署)
查看helm repo里是否有你需要部署的版本
helm search repo rdb-release-repo/roaddb --devel -l
helm search repo rdb-release/roaddb --devel -l
helm install ting-test -f values.yaml rdb-release/roaddb --version 0.0.0-custom-2020.0807-3360
helm install ting-test -f values.yaml rdb-release-repo/roaddb --version 4.4.1+2
helm install ting-test rdb-release-repo/roaddb --version 4.4.1+2
kubectl get node -l node.roaddb.net/role=vehicle