diff --git a/conformance/tests/gateway-infrastructure-metadata.go b/conformance/tests/gateway-infrastructure-metadata.go new file mode 100644 index 0000000000..ecd950edda --- /dev/null +++ b/conformance/tests/gateway-infrastructure-metadata.go @@ -0,0 +1,69 @@ +/* +Copyright 2024 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package tests + +import ( + "testing" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + + gatewayv1 "sigs.k8s.io/gateway-api/apis/v1" + "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" + "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/pkg/features" +) + +func init() { + ConformanceTests = append(ConformanceTests, GatewayInfraMetadata) +} + +var GatewayInfraMetadata = suite.ConformanceTest{ + ShortName: "GatewayInfraMetadata", + Description: "A Gateway should accept infrastructure metadata", + Features: []features.SupportedFeature{ + features.SupportGateway, + features.SupportGatewayInfrastructureMetadata, + }, + Manifests: []string{ + "tests/gateway-infrastructure-metadata.yaml", + }, + Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { + gwNN := types.NamespacedName{ + Name: "gateway-infra-metadata", + Namespace: "gateway-conformance-infra", + } + + conditions := []metav1.Condition{ + { + Type: string(gatewayv1.GatewayConditionAccepted), + Status: metav1.ConditionTrue, + Reason: "", // any reason + }, + { + Type: string(gatewayv1.GatewayConditionProgrammed), + Status: metav1.ConditionTrue, + Reason: "", // any reason + }, + } + + kubernetes.GatewayMustHaveLatestConditions(t, suite.Client, suite.TimeoutConfig, gwNN) + for _, condition := range conditions { + kubernetes.GatewayMustHaveCondition(t, suite.Client, suite.TimeoutConfig, gwNN, condition) + } + }, +} diff --git a/conformance/tests/gateway-infrastructure-metadata.yaml b/conformance/tests/gateway-infrastructure-metadata.yaml new file mode 100644 index 0000000000..e853e11c3b --- /dev/null +++ b/conformance/tests/gateway-infrastructure-metadata.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: gateway.networking.k8s.io/v1 +kind: Gateway +metadata: + name: gateway-infra-metadata + namespace: gateway-conformance-infra +spec: + gatewayClassName: "{GATEWAY_CLASS_NAME}" + infrastructure: + labels: + label-key: label-value + annotations: + annotation-key: annotation-value + listeners: + - name: http + port: 8080 + protocol: HTTP diff --git a/pkg/features/features.go b/pkg/features/features.go index fcb6d28019..123f440917 100644 --- a/pkg/features/features.go +++ b/pkg/features/features.go @@ -63,6 +63,23 @@ var GatewayExtendedFeatures = sets.New( SupportGatewayStaticAddresses, ) +// ----------------------------------------------------------------------------- +// Features - Gateway Conformance (Experimental) +// ----------------------------------------------------------------------------- + +const ( + // SupportGatewayInfrastructureMetadata option indicates that the Gateway is capable + // having annotations and labels which are propagated to underlying resources + SupportGatewayInfrastructureMetadata SupportedFeature = "GatewayInfrastructureMetadata" +) + +// GatewayExperimentalFeatures includes all the supported experimental features, currently only +// available in our experimental release channel. +// Implementations have the flexibility to opt-in for either specific features or the entire set. +var GatewayExperimentalFeatures = sets.New( + SupportGatewayInfrastructureMetadata, +) + // ----------------------------------------------------------------------------- // Features - ReferenceGrant Conformance (Core) // ----------------------------------------------------------------------------- @@ -255,6 +272,7 @@ var GRPCRouteCoreFeatures = sets.New( // NOTE: as new feature sets are added they should be inserted into this set. var AllFeatures = sets.New[SupportedFeature](). Insert(GatewayCoreFeatures.UnsortedList()...). + Insert(GatewayExperimentalFeatures.UnsortedList()...). Insert(GatewayExtendedFeatures.UnsortedList()...). Insert(ReferenceGrantCoreFeatures.UnsortedList()...). Insert(HTTPRouteCoreFeatures.UnsortedList()...).