Skip to content

Allow specifying --enable-ula-internal-ipv6 at network creation. This… #35162

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

Closed
wants to merge 2 commits into from
Closed
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
23 changes: 22 additions & 1 deletion kubetest/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ var (
gkeRemoveNetwork = flag.Bool("gke-remove-network", true, "(gke only) At the end of the test remove non-default network that was used by cluster.")
gkeDumpConfigMaps = flag.String("gke-dump-configmaps", "[]", `(gke-only) A JSON description of ConfigMaps to dump as part of gathering cluster logs. Note: --dump or --dump-pre-test-logs flags must also be set. Example: '[{"Name":"my-map", "Namespace":"default", "DataKey":"my-data-key"}]`)
gkeDumpAdditionalLogsCmd = flag.String("gke-dump-additional-logs-cmd", "", "(gke-only) if set, run this command to dump cluster logs.")
gkeNetworkULAInternalIPv6 = flag.Bool("gke-network-ula-internal-ipv6", false, "(gke-only) if true, create a network with --enable-ula-internal-ipv6.")

// poolReTemplate matches instance group URLs of the form `https://www.googleapis.com/compute/v1/projects/some-project/zones/a-zone/instanceGroupManagers/gke-some-cluster-some-pool-90fcb815-grp`. Match meaning:
// m[0]: path starting with zones/
Expand Down Expand Up @@ -102,6 +103,7 @@ type gkeDeployer struct {
cluster string
shape map[string]gkeNodePool
network string
networkULAInternalIPv6 bool
subnetwork string
subnetMode string
subnetworkRegion string
Expand Down Expand Up @@ -167,6 +169,8 @@ func newGKE(provider, project, zone, region, network, image, imageFamily, imageP
}
g.network = network

g.networkULAInternalIPv6 = *gkeNetworkULAInternalIPv6

if strings.ToUpper(image) == "CUSTOM" {
if imageFamily == "" || imageProject == "" {
return nil, fmt.Errorf("--image-family and --image-project must be set for GKE deployment if --gcp-node-image=CUSTOM")
Expand Down Expand Up @@ -326,9 +330,16 @@ func (g *gkeDeployer) Up() error {
"--format=value(name)")) != nil {
// Assume error implies non-existent.
log.Printf("Couldn't describe network '%s', assuming it doesn't exist and creating it", g.network)

enableULAInternalIPv6 := ""
if g.networkULAInternalIPv6 {
enableULAInternalIPv6 = "--enable-ula-internal-ipv6"
}

if err := control.FinishRunning(exec.Command("gcloud", "compute", "networks", "create", g.network,
"--project="+g.project,
"--subnet-mode="+g.subnetMode)); err != nil {
"--subnet-mode="+g.subnetMode,
enableULAInternalIPv6)); err != nil {
return err
}
}
Expand Down Expand Up @@ -437,6 +448,16 @@ func (g *gkeDeployer) Up() error {
return fmt.Errorf("error creating node pool %q: %w", poolName, err)
}
}

endpoint, err := exec.Command("gcloud", "container", "clusters", "describe", g.cluster, "--project=", g.project, "--location", g.location, "--format='value(controlPlaneEndpointsConfig.dnsEndpointConfig.endpoint)'")
if err != nil {
return fmt.Errorf("error fetching cluster endpoint: %v", err)
}

if err = os.Setenv("GKFE_CLUSTER_ENDPOINT", string(endpoint)); err != nil {
return fmt.Errorf("error setting GKFE cluster endpoint: %v", err)
}

return nil
}

Expand Down