• k8s查询指定app的podname、查看pod log 删除pod


    1、查看service的appname

    [root@k8s-master ~]# kubectl get service -n rkw-ezc-test -o wide 
    NAME                                             TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)           AGE     SELECTOR
    chinapopin-apply-vsitregist-application-test     NodePort   10.96.235.105   <none>        8092:32208/TCP    434d    app=chinapopin-apply-vsitregist-application-test
    chinapopin-platform-address-application-test     NodePort   10.96.99.208    <none>        8071:31583/TCP    434d    app=chinapopin-platform-address-application-test
    
    2、根据app name获取pod
    [root@k8s-master ~]# kubectl get service -n rkw-ezc-test -l app=notice-shortmsg-test
    NAME                   TYPE       CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
    notice-shortmsg-test   NodePort   10.96.96.221   <none>        8078:30631/TCP   6d22h
    [root@k8s-master ~]# kubectl get pod -n rkw-ezc-test -l app=notice-shortmsg-test
    NAME                                           READY   STATUS    RESTARTS   AGE
    notice-shortmsg-test-gb2w91-5f55794f9b-8zb44   1/1     Running   0          6d4h
    
    3、使用json方式获取pod的name (如果多个需要修改item的指针)
    [root@k8s-master ~]# kubectl get pod -n rkw-ezc-test -l app=notice-shortmsg-test -o jsonpath='{.items[0].metadata.name}'
    notice-shortmsg-test-gb2w91-5f55794f9b-8zb44
    
    4、如果要显示全部的pod名称 使用* 代替角标
    [root@k8s-master ~]# kubectl get pod -n kubesphere-monitoring-system -l app=node-exporter -o jsonpath='{.items[*].metadata.name}'
    node-exporter-b5pvs node-exporter-bxk2h node-exporter-h9kmd node-exporter-l4cb2
    
    5、直接删除某个名称的所有pod
    # 删除所有带有lable name=myLabel的pod和service
    $ kubectl delete pods,services -l name=myLabel
    [root@k8s-master ~]# kubectl delete pod -n zhxq3-test -l app=community-manager-login
    pod "community-manager-login-gucvi3-6f8bd995f8-l6vtm" deleted
    [root@k8s-master ~]# kubectl get pod -n zhxq3-test -l app=community-manager-login
    NAME                                              READY   STATUS    RESTARTS   AGE
    community-manager-login-gucvi3-6f8bd995f8-6srfx   1/1     Running   0          9s
    
    6、查询事件 (常用命令)
    kubectl get events --all-namespaces
    
    7、多个pod如何查询全部日志
    kubectl logs -f --tail=100 -n chinapopin-system-prod -l  app=chinapopin-biz-student
    

      

      

      

      

      

      

      

    做一个决定,并不难,难的是付诸行动,并且坚持到底。
  • 相关阅读:
    [BZOJ1015] [JSOI2008]星球大战starwar
    [BZOJ2321,LuoguP1861]星(之)器
    Google Search Operators
    Python blockchain
    CCAE词频表(转)
    python小技巧(转)
    Python著名的lib和开发框架(均为转载)
    Yarn取代job/task tracker
    hadoop 2.73‘s four xml
    HDFS NN,SNN,BN和HA
  • 原文地址:https://www.cnblogs.com/wukc/p/15768097.html
Copyright © 2020-2023  润新知