Skip to content

Commit

Permalink
Add GatewayAPI parameter in AKODeploymentConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
chenlin07 committed Oct 24, 2023
1 parent b6cd7e6 commit b68b3c4
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/v1alpha1/akodeploymentconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ type ExtraConfigs struct {
// Rbac specifies the configuration for AKO Rbac
// +optional
Rbac AKORbacConfig `json:"rbac,omitempty"`

// FeatureGates specifies the configuration for AKO features
FeatureGates FeatureGates `json:"featureGates,omitempty"`
}

// NameSpaceSelector contains label key and value used for namespace migration
Expand Down Expand Up @@ -341,6 +344,12 @@ type AKORbacConfig struct {
PspEnabled *bool `json:"pspEnabled,omitempty"`
}

// FeatureGates describes the configuration for AKO features
type FeatureGates struct {
// GatewayAPI enables/disables processing of Kubernetes Gateway API CRDs.
GatewayAPI *bool `json:"GatewayAPI,omitempty"`
}

// AVITenant describes settings for an AVI Tenant object
type AVITenant struct {
// Context is the type of AVI tenant context. Defaults to Provider. This field is immutable.
Expand Down
21 changes: 21 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ spec:
description: Defines Enable or disable Event broadcasting via
AKO
type: boolean
featureGates:
description: FeatureGates specifies the configuration for AKO
features
properties:
GatewayAPI:
description: GatewayAPI enables/disables processing of Kubernetes
Gateway API CRDs.
type: boolean
type: object
fullSyncFrequency:
description: FullSyncFrequency controls how often AKO polls the
Avi controller to update itself with cloud configurations. Default
Expand Down
9 changes: 9 additions & 0 deletions config/ytt/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@ spec:
description: Defines Enable or disable Event broadcasting via
AKO
type: boolean
featureGates:
description: FeatureGates specifies the configuration for AKO
features
properties:
GatewayAPI:
description: GatewayAPI enables/disables processing of Kubernetes
Gateway API CRDs.
type: boolean
type: object
fullSyncFrequency:
description: FullSyncFrequency controls how often AKO polls the
Avi controller to update itself with cloud configurations. Default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ loadBalancerAndIngressService:
username: admin
password: Admin!23
certificate_authority_data: '-----BEGIN CERTIFICATE-----jf5Hlg==-----END CERTIFICATE-----'
feature_gates:
gateway_api: true
`

func unitTestAKODeploymentYaml() {
Expand Down Expand Up @@ -149,6 +151,9 @@ func unitTestAKODeploymentYaml() {
},
},
DisableStaticRouteSync: pointer.BoolPtr(true),
FeatureGates: akoov1alpha1.FeatureGates{
GatewayAPI: pointer.Bool(true),
},
},
},
}
Expand Down
18 changes: 18 additions & 0 deletions pkg/ako/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func NewValues(obj *akoov1alpha1.AKODeploymentConfig, clusterNameSpacedName stri
l4Settings := NewL4Settings(&obj.Spec.ExtraConfigs.L4Configs)
nodePortSelector := NewNodePortSelector(&obj.Spec.ExtraConfigs.NodePortSelector)
rbac := NewRbac(obj.Spec.ExtraConfigs.Rbac)
featureGates := NewFeatureGates(obj.Spec.ExtraConfigs.FeatureGates)

return &Values{
LoadBalancerAndIngressService: LoadBalancerAndIngressService{
Expand All @@ -66,6 +67,7 @@ func NewValues(obj *akoov1alpha1.AKODeploymentConfig, clusterNameSpacedName stri
PersistentVolumeClaim: obj.Spec.ExtraConfigs.Log.PersistentVolumeClaim,
MountPath: obj.Spec.ExtraConfigs.Log.MountPath,
LogFile: obj.Spec.ExtraConfigs.Log.LogFile,
FeatureGates: featureGates,
},
},
}, nil
Expand Down Expand Up @@ -120,6 +122,7 @@ type Config struct {
MountPath string `yaml:"mount_path"`
LogFile string `yaml:"log_file"`
Avicredentials Avicredentials `yaml:"avi_credentials"`
FeatureGates *FeatureGates `yaml:"feature_gates"`
}

// NamespaceSelector contains label key and value used for namespace migration.
Expand Down Expand Up @@ -501,3 +504,18 @@ func (v Values) GetName() string {
return "ako-" + strconv.FormatInt(rand.New(rand.NewSource(time.Now().UnixNano())).Int63n(10000000000), 10)
//Be aware that during upgrades, templates are re-executed. When a template run generates data that differs from the last run, that will trigger an update of that resource.
}

// FeatureGates describes the configuration for AKO features
type FeatureGates struct {
GatewayAPI bool `yaml:"gateway_api"`
}

func NewFeatureGates(config v1alpha1.FeatureGates) *FeatureGates {
gatewayAPIEnabled := false
if config.GatewayAPI != nil {
gatewayAPIEnabled = *config.GatewayAPI
}
return &FeatureGates{
GatewayAPI: gatewayAPIEnabled,
}
}
8 changes: 8 additions & 0 deletions pkg/ako/values_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var _ = Describe("AKO", func() {
networkSettings := config.NetworkSettings
l7Settings := config.L7Settings
rbac := config.Rbac
featureGates := config.FeatureGates

expectedPairs := map[string]string{
akoSettings.ClusterName: "test",
Expand Down Expand Up @@ -67,6 +68,7 @@ var _ = Describe("AKO", func() {
l7Settings.DisableIngressClass: *akoDeploymentConfig.Spec.ExtraConfigs.IngressConfigs.DisableIngressClass,
l7Settings.DefaultIngController: *akoDeploymentConfig.Spec.ExtraConfigs.IngressConfigs.DefaultIngressController,
rbac.PspEnabled: *akoDeploymentConfig.Spec.ExtraConfigs.Rbac.PspEnabled,
featureGates.GatewayAPI: *akoDeploymentConfig.Spec.ExtraConfigs.FeatureGates.GatewayAPI,
}
for k, v := range expectedBoolPairs {
Expect(k).To(Equal(v))
Expand Down Expand Up @@ -130,6 +132,9 @@ var _ = Describe("AKO", func() {
},
DisableStaticRouteSync: pointer.BoolPtr(true),
CniPlugin: "antrea",
FeatureGates: akoov1alpha1.FeatureGates{
GatewayAPI: pointer.Bool(true),
},
},
},
}
Expand Down Expand Up @@ -181,6 +186,9 @@ var _ = Describe("AKO", func() {
},
DisableStaticRouteSync: pointer.BoolPtr(true),
CniPlugin: "antrea",
FeatureGates: akoov1alpha1.FeatureGates{
GatewayAPI: pointer.Bool(false),
},
},
},
}
Expand Down

0 comments on commit b68b3c4

Please sign in to comment.