kruise-game/cloudprovider/jdcloud/README.zh_CN.md

6.0 KiB
Raw Blame History

中文 | English

基于京东云容器服务针对游戏场景结合OKG提供各网络模型插件。

JdCloud-NLB 相关配置

京东云容器服务支持在k8s中对NLB复用的机制不同的svc可以使用同一个NLB的不同端口。由此JdCloud-NLB network plugin将记录各NLB对应的端口分配情况对于指定了网络类型为JdCloud-NLBJdCloud-NLB网络插件将会自动分配一个端口并创建一个service对象待检测到svc公网IP创建成功后GameServer的网络变为Ready状态该过程执行完成。

plugin配置

[jdcloud]
enable = true
[jdcloud.nlb]
#填写nlb可使用的空闲端口段用于为pod分配外部接入端口范围最大为200
max_port = 700
min_port = 500

参数

NlbIds

  • 含义填写nlb的id可填写多个需要先在【京东云】中创建好nlb。
  • 填写格式各个nlbId用,分割。例如netlb-aaa,netlb-bbb,...
  • 是否支持变更:是

PortProtocols

  • 含义pod暴露的端口及协议支持填写多个端口/协议
  • 填写格式port1/protocol1,port2/protocol2,...(协议需大写)
  • 是否支持变更:是

Fixed

  • 含义是否固定访问IP/端口。若是即使pod删除重建网络内外映射关系不会改变
  • 填写格式false / true
  • 是否支持变更:是

AllocateLoadBalancerNodePorts

  • 含义生成的service是否分配nodeport, 仅在nlb的直通模式passthrough才能设置为false
  • 填写格式true/false
  • 是否支持变更:是

AllowNotReadyContainers

  • 含义:在容器原地升级时允许不断流的对应容器名称,可填写多个
  • 填写格式:{containerName_0},{containerName_1},... 例如sidecar
  • 是否支持变更:在原地升级过程中不可变更

Annotations

  • 含义添加在service上的anno可填写多个
  • 填写格式key1:value1,key2:value2...
  • 是否支持变更:是

使用示例

cat <<EOF | kubectl apply -f -
apiVersion: game.kruise.io/v1alpha1
kind: GameServerSet
metadata:
  name: nlb
  namespace: default
spec:
  replicas: 3
  updateStrategy:
    rollingUpdate:
      podUpdatePolicy: InPlaceIfPossible
  network:
    networkType: JdCloud-NLB
    networkConf:
      - name: NlbIds
        #Fill in Jdcloud Cloud LoadBalancer Id here
        value: netlb-xxxxx
      - name: PortProtocols
        #Fill in the exposed ports and their corresponding protocols here. 
        #If there are multiple ports, the format is as follows: {port1}/{protocol1},{port2}/{protocol2}...
        #If the protocol is not filled in, the default is TCP
        value: 80/TCP
      - name: AllocateLoadBalancerNodePorts
        # Whether the generated service is assigned nodeport.
        value: "true"
      - name: Fixed
        #Fill in here whether a fixed IP is required [optional] ; Default is false
        value: "false"
      - name: Annotations
        #Fill in the anno related to clb on the service
        #The format is as follows: {key1}:{value1},{key2}:{value2}...
        value: "key1:value1,key2:value2"
  gameServerTemplate: 
    spec:
      containers:
        - args:
          - /data/server/start.sh
          command:
          - /bin/bash
          image: gss-cn-north-1.jcr.service.jdcloud.com/gsshosting/pal:v1
          name: game-server
EOF

检查GameServer中的网络状态:

networkStatus:
    createTime: "2024-11-04T08:00:20Z"
    currentNetworkState: Ready
    desiredNetworkState: Ready
    externalAddresses:
    - ip: xxx.xxx.xxx.xxx
      ports:
      - name: "8211"
        port: 531
        protocol: UDP
    internalAddresses:
    - ip: 10.0.0.95
      ports:
      - name: "8211"
        port: 8211
        protocol: UDP
    lastTransitionTime: "2024-11-04T08:00:20Z"
    networkType: JdCloud-NLB

JdCloud-EIP 相关配置

京东云容器服务支持在k8s中让一个 pod 和弹性公网 IP 直接进行绑定,可以让 pod 直接与外部网络进行通信。

  • 集群的网络插件使用 yunjian-CNI不可使用 flannel 创建集群
  • 弹性公网 IP 使用限制请具体参考京东云弹性公网 IP 产品文档
  • 安装 EIP-Controller 组件
  • 弹性公网 IP 不会随 POD 的销毁而删除

参数

BandwidthConfigName

  • 含义弹性公网IP的带宽单位为 Mbps取值范围为 [1,1024]
  • 填写格式:必须填整数,且不带单位
  • 是否支持变更:是

ChargeTypeConfigName

  • 含义弹性公网IP的计费方式取值按量计费postpaid_by_usage包年包月postpaid_by_duration
  • 填写格式:字符串
  • 是否支持变更:是

FixedEIPConfigName

  • 含义是否固定弹性公网IP。若是即使pod删除重建弹性公网IP也不会改变
  • 填写格式:"false" / "true",字符串
  • 是否支持变更:是

AssignEIPConfigName

  • 含义是否指定使用某个弹性公网IP请填写 true否则自动分配一个EIP
  • 填写格式:"false" / "true",字符串

EIPIdConfigName

  • 含义若指定使用某个弹性公网IP则必须填写弹性公网IP的ID组件会自动进行进行查询和绑定
  • 填写格式字符串例如fip-xxxxxxxx

使用示例

cat <<EOF | kubectl apply -f -
apiVersion: game.kruise.io/v1alpha1
kind: GameServerSet
metadata:
  name: eip
  namespace: default
spec:
  containers:
    - args:
        - /data/server/start.sh
      command:
        - /bin/bash
      image: gss-cn-north-1.jcr.service.jdcloud.com/gsshosting/pal:v1
      name: game-server
  network:
    networkType: JdCloud-EIP
    networkConf:
      - name: "BandWidth"
        value: "10"
      - name: "ChargeType"
        value: postpaid_by_usage
      - name: "Fixed"
        value: "false"
  replicas: 3
EOF

检查GameServer中的网络状态:

networkStatus:
    createTime: "2024-11-04T10:53:14Z"
    currentNetworkState: Ready
    desiredNetworkState: Ready
    externalAddresses:
    - ip: xxx.xxx.xxx.xxx
    internalAddresses:
    - ip: 10.0.0.95
    lastTransitionTime: "2024-11-04T10:53:14Z"
    networkType: JdCloud-EIP