Skip to content

Commit 4df2580

Browse files
committed
Use CiliumNetworkingSpec in GCPNetworkingSpec
This allows the configuration of Cilium when networking=gcp
1 parent 9c98907 commit 4df2580

19 files changed

Lines changed: 625 additions & 29 deletions

File tree

k8s/crds/kops.k8s.io_clusters.yaml

Lines changed: 520 additions & 2 deletions
Large diffs are not rendered by default.

pkg/apis/kops/networking.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ func (n *NetworkingSpec) UsesKubenet() bool {
114114
return false
115115
}
116116

117+
// NetworkingIsGCPCilium returns true if our networking is derived from GCP with Cilium
118+
func (n *NetworkingSpec) NetworkingIsGCPCilium() bool {
119+
return n.GCP != nil && n.GCP.Cilium != nil
120+
}
121+
117122
// ClassicNetworkingSpec is the specification of classic networking mode, integrated into kubernetes.
118123
// Support been removed since Kubernetes 1.4.
119124
type ClassicNetworkingSpec struct{}
@@ -583,7 +588,8 @@ type LyftVPCNetworkingSpec struct {
583588
// GCPNetworkingSpec is the specification of GCP's native networking mode, using IP aliases.
584589
type GCPNetworkingSpec struct {
585590
// Cilium enables Cilium on GCP.
586-
Cilium *bool `json:"cilium,omitempty"`
591+
// Cilium *bool `json:"cilium,omitempty"`
592+
Cilium *CiliumNetworkingSpec `json:"cilium,omitempty"`
587593
}
588594

589595
// KindnetNetworkingSpec configures Kindnet settings.
@@ -612,11 +618,6 @@ type KindnetMasqueradeSpec struct {
612618
NonMasqueradeCIDRs []string `json:"nonMasqueradeCIDRs,omitempty"`
613619
}
614620

615-
616-
func (n *NetworkingSpec) NetworkingIsGCPCilium() bool {
617-
return n.GCP != nil && ValueOf(n.GCP.Cilium)
618-
}
619-
620621
// ValueOf returns the value of a pointer or its zero value
621622
func ValueOf[T any](v *T) T {
622623
if v == nil {

pkg/apis/kops/v1alpha2/networking.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,8 @@ 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"`
706+
// Cilium *bool `json:"cilium,omitempty"`
707+
Cilium *CiliumNetworkingSpec `json:"cilium,omitempty"`
707708
}
708709

709710
// KindnetNetworkingSpec configures Kindnet settings.

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

Lines changed: 18 additions & 2 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: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha3/networking.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ 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"`
531+
// Cilium *bool `json:"cilium,omitempty"`
532+
Cilium *CiliumNetworkingSpec `json:"cilium,omitempty"`
532533
}
533534

534535
// KindnetNetworkingSpec configures Kindnet settings.

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

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

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

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

pkg/apis/kops/zz_generated.deepcopy.go

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

pkg/apis/nodeup/config.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,14 @@ func NewConfig(cluster *kops.Cluster, instanceGroup *kops.InstanceGroup) (*Confi
347347

348348
if cluster.Spec.Networking.GCP != nil {
349349
config.Networking.GCP = &kops.GCPNetworkingSpec{}
350-
if ValueOf(cluster.Spec.Networking.GCP.Cilium) {
350+
if cluster.Spec.Networking.GCP.Cilium != nil {
351351
config.Networking.GCP.Cilium = cluster.Spec.Networking.GCP.Cilium
352+
if cluster.Spec.Networking.GCP.Cilium.IPAM == kops.CiliumIpamEni {
353+
config.Networking.GCP.Cilium.IPAM = kops.CiliumIpamEni
354+
}
355+
if model.UseCiliumEtcd(cluster) {
356+
config.UseCiliumEtcd = true
357+
}
352358
}
353359
}
354360

@@ -522,4 +528,4 @@ func ValueOf[T any](v *T) T {
522528
return *new(T)
523529
}
524530
return *v
525-
}
531+
}

0 commit comments

Comments
 (0)