Skip to content

Commit ee9405f

Browse files
committed
v1 changes
1 parent ed2cc11 commit ee9405f

File tree

9 files changed

+449
-493
lines changed

9 files changed

+449
-493
lines changed

control-plane/api-gateway/binding/annotations.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package binding
66
import (
77
"encoding/json"
88

9-
gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
9+
gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1"
1010

1111
"github.com/hashicorp/consul-k8s/control-plane/api-gateway/common"
1212
"github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1"

control-plane/api-gateway/binding/binder.go

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import (
1010
corev1 "k8s.io/api/core/v1"
1111
"k8s.io/apimachinery/pkg/types"
1212
"sigs.k8s.io/controller-runtime/pkg/client"
13-
gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
14-
gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"
13+
gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1"
14+
15+
// gwv1alpha2 "sigs.k8s.io/gateway-api/apis/v1beta1"
1516

1617
"github.com/hashicorp/consul-k8s/control-plane/api-gateway/common"
1718
"github.com/hashicorp/consul-k8s/control-plane/api/v1alpha1"
@@ -42,13 +43,12 @@ type BinderConfig struct {
4243
// state that we may have set on the Gateway, its corresponding Routes or in
4344
// Consul, because we should no longer be managing the Gateway (its association
4445
// to our controller is through a parameter on the GatewayClass).
45-
GatewayClass *gwv1beta1.GatewayClass
46+
GatewayClass *gwv1alpha2.GatewayClass
4647
// Gateway is the Gateway being reconciled that we want to bind routes to.
47-
Gateway gwv1beta1.Gateway
48+
Gateway gwv1alpha2.Gateway
4849
// HTTPRoutes is a list of HTTPRoute objects that ought to be bound to the Gateway.
49-
HTTPRoutes []gwv1beta1.HTTPRoute
50+
HTTPRoutes []gwv1alpha2.HTTPRoute
5051
// TCPRoutes is a list of TCPRoute objects that ought to be bound to the Gateway.
51-
TCPRoutes []gwv1alpha2.TCPRoute
5252
// Pods are any pods that are part of the Gateway deployment.
5353
Pods []corev1.Pod
5454
// Service is the deployed service associated with the Gateway deployment.
@@ -152,17 +152,17 @@ func (b *Binder) Snapshot() *Snapshot {
152152
// used for tracking how many routes have successfully bound to which listeners
153153
// on a gateway for reporting the number of bound routes in a gateway listener's
154154
// status
155-
boundCounts := make(map[gwv1beta1.SectionName]int)
155+
boundCounts := make(map[gwv1alpha2.SectionName]int)
156156

157157
// attempt to bind all routes
158158

159159
for _, r := range b.config.HTTPRoutes {
160160
b.bindRoute(common.PointerTo(r), boundCounts, snapshot)
161161
}
162162

163-
for _, r := range b.config.TCPRoutes {
164-
b.bindRoute(common.PointerTo(r), boundCounts, snapshot)
165-
}
163+
// for _, r := range b.config.TCPRoutes {
164+
// b.bindRoute(common.PointerTo(r), boundCounts, snapshot)
165+
// }
166166

167167
// process secrets
168168
gatewaySecrets := secretsForGateway(b.config.Gateway, b.config.Resources)
@@ -223,9 +223,9 @@ func (b *Binder) Snapshot() *Snapshot {
223223
}
224224

225225
// calculate the status for the gateway
226-
var status gwv1beta1.GatewayStatus
226+
var status gwv1alpha2.GatewayStatus
227227
for i, listener := range b.config.Gateway.Spec.Listeners {
228-
status.Listeners = append(status.Listeners, gwv1beta1.ListenerStatus{
228+
status.Listeners = append(status.Listeners, gwv1alpha2.ListenerStatus{
229229
Name: listener.Name,
230230
SupportedKinds: supportedKinds(listener),
231231
AttachedRoutes: int32(boundCounts[listener.Name]),
@@ -302,7 +302,7 @@ func (b *Binder) Snapshot() *Snapshot {
302302
return snapshot
303303
}
304304

305-
func secretsForGateway(gateway gwv1beta1.Gateway, resources *common.ResourceMap) mapset.Set {
305+
func secretsForGateway(gateway gwv1alpha2.Gateway, resources *common.ResourceMap) mapset.Set {
306306
set := mapset.NewSet()
307307

308308
for _, listener := range gateway.Spec.Listeners {
@@ -323,7 +323,7 @@ func secretsForGateway(gateway gwv1beta1.Gateway, resources *common.ResourceMap)
323323
return set
324324
}
325325

326-
func addressesForGateway(service *corev1.Service, pods []corev1.Pod) []gwv1beta1.GatewayAddress {
326+
func addressesForGateway(service *corev1.Service, pods []corev1.Pod) []gwv1alpha2.GatewayAddress {
327327
if service == nil {
328328
return addressesFromPods(pods)
329329
}
@@ -344,22 +344,22 @@ func addressesForGateway(service *corev1.Service, pods []corev1.Pod) []gwv1beta1
344344
return addressesFromPodHosts(pods)
345345
}
346346

347-
return []gwv1beta1.GatewayAddress{}
347+
return []gwv1alpha2.GatewayAddress{}
348348
}
349349

350-
func addressesFromLoadBalancer(service *corev1.Service) []gwv1beta1.GatewayAddress {
351-
addresses := []gwv1beta1.GatewayAddress{}
350+
func addressesFromLoadBalancer(service *corev1.Service) []gwv1alpha2.GatewayAddress {
351+
addresses := []gwv1alpha2.GatewayAddress{}
352352

353353
for _, ingress := range service.Status.LoadBalancer.Ingress {
354354
if ingress.IP != "" {
355-
addresses = append(addresses, gwv1beta1.GatewayAddress{
356-
Type: common.PointerTo(gwv1beta1.IPAddressType),
355+
addresses = append(addresses, gwv1alpha2.GatewayAddress{
356+
Type: common.PointerTo(gwv1alpha2.IPAddressType),
357357
Value: ingress.IP,
358358
})
359359
}
360360
if ingress.Hostname != "" {
361-
addresses = append(addresses, gwv1beta1.GatewayAddress{
362-
Type: common.PointerTo(gwv1beta1.HostnameAddressType),
361+
addresses = append(addresses, gwv1alpha2.GatewayAddress{
362+
Type: common.PointerTo(gwv1alpha2.HostnameAddressType),
363363
Value: ingress.Hostname,
364364
})
365365
}
@@ -368,28 +368,28 @@ func addressesFromLoadBalancer(service *corev1.Service) []gwv1beta1.GatewayAddre
368368
return addresses
369369
}
370370

371-
func addressesFromClusterIP(service *corev1.Service) []gwv1beta1.GatewayAddress {
372-
addresses := []gwv1beta1.GatewayAddress{}
371+
func addressesFromClusterIP(service *corev1.Service) []gwv1alpha2.GatewayAddress {
372+
addresses := []gwv1alpha2.GatewayAddress{}
373373

374374
if service.Spec.ClusterIP != "" {
375-
addresses = append(addresses, gwv1beta1.GatewayAddress{
376-
Type: common.PointerTo(gwv1beta1.IPAddressType),
375+
addresses = append(addresses, gwv1alpha2.GatewayAddress{
376+
Type: common.PointerTo(gwv1alpha2.IPAddressType),
377377
Value: service.Spec.ClusterIP,
378378
})
379379
}
380380

381381
return addresses
382382
}
383383

384-
func addressesFromPods(pods []corev1.Pod) []gwv1beta1.GatewayAddress {
385-
addresses := []gwv1beta1.GatewayAddress{}
384+
func addressesFromPods(pods []corev1.Pod) []gwv1alpha2.GatewayAddress {
385+
addresses := []gwv1alpha2.GatewayAddress{}
386386
seenIPs := make(map[string]struct{})
387387

388388
for _, pod := range pods {
389389
if pod.Status.PodIP != "" {
390390
if _, found := seenIPs[pod.Status.PodIP]; !found {
391-
addresses = append(addresses, gwv1beta1.GatewayAddress{
392-
Type: common.PointerTo(gwv1beta1.IPAddressType),
391+
addresses = append(addresses, gwv1alpha2.GatewayAddress{
392+
Type: common.PointerTo(gwv1alpha2.IPAddressType),
393393
Value: pod.Status.PodIP,
394394
})
395395
seenIPs[pod.Status.PodIP] = struct{}{}
@@ -400,15 +400,15 @@ func addressesFromPods(pods []corev1.Pod) []gwv1beta1.GatewayAddress {
400400
return addresses
401401
}
402402

403-
func addressesFromPodHosts(pods []corev1.Pod) []gwv1beta1.GatewayAddress {
404-
addresses := []gwv1beta1.GatewayAddress{}
403+
func addressesFromPodHosts(pods []corev1.Pod) []gwv1alpha2.GatewayAddress {
404+
addresses := []gwv1alpha2.GatewayAddress{}
405405
seenIPs := make(map[string]struct{})
406406

407407
for _, pod := range pods {
408408
if pod.Status.HostIP != "" {
409409
if _, found := seenIPs[pod.Status.HostIP]; !found {
410-
addresses = append(addresses, gwv1beta1.GatewayAddress{
411-
Type: common.PointerTo(gwv1beta1.IPAddressType),
410+
addresses = append(addresses, gwv1alpha2.GatewayAddress{
411+
Type: common.PointerTo(gwv1alpha2.IPAddressType),
412412
Value: pod.Status.HostIP,
413413
})
414414
seenIPs[pod.Status.HostIP] = struct{}{}
@@ -424,13 +424,13 @@ func isDeleted(object client.Object) bool {
424424
return !object.GetDeletionTimestamp().IsZero()
425425
}
426426

427-
func supportedKinds(listener gwv1beta1.Listener) []gwv1beta1.RouteGroupKind {
427+
func supportedKinds(listener gwv1alpha2.Listener) []gwv1alpha2.RouteGroupKind {
428428
if listener.AllowedRoutes != nil && listener.AllowedRoutes.Kinds != nil {
429-
return common.Filter(listener.AllowedRoutes.Kinds, func(kind gwv1beta1.RouteGroupKind) bool {
429+
return common.Filter(listener.AllowedRoutes.Kinds, func(kind gwv1alpha2.RouteGroupKind) bool {
430430
if _, ok := allSupportedRouteKinds[kind.Kind]; !ok {
431431
return true
432432
}
433-
return !common.NilOrEqual(kind.Group, gwv1beta1.GroupVersion.Group)
433+
return !common.NilOrEqual(kind.Group, gwv1alpha2.GroupVersion.Group)
434434
})
435435
}
436436
return supportedKindsForProtocol[listener.Protocol]

0 commit comments

Comments
 (0)