Change Ingress version from v1beta1 to v1 for K8s 1.22+ compatibility (#2124)
* Change Ingress version from v1beta1 to v1 for K8s 1.22+ compatibility Signed-off-by: Sanket Sudake <sanketsudake@gmail.com> * Minor fix Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
+17
-16
@@ -17,14 +17,14 @@ limitations under the License.
|
||||
package util
|
||||
|
||||
import (
|
||||
"k8s.io/api/extensions/v1beta1"
|
||||
v1 "k8s.io/api/networking/v1"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
)
|
||||
|
||||
func GetIngressSpec(namespace string, trigger *fv1.HTTPTrigger) *v1beta1.Ingress {
|
||||
func GetIngressSpec(namespace string, trigger *fv1.HTTPTrigger) *v1.Ingress {
|
||||
// TODO: remove backward compatibility
|
||||
host, path := trigger.Spec.Host, trigger.Spec.RelativeURL
|
||||
if trigger.Spec.Prefix != nil && *trigger.Spec.Prefix != "" {
|
||||
@@ -41,9 +41,9 @@ func GetIngressSpec(namespace string, trigger *fv1.HTTPTrigger) *v1beta1.Ingress
|
||||
host = "" // wildcard Ingress host
|
||||
}
|
||||
|
||||
var ingTLS []v1beta1.IngressTLS
|
||||
var ingTLS []v1.IngressTLS
|
||||
if len(trigger.Spec.IngressConfig.TLS) > 0 {
|
||||
ingTLS = []v1beta1.IngressTLS{
|
||||
ingTLS = []v1.IngressTLS{
|
||||
{
|
||||
Hosts: []string{
|
||||
trigger.Spec.IngressConfig.Host,
|
||||
@@ -53,7 +53,7 @@ func GetIngressSpec(namespace string, trigger *fv1.HTTPTrigger) *v1beta1.Ingress
|
||||
}
|
||||
}
|
||||
|
||||
ing := &v1beta1.Ingress{
|
||||
ing := &v1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: GetDeployLabels(trigger),
|
||||
Name: trigger.ObjectMeta.Name,
|
||||
@@ -63,20 +63,21 @@ func GetIngressSpec(namespace string, trigger *fv1.HTTPTrigger) *v1beta1.Ingress
|
||||
Namespace: namespace,
|
||||
Annotations: trigger.Spec.IngressConfig.Annotations,
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
Spec: v1.IngressSpec{
|
||||
TLS: ingTLS,
|
||||
Rules: []v1beta1.IngressRule{
|
||||
Rules: []v1.IngressRule{
|
||||
{
|
||||
Host: host,
|
||||
IngressRuleValue: v1beta1.IngressRuleValue{
|
||||
HTTP: &v1beta1.HTTPIngressRuleValue{
|
||||
Paths: []v1beta1.HTTPIngressPath{
|
||||
IngressRuleValue: v1.IngressRuleValue{
|
||||
HTTP: &v1.HTTPIngressRuleValue{
|
||||
Paths: []v1.HTTPIngressPath{
|
||||
{
|
||||
Backend: v1beta1.IngressBackend{
|
||||
ServiceName: "router",
|
||||
ServicePort: intstr.IntOrString{
|
||||
Type: intstr.Int,
|
||||
IntVal: 80,
|
||||
Backend: v1.IngressBackend{
|
||||
Service: &v1.IngressServiceBackend{
|
||||
Name: "router",
|
||||
Port: v1.ServiceBackendPort{
|
||||
Number: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
Path: path,
|
||||
|
||||
@@ -20,9 +20,8 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/extensions/v1beta1"
|
||||
v1 "k8s.io/api/networking/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/intstr"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
)
|
||||
@@ -35,7 +34,7 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want *v1beta1.Ingress
|
||||
want *v1.Ingress
|
||||
}{
|
||||
{
|
||||
name: "host-backward-compatibility",
|
||||
@@ -58,7 +57,7 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: &v1beta1.Ingress{
|
||||
want: &v1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"triggerName": "foo",
|
||||
@@ -69,19 +68,20 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
Namespace: "foobarNS",
|
||||
Annotations: nil,
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
Rules: []v1beta1.IngressRule{
|
||||
Spec: v1.IngressSpec{
|
||||
Rules: []v1.IngressRule{
|
||||
{
|
||||
Host: "test.com",
|
||||
IngressRuleValue: v1beta1.IngressRuleValue{
|
||||
HTTP: &v1beta1.HTTPIngressRuleValue{
|
||||
Paths: []v1beta1.HTTPIngressPath{
|
||||
IngressRuleValue: v1.IngressRuleValue{
|
||||
HTTP: &v1.HTTPIngressRuleValue{
|
||||
Paths: []v1.HTTPIngressPath{
|
||||
{
|
||||
Backend: v1beta1.IngressBackend{
|
||||
ServiceName: "router",
|
||||
ServicePort: intstr.IntOrString{
|
||||
Type: intstr.Int,
|
||||
IntVal: 80,
|
||||
Backend: v1.IngressBackend{
|
||||
Service: &v1.IngressServiceBackend{
|
||||
Name: "router",
|
||||
Port: v1.ServiceBackendPort{
|
||||
Number: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
Path: "/foo/bar",
|
||||
@@ -116,7 +116,7 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: &v1beta1.Ingress{
|
||||
want: &v1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"triggerName": "foo",
|
||||
@@ -129,19 +129,20 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
"key": "value",
|
||||
},
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
Rules: []v1beta1.IngressRule{
|
||||
Spec: v1.IngressSpec{
|
||||
Rules: []v1.IngressRule{
|
||||
{
|
||||
Host: "",
|
||||
IngressRuleValue: v1beta1.IngressRuleValue{
|
||||
HTTP: &v1beta1.HTTPIngressRuleValue{
|
||||
Paths: []v1beta1.HTTPIngressPath{
|
||||
IngressRuleValue: v1.IngressRuleValue{
|
||||
HTTP: &v1.HTTPIngressRuleValue{
|
||||
Paths: []v1.HTTPIngressPath{
|
||||
{
|
||||
Backend: v1beta1.IngressBackend{
|
||||
ServiceName: "router",
|
||||
ServicePort: intstr.IntOrString{
|
||||
Type: intstr.Int,
|
||||
IntVal: 80,
|
||||
Backend: v1.IngressBackend{
|
||||
Service: &v1.IngressServiceBackend{
|
||||
Name: "router",
|
||||
Port: v1.ServiceBackendPort{
|
||||
Number: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
Path: "/foo/bar",
|
||||
@@ -176,7 +177,7 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: &v1beta1.Ingress{
|
||||
want: &v1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"triggerName": "foo",
|
||||
@@ -187,19 +188,20 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
Namespace: "foobarNS",
|
||||
Annotations: nil,
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
Rules: []v1beta1.IngressRule{
|
||||
Spec: v1.IngressSpec{
|
||||
Rules: []v1.IngressRule{
|
||||
{
|
||||
Host: "test.com",
|
||||
IngressRuleValue: v1beta1.IngressRuleValue{
|
||||
HTTP: &v1beta1.HTTPIngressRuleValue{
|
||||
Paths: []v1beta1.HTTPIngressPath{
|
||||
IngressRuleValue: v1.IngressRuleValue{
|
||||
HTTP: &v1.HTTPIngressRuleValue{
|
||||
Paths: []v1.HTTPIngressPath{
|
||||
{
|
||||
Backend: v1beta1.IngressBackend{
|
||||
ServiceName: "router",
|
||||
ServicePort: intstr.IntOrString{
|
||||
Type: intstr.Int,
|
||||
IntVal: 80,
|
||||
Backend: v1.IngressBackend{
|
||||
Service: &v1.IngressServiceBackend{
|
||||
Name: "router",
|
||||
Port: v1.ServiceBackendPort{
|
||||
Number: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
Path: "/foo/bar",
|
||||
@@ -234,7 +236,7 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: &v1beta1.Ingress{
|
||||
want: &v1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"triggerName": "foo",
|
||||
@@ -245,19 +247,20 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
Namespace: "foobarNS",
|
||||
Annotations: nil,
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
Rules: []v1beta1.IngressRule{
|
||||
Spec: v1.IngressSpec{
|
||||
Rules: []v1.IngressRule{
|
||||
{
|
||||
Host: "",
|
||||
IngressRuleValue: v1beta1.IngressRuleValue{
|
||||
HTTP: &v1beta1.HTTPIngressRuleValue{
|
||||
Paths: []v1beta1.HTTPIngressPath{
|
||||
IngressRuleValue: v1.IngressRuleValue{
|
||||
HTTP: &v1.HTTPIngressRuleValue{
|
||||
Paths: []v1.HTTPIngressPath{
|
||||
{
|
||||
Backend: v1beta1.IngressBackend{
|
||||
ServiceName: "router",
|
||||
ServicePort: intstr.IntOrString{
|
||||
Type: intstr.Int,
|
||||
IntVal: 80,
|
||||
Backend: v1.IngressBackend{
|
||||
Service: &v1.IngressServiceBackend{
|
||||
Name: "router",
|
||||
Port: v1.ServiceBackendPort{
|
||||
Number: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
Path: "/foo/{bar}",
|
||||
@@ -292,7 +295,7 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: &v1beta1.Ingress{
|
||||
want: &v1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"triggerName": "foo",
|
||||
@@ -303,19 +306,20 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
Namespace: "foobarNS",
|
||||
Annotations: nil,
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
Rules: []v1beta1.IngressRule{
|
||||
Spec: v1.IngressSpec{
|
||||
Rules: []v1.IngressRule{
|
||||
{
|
||||
Host: "",
|
||||
IngressRuleValue: v1beta1.IngressRuleValue{
|
||||
HTTP: &v1beta1.HTTPIngressRuleValue{
|
||||
Paths: []v1beta1.HTTPIngressPath{
|
||||
IngressRuleValue: v1.IngressRuleValue{
|
||||
HTTP: &v1.HTTPIngressRuleValue{
|
||||
Paths: []v1.HTTPIngressPath{
|
||||
{
|
||||
Backend: v1beta1.IngressBackend{
|
||||
ServiceName: "router",
|
||||
ServicePort: intstr.IntOrString{
|
||||
Type: intstr.Int,
|
||||
IntVal: 80,
|
||||
Backend: v1.IngressBackend{
|
||||
Service: &v1.IngressServiceBackend{
|
||||
Name: "router",
|
||||
Port: v1.ServiceBackendPort{
|
||||
Number: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
Path: "/foo/{bar}",
|
||||
@@ -351,7 +355,7 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: &v1beta1.Ingress{
|
||||
want: &v1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"triggerName": "foo",
|
||||
@@ -362,19 +366,20 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
Namespace: "foobarNS",
|
||||
Annotations: nil,
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
Rules: []v1beta1.IngressRule{
|
||||
Spec: v1.IngressSpec{
|
||||
Rules: []v1.IngressRule{
|
||||
{
|
||||
Host: "test.com",
|
||||
IngressRuleValue: v1beta1.IngressRuleValue{
|
||||
HTTP: &v1beta1.HTTPIngressRuleValue{
|
||||
Paths: []v1beta1.HTTPIngressPath{
|
||||
IngressRuleValue: v1.IngressRuleValue{
|
||||
HTTP: &v1.HTTPIngressRuleValue{
|
||||
Paths: []v1.HTTPIngressPath{
|
||||
{
|
||||
Backend: v1beta1.IngressBackend{
|
||||
ServiceName: "router",
|
||||
ServicePort: intstr.IntOrString{
|
||||
Type: intstr.Int,
|
||||
IntVal: 80,
|
||||
Backend: v1.IngressBackend{
|
||||
Service: &v1.IngressServiceBackend{
|
||||
Name: "router",
|
||||
Port: v1.ServiceBackendPort{
|
||||
Number: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
Path: "/foo/bar",
|
||||
@@ -409,7 +414,7 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: &v1beta1.Ingress{
|
||||
want: &v1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"triggerName": "foo",
|
||||
@@ -420,19 +425,20 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
Namespace: "foobarNS",
|
||||
Annotations: nil,
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
Rules: []v1beta1.IngressRule{
|
||||
Spec: v1.IngressSpec{
|
||||
Rules: []v1.IngressRule{
|
||||
{
|
||||
Host: "",
|
||||
IngressRuleValue: v1beta1.IngressRuleValue{
|
||||
HTTP: &v1beta1.HTTPIngressRuleValue{
|
||||
Paths: []v1beta1.HTTPIngressPath{
|
||||
IngressRuleValue: v1.IngressRuleValue{
|
||||
HTTP: &v1.HTTPIngressRuleValue{
|
||||
Paths: []v1.HTTPIngressPath{
|
||||
{
|
||||
Backend: v1beta1.IngressBackend{
|
||||
ServiceName: "router",
|
||||
ServicePort: intstr.IntOrString{
|
||||
Type: intstr.Int,
|
||||
IntVal: 80,
|
||||
Backend: v1.IngressBackend{
|
||||
Service: &v1.IngressServiceBackend{
|
||||
Name: "router",
|
||||
Port: v1.ServiceBackendPort{
|
||||
Number: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
Path: "/foo/bar",
|
||||
@@ -469,7 +475,7 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
want: &v1beta1.Ingress{
|
||||
want: &v1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Labels: map[string]string{
|
||||
"triggerName": "foo",
|
||||
@@ -482,8 +488,8 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
"key": "value",
|
||||
},
|
||||
},
|
||||
Spec: v1beta1.IngressSpec{
|
||||
TLS: []v1beta1.IngressTLS{
|
||||
Spec: v1.IngressSpec{
|
||||
TLS: []v1.IngressTLS{
|
||||
{
|
||||
Hosts: []string{
|
||||
"test.com",
|
||||
@@ -491,18 +497,19 @@ func TestGetIngressSpec(t *testing.T) {
|
||||
SecretName: "foobar",
|
||||
},
|
||||
},
|
||||
Rules: []v1beta1.IngressRule{
|
||||
Rules: []v1.IngressRule{
|
||||
{
|
||||
Host: "",
|
||||
IngressRuleValue: v1beta1.IngressRuleValue{
|
||||
HTTP: &v1beta1.HTTPIngressRuleValue{
|
||||
Paths: []v1beta1.HTTPIngressPath{
|
||||
IngressRuleValue: v1.IngressRuleValue{
|
||||
HTTP: &v1.HTTPIngressRuleValue{
|
||||
Paths: []v1.HTTPIngressPath{
|
||||
{
|
||||
Backend: v1beta1.IngressBackend{
|
||||
ServiceName: "router",
|
||||
ServicePort: intstr.IntOrString{
|
||||
Type: intstr.Int,
|
||||
IntVal: 80,
|
||||
Backend: v1.IngressBackend{
|
||||
Service: &v1.IngressServiceBackend{
|
||||
Name: "router",
|
||||
Port: v1.ServiceBackendPort{
|
||||
Number: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
Path: "/foo/bar",
|
||||
|
||||
Reference in New Issue
Block a user