zoukankan      html  css  js  c++  java
  • k8s nodePort类型的service,session保持



    apiVersion: v1
    kind: Service
    metadata:
      name: helloworldsvc
      labels:
        weblogic-app: helloworld
    spec:
      type: NodePort
      ports:
      - port: 7001
        protocol: TCP
        targetPort: 7001
        name: http
        nodePort: 30005
      selector:
        weblogic-app: helloworld
      sessionAffinity: ClientIP
    sessionAffinityConfig:
    clientIP:
    timeoutSeconds: 10800
    
    

    最核心就是最后那句,会基于客户端访问服务的ip进行hash运算后把同一ip的请求路由到同一个pod.这样通过nodePort方式过来的请求就不会到处分发了.下面的timeoutSeconds指的是session保持的时间,这个时间默认是10800秒,也就是三个小时。那么原理是啥呢?当不设置session保持时,service向后台pod转发规则是轮询。当设置了session保持之后,k8s会根据访问的ip来把请求转发给他以前访问过的pod,这样session就保持住了。

     
     
     
  • 相关阅读:
    Ceph相关
    Redis学习
    docker mysql
    WebSocket学习与使用
    nginx学习与使用
    python学习小记
    基数计数——HyperLogLog
    Swagger使用小记
    理解Java枚举类型
    Jenkins使用
  • 原文地址:https://www.cnblogs.com/wxwgk/p/15230015.html
Copyright © 2011-2022 走看看