Skip to content

Commit

Permalink
add network plugin: TencentCloud-CLB
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed Oct 29, 2024
1 parent 3bbb05b commit f809635
Show file tree
Hide file tree
Showing 2 changed files with 208 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1408,6 +1408,109 @@ networkStatus:
networkType: AmazonWebServices-NLB
```

---

### TencentCloud-CLB

#### 插件名称

`TencentCloud-CLB`

#### Cloud Provider

TencentCloud

#### 插件说明

- TencentCloud-CLB 使用腾讯云负载均衡器(CLB)作为对外服务的承载实体,在此模式下,不同游戏服使用 CLB 的不同端口对外暴露,此时 CLB 只做转发,并未均衡流量。
- 需安装 [tke-extend-network-controller](https://github.com/tkestack/tke-extend-network-controller) 网络插件(可通过 TKE 应用市场安装)。
- 是否支持网络隔离:否。

#### 网络参数

ClbIds

- 含义:填写clb的id。可填写多个。
- 填写格式:各个clbId用,分割。例如:lb-xxxx,lb-yyyy,...
- 是否支持变更:支持。

PortProtocols

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

#### 插件配置

```toml
[tencentcloud]
enable = true
[tencentcloud.clb]
# 填写clb可使用的空闲端口段,用于为pod分配外部接入端口
min_port = 1000
max_port = 1100
```

#### 示例说明

```yaml
apiVersion: game.kruise.io/v1alpha1
kind: GameServerSet
metadata:
name: clb-nginx
namespace: default
spec:
replicas: 1
updateStrategy:
rollingUpdate:
podUpdatePolicy: InPlaceIfPossible
network:
networkType: TencentCloud-CLB
networkConf:
- name: ClbIds
value: "lb-3ip9k5kr,lb-4ia8k0yh"
- name: PortProtocols
value: "80/TCP,7777/UDP"
gameServerTemplate:
spec:
containers:
- image: nginx
name: nginx
```
生成的 gameserver clb-nginx-0 networkStatus 字段如下所示:
```yaml
networkStatus:
createTime: "2024-10-28T03:16:20Z"
currentNetworkState: Ready
desiredNetworkState: Ready
externalAddresses:
- ip: 139.155.64.52
ports:
- name: "80"
port: 1002
protocol: TCP
- ip: 139.155.64.52
ports:
- name: "7777"
port: 1003
protocol: UDP
internalAddresses:
- ip: 172.16.7.106
ports:
- name: "80"
port: 80
protocol: TCP
- ip: 172.16.7.106
ports:
- name: "7777"
port: 7777
protocol: UDP
lastTransitionTime: "2024-10-28T03:16:20Z"
networkType: TencentCloud-CLB
```
## 网络隔离
考虑以下场景,如:
Expand Down Expand Up @@ -1538,4 +1641,4 @@ echo " IP: $ip, Port: $port"

Q: 如何更改网络插件配置?

A: 可以通过编辑kruise-game-system命名空间下的configmap对默认参数进行更改。更改后重建kruise-game-manager,使配置生效。建议集群游戏服已使用OKG网络插件的情况下不轻易更改相应配置,应提前做好合理的网络规划。
A: 可以通过编辑kruise-game-system命名空间下的configmap对默认参数进行更改。更改后重建kruise-game-manager,使配置生效。建议集群游戏服已使用OKG网络插件的情况下不轻易更改相应配置,应提前做好合理的网络规划。
105 changes: 104 additions & 1 deletion kruisegame/user-manuals/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,109 @@ spec:
EOF
```

---

### TencentCloud-CLB

#### Plugin name

`TencentCloud-CLB`

#### Cloud Provider

TencentCloud

#### Plugin description

- TencentCloud-CLB enables game servers to be accessed from the Internet by using Cloud Load Balancer (CLB) of Tencent Cloud. CLB is a type of Server Load Balancer (CLB). TencentCloud-CLB uses different ports for different game servers. The CLB instance only forwards traffic, but does not implement load balancing.
- The [tke-extend-network-controller](https://github.com/tkestack/tke-extend-network-controller) network plugin needs to be installed (can be installed through the TKE application market).
- This network plugin does not support network isolation.

#### Network parameters

ClbIds

- Meaning: the CLB instance ID. You can fill in multiple ids.
- Value: in the format of slbId-0,slbId-1,... An example value can be "lb-9zeo7prq1m25ctpfrw1m7,lb-bp1qz7h50yd3w58h2f8je"
- Configuration change supported or not: yes. You can add new slbIds at the end. However, it is recommended not to change existing slbId that is in use.

PortProtocols

- Meaning: the ports in the pod to be exposed and the protocols. You can specify multiple ports and protocols.
- Value: in the format of port1/protocol1,port2/protocol2,... The protocol names must be in uppercase letters.
- Configuration change supported or not: yes.

#### Plugin configuration

```toml
[tencentcloud]
enable = true
[tencentcloud.clb]
# Specify the range of available ports of the CLB instance. Ports in this range can be used to forward Internet traffic to pods. In this example, the range includes 200 ports.
min_port = 1000
max_port = 1100
```

#### Example

```yaml
apiVersion: game.kruise.io/v1alpha1
kind: GameServerSet
metadata:
name: clb-nginx
namespace: default
spec:
replicas: 1
updateStrategy:
rollingUpdate:
podUpdatePolicy: InPlaceIfPossible
network:
networkType: TencentCloud-CLB
networkConf:
- name: ClbIds
value: "lb-3ip9k5kr,lb-4ia8k0yh"
- name: PortProtocols
value: "80/TCP,7777/UDP"
gameServerTemplate:
spec:
containers:
- image: nginx
name: nginx
```

The network status of GameServer would be as follows:

```yaml
networkStatus:
createTime: "2024-10-28T03:16:20Z"
currentNetworkState: Ready
desiredNetworkState: Ready
externalAddresses:
- ip: 139.155.64.52
ports:
- name: "80"
port: 1002
protocol: TCP
- ip: 139.155.64.52
ports:
- name: "7777"
port: 1003
protocol: UDP
internalAddresses:
- ip: 172.16.7.106
ports:
- name: "80"
port: 80
protocol: TCP
- ip: 172.16.7.106
ports:
- name: "7777"
port: 7777
protocol: UDP
lastTransitionTime: "2024-10-28T03:16:20Z"
networkType: TencentCloud-CLB
```

## Network Isolation

Consider the following scenarios, such as:
Expand Down Expand Up @@ -1508,4 +1611,4 @@ echo " IP: $ip, Port: $port"

Q: How to change the network plugin configuration?

A: The default parameters can be changed by editing the configmap under the kruise-game-system namespace. After the change, rebuild kruise-game-manager to make the configuration take effect. It is recommended that the cluster game service already uses the OKG network plug-in does not easily change the corresponding configuration, and should do a reasonable network planning in advance.
A: The default parameters can be changed by editing the configmap under the kruise-game-system namespace. After the change, rebuild kruise-game-manager to make the configuration take effect. It is recommended that the cluster game service already uses the OKG network plug-in does not easily change the corresponding configuration, and should do a reasonable network planning in advance.

0 comments on commit f809635

Please sign in to comment.