Skip to content

Commit 9c98907

Browse files
committed
Add Cilium bool field to GCPNetworkingSpec
Also makes it so IP alias is always used when GCP is set
1 parent 46d8ed7 commit 9c98907

49 files changed

Lines changed: 4052 additions & 18 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/kops/create_cluster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command {
325325
cmd.Flags().StringVar(&options.EtcdStorageType, "etcd-storage-type", options.EtcdStorageType, "The default storage type for etcd members")
326326
cmd.RegisterFlagCompletionFunc("etcd-storage-type", completeStorageType)
327327

328-
cmd.Flags().StringVar(&options.Networking, "networking", options.Networking, "Networking mode. kubenet, external, flannel-vxlan (or flannel), flannel-udp, calico, kube-router, amazonvpc, cilium, cilium-etcd, kindnet, cni.")
328+
cmd.Flags().StringVar(&options.Networking, "networking", options.Networking, "Networking mode. kubenet, external, flannel-vxlan (or flannel), flannel-udp, calico, kube-router, amazonvpc, cilium, gcp-with-cilium, cilium-etcd, kindnet, cni.")
329329
cmd.RegisterFlagCompletionFunc("networking", completeNetworking(options))
330330

331331
cmd.Flags().StringVar(&options.DNSZone, "dns-zone", options.DNSZone, "DNS hosted zone (defaults to longest matching zone)")
@@ -1016,7 +1016,7 @@ func completeNetworking(options *CreateClusterOptions) func(cmd *cobra.Command,
10161016
}
10171017

10181018
if options.CloudProvider == "gce" || options.CloudProvider == "" {
1019-
completions = append(completions, "gcp")
1019+
completions = append(completions, "gcp", "gcp-with-cilium")
10201020
}
10211021
}
10221022

cmd/kops/create_cluster_integration_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ 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
85+
func TestCreateClusterCiliumGCE(t *testing.T) {
86+
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/cilium-gce", "v1alpha2")
87+
}
88+
8489
// TestCreateClusterOverride tests the override flag
8590
func TestCreateClusterOverride(t *testing.T) {
8691
runCreateClusterIntegrationTest(t, "../../tests/integration/create_cluster/overrides", "v1alpha2")

cmd/kops/integration_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,15 @@ func TestMinimalIPv6Cilium(t *testing.T) {
541541
runTestTerraformAWS(t)
542542
}
543543

544+
func TestCiliumGCE(t *testing.T) {
545+
newIntegrationTest("cilium-gce.example.com", "cilium-gce").
546+
withAddons(
547+
ciliumAddon,
548+
dnsControllerAddon,
549+
gcpCCMAddon).
550+
runTestTerraformGCE(t)
551+
}
552+
544553
// TestMinimalIPv6NoSubnetPrefix runs the test with "/64#N" subnet notation
545554
func TestMinimalIPv6NoSubnetPrefix(t *testing.T) {
546555
newIntegrationTest("minimal-ipv6.example.com", "minimal-ipv6-no-subnet-prefix").

k8s/crds/kops.k8s.io_clusters.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5948,6 +5948,10 @@ spec:
59485948
gce:
59495949
description: GCPNetworkingSpec is the specification of GCP's native
59505950
networking mode, using IP aliases.
5951+
properties:
5952+
cilium:
5953+
description: Cilium enables Cilium on GCP.
5954+
type: boolean
59515955
type: object
59525956
kindnet:
59535957
description: KindnetNetworkingSpec configures Kindnet settings.

pkg/apis/kops/cluster.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,8 @@ func (c *Cluster) UsesNoneDNS() bool {
955955
func (c *Cluster) InstallCNIAssets() bool {
956956
return c.Spec.Networking.AmazonVPC == nil &&
957957
c.Spec.Networking.Calico == nil &&
958-
c.Spec.Networking.Cilium == nil
958+
c.Spec.Networking.Cilium == nil &&
959+
!c.Spec.Networking.NetworkingIsGCPCilium()
959960
}
960961

961962
func (c *Cluster) HasImageVolumesSupport() bool {

pkg/apis/kops/model/features.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func UseKopsControllerForNodeConfig(cluster *kops.Cluster) bool {
5454

5555
// UseCiliumEtcd is true if we are using the Cilium etcd cluster.
5656
func UseCiliumEtcd(cluster *kops.Cluster) bool {
57-
if cluster.Spec.Networking.Cilium == nil {
57+
if cluster.Spec.Networking.Cilium == nil && !cluster.Spec.Networking.NetworkingIsGCPCilium() {
5858
return false
5959
}
6060

pkg/apis/kops/networking.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,7 @@ func (n *NetworkingSpec) UsesKubenet() bool {
103103
}
104104
if n.Kubenet != nil {
105105
return true
106-
} else if n.GCP != nil {
107-
// GCP IP Alias networking is based on kubenet
108-
return true
109-
} else if n.External != nil {
106+
} else if n.External != nil { //TODO: Change behaviour with GCP
110107
// external is based on kubenet
111108
return true
112109
} else if n.Kopeio != nil {
@@ -584,7 +581,10 @@ type LyftVPCNetworkingSpec struct {
584581
}
585582

586583
// GCPNetworkingSpec is the specification of GCP's native networking mode, using IP aliases.
587-
type GCPNetworkingSpec struct{}
584+
type GCPNetworkingSpec struct {
585+
// Cilium enables Cilium on GCP.
586+
Cilium *bool `json:"cilium,omitempty"`
587+
}
588588

589589
// KindnetNetworkingSpec configures Kindnet settings.
590590
type KindnetNetworkingSpec struct {
@@ -611,3 +611,16 @@ type KindnetMasqueradeSpec struct {
611611
Enabled *bool `json:"enabled,omitempty"`
612612
NonMasqueradeCIDRs []string `json:"nonMasqueradeCIDRs,omitempty"`
613613
}
614+
615+
616+
func (n *NetworkingSpec) NetworkingIsGCPCilium() bool {
617+
return n.GCP != nil && ValueOf(n.GCP.Cilium)
618+
}
619+
620+
// ValueOf returns the value of a pointer or its zero value
621+
func ValueOf[T any](v *T) T {
622+
if v == nil {
623+
return *new(T)
624+
}
625+
return *v
626+
}

pkg/apis/kops/v1alpha2/networking.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,10 @@ type LyftVPCNetworkingSpec struct {
701701
}
702702

703703
// GCPNetworkingSpec is the specification of GCP's native networking mode, using IP aliases.
704-
type GCPNetworkingSpec struct{}
704+
type GCPNetworkingSpec struct {
705+
// Cilium enables Cilium on GCP.
706+
Cilium *bool `json:"cilium,omitempty"`
707+
}
705708

706709
// KindnetNetworkingSpec configures Kindnet settings.
707710
type KindnetNetworkingSpec struct {

pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)