Skip to content

Commit

Permalink
Add GatewayAPI parameter in AKODeploymentConfig (#173)
Browse files Browse the repository at this point in the history
* Add GatewayAPI parameter in AKODeploymentConfig

* Add ako_gateway_log_file
  • Loading branch information
chenlin07 authored Oct 25, 2023
1 parent b6cd7e6 commit 50b8bc6
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 0 deletions.
13 changes: 13 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 @@ -329,6 +332,10 @@ type AKOLogConfig struct {
// LogFile specifies the log file name
// +optional
LogFile string `json:"logFile,omitempty"`

// AKOGatewayLogFile specifies the AKO Gateway log file name
// +optional
AKOGatewayLogFile string `json:"akoGatewayLogFile,omitempty"`
}

type AKORbacConfig struct {
Expand All @@ -341,6 +348,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 string `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
16 changes: 16 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: string
type: object
fullSyncFrequency:
description: FullSyncFrequency controls how often AKO polls the
Avi controller to update itself with cloud configurations. Default
Expand Down Expand Up @@ -344,6 +353,10 @@ spec:
log:
description: Log specifies the configuration for AKO logging
properties:
akoGatewayLogFile:
description: AKOGatewayLogFile specifies the AKO Gateway log
file name
type: string
logFile:
description: LogFile specifies the log file name
type: string
Expand Down
13 changes: 13 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: string
type: object
fullSyncFrequency:
description: FullSyncFrequency controls how often AKO polls the
Avi controller to update itself with cloud configurations. Default
Expand Down Expand Up @@ -346,6 +355,10 @@ spec:
log:
description: Log specifies the configuration for AKO logging
properties:
akoGatewayLogFile:
description: AKOGatewayLogFile specifies the AKO Gateway log
file name
type: string
logFile:
description: LogFile specifies the log file name
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ loadBalancerAndIngressService:
persistent_volume_claim: "true"
mount_path: /var/log
log_file: test-avi.log
ako_gateway_log_file: test-gateway-api.log
avi_credentials:
username: admin
password: Admin!23
certificate_authority_data: '-----BEGIN CERTIFICATE-----jf5Hlg==-----END CERTIFICATE-----'
feature_gates:
gateway_api: "true"
`

func unitTestAKODeploymentYaml() {
Expand Down Expand Up @@ -135,6 +138,7 @@ func unitTestAKODeploymentYaml() {
PersistentVolumeClaim: "true",
MountPath: "/var/log",
LogFile: "test-avi.log",
AKOGatewayLogFile: "test-gateway-api.log",
},
IngressConfigs: akoov1alpha1.AKOIngressConfig{
DisableIngressClass: pointer.Bool(true),
Expand All @@ -149,6 +153,9 @@ func unitTestAKODeploymentYaml() {
},
},
DisableStaticRouteSync: pointer.BoolPtr(true),
FeatureGates: akoov1alpha1.FeatureGates{
GatewayAPI: "true",
},
},
},
}
Expand Down
20 changes: 20 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,8 @@ 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,
AKOGatewayLogFile: obj.Spec.ExtraConfigs.Log.AKOGatewayLogFile,
FeatureGates: featureGates,
},
},
}, nil
Expand Down Expand Up @@ -119,7 +122,9 @@ type Config struct {
PersistentVolumeClaim string `yaml:"persistent_volume_claim"`
MountPath string `yaml:"mount_path"`
LogFile string `yaml:"log_file"`
AKOGatewayLogFile string `yaml:"ako_gateway_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 +506,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 string `yaml:"gateway_api"`
}

func NewFeatureGates(config v1alpha1.FeatureGates) *FeatureGates {
gatewayAPIEnabled := "false"
if config.GatewayAPI != "" {
gatewayAPIEnabled = config.GatewayAPI
}
return &FeatureGates{
GatewayAPI: gatewayAPIEnabled,
}
}
11 changes: 11 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 All @@ -53,11 +54,13 @@ var _ = Describe("AKO", func() {
config.PersistentVolumeClaim: akoDeploymentConfig.Spec.ExtraConfigs.Log.PersistentVolumeClaim,
config.MountPath: akoDeploymentConfig.Spec.ExtraConfigs.Log.MountPath,
config.LogFile: akoDeploymentConfig.Spec.ExtraConfigs.Log.LogFile,
config.AKOGatewayLogFile: akoDeploymentConfig.Spec.ExtraConfigs.Log.AKOGatewayLogFile,
value.LoadBalancerAndIngressService.Name: "ako-test",
rbac.PspPolicyApiVersion: akoDeploymentConfig.Spec.ExtraConfigs.Rbac.PspPolicyAPIVersion,
rbac.PspPolicyApiVersion: "test/1.2",
l7Settings.ShardVSSize: akoDeploymentConfig.Spec.ExtraConfigs.IngressConfigs.ShardVSSize,
l7Settings.ServiceType: akoDeploymentConfig.Spec.ExtraConfigs.IngressConfigs.ServiceType,
featureGates.GatewayAPI: akoDeploymentConfig.Spec.ExtraConfigs.FeatureGates.GatewayAPI,
}
for k, v := range expectedPairs {
Expect(k).To(Equal(v))
Expand Down Expand Up @@ -115,6 +118,7 @@ var _ = Describe("AKO", func() {
PersistentVolumeClaim: "true",
MountPath: "/var/log",
LogFile: "test-avi.log",
AKOGatewayLogFile: "test-gateway-api.log",
},
IngressConfigs: akoov1alpha1.AKOIngressConfig{
DisableIngressClass: pointer.Bool(true),
Expand All @@ -130,6 +134,9 @@ var _ = Describe("AKO", func() {
},
DisableStaticRouteSync: pointer.BoolPtr(true),
CniPlugin: "antrea",
FeatureGates: akoov1alpha1.FeatureGates{
GatewayAPI: "true",
},
},
},
}
Expand Down Expand Up @@ -181,6 +188,9 @@ var _ = Describe("AKO", func() {
},
DisableStaticRouteSync: pointer.BoolPtr(true),
CniPlugin: "antrea",
FeatureGates: akoov1alpha1.FeatureGates{
GatewayAPI: "false",
},
},
},
}
Expand All @@ -195,6 +205,7 @@ var _ = Describe("AKO", func() {
networkSettings := rendered.LoadBalancerAndIngressService.Config.NetworkSettings
Expect(jsonerr).ShouldNot(HaveOccurred())
Expect(networkSettings.VIPNetworkListJson).To(Equal(string(vipNetworkList)))
Expect(rendered.LoadBalancerAndIngressService.Config.FeatureGates.GatewayAPI).To(Equal("false"))
})
})
})
Expand Down

0 comments on commit 50b8bc6

Please sign in to comment.