Skip to content

Commit

Permalink
Migrate Ingress from API extensions/v1beta1 to networking.k8s.io/v1beta1
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
  • Loading branch information
rubenvp8510 committed Apr 28, 2020
1 parent f2eded8 commit ad6a743
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 26 deletions.
12 changes: 12 additions & 0 deletions deploy/cluster_role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ rules:
- 'update'
- 'delete'
- 'watch'
# Ingress for kubernetes 1.14 or higher
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- 'get'
- 'list'
- 'create'
- 'update'
- 'delete'
- 'watch'
- apiGroups:
- batch
resources:
Expand Down
13 changes: 13 additions & 0 deletions deploy/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ rules:
- 'update'
- 'delete'
- 'watch'
# Ingress for kubernetes 1.14 or higher
- apiGroups:
- networking.k8s.io
resources:
- ingresses
verbs:
- 'get'
- 'list'
- 'create'
- 'update'
- 'delete'
- 'watch'
- apiGroups:
- batch
resources:
Expand Down Expand Up @@ -156,3 +168,4 @@ rules:
- 'update'
- 'delete'
- 'watch'

2 changes: 1 addition & 1 deletion pkg/controller/jaeger/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

log "github.com/sirupsen/logrus"
"go.opentelemetry.io/otel/global"
"k8s.io/api/extensions/v1beta1"
"k8s.io/api/networking/v1beta1"
"sigs.k8s.io/controller-runtime/pkg/client"

v1 "github.com/jaegertracing/jaeger-operator/pkg/apis/jaegertracing/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/jaeger/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"k8s.io/api/extensions/v1beta1"
"k8s.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
Expand Down
36 changes: 18 additions & 18 deletions pkg/ingress/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package ingress
import (
"fmt"

extv1beta1 "k8s.io/api/extensions/v1beta1"
netv1beta1 "k8s.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"

Expand All @@ -23,7 +23,7 @@ func NewQueryIngress(jaeger *v1.Jaeger) *QueryIngress {
}

// Get returns an ingress specification for the current instance
func (i *QueryIngress) Get() *extv1beta1.Ingress {
func (i *QueryIngress) Get() *netv1beta1.Ingress {
if i.jaeger.Spec.Ingress.Enabled != nil && *i.jaeger.Spec.Ingress.Enabled == false {
return nil
}
Expand All @@ -36,8 +36,8 @@ func (i *QueryIngress) Get() *extv1beta1.Ingress {

commonSpec := util.Merge([]v1.JaegerCommonSpec{i.jaeger.Spec.Ingress.JaegerCommonSpec, i.jaeger.Spec.JaegerCommonSpec, baseCommonSpec})

spec := extv1beta1.IngressSpec{}
backend := extv1beta1.IngressBackend{
spec := netv1beta1.IngressSpec{}
backend := netv1beta1.IngressBackend{
ServiceName: service.GetNameForQueryService(i.jaeger),
ServicePort: intstr.FromInt(service.GetPortForQueryService(i.jaeger)),
}
Expand All @@ -46,10 +46,10 @@ func (i *QueryIngress) Get() *extv1beta1.Ingress {

i.addTLSSpec(&spec)

return &extv1beta1.Ingress{
return &netv1beta1.Ingress{
TypeMeta: metav1.TypeMeta{
Kind: "Ingress",
APIVersion: "extensions/v1beta1",
APIVersion: "networking.k8s.io/v1beta1",
},
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-query", i.jaeger.Name),
Expand All @@ -70,7 +70,7 @@ func (i *QueryIngress) Get() *extv1beta1.Ingress {
}
}

func (i *QueryIngress) addRulesSpec(spec *extv1beta1.IngressSpec, backend *extv1beta1.IngressBackend) {
func (i *QueryIngress) addRulesSpec(spec *netv1beta1.IngressSpec, backend *netv1beta1.IngressBackend) {
path := ""

if allInOneQueryBasePath, ok := i.jaeger.Spec.AllInOne.Options.Map()["query.base-path"]; ok && i.jaeger.Spec.Strategy == v1.DeploymentStrategyAllInOne {
Expand All @@ -87,10 +87,10 @@ func (i *QueryIngress) addRulesSpec(spec *extv1beta1.IngressSpec, backend *extv1
}
}

func (i *QueryIngress) addTLSSpec(spec *extv1beta1.IngressSpec) {
func (i *QueryIngress) addTLSSpec(spec *netv1beta1.IngressSpec) {
if len(i.jaeger.Spec.Ingress.TLS) > 0 {
for _, tls := range i.jaeger.Spec.Ingress.TLS {
spec.TLS = append(spec.TLS, extv1beta1.IngressTLS{
spec.TLS = append(spec.TLS, netv1beta1.IngressTLS{
Hosts: tls.Hosts,
SecretName: tls.SecretName,
})
Expand All @@ -99,31 +99,31 @@ func (i *QueryIngress) addTLSSpec(spec *extv1beta1.IngressSpec) {
i.jaeger.Logger().Warn("Both 'ingress.secretName' and 'ingress.tls' are set. 'ingress.secretName' is deprecated and is therefore ignored.")
}
} else if i.jaeger.Spec.Ingress.SecretName != "" {
spec.TLS = append(spec.TLS, extv1beta1.IngressTLS{
spec.TLS = append(spec.TLS, netv1beta1.IngressTLS{
SecretName: i.jaeger.Spec.Ingress.SecretName,
})
i.jaeger.Logger().Warn("'ingress.secretName' property is deprecated and will be removed in the future. Please use 'ingress.tls' instead.")
}
}

func getRules(path string, hosts []string, backend *extv1beta1.IngressBackend) []extv1beta1.IngressRule {
func getRules(path string, hosts []string, backend *netv1beta1.IngressBackend) []netv1beta1.IngressRule {
if len(hosts) > 0 {
rules := make([]extv1beta1.IngressRule, len(hosts))
rules := make([]netv1beta1.IngressRule, len(hosts))
for i, host := range hosts {
rule := getRule(host, path, backend)
rules[i] = rule
}
return rules
}
return []extv1beta1.IngressRule{getRule("", path, backend)}
return []netv1beta1.IngressRule{getRule("", path, backend)}
}

func getRule(host string, path string, backend *extv1beta1.IngressBackend) extv1beta1.IngressRule {
rule := extv1beta1.IngressRule{}
func getRule(host string, path string, backend *netv1beta1.IngressBackend) netv1beta1.IngressRule {
rule := netv1beta1.IngressRule{}
rule.Host = host
rule.HTTP = &extv1beta1.HTTPIngressRuleValue{
Paths: []extv1beta1.HTTPIngressPath{
extv1beta1.HTTPIngressPath{
rule.HTTP = &netv1beta1.HTTPIngressRuleValue{
Paths: []netv1beta1.HTTPIngressPath{
netv1beta1.HTTPIngressPath{
Path: path,
Backend: *backend,
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/inventory/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package inventory
import (
"fmt"

"k8s.io/api/extensions/v1beta1"
"k8s.io/api/networking/v1beta1"

"github.com/jaegertracing/jaeger-operator/pkg/util"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/inventory/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"

"github.com/stretchr/testify/assert"
"k8s.io/api/extensions/v1beta1"
"k8s.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/strategy/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
corev1 "k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
"k8s.io/api/networking/v1beta1"
rbac "k8s.io/api/rbac/v1"

v1 "github.com/jaegertracing/jaeger-operator/pkg/apis/jaegertracing/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/strategy/strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
batchv1 "k8s.io/api/batch/v1"
batchv1beta1 "k8s.io/api/batch/v1beta1"
v1 "k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
"k8s.io/api/networking/v1beta1"
rbac "k8s.io/api/rbac/v1"

kafkav1beta1 "github.com/jaegertracing/jaeger-operator/pkg/apis/kafka/v1beta1"
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/wait_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/operator-framework/operator-sdk/pkg/test/e2eutil"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
"k8s.io/api/extensions/v1beta1"
"k8s.io/api/networking/v1beta1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -77,7 +77,7 @@ func WaitForIngress(t *testing.T, kubeclient kubernetes.Interface, namespace, na
start := time.Now()
var ingress *v1beta1.Ingress
err := wait.Poll(retryInterval, timeout, func() (done bool, err error) {
ingress, err = kubeclient.ExtensionsV1beta1().Ingresses(namespace).Get(name, metav1.GetOptions{})
ingress, err = kubeclient.NetworkingV1beta1().Ingresses(namespace).Get(name, metav1.GetOptions{})
if err != nil {
if apierrors.IsNotFound(err) {
t.Logf("Waiting for availability of %s ingress\n", name)
Expand Down

0 comments on commit ad6a743

Please sign in to comment.