Skip to content

Commit

Permalink
use v1 instead of v1beta1 for networking
Browse files Browse the repository at this point in the history
  • Loading branch information
sethsaperstein-lyft committed Nov 27, 2023
1 parent 52e4c60 commit d5c3685
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
31 changes: 16 additions & 15 deletions pkg/controller/flink/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import (
"github.com/lyft/flinkk8soperator/pkg/controller/common"
"github.com/lyft/flinkk8soperator/pkg/controller/config"
"github.com/lyft/flinkk8soperator/pkg/controller/k8"
"k8s.io/api/networking/v1beta1"
networkV1 "k8s.io/api/networking/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)

const AppIngressName = "%s-%s"
Expand All @@ -25,7 +24,7 @@ func GetFlinkUIIngressURL(jobName string) string {
return ReplaceJobURL(config.GetConfig().FlinkIngressURLFormat, jobName)
}

func FetchJobManagerIngressCreateObj(app *flinkapp.FlinkApplication) *v1beta1.Ingress {
func FetchJobManagerIngressCreateObj(app *flinkapp.FlinkApplication) *networkV1.Ingress {
podLabels := common.DuplicateMap(app.Labels)
podLabels = common.CopyMap(podLabels, k8.GetAppLabel(app.Name))

Expand All @@ -38,30 +37,32 @@ func FetchJobManagerIngressCreateObj(app *flinkapp.FlinkApplication) *v1beta1.In
},
}

backend := v1beta1.IngressBackend{
ServiceName: getJobManagerServiceName(app),
ServicePort: intstr.IntOrString{
Type: intstr.Int,
IntVal: getUIPort(app),
backend := networkV1.IngressBackend{
Service: &networkV1.IngressServiceBackend{
Name: getJobManagerServiceName(app),
Port: networkV1.ServiceBackendPort{
Name: getJobManagerServiceName(app),
Number: getUIPort(app),
},
},
}

ingressSpec := v1beta1.IngressSpec{
Rules: []v1beta1.IngressRule{{
ingressSpec := networkV1.IngressSpec{
Rules: []networkV1.IngressRule{{
Host: GetFlinkUIIngressURL(getIngressName(app)),
IngressRuleValue: v1beta1.IngressRuleValue{
HTTP: &v1beta1.HTTPIngressRuleValue{
Paths: []v1beta1.HTTPIngressPath{{
IngressRuleValue: networkV1.IngressRuleValue{
HTTP: &networkV1.HTTPIngressRuleValue{
Paths: []networkV1.HTTPIngressPath{{
Backend: backend,
}},
},
},
}},
}
return &v1beta1.Ingress{
return &networkV1.Ingress{
ObjectMeta: ingressMeta,
TypeMeta: v1.TypeMeta{
APIVersion: v1beta1.SchemeGroupVersion.String(),
APIVersion: networkV1.SchemeGroupVersion.String(),
Kind: k8.Ingress,
},
Spec: ingressSpec,
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/flink/job_manager_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/stretchr/testify/assert"
v1 "k8s.io/api/apps/v1"
coreV1 "k8s.io/api/core/v1"
"k8s.io/api/networking/v1beta1"
networkV1 "k8s.io/api/networking/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime/schema"
)
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestJobManagerCreateSuccess(t *testing.T) {
labels := map[string]string{
"flink-app": "app-name",
}
ingress := object.(*v1beta1.Ingress)
ingress := object.(*networkV1.Ingress)
assert.Equal(t, app.Name, ingress.Name)
assert.Equal(t, app.Namespace, ingress.Namespace)
assert.Equal(t, labels, ingress.Labels)
Expand Down Expand Up @@ -215,7 +215,7 @@ func TestJobManagerHACreateSuccess(t *testing.T) {
labels := map[string]string{
"flink-app": "app-name",
}
ingress := object.(*v1beta1.Ingress)
ingress := object.(*networkV1.Ingress)
assert.Equal(t, app.Name, ingress.Name)
assert.Equal(t, app.Namespace, ingress.Namespace)
assert.Equal(t, labels, ingress.Labels)
Expand Down Expand Up @@ -430,7 +430,7 @@ func TestJobManagerCreateSuccessWithVersion(t *testing.T) {
labels := map[string]string{
"flink-app": "app-name",
}
ingress := object.(*v1beta1.Ingress)
ingress := object.(*networkV1.Ingress)
assert.Equal(t, app.Name+"-"+testVersion, ingress.Name)
assert.Equal(t, app.Namespace, ingress.Namespace)
assert.Equal(t, labels, ingress.Labels)
Expand Down

0 comments on commit d5c3685

Please sign in to comment.