Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
480 changes: 480 additions & 0 deletions .crds/v1.2.1/gateway-class.yml

Large diffs are not rendered by default.

2,106 changes: 2,106 additions & 0 deletions .crds/v1.2.1/gateway.yml

Large diffs are not rendered by default.

2,011 changes: 2,011 additions & 0 deletions .crds/v1.2.1/grpc.yml

Large diffs are not rendered by default.

5,530 changes: 5,530 additions & 0 deletions .crds/v1.2.1/http.yml

Large diffs are not rendered by default.

190 changes: 190 additions & 0 deletions .crds/v1.2.1/reference-grants.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
#
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
api-approved.kubernetes.io: https://github.com/kubernetes-sigs/gateway-api/pull/3328
gateway.networking.k8s.io/bundle-version: v1.2.1
gateway.networking.k8s.io/channel: standard
creationTimestamp: null
name: referencegrants.gateway.networking.k8s.io
spec:
group: gateway.networking.k8s.io
names:
categories:
- gateway-api
kind: ReferenceGrant
listKind: ReferenceGrantList
plural: referencegrants
shortNames:
- refgrant
singular: referencegrant
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1beta1
schema:
openAPIV3Schema:
description: |-
ReferenceGrant identifies kinds of resources in other namespaces that are
trusted to reference the specified kinds of resources in the same namespace
as the policy.

Each ReferenceGrant can be used to represent a unique trust relationship.
Additional Reference Grants can be used to add to the set of trusted
sources of inbound references for the namespace they are defined within.

All cross-namespace references in Gateway API (with the exception of cross-namespace
Gateway-route attachment) require a ReferenceGrant.

ReferenceGrant is a form of runtime verification allowing users to assert
which cross-namespace object references are permitted. Implementations that
support ReferenceGrant MUST NOT permit cross-namespace references which have
no grant, and MUST respond to the removal of a grant by revoking the access
that the grant allowed.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
type: string
metadata:
type: object
spec:
description: Spec defines the desired state of ReferenceGrant.
properties:
from:
description: |-
From describes the trusted namespaces and kinds that can reference the
resources described in "To". Each entry in this list MUST be considered
to be an additional place that references can be valid from, or to put
this another way, entries MUST be combined using OR.

Support: Core
items:
description: ReferenceGrantFrom describes trusted namespaces and
kinds.
properties:
group:
description: |-
Group is the group of the referent.
When empty, the Kubernetes core API group is inferred.

Support: Core
maxLength: 253
pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
kind:
description: |-
Kind is the kind of the referent. Although implementations may support
additional resources, the following types are part of the "Core"
support level for this field.

When used to permit a SecretObjectReference:

* Gateway

When used to permit a BackendObjectReference:

* GRPCRoute
* HTTPRoute
* TCPRoute
* TLSRoute
* UDPRoute
maxLength: 63
minLength: 1
pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$
type: string
namespace:
description: |-
Namespace is the namespace of the referent.

Support: Core
maxLength: 63
minLength: 1
pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$
type: string
required:
- group
- kind
- namespace
type: object
maxItems: 16
minItems: 1
type: array
to:
description: |-
To describes the resources that may be referenced by the resources
described in "From". Each entry in this list MUST be considered to be an
additional place that references can be valid to, or to put this another
way, entries MUST be combined using OR.

Support: Core
items:
description: |-
ReferenceGrantTo describes what Kinds are allowed as targets of the
references.
properties:
group:
description: |-
Group is the group of the referent.
When empty, the Kubernetes core API group is inferred.

Support: Core
maxLength: 253
pattern: ^$|^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
type: string
kind:
description: |-
Kind is the kind of the referent. Although implementations may support
additional resources, the following types are part of the "Core"
support level for this field:

* Secret when used to permit a SecretObjectReference
* Service when used to permit a BackendObjectReference
maxLength: 63
minLength: 1
pattern: ^[a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?$
type: string
name:
description: |-
Name is the name of the referent. When unspecified, this policy
refers to all resources of the specified Group and Kind in the local
namespace.
maxLength: 253
minLength: 1
type: string
required:
- group
- kind
type: object
maxItems: 16
minItems: 1
type: array
required:
- from
- to
type: object
type: object
served: true
storage: true
subresources: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: null
storedVersions: null
4 changes: 2 additions & 2 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_to_workspace = false
CARGO_MAKE_CLIPPY_ARGS = "-- --no-deps"
CARGO_MAKE_COVERAGE_PROVIDER = "llvm-cov"
CARGO_MAKE_CARGO_BUILD_TEST_FLAGS = ""
GATEWAY_API_VERSION = "1.4.1"
GATEWAY_API_VERSION = "1.2.1"
# This is the directory where we generate the CLI's reference
# documentation.
CLI_REFERENCE_DIR = "target/debug/"
Expand Down Expand Up @@ -280,7 +280,7 @@ category = "Development"
script_runner = "bash"
script = '''
gen_crd() { kopium --filename .crds/v${GATEWAY_API_VERSION}/${1}.yml | rustfmt > crates/gateway-crds/src/${1//-/_}.rs; }
gen_crd backend-tls-policies
# gen_crd backend-tls-policies # Not available in v1.2.1
gen_crd gateway
gen_crd gateway-class
gen_crd grpc
Expand Down
5 changes: 0 additions & 5 deletions crates/controlplane/src/controller/gateway_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ mod tests {
reason: "Accepted".to_string(),
message: "Accepted".to_string(),
}]),
supported_features: None,
});
assert!(is_gateway_class_accepted(&gc));
}
Expand All @@ -211,7 +210,6 @@ mod tests {
reason: "InvalidConfiguration".to_string(),
message: "Configuration is invalid".to_string(),
}]),
supported_features: None,
});
assert!(!is_gateway_class_accepted(&gc));
}
Expand All @@ -230,7 +228,6 @@ mod tests {
reason: "Accepted".to_string(),
message: "Accepted".to_string(),
}]),
supported_features: None,
});

// Should be accepted when observedGeneration matches resource generation
Expand All @@ -243,7 +240,6 @@ mod tests {
let mut gc = create_test_gateway_class(CONTROLLER_NAME);
gc.status = Some(GatewayClassStatus {
conditions: Some(vec![]),
supported_features: None,
});
assert!(!is_gateway_class_accepted(&gc));
}
Expand All @@ -261,7 +257,6 @@ mod tests {
reason: "Something".to_string(),
message: "Something".to_string(),
}]),
supported_features: None,
});
assert!(!is_gateway_class_accepted(&gc));
}
Expand Down
13 changes: 8 additions & 5 deletions crates/controlplane/src/controller/httproute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ pub fn convert_httproute_to_config(

/// Convert an HTTPRoute rule to our internal format
fn convert_rule(rule: &HttpRouteRules, route_namespace: &str) -> Result<RouteRule> {
// Note: rule.name field not available in Gateway API v1.2.1
let mut route_rule = RouteRule {
name: rule.name.clone(),
name: None,
matches: Vec::new(),
filters: Vec::new(),
backends: Vec::new(),
Expand Down Expand Up @@ -407,7 +408,8 @@ fn convert_filter(filter: &HttpRouteRulesFilters) -> Result<Option<RouteFilter>>
&backend_ref.name,
backend_ref.port.unwrap_or(80) as u16,
),
percent: mirror.percent.map(|p| p as u32),
// Note: percent field not available in Gateway API v1.2.1
percent: None,
}))
} else {
Ok(None)
Expand Down Expand Up @@ -888,8 +890,8 @@ mod tests {
/// Spec: Rule with no matches should match all requests
#[test]
fn test_convert_rule_no_matches() {
// Note: name field not available in Gateway API v1.2.1
let rule = HttpRouteRules {
name: Some("catch-all".to_string()),
matches: None,
filters: None,
backend_refs: Some(vec![HttpRouteRulesBackendRefs {
Expand All @@ -905,7 +907,8 @@ mod tests {
};

let result = convert_rule(&rule, "default").unwrap();
assert_eq!(result.name, Some("catch-all".to_string()));
// Note: name field not available in Gateway API v1.2.1
assert_eq!(result.name, None);
// Should have a default match
assert_eq!(result.matches.len(), 1);
assert!(result.matches[0].path.is_none());
Expand All @@ -914,8 +917,8 @@ mod tests {
/// Spec: Rule with timeouts
#[test]
fn test_convert_rule_with_timeouts() {
// Note: name field not available in Gateway API v1.2.1
let rule = HttpRouteRules {
name: None,
matches: None,
filters: None,
backend_refs: Some(vec![HttpRouteRulesBackendRefs {
Expand Down
31 changes: 13 additions & 18 deletions crates/controlplane/src/core/reconcile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use std::time::Duration;

use chrono::DateTime;
use gateway_crds::{
Gateway, GatewayClassStatus, GatewayClassStatusSupportedFeatures, GatewayStatus,
GatewayStatusAddresses, GatewayStatusListeners, GatewayStatusListenersSupportedKinds,
HttpRouteStatus, HttpRouteStatusParents, HttpRouteStatusParentsParentRef,
Gateway, GatewayClassStatus, GatewayStatus, GatewayStatusAddresses, GatewayStatusListeners,
GatewayStatusListenersSupportedKinds, HttpRouteStatus, HttpRouteStatusParents,
HttpRouteStatusParentsParentRef,
};
use k8s_openapi::api::apps::v1::{Deployment, DeploymentSpec};
use k8s_openapi::api::core::v1::{
Expand All @@ -30,8 +30,8 @@ use kube::{Resource, ResourceExt};
use super::result::ReconcileResult;
use super::snapshot::WorldSnapshot;
use super::validate::{
SUPPORTED_FEATURES, get_accepted_gateway_class, is_our_gateway_class, validate_gateway_class,
validate_listeners, validate_parent_ref,
get_accepted_gateway_class, is_our_gateway_class, validate_gateway_class, validate_listeners,
validate_parent_ref,
};
use crate::controller::config::{
CONFIG_KEY, DataPlaneNames, GatewayConfig, ListenerConfig, Protocol,
Expand Down Expand Up @@ -109,16 +109,9 @@ fn build_gateway_class_status(
message: message.to_string(),
};

let supported_features: Vec<GatewayClassStatusSupportedFeatures> = SUPPORTED_FEATURES
.iter()
.map(|f| GatewayClassStatusSupportedFeatures {
name: f.to_string(),
})
.collect();

// Note: supported_features field not available in Gateway API v1.2.1
GatewayClassStatus {
conditions: Some(vec![condition]),
supported_features: Some(supported_features),
}
}

Expand Down Expand Up @@ -754,7 +747,7 @@ fn build_parent_status(
port: parent_ref.port,
section_name: parent_ref.section_name.clone(),
},
conditions: vec![
conditions: Some(vec![
Condition {
type_: "Accepted".to_string(),
status: status_value.to_string(),
Expand All @@ -771,7 +764,7 @@ fn build_parent_status(
reason: if accepted { "ResolvedRefs" } else { reason }.to_string(),
message: message.to_string(),
},
],
]),
}
}

Expand Down Expand Up @@ -824,7 +817,6 @@ mod tests {
reason: "Accepted".to_string(),
message: "Accepted".to_string(),
}]),
supported_features: None,
}),
}
}
Expand Down Expand Up @@ -936,8 +928,7 @@ mod tests {
assert_eq!(conditions[0].type_, "Accepted");
assert_eq!(conditions[0].status, "True");

// Should have supported features
assert!(status.supported_features.is_some());
// Note: supported_features field not available in Gateway API v1.2.1
}

// ========================================
Expand Down Expand Up @@ -1095,6 +1086,8 @@ mod tests {

let accepted = status.parents[0]
.conditions
.as_ref()
.unwrap()
.iter()
.find(|c| c.type_ == "Accepted")
.unwrap();
Expand Down Expand Up @@ -1125,6 +1118,8 @@ mod tests {

let accepted = status.parents[0]
.conditions
.as_ref()
.unwrap()
.iter()
.find(|c| c.type_ == "Accepted")
.unwrap();
Expand Down
Loading