Skip to content

Commit 6bba287

Browse files
authored
feat: add jdcloud provider and the nlb&eip plugin (openkruise#180)
1 parent 468b2c7 commit 6bba287

File tree

11 files changed

+1532
-0
lines changed

11 files changed

+1532
-0
lines changed

cloudprovider/config.go

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type CloudProviderConfig struct {
4848
VolcengineOptions CloudProviderOptions
4949
AmazonsWebServicesOptions CloudProviderOptions
5050
TencentCloudOptions CloudProviderOptions
51+
JdCloudOptions CloudProviderOptions
5152
}
5253

5354
type tomlConfigs struct {
@@ -56,6 +57,7 @@ type tomlConfigs struct {
5657
Volcengine options.VolcengineOptions `toml:"volcengine"`
5758
AmazonsWebServices options.AmazonsWebServicesOptions `toml:"aws"`
5859
TencentCloud options.TencentCloudOptions `toml:"tencentcloud"`
60+
JdCloud options.JdCloudOptions `toml:"jdcloud"`
5961
}
6062

6163
func (cf *ConfigFile) Parse() *CloudProviderConfig {
@@ -70,6 +72,7 @@ func (cf *ConfigFile) Parse() *CloudProviderConfig {
7072
VolcengineOptions: config.Volcengine,
7173
AmazonsWebServicesOptions: config.AmazonsWebServices,
7274
TencentCloudOptions: config.TencentCloud,
75+
JdCloudOptions: config.JdCloud,
7376
}
7477
}
7578

cloudprovider/jdcloud/README.md

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
English | [中文](./README.md)
2+
3+
Based on JdCloud Container Service, for game scenarios, combine OKG to provide various network model plugins.
4+
5+
## JdCloud-NLB configuration
6+
7+
JdCloud Container Service supports the reuse of NLB (Network Load Balancer) in Kubernetes. Different services (svcs) can use different ports of the same NLB. As a result, the JdCloud-NLB network plugin will record the port allocation for each NLB. For services that specify the network type as JdCloud-NLB, the JdCloud-NLB network plugin will automatically allocate a port and create a service object. Once it detects that the public IP of the svc has been successfully created, the GameServer's network will transition to the Ready state, completing the process.
8+
9+
### plugin configuration
10+
```toml
11+
[jdcloud]
12+
enable = true
13+
[jdcloud.nlb]
14+
#To allocate external access ports for Pods, you need to define the idle port ranges that the NLB (Network Load Balancer) can use. The maximum range for each port segment is 200 ports.
15+
max_port = 700
16+
min_port = 500
17+
```
18+
19+
### Parameter
20+
#### NlbIds
21+
- Meaning:fill in the id of the clb. You can fill in more than one. You need to create the clb in [JdCloud].
22+
- Value:each clbId is divided by `,` . For example:`netlb-aaa,netlb-bbb,...`
23+
- Configurable:Y
24+
25+
#### PortProtocols
26+
- Meaning:the ports and protocols exposed by the pod, support filling in multiple ports/protocols
27+
- Value:`port1/protocol1`,`port2/protocol2`,... The protocol names must be in uppercase letters.
28+
- Configurable:Y
29+
30+
#### Fixed
31+
- Meaning:whether the mapping relationship is fixed. If the mapping relationship is fixed, the mapping relationship remains unchanged even if the pod is deleted and recreated.
32+
- Value:false / true
33+
- Configurable:Y
34+
35+
#### AllocateLoadBalancerNodePorts
36+
- Meaning:Whether the generated service is assigned nodeport, this can be set to false only in nlb passthrough mode
37+
- Value:false / true
38+
- Configurable:Y
39+
40+
#### AllowNotReadyContainers
41+
- Meaning:the container names that are allowed not ready when inplace updating, when traffic will not be cut.
42+
- Value:{containerName_0},{containerName_1},... eg:sidecar
43+
- Configurable:It cannot be changed during the in-place updating process.
44+
45+
#### Annotations
46+
- Meaning:the anno added to the service
47+
- Value:key1:value1,key2:value2...
48+
- Configurable:Y
49+
50+
51+
### Example
52+
```yaml
53+
cat <<EOF | kubectl apply -f -
54+
apiVersion: game.kruise.io/v1alpha1
55+
kind: GameServerSet
56+
metadata:
57+
name: nlb
58+
namespace: default
59+
spec:
60+
replicas: 3
61+
updateStrategy:
62+
rollingUpdate:
63+
podUpdatePolicy: InPlaceIfPossible
64+
network:
65+
networkType: JdCloud-NLB
66+
networkConf:
67+
- name: NlbIds
68+
#Fill in Jdcloud Cloud LoadBalancer Id here
69+
value: netlb-xxxxx
70+
- name: PortProtocols
71+
#Fill in the exposed ports and their corresponding protocols here.
72+
#If there are multiple ports, the format is as follows: {port1}/{protocol1},{port2}/{protocol2}...
73+
#If the protocol is not filled in, the default is TCP
74+
value: 80/TCP
75+
- name: AllocateLoadBalancerNodePorts
76+
# Whether the generated service is assigned nodeport.
77+
value: "true"
78+
- name: Fixed
79+
#Fill in here whether a fixed IP is required [optional] ; Default is false
80+
value: "false"
81+
- name: Annotations
82+
#Fill in the anno related to clb on the service
83+
#The format is as follows: {key1}:{value1},{key2}:{value2}...
84+
value: "key1:value1,key2:value2"
85+
gameServerTemplate:
86+
spec:
87+
containers:
88+
- args:
89+
- /data/server/start.sh
90+
command:
91+
- /bin/bash
92+
image: gss-cn-north-1.jcr.service.jdcloud.com/gsshosting/pal:v1
93+
name: game-server
94+
EOF
95+
```
96+
97+
Check the network status in GameServer:
98+
```
99+
networkStatus:
100+
createTime: "2024-11-04T08:00:20Z"
101+
currentNetworkState: Ready
102+
desiredNetworkState: Ready
103+
externalAddresses:
104+
- ip: xxx.xxx.xxx.xxx
105+
ports:
106+
- name: "8211"
107+
port: 531
108+
protocol: UDP
109+
internalAddresses:
110+
- ip: 10.0.0.95
111+
ports:
112+
- name: "8211"
113+
port: 8211
114+
protocol: UDP
115+
lastTransitionTime: "2024-11-04T08:00:20Z"
116+
networkType: JdCloud-NLB
117+
```
118+
119+
120+
## JdCloud-EIP configuration
121+
JdCloud Container Service supports binding an Elastic Public IP directly to a pod in Kubernetes, allowing the pod to communicate directly with the external network.
122+
- The cluster's network plugin uses Yunjian-CNI and cannot use Flannel to create the cluster.
123+
- For specific usage restrictions of Elastic Public IPs, please refer to the JdCloud Elastic Public IP product documentation.
124+
- Install the EIP-Controller component.
125+
- The Elastic Public IP will not be deleted when the pod is destroyed.
126+
127+
### Parameter
128+
129+
#### BandwidthConfigName
130+
- Meaning:The bandwidth of the Elastic Public IP, measured in Mbps, has a value range of [1, 1024].
131+
- Value:Must be an integer
132+
- Configurable:Y
133+
134+
#### ChargeTypeConfigName
135+
- Meaning:The billing method for the Elastic Public IP
136+
- Value:string, `postpaid_by_usage`/`postpaid_by_duration`
137+
- Configurable:Y
138+
139+
#### FixedEIPConfigName
140+
- Meaning:Whether to fixed the Elastic Public IP,if so, the EIP will not be changed when the pod is recreated.
141+
- Value:string, "false" / "true"
142+
- Configurable:Y
143+
144+
#### AssignEIPConfigName
145+
- Meaning:Whether to designate a specific Elastic Public IP. If true, provide the ID of the Elastic Public IP; otherwise, an EIP will be automatically allocated.
146+
- Value:string, "false" / "true"
147+
148+
#### EIPIdConfigName
149+
- Meaning:If a specific Elastic Public IP is designated, the ID of the Elastic Public IP must be provided, and the component will automatically perform the lookup and binding.
150+
- Value:string,for example:`fip-xxxxxxxx`
151+
152+
### Example
153+
```yaml
154+
cat <<EOF | kubectl apply -f -
155+
apiVersion: game.kruise.io/v1alpha1
156+
kind: GameServerSet
157+
metadata:
158+
name: eip
159+
namespace: default
160+
spec:
161+
containers:
162+
- args:
163+
- /data/server/start.sh
164+
command:
165+
- /bin/bash
166+
image: gss-cn-north-1.jcr.service.jdcloud.com/gsshosting/pal:v1
167+
name: game-server
168+
network:
169+
networkType: JdCloud-EIP
170+
networkConf:
171+
- name: "BandWidth"
172+
value: "10"
173+
- name: "ChargeType"
174+
value: postpaid_by_usage
175+
- name: "Fixed"
176+
value: "false"
177+
replicas: 3
178+
EOF
179+
```
180+
181+
Check the network status in GameServer:
182+
```
183+
networkStatus:
184+
createTime: "2024-11-04T10:53:14Z"
185+
currentNetworkState: Ready
186+
desiredNetworkState: Ready
187+
externalAddresses:
188+
- ip: xxx.xxx.xxx.xxx
189+
internalAddresses:
190+
- ip: 10.0.0.95
191+
lastTransitionTime: "2024-11-04T10:53:14Z"
192+
networkType: JdCloud-EIP
193+
```

0 commit comments

Comments
 (0)