首页 > 其他分享 >如何查看在当前的ingress-controller中,有哪些backend?每个backend的endpoints是什么?

如何查看在当前的ingress-controller中,有哪些backend?每个backend的endpoints是什么?

时间:2023-06-14 11:57:46浏览次数:44  
标签:ingress name nginx controller backends 80 port backend


通过kubectl ingress-nginx命令,可以查看在ingress controller中,有哪些backends,每个backends的后端的endpoints信息和对应其他的参数设置

 

比如:

 

kubectl ingress-nginx backends -n ingress-nginx

 

 

[root@nccztsjb-node-23 data]# kubectl ingress-nginx backends -n ingress-nginx
[
  {
    "name": "default-nginx-deployment-80",
    "service": {
      "metadata": {
        "creationTimestamp": null
      },
      "spec": {
        "ports": [
          {
            "protocol": "TCP",
            "port": 80,
            "targetPort": 80
          }
        ],
        "selector": {
          "app": "nginx"
        },
        "clusterIP": "10.98.87.101",
        "clusterIPs": [
          "10.98.87.101"
        ],
        "type": "ClusterIP",
        "sessionAffinity": "ClientIP",
        "sessionAffinityConfig": {
          "clientIP": {
            "timeoutSeconds": 10800
          }
        },
        "ipFamilies": [
          "IPv4"
        ],
        "ipFamilyPolicy": "SingleStack",
        "internalTrafficPolicy": "Cluster"
      },
      "status": {
        "loadBalancer": {}
      }
    },
    "port": 80,
    "sslPassthrough": false,
    "endpoints": [
      {
        "address": "172.39.157.239",
        "port": "80"
      },
      {
        "address": "172.39.21.93",
        "port": "80"
      },
      {
        "address": "172.39.21.95",
        "port": "80"
      }
    ],
    "sessionAffinityConfig": {
      "name": "",
      "mode": "",
      "cookieSessionAffinity": {
        "name": ""
      }
    },
    "upstreamHashByConfig": {
      "upstream-hash-by-subset-size": 3
    },
    "noServer": false,
    "trafficShapingPolicy": {
      "weight": 0,
      "weightTotal": 0,
      "header": "",
      "headerValue": "",
      "headerPattern": "",
      "cookie": ""
    }
  },
  {
    "name": "upstream-default-backend",
    "port": 0,
    "sslPassthrough": false,
    "endpoints": [
      {
        "address": "127.0.0.1",
        "port": "8181"
      }
    ],
    "sessionAffinityConfig": {
      "name": "",
      "mode": "",
      "cookieSessionAffinity": {
        "name": ""
      }
    },
    "upstreamHashByConfig": {},
    "noServer": false,
    "trafficShapingPolicy": {
      "weight": 0,
      "weightTotal": 0,
      "header": "",
      "headerValue": "",
      "headerPattern": "",
      "cookie": ""
    }
  }
]
 

 


如果这个数据很多,想要查看到底有哪些的backends呢?

 

可以使用jq工具,可以将数据转换为json格式,然后选择出来某个字段

kubectl ingress-nginx backends -n ingress-nginx | jq ".[].name"

 

 

[root@nccztsjb-node-23 data]# kubectl ingress-nginx backends -n ingress-nginx | jq ".[].name"
"default-nginx-deployment-80"
"upstream-default-backend"
[root@nccztsjb-node-23 data]# 

 

jq工具,可以通过

 

yum install -y jq

 

 

来进行安装

 

这样呢,就可获取到了所有的backends的信息

 

然后,这个时候呢,就可以获取某个特定的backends的信息了,比如:

 

使用--backend参数

kubectl ingress-nginx backends -n ingress-nginx --backend default-nginx-deployment-80
 

 

[root@nccztsjb-node-23 data]# kubectl ingress-nginx backends -n ingress-nginx --backend default-nginx-deployment-80
{
  "endpoints": [
    {
      "address": "172.39.157.239",
      "port": "80"
    },
    {
      "address": "172.39.21.93",
      "port": "80"
    },
    {
      "address": "172.39.21.95",
      "port": "80"
    }
  ],
  "name": "default-nginx-deployment-80",
  "noServer": false,
  "port": 80,
  "service": {
    "metadata": {
      "creationTimestamp": null
    },
    "spec": {
      "clusterIP": "10.98.87.101",
      "clusterIPs": [
        "10.98.87.101"
      ],
      "internalTrafficPolicy": "Cluster",
      "ipFamilies": [
        "IPv4"
      ],
      "ipFamilyPolicy": "SingleStack",
      "ports": [
        {
          "port": 80,
          "protocol": "TCP",
          "targetPort": 80
        }
      ],
      "selector": {
        "app": "nginx"
      },
      "sessionAffinity": "ClientIP",
      "sessionAffinityConfig": {
        "clientIP": {
          "timeoutSeconds": 10800
        }
      },
      "type": "ClusterIP"
    },
    "status": {
      "loadBalancer": {}
    }
  },
  "sessionAffinityConfig": {
    "cookieSessionAffinity": {
      "name": ""
    },
    "mode": "",
    "name": ""
  },
  "sslPassthrough": false,
  "trafficShapingPolicy": {
    "cookie": "",
    "header": "",
    "headerPattern": "",
    "headerValue": "",
    "weight": 0,
    "weightTotal": 0
  },
  "upstreamHashByConfig": {
    "upstream-hash-by-subset-size": 3
  }
}
 

 

还可以查看这个backend的endpoints

[root@nccztsjb-node-23 data]# kubectl ingress-nginx backends -n ingress-nginx --backend default-nginx-deployment-80 | jq ".endpoints"
[
  {
    "address": "172.39.157.239",
    "port": "80"
  },
  {
    "address": "172.39.21.93",
    "port": "80"
  },
  {
    "address": "172.39.21.95",
    "port": "80"
  }
]
[root@nccztsjb-node-23 data]#

 

 

这里面,主要是借助了jq这个工具,对输出进行格式化,对某个字段值的值进行选择。

标签:ingress,name,nginx,controller,backends,80,port,backend
From: https://www.cnblogs.com/chuanzhang053/p/17479780.html

相关文章

  • UIViewController生命周期方法viewDidLoad、viewWillAppear和viewDidAppear
    UIViewController生命周期方法viewDidLoad、viewWillAppear和viewDidAppear 这3个方法执行顺序为:viewDidLoad-》viewWillAppear-》viewDidAppear  viewDidLoadCalledaftertheviewhasbeenloaded.Forviewcontrollerscreatedincode,thisisafter-loadView.Forviewc......
  • beego: panic: 'detail' method doesn't exist in the controller StudentController
    beego使用报错panic:'detail'methoddoesn'texistinthecontrollerStudentControllergoroutine1[running]:github.com/astaxie/beego.(*ControllerRegister).addWithMethodParams(0xc0000d8d10,0x164d100,0x7,0x1736900,0xc0000c37a0,0x0,0x0,0x......
  • Controller 对应 Service 操作的命名【经验】
    结构层查询新增删除修改ControllerfindaddremovemodifyServiceselectinsertdeleteupdate......
  • k8s 1.26.5 Ingress-nginx 的高可用部署
    1.安装部署ingress-nginx本次部署使用了高可用的形式,会在每个node节点做亲和性(master不部署),让每一个pod都部署上去,然后加入NGINX去过负载,这样我们之后用NGINX的80端口访问域名就可以了。主机地址端口k8s-node01192.168.80.48nginx启动端口:3080,负载均衡端口:根据ingre......
  • controller层
    AllControllerpackagecom.example.academicadministration.controller;importcom.example.academicadministration.service.StudentService;importcom.example.academicadministration.service.TeacherService;importjakarta.servlet.http.HttpServletRequest;impo......
  • java 访问ingress https报错javax.net.ssl.SSLHandshakeException: Received fatal al
    一、报错及部署环境Java程序访问测试域名https方法正常,访问生产域名https域名报错,报错如下javax.net.ssl.SSLHandshakeException:Receivedfatalalert:protocol_version测试环境使用KubeSphereingress生产环境使用阿里云ACK服务的ingress配置二、问题原因客户端......
  • Nginx conf for fastapi backend project with variables
    带变量的nginx后端项目配置不同的api项目,挂载不同的域名,只需在配置夹里,修改文件名(建议文件名和域名保持一致)、修改端口号、修改第5行第22行backend_api后面的编号、修改第11行的项目名、可能还需要修改第12行的文件夹名、修改第14行的域名$cat/etc/nginx/sites-avaliable/myap......
  • spring aop 如何切面到mvc 的controller, service
    [size=large][color=red]Spring+SpringMVC+Mybatis利用AOP自定义注解实现可配置日志快照记录[/color][/size][url]http://unkeltao.com/blog/2014/07/22/spring-plus-springmvc-plus-mybatis-aop/[/url][size=large][color=red]拦截Controller[/color][/si......
  • Map 接收 @RequestBody,Controller 层可以打印值,但是 mybatis 编译 SQL 语句显示 NULL
    mybatis#{}获取的key是否一致;前端发送请求类型是否与后端接口定义的请求类型一致;前端发送请求与接口请求的类型一致的情况下,检查post请求封装data时是否以get形式传递数据。我的问题是第三个,尤其是后端不报任何错误的情况下,第三种情况极有可能。我把axios.post......
  • ingress 调用istio ingress 控制器
    清理环境[root@k8s-master01httpbin]#  kubectldelete-fhttpbin-gateway1.yaml-nistiogateway.networking.istio.io"httpbin-gateway"deletedvirtualservice.networking.istio.io"httpbin"deleted[root@k8s-master01httpbin]#[root@k8s-master......