Skip to content

Commit 94c73aa

Browse files
committed
Refactor code
1 parent c86625a commit 94c73aa

File tree

16 files changed

+49
-78
lines changed

16 files changed

+49
-78
lines changed

cmd/kops/create_cluster_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func TestCreateClusterCilium(t *testing.T) {
8181
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/cilium-eni", "v1alpha2")
8282
}
8383

84-
// TestCreateClusterCiliumGCE runs kops with the cilium networking flags
84+
// TestCreateClusterCiliumGCE runs kops with the gcp-with-cilium networking flag
8585
func TestCreateClusterCiliumGCE(t *testing.T) {
8686
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/cilium-gce", "v1alpha2")
8787
}

docs/cli/kops_create_cluster.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

k8s/crds/kops.k8s.io_clusters.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5950,9 +5950,7 @@ spec:
59505950
networking mode, using IP aliases.
59515951
properties:
59525952
cilium:
5953-
description: |-
5954-
Cilium enables Cilium on GCP.
5955-
Cilium *bool `json:"cilium,omitempty"`
5953+
description: Cilium enables Cilium on GCP.
59565954
properties:
59575955
IPTablesRulesNoinstall:
59585956
description: |-

pkg/apis/kops/networking.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ func (n *NetworkingSpec) UsesKubenet() bool {
103103
}
104104
if n.Kubenet != nil {
105105
return true
106-
} else if n.External != nil { //TODO: Change behaviour with GCP
106+
} else if n.GCP != nil && n.GCP.Cilium == nil {
107+
// GCP IP Alias networking is based on kubenet
108+
return true
109+
} else if n.External != nil {
107110
// external is based on kubenet
108111
return true
109112
} else if n.Kopeio != nil {
@@ -588,7 +591,6 @@ type LyftVPCNetworkingSpec struct {
588591
// GCPNetworkingSpec is the specification of GCP's native networking mode, using IP aliases.
589592
type GCPNetworkingSpec struct {
590593
// Cilium enables Cilium on GCP.
591-
// Cilium *bool `json:"cilium,omitempty"`
592594
Cilium *CiliumNetworkingSpec `json:"cilium,omitempty"`
593595
}
594596

@@ -617,11 +619,3 @@ type KindnetMasqueradeSpec struct {
617619
Enabled *bool `json:"enabled,omitempty"`
618620
NonMasqueradeCIDRs []string `json:"nonMasqueradeCIDRs,omitempty"`
619621
}
620-
621-
// ValueOf returns the value of a pointer or its zero value
622-
func ValueOf[T any](v *T) T {
623-
if v == nil {
624-
return *new(T)
625-
}
626-
return *v
627-
}

pkg/apis/kops/v1alpha2/networking.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,6 @@ type LyftVPCNetworkingSpec struct {
703703
// GCPNetworkingSpec is the specification of GCP's native networking mode, using IP aliases.
704704
type GCPNetworkingSpec struct {
705705
// Cilium enables Cilium on GCP.
706-
// Cilium *bool `json:"cilium,omitempty"`
707706
Cilium *CiliumNetworkingSpec `json:"cilium,omitempty"`
708707
}
709708

pkg/apis/kops/v1alpha3/networking.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,6 @@ type HubbleSpec struct {
528528
// GCPNetworkingSpec is the specification of GCP's native networking mode, using IP aliases.
529529
type GCPNetworkingSpec struct {
530530
// Cilium enables Cilium on GCP.
531-
// Cilium *bool `json:"cilium,omitempty"`
532531
Cilium *CiliumNetworkingSpec `json:"cilium,omitempty"`
533532
}
534533

pkg/apis/nodeup/config.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,3 @@ func containsRole(v kops.InstanceGroupRole, list []kops.InstanceGroupRole) bool
521521

522522
return false
523523
}
524-
525-
// ValueOf returns the value of a pointer or its zero value
526-
func ValueOf[T any](v *T) T {
527-
if v == nil {
528-
return *new(T)
529-
}
530-
return *v
531-
}

tests/integration/create_cluster/cilium-gce/expected-v1alpha2.yaml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ spec:
1616
etcdClusters:
1717
- cpuRequest: 200m
1818
etcdMembers:
19-
- instanceGroup: control-plane-us-test-1a
19+
- instanceGroup: control-plane-us-test1-a
2020
name: a
2121
manager:
2222
backupRetentionDays: 90
2323
memoryRequest: 100Mi
2424
name: main
2525
- cpuRequest: 100m
2626
etcdMembers:
27-
- instanceGroup: control-plane-us-test-1a
27+
- instanceGroup: control-plane-us-test1-a
2828
name: a
2929
manager:
3030
backupRetentionDays: 90
@@ -42,17 +42,20 @@ spec:
4242
- ::/0
4343
kubernetesVersion: v1.32.0
4444
networking:
45-
cilium:
46-
enableNodePort: true
47-
nonMasqueradeCIDR: 100.64.0.0/10
45+
gce:
46+
cilium:
47+
enableNodePort: true
48+
nonMasqueradeCIDR: 10.0.0.0/8
49+
podCIDR: 10.4.0.0/14
4850
project: testproject
51+
serviceClusterIPRange: 10.1.0.0/16
4952
sshAccess:
5053
- 0.0.0.0/0
5154
- ::/0
5255
subnets:
53-
- cidr: 10.0.16.0/20
54-
name: us-test
55-
region: us-test
56+
- cidr: 10.0.32.0/19
57+
name: us-test1
58+
region: us-test1
5659
type: Public
5760
topology:
5861
dns:
@@ -66,17 +69,17 @@ metadata:
6669
creationTimestamp: "2017-01-01T00:00:00Z"
6770
labels:
6871
kops.k8s.io/cluster: minimal.example.com
69-
name: control-plane-us-test-1a
72+
name: control-plane-us-test1-a
7073
spec:
7174
image: ubuntu-os-cloud/ubuntu-2404-noble-amd64-v20250606
7275
machineType: e2-medium
7376
maxSize: 1
7477
minSize: 1
7578
role: Master
7679
subnets:
77-
- us-test
80+
- us-test1
7881
zones:
79-
- us-test-1a
82+
- us-test1-a
8083

8184
---
8285

@@ -86,14 +89,14 @@ metadata:
8689
creationTimestamp: "2017-01-01T00:00:00Z"
8790
labels:
8891
kops.k8s.io/cluster: minimal.example.com
89-
name: nodes-us-test-1a
92+
name: nodes-us-test1-a
9093
spec:
9194
image: ubuntu-os-cloud/ubuntu-2404-noble-amd64-v20250606
9295
machineType: e2-medium
9396
maxSize: 1
9497
minSize: 1
9598
role: Node
9699
subnets:
97-
- us-test
100+
- us-test1
98101
zones:
99-
- us-test-1a
102+
- us-test1-a
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ClusterName: minimal.example.com
2+
CloudProvider: gce
3+
Networking: gcp-with-cilium
24
Project: testproject
5+
KubernetesVersion: v1.32.0
36
Zones:
4-
- us-test-1a
5-
CloudProvider: gce
6-
Networking: cilium
7-
KubernetesVersion: v1.32.0
7+
- us-test1-a

tests/integration/update_cluster/cilium-gce/kubernetes.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -653,14 +653,14 @@ resource "google_compute_subnetwork" "us-test1-cilium-gce-example-com" {
653653
name = "us-test1-cilium-gce-example-com"
654654
network = google_compute_network.cilium-gce-example-com.name
655655
region = "us-test1"
656-
secondary_ip_range {
657-
ip_cidr_range = "10.4.0.0/14"
658-
range_name = "pods-cilium-gce-example-com"
659-
}
660656
secondary_ip_range {
661657
ip_cidr_range = "10.1.0.0/16"
662658
range_name = "services-cilium-gce-example-com"
663659
}
660+
secondary_ip_range {
661+
ip_cidr_range = "10.4.0.0/14"
662+
range_name = "pods-cilium-gce-example-com"
663+
}
664664
stack_type = "IPV4_ONLY"
665665
}
666666

0 commit comments

Comments
 (0)