Skip to content

Commit

Permalink
fix: name LB with KCE not k8s (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
strideynet authored Jul 20, 2021
1 parent 0814c49 commit 74f0c98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion kce/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func loadBalancerName(clusterName string, service *v1.Service) string {
if service.Namespace != "default" {
ns = fmt.Sprintf("%s-", service.Namespace)
}
untrimmed := fmt.Sprintf("k8s-%s-%s%s", clusterName, ns, service.Name)
untrimmed := fmt.Sprintf("kce-%s-%s%s", clusterName, ns, service.Name)

const trimLength = 60
if len(untrimmed) > trimLength {
Expand Down
16 changes: 8 additions & 8 deletions kce/loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func TestLoadBalancerManager_GetLoadBalancer(t *testing.T) {
name: "exists",
loadBalancers: []core.LoadBalancer{
{
Name: "k8s-test-test-service",
Name: "kce-test-test-service",
IPAddress: &core.IPAddress{Address: "10.0.0.1"},
},
},
Expand Down Expand Up @@ -522,7 +522,7 @@ func TestLoadBalancerManager_GetLoadBalancerName(t *testing.T) {
Namespace: "default",
},
},
want: "k8s-boo-foobar",
want: "kce-boo-foobar",
},
{
name: "custom ns",
Expand All @@ -533,7 +533,7 @@ func TestLoadBalancerManager_GetLoadBalancerName(t *testing.T) {
Namespace: "not-default",
},
},
want: "k8s-boo-not-default-foobar",
want: "kce-boo-not-default-foobar",
},
{
name: "ensure trim to 60",
Expand All @@ -544,7 +544,7 @@ func TestLoadBalancerManager_GetLoadBalancerName(t *testing.T) {
Namespace: "not-default",
},
},
want: "k8s-boo-not-default-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
want: "kce-boo-not-default-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
},
}

Expand Down Expand Up @@ -581,7 +581,7 @@ func TestLoadBalancerManager_EnsureLoadBalancerDeleted(t *testing.T) {
name: "deletes",
loadBalancers: []core.LoadBalancer{
{
Name: "k8s-test-bar-foo",
Name: "kce-test-bar-foo",
IPAddress: &core.IPAddress{Address: "10.0.0.1"},
},
},
Expand Down Expand Up @@ -820,7 +820,7 @@ func TestLoadBalancerManager_EnsureLoadBalancer(t *testing.T) {
loadBalancers: []core.LoadBalancer{
{
ID: "lb_npORVDLVrf7MlghA",
Name: "k8s-example-foobar-bar",
Name: "kce-example-foobar-bar",
IPAddress: &core.IPAddress{Address: "133.7.42.0"},
},
},
Expand All @@ -840,7 +840,7 @@ func TestLoadBalancerManager_EnsureLoadBalancer(t *testing.T) {
wantLoadBalancers: []core.LoadBalancer{
{
ID: "lb_npORVDLVrf7MlghA",
Name: "k8s-example-foobar-bar",
Name: "kce-example-foobar-bar",
IPAddress: &core.IPAddress{Address: "133.7.42.0"},
},
},
Expand All @@ -864,7 +864,7 @@ func TestLoadBalancerManager_EnsureLoadBalancer(t *testing.T) {
wantLoadBalancers: []core.LoadBalancer{
{
ID: "created-0",
Name: "k8s-example-foobar-bar",
Name: "kce-example-foobar-bar",
IPAddress: &core.IPAddress{Address: "10.0.0.0"},
ResourceType: core.VirtualMachineGroupsResourceType,
ResourceIDs: []string{"node-tag-id"},
Expand Down

0 comments on commit 74f0c98

Please sign in to comment.