Skip to content

Commit

Permalink
feat BackendTrafficPolicy (envoyproxy#2053)
Browse files Browse the repository at this point in the history
* feat BackendTrafficPolicy

Takes PR envoyproxy#1961 forward

Signed-off-by: Arko Dasgupta <[email protected]>

* lint

Signed-off-by: Arko Dasgupta <[email protected]>

* k8s status

Signed-off-by: Arko Dasgupta <[email protected]>

* k8s watch

Signed-off-by: Arko Dasgupta <[email protected]>

* Update site/content/en/latest/design/backend-traffic-policy.md

Co-authored-by: zirain <[email protected]>
Signed-off-by: Arko Dasgupta <[email protected]>

* Update site/content/en/latest/design/backend-traffic-policy.md

Co-authored-by: zirain <[email protected]>
Signed-off-by: Arko Dasgupta <[email protected]>

---------

Signed-off-by: Arko Dasgupta <[email protected]>
Signed-off-by: Arko Dasgupta <[email protected]>
Co-authored-by: zirain <[email protected]>
  • Loading branch information
arkodg and zirain authored Oct 24, 2023
1 parent 5a91d2d commit a858547
Show file tree
Hide file tree
Showing 19 changed files with 1,507 additions and 49 deletions.
71 changes: 71 additions & 0 deletions api/v1alpha1/backendtrafficpolicy_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright Envoy Gateway Authors
// SPDX-License-Identifier: Apache-2.0
// The full text of the Apache license is available in the LICENSE file at
// the root of the repo.

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gwapiv1a2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
)

const (
// KindBackendTrafficPolicy is the name of the BackendTrafficPolicy kind.
KindBackendTrafficPolicy = "BackendTrafficPolicy"
)

// +kubebuilder:object:root=true
// +kubebuilder:resource:shortName=btpolicy
// +kubebuilder:subresource:status
// +kubebuilder:subresource:overrideStrategy
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.conditions[?(@.type=="Accepted")].reason`
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
//
// BackendTrafficPolicy allows the user to configure the behavior of the connection
// between the downstream client and Envoy Proxy listener.
type BackendTrafficPolicy struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// spec defines the desired state of BackendTrafficPolicy.
Spec BackendTrafficPolicySpec `json:"spec"`

// status defines the current status of BackendTrafficPolicy.
Status BackendTrafficPolicyStatus `json:"status,omitempty"`
}

// spec defines the desired state of BackendTrafficPolicy.
type BackendTrafficPolicySpec struct {

// +kubebuilder:validation:XValidation:rule="self.kind == 'Gateway' || self.kind == 'HTTPRoute' || self.kind == 'GRPCRoute' || self.kind == 'UDPRoute' || self.kind == 'TCPRoute' || self.kind == 'TLSRoute'", message="this policy can only have a targetRef.kind of Gateway/HTTPRoute/GRPCRoute/TCPRoute/UDPRoute/TLSRoute"
//
// targetRef is the name of the resource this policy
// is being attached to.
// This Policy and the TargetRef MUST be in the same namespace
// for this Policy to have effect and be applied to the Gateway.
TargetRef gwapiv1a2.PolicyTargetReferenceWithSectionName `json:"targetRef"`
}

// BackendTrafficPolicyStatus defines the state of BackendTrafficPolicy
type BackendTrafficPolicyStatus struct {
// Conditions describe the current conditions of the BackendTrafficPolicy.
//
// +optional
// +listType=map
// +listMapKey=type
// +kubebuilder:validation:MaxItems=8
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// BackendTrafficPolicyList contains a list of BackendTrafficPolicy resources.
type BackendTrafficPolicyList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []BackendTrafficPolicy `json:"items"`
}

func init() {
SchemeBuilder.Register(&BackendTrafficPolicy{}, &BackendTrafficPolicyList{})
}
113 changes: 105 additions & 8 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Loading

0 comments on commit a858547

Please sign in to comment.