kubernetes常用命令

查看namesapce:

kubectl get ns

查看指定ns下的pod

kubectl get pod -n skiff-gtxs
kubectl -n skiff-env1-demo get pod -o yaml
kubectl -n skiff-apm get po -o wide

进入容器:

kubectl -n gateway-system exec -it gateway-proxy-6d98685488-kdgds bash

删除pod:

kubectl -n skiff-nsf delete po nsf-demo-stock-provider-7cfc5f5b48-wldcb

查看日志:

kubectl logs -f nsf-demo-stock-advisor2-689fb7b44d-zsd7f -n skiff-env1 | grep health

查看事件:

kubectl describe pod gtxs-server-8497dbfd46-zp5vp -n skiff-env1 | grep readness

编辑:

kubectl -n skiff-apm edit deploy apm-webserver

查看数据库信息:

kubectl -n skiff-platform get cm
kubectl -n skiff-platform get cm platform-service-auth-config -o yaml

shell脚本:

kubectl delete po -n skiff-env2 ` kubectl get po -n skiff-env2|grep Evicted|awk '{print $2}' `
lsc1=`kubectl  -n skiff-nsf get pod | grep prov | grep -v provider2 | awk '{print $1}'`
kubectl -napm-bin-8 skiff-nsf de po $lsc1

查看服务ip:port:

kubectl  get svc  -n skiff-env1

查看node标签:

kubectl get nodes --show-labels | grep 10-246-250-214

添加node标签:

 kubectl label node 10-246-250-214 skiff/nsf-demo=true
 ns添加标签:
 kubectl label ns skiff-nsfdemo istio.io/rev=qz17
 修改label:
 kubectl label nodes <node-name> <label-key>=<label-value> --overwrite

创建删除namesapce:

kubectl create/delete namespace namespacename

更改镜像:

kubectl get deployment -n skiff-env1-demo
kubectl edit  deployment gtxs-demo-show -n skiff-env1-demo
kubectl get pod -n skiff-env1-demo
回退:
docker images | grep nsf(查看历史版本)
kubectl get deployment --all-namespaces | grep nsf (查看nsf_server)
kubectl edit  deployment nsf-server -n skiff-env1(更改镜像image)
kubectl get pod  -n skiff-env1(查看pod是否启动成功)

配置表测试接口:

添加配置表后,需要重启生效
http://nsf-demo-stock-viewer.210430rc.service.163.org/getConfigs?key=asd	

NSF_demo:

kubectl get deployment -n skiff-nsfdemo
kubectl edit deployment nsf-demo-stock-provider-agent -n skiff-nsfdemo
kubectl -n skiff-nsfdemo get cm
kubectl -n skiff-nsfdemo get cm nsf-demo-stock-config -o yaml

重启实例:

kubectl get pod -n skiff-nsfdemo
kubectl -n skiff-nsfdemo delete pod nsf-demo-stock-advisor-agent-7c4f67886f-w6bmw

缩容:

kubectl scale deployment nsf-demo-stock-lscprovider -n skiff-nsfdemo --replicas=0

查看host:

kubectl edit cm coredns -n kube-system

限流规则后台配置:

	kubectl get  envoyfilter  -n skiff-nsfdemo
	kubectl exec -n skiff-nsfdemo nsf-demo-stock-dubbo-echo-56f97549b7-9m6sz -c istio-proxy -- curl localhost:15000/config_dump | less
	kubectl exec -n skiff-nsfdemo nsf-demo-stock-dubbo-echo-56f97549b7-9m6sz -- curl localhost:15000/clusters | less
	curl -H "host:nsf-demo-stock-provider" http://172.23.56.121:8973/divide
demo调不通组件:
	mesh-registry-6f686d898c-x5zrc
	istiod-qz17-5897469cb9-x6cfm
https://currentmillis.com/ 时间

kubectl:

alias k="kubectl --kubeconfig=/home/appadmin/htsc-user1/admin.conf"

批量删除:

kubectl  get po -n skiff-nsfdemo |grep dubbo|sed 's/\s.*//g'|xargs kubectl delete po -n skiff-nsfdemo

你可能感兴趣的:(k8s,服务网格(Service,Mesh),kubernetes,linux,docker)