kind: Service #
apiVersion: v1 #
metadata:
labels: # 标签
k8s-app: drifter-app # 唯一标签 于pod对应
name: drifter-server # svc Name
namespace: ns-drifter # 指定 namespace
spec:
selector:
k8s-app: drifter-app # 唯一标签 于pod 对应
ports: # 注意避免端口冲突哦
- protocol: TCP # 协议
port: 8899 # service ip中的端口
name: drifter-app # 端口名称
targetPort: 8899 # 容器ip中的端口
sessionAffinity: ClientIP # 回话保持配置段
sessionAffinityConfig: #
clientIP: #若有多个副本 sessionAffinity 会未设置导致的问题:第一次请求成功,第二次失败,- 如果是单副本,可忽略
timeoutSeconds: 10800 # session保持的时间 默认10800,也就是3小时
type: ClusterIP # 默认模式,仅用于集群内通信
externalTrafficPolicy: Cluster # (local/Cluster)
# type: NodePort # 接入集群外部的流量 对应的NodePort可以直接访问
k8s Service yml 浅薄理解
于 2020-10-28 10:10:08 首次发布