Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Set the k8s-cloud-provider API domain" #2060

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions cmd/glbc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"os"
"time"

k8scp "github.com/GoogleCloudPlatform/k8s-cloud-provider/pkg/cloud"
flag "github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/ingress-gce/pkg/frontendconfig"
Expand All @@ -35,7 +34,6 @@ import (
"k8s.io/ingress-gce/pkg/serviceattachment"
"k8s.io/ingress-gce/pkg/servicemetrics"
"k8s.io/ingress-gce/pkg/svcneg"
"k8s.io/ingress-gce/pkg/utils"
"k8s.io/klog/v2"

crdclient "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
Expand Down Expand Up @@ -191,14 +189,6 @@ func main() {
kubeSystemUID := kubeSystemNS.GetUID()

cloud := app.NewGCEClient()

// Globally set the domain for all urls generated by GoogleCloudPlatform/k8s-cloud-provider.
// The cloud object is configured by the gce.conf file and parsed in app.NewGCEClient().
// basePath will be of the form <URL>/v1
domain := utils.GetDomainFromGABasePath(cloud.ComputeServices().GA.BasePath)
klog.Infof("Setting k8s-cloud-provider API Domain to %q", domain)
k8scp.SetAPIDomain(domain)

defaultBackendServicePort := app.DefaultBackendServicePort(kubeClient)
ctxConfig := ingctx.ControllerContextConfig{
Namespace: flags.F.WatchNamespace,
Expand Down
9 changes: 0 additions & 9 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -868,12 +868,3 @@ func AddIPToLBStatus(status *api_v1.LoadBalancerStatus, ips ...string) *api_v1.L
}
return status
}

// GetDomainFromGABasePath takes a GA base path of the form <path>/compute/v1 and returns the path.
func GetDomainFromGABasePath(basePath string) string {
// Trim URL to remove the "/v1" part since we are using the GA path.
// Start by trimming any trailing "/"
domain := strings.TrimSuffix(basePath, "/")
domain = strings.TrimSuffix(domain, "/compute/v1")
return domain
}
40 changes: 0 additions & 40 deletions pkg/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1535,43 +1535,3 @@ func TestAddIPToLBStatus(t *testing.T) {
})
}
}

func TestGetDomainFromGABasePath(t *testing.T) {
testCases := []struct {
desc string
basePath string
want string
}{
{
desc: "empty string",
},
{
desc: "compute.googleapis.com path",
basePath: "https://www.compute.googleapis.com/compute/v1",
want: "https://www.compute.googleapis.com",
},
{
desc: "arbitary path",
basePath: "mycompute.mydomain.com/mypath/compute/v1",
want: "mycompute.mydomain.com/mypath",
},
{
desc: "arbitary path with trailing /",
basePath: "mycompute.mydomain.com/mypath/compute/v1/",
want: "mycompute.mydomain.com/mypath",
},
{
desc: "arbitary path without /v1 -- should return same string",
basePath: "mycompute.mydomain.com/mypath/compute",
want: "mycompute.mydomain.com/mypath/compute",
},
}

for _, tc := range testCases {
t.Run(tc.desc, func(t *testing.T) {
if got := GetDomainFromGABasePath(tc.basePath); got != tc.want {
t.Errorf("GetDomainFromGABasePath(%s) = %s, want %s", tc.basePath, got, tc.want)
}
})
}
}