Skip to content

Commit

Permalink
feat: AlibabaCloud-EIP support to define EIP name & description (#91)
Browse files Browse the repository at this point in the history
Signed-off-by: ChrisLiu <[email protected]>
  • Loading branch information
chrisliu1995 authored Aug 4, 2023
1 parent acc12c1 commit 3f5a1ea
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cloudprovider/alibabacloud/eip.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ const (
BandwidthConfigName = "Bandwidth"
BandwidthPackageIdConfigName = "BandwidthPackageId"
ChargeTypeConfigName = "ChargeType"
DescriptionConfigName = "Description"
WithEIPAnnotationKey = "k8s.aliyun.com/pod-with-eip"
ReleaseStrategyAnnotationkey = "k8s.aliyun.com/pod-eip-release-strategy"
PoolIdAnnotationkey = "k8s.aliyun.com/eip-public-ip-address-pool-id"
ResourceGroupIdAnnotationkey = "k8s.aliyun.com/eip-resource-group-id"
BandwidthAnnotationkey = "k8s.aliyun.com/eip-bandwidth"
BandwidthPackageIdAnnotationkey = "k8s.aliyun.com/eip-common-bandwidth-package-id"
ChargeTypeConfigAnnotationkey = "k8s.aliyun.com/eip-internet-charge-type"
EIPNameAnnotationKey = "k8s.aliyun.com/eip-name"
EIPDescriptionAnnotationKey = "k8s.aliyun.com/eip-description"
)

type EipPlugin struct {
Expand All @@ -50,6 +53,7 @@ func (E EipPlugin) OnPodAdded(client client.Client, pod *corev1.Pod, ctx context
conf := networkManager.GetNetworkConfig()

pod.Annotations[WithEIPAnnotationKey] = "true"
pod.Annotations[EIPNameAnnotationKey] = pod.GetNamespace() + "/" + pod.GetName()
// parse network configuration
for _, c := range conf {
switch c.Name {
Expand All @@ -65,6 +69,8 @@ func (E EipPlugin) OnPodAdded(client client.Client, pod *corev1.Pod, ctx context
pod.Annotations[BandwidthPackageIdAnnotationkey] = c.Value
case ChargeTypeConfigName:
pod.Annotations[ChargeTypeConfigAnnotationkey] = c.Value
case DescriptionConfigName:
pod.Annotations[EIPDescriptionAnnotationKey] = c.Value
}
}

Expand Down
9 changes: 8 additions & 1 deletion docs/en/user_manuals/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,11 @@ ChargeType
- PayByBandwidth: Fees are charged based on bandwidth usage.
- Configuration change supported or not: no.
Description
- Meaning: The description of EIP resource
- Configuration change supported or not: no.
#### Plugin configuration
None
Expand Down Expand Up @@ -609,4 +614,6 @@ status:
privateIPAddress: 192.168.1.51
resourceGroupID: rg-xxx
status: InUse
```
```
In addition, the generated EIP resource will be named after {pod namespace}/{pod name} in the Alibaba Cloud console, which corresponds to each game server one by one.
7 changes: 7 additions & 0 deletions docs/中文/用户手册/网络模型.md
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ ChargeType
- PayByBandwidth:按带宽计费,为默认值。
- 是否支持变更:否
Description
- 含义:对EIP资源的描述。
- 是否支持变更:否
#### 插件配置
Expand Down Expand Up @@ -609,6 +614,8 @@ status:
status: InUse
```
此外,生成的EIP资源在阿里云控制台中会以{pod namespace}/{pod name}命名,与每一个游戏服一一对应。
## 获取网络信息
GameServer Network Status可以通过两种方式获取
Expand Down

0 comments on commit 3f5a1ea

Please sign in to comment.