Skip to content

Commit a5204e1

Browse files
M00nF1shTimothy-Dougherty
authored andcommitted
promote targetgroupbinding api from v1alpha1 to v1beta1 (kubernetes-sigs#1478)
1 parent c384377 commit a5204e1

25 files changed

+501
-24
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package v1beta1 contains API Schema definitions for the elbv2 v1beta1 API group
18+
// +kubebuilder:object:generate=true
19+
// +groupName=elbv2.k8s.aws
20+
package v1beta1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects
29+
GroupVersion = schema.GroupVersion{Group: "elbv2.k8s.aws", Version: "v1beta1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
/*
2+
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package v1beta1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
"k8s.io/apimachinery/pkg/util/intstr"
22+
)
23+
24+
// +kubebuilder:validation:Enum=instance;ip
25+
type TargetType string
26+
27+
const (
28+
TargetTypeInstance TargetType = "instance"
29+
TargetTypeIP TargetType = "ip"
30+
)
31+
32+
// ServiceReference defines reference to a Kubernetes Service and its ServicePort.
33+
type ServiceReference struct {
34+
// Name is the name of the Service.
35+
Name string `json:"name"`
36+
37+
// Port is the port of the ServicePort.
38+
Port intstr.IntOrString `json:"port"`
39+
}
40+
41+
// IPBlock defines source/destination IPBlock in networking rules.
42+
type IPBlock struct {
43+
// CIDR is the network CIDR.
44+
// Both IPV4 or IPV6 CIDR are accepted.
45+
CIDR string `json:"cidr"`
46+
}
47+
48+
// SecurityGroup defines reference to an AWS EC2 SecurityGroup.
49+
type SecurityGroup struct {
50+
// GroupID is the EC2 SecurityGroupID.
51+
GroupID string `json:"groupID"`
52+
}
53+
54+
// NetworkingPeer defines the source/destination peer for networking rules.
55+
type NetworkingPeer struct {
56+
// IPBlock defines an IPBlock peer.
57+
// If specified, none of the other fields can be set.
58+
// +optional
59+
IPBlock *IPBlock `json:"ipBlock,omitempty"`
60+
61+
// SecurityGroup defines a SecurityGroup peer.
62+
// If specified, none of the other fields can be set.
63+
// +optional
64+
SecurityGroup *SecurityGroup `json:"securityGroup,omitempty"`
65+
}
66+
67+
// +kubebuilder:validation:Enum=TCP;UDP
68+
type NetworkingProtocol string
69+
70+
const (
71+
// NetworkingProtocolTCP is the TCP protocol.
72+
NetworkingProtocolTCP NetworkingProtocol = "TCP"
73+
74+
// NetworkingProtocolUDP is the UDP protocol.
75+
NetworkingProtocolUDP NetworkingProtocol = "UDP"
76+
)
77+
78+
type NetworkingPort struct {
79+
// The protocol which traffic must match.
80+
// If protocol is unspecified, it defaults to TCP.
81+
Protocol *NetworkingProtocol `json:"protocol,omitempty"`
82+
83+
// The port which traffic must match.
84+
// When NodePort endpoints(instance TargetType) is used, this must be a numerical port.
85+
// When Port endpoints(ip TargetType) is used, this can be either numerical or named port on pods.
86+
// if port is unspecified, it defaults to all ports.
87+
// +optional
88+
Port *intstr.IntOrString `json:"port,omitempty"`
89+
}
90+
91+
type NetworkingIngressRule struct {
92+
// List of peers which should be able to access the targets in TargetGroup.
93+
// At least one NetworkingPeer should be specified.
94+
From []NetworkingPeer `json:"from"`
95+
96+
// List of ports which should be made accessible on the targets in TargetGroup.
97+
// If ports is empty or unspecified, it defaults to all ports with TCP.
98+
Ports []NetworkingPort `json:"ports"`
99+
}
100+
101+
type TargetGroupBindingNetworking struct {
102+
// List of ingress rules to allow ELBV2 LoadBalancer to access targets in TargetGroup.
103+
// +optional
104+
Ingress []NetworkingIngressRule `json:"ingress,omitempty"`
105+
}
106+
107+
// TargetGroupBindingSpec defines the desired state of TargetGroupBinding
108+
type TargetGroupBindingSpec struct {
109+
// targetGroupARN is the Amazon Resource Name (ARN) for the TargetGroup.
110+
TargetGroupARN string `json:"targetGroupARN"`
111+
112+
// targetType is the TargetType of TargetGroup. If unspecified, it will be automatically inferred.
113+
// +optional
114+
TargetType *TargetType `json:"targetType,omitempty"`
115+
116+
// serviceRef is a reference to a Kubernetes Service and ServicePort.
117+
ServiceRef ServiceReference `json:"serviceRef"`
118+
119+
// networking provides the networking setup for ELBV2 LoadBalancer to access targets in TargetGroup.
120+
// +optional
121+
Networking *TargetGroupBindingNetworking `json:"networking,omitempty"`
122+
}
123+
124+
// TargetGroupBindingStatus defines the observed state of TargetGroupBinding
125+
type TargetGroupBindingStatus struct {
126+
// The generation observed by the TargetGroupBinding controller.
127+
// +optional
128+
ObservedGeneration *int64 `json:"observedGeneration,omitempty"`
129+
}
130+
131+
// +kubebuilder:object:root=true
132+
// +kubebuilder:resource:categories=all
133+
// +kubebuilder:subresource:status
134+
// +kubebuilder:storageversion
135+
// +kubebuilder:printcolumn:name="SERVICE-NAME",type="string",JSONPath=".spec.serviceRef.name",description="The Kubernetes Service's name"
136+
// +kubebuilder:printcolumn:name="SERVICE-PORT",type="string",JSONPath=".spec.serviceRef.port",description="The Kubernetes Service's port"
137+
// +kubebuilder:printcolumn:name="TARGET-TYPE",type="string",JSONPath=".spec.targetType",description="The AWS TargetGroup's TargetType"
138+
// +kubebuilder:printcolumn:name="ARN",type="string",JSONPath=".spec.targetGroupARN",description="The AWS TargetGroup's Amazon Resource Name",priority=1
139+
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
140+
// TargetGroupBinding is the Schema for the TargetGroupBinding API
141+
type TargetGroupBinding struct {
142+
metav1.TypeMeta `json:",inline"`
143+
metav1.ObjectMeta `json:"metadata,omitempty"`
144+
145+
Spec TargetGroupBindingSpec `json:"spec,omitempty"`
146+
Status TargetGroupBindingStatus `json:"status,omitempty"`
147+
}
148+
149+
// +kubebuilder:object:root=true
150+
151+
// TargetGroupBindingList contains a list of TargetGroupBinding
152+
type TargetGroupBindingList struct {
153+
metav1.TypeMeta `json:",inline"`
154+
metav1.ListMeta `json:"metadata,omitempty"`
155+
Items []TargetGroupBinding `json:"items"`
156+
}
157+
158+
func init() {
159+
SchemeBuilder.Register(&TargetGroupBinding{}, &TargetGroupBindingList{})
160+
}

0 commit comments

Comments
 (0)