Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/router: update ingress API to networking.k8s.io/v1beta1 #534

Merged
merged 4 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion artifacts/flagger/account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ rules:
- horizontalpodautoscalers
verbs: ["*"]
- apiGroups:
- "extensions"
- extensions
- networking.k8s.io
resources:
- ingresses
- ingresses/status
Expand Down
3 changes: 2 additions & 1 deletion charts/flagger/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ rules:
- horizontalpodautoscalers
verbs: ["*"]
- apiGroups:
- "extensions"
- extensions
- networking.k8s.io
resources:
- ingresses
- ingresses/status
Expand Down
6 changes: 3 additions & 3 deletions docs/gitbook/tutorials/nginx-progressive-delivery.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This guide shows you how to use the NGINX ingress controller and Flagger to auto

## Prerequisites

Flagger requires a Kubernetes cluster **v1.11** or newer and NGINX ingress **0.24** or newer.
Flagger requires a Kubernetes cluster **v1.14** or newer and NGINX ingress **0.24** or newer.

Install NGINX with Helm v3:

Expand Down Expand Up @@ -69,7 +69,7 @@ helm upgrade -i flagger-loadtester flagger/loadtester \
Create an ingress definition \(replace `app.example.com` with your own domain\):

```yaml
apiVersion: extensions/v1beta1
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: podinfo
Expand Down Expand Up @@ -111,7 +111,7 @@ spec:
name: podinfo
# ingress reference
ingressRef:
apiVersion: extensions/v1beta1
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
name: podinfo
# HPA reference (optional)
Expand Down
3 changes: 2 additions & 1 deletion kustomize/base/flagger/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ rules:
- horizontalpodautoscalers
verbs: ["*"]
- apiGroups:
- "extensions"
- extensions
- networking.k8s.io
resources:
- ingresses
- ingresses/status
Expand Down
16 changes: 8 additions & 8 deletions pkg/router/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/google/go-cmp/cmp"
"go.uber.org/zap"
"k8s.io/api/extensions/v1beta1"
"k8s.io/api/networking/v1beta1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
Expand All @@ -31,7 +31,7 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error {
canaryName := fmt.Sprintf("%s-canary", apexName)
canaryIngressName := fmt.Sprintf("%s-canary", canary.Spec.IngressRef.Name)

ingress, err := i.kubeClient.ExtensionsV1beta1().Ingresses(canary.Namespace).Get(canary.Spec.IngressRef.Name, metav1.GetOptions{})
ingress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(canary.Spec.IngressRef.Name, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("ingress %s.%s get query error: %w", canary.Spec.IngressRef.Name, canary.Namespace, err)
}
Expand All @@ -54,7 +54,7 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error {
return fmt.Errorf("backend %s not found in ingress %s", apexName, canary.Spec.IngressRef.Name)
}

canaryIngress, err := i.kubeClient.ExtensionsV1beta1().Ingresses(canary.Namespace).Get(canaryIngressName, metav1.GetOptions{})
canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(canaryIngressName, metav1.GetOptions{})

if errors.IsNotFound(err) {
ing := &v1beta1.Ingress{
Expand All @@ -74,7 +74,7 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error {
Spec: ingressClone.Spec,
}

_, err := i.kubeClient.ExtensionsV1beta1().Ingresses(canary.Namespace).Create(ing)
_, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Create(ing)
if err != nil {
return fmt.Errorf("ingress %s.%s create error: %w", ing.Name, ing.Namespace, err)
}
Expand All @@ -90,7 +90,7 @@ func (i *IngressRouter) Reconcile(canary *flaggerv1.Canary) error {
iClone := canaryIngress.DeepCopy()
iClone.Spec = ingressClone.Spec

_, err := i.kubeClient.ExtensionsV1beta1().Ingresses(canary.Namespace).Update(iClone)
_, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Update(iClone)
if err != nil {
return fmt.Errorf("ingress %s.%s update error: %w", canaryIngressName, iClone.Namespace, err)
}
Expand All @@ -109,7 +109,7 @@ func (i *IngressRouter) GetRoutes(canary *flaggerv1.Canary) (
err error,
) {
canaryIngressName := fmt.Sprintf("%s-canary", canary.Spec.IngressRef.Name)
canaryIngress, err := i.kubeClient.ExtensionsV1beta1().Ingresses(canary.Namespace).Get(canaryIngressName, metav1.GetOptions{})
canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(canaryIngressName, metav1.GetOptions{})
if err != nil {
err = fmt.Errorf("ingress %s.%s get query error: %w", canaryIngressName, canary.Namespace, err)
return
Expand Down Expand Up @@ -150,7 +150,7 @@ func (i *IngressRouter) SetRoutes(
_ bool,
) error {
canaryIngressName := fmt.Sprintf("%s-canary", canary.Spec.IngressRef.Name)
canaryIngress, err := i.kubeClient.ExtensionsV1beta1().Ingresses(canary.Namespace).Get(canaryIngressName, metav1.GetOptions{})
canaryIngress, err := i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Get(canaryIngressName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("ingress %s.%s get query error: %w", canaryIngressName, canary.Namespace, err)
}
Expand Down Expand Up @@ -184,7 +184,7 @@ func (i *IngressRouter) SetRoutes(
iClone.Annotations = i.makeAnnotations(iClone.Annotations)
}

_, err = i.kubeClient.ExtensionsV1beta1().Ingresses(canary.Namespace).Update(iClone)
_, err = i.kubeClient.NetworkingV1beta1().Ingresses(canary.Namespace).Update(iClone)
if err != nil {
return fmt.Errorf("ingress %s.%s update error %v", iClone.Name, iClone.Namespace, err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/router/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestIngressRouter_Reconcile(t *testing.T) {
canaryWeightAn := "custom.ingress.kubernetes.io/canary-weight"

canaryName := fmt.Sprintf("%s-canary", mocks.ingressCanary.Spec.IngressRef.Name)
inCanary, err := router.kubeClient.ExtensionsV1beta1().Ingresses("default").Get(canaryName, metav1.GetOptions{})
inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(canaryName, metav1.GetOptions{})
require.NoError(t, err)

// test initialisation
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestIngressRouter_GetSetRoutes(t *testing.T) {
canaryWeightAn := "prefix1.nginx.ingress.kubernetes.io/canary-weight"

canaryName := fmt.Sprintf("%s-canary", mocks.ingressCanary.Spec.IngressRef.Name)
inCanary, err := router.kubeClient.ExtensionsV1beta1().Ingresses("default").Get(canaryName, metav1.GetOptions{})
inCanary, err := router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(canaryName, metav1.GetOptions{})
require.NoError(t, err)

// test rollout
Expand All @@ -72,7 +72,7 @@ func TestIngressRouter_GetSetRoutes(t *testing.T) {
err = router.SetRoutes(mocks.ingressCanary, p, c, m)
require.NoError(t, err)

inCanary, err = router.kubeClient.ExtensionsV1beta1().Ingresses("default").Get(canaryName, metav1.GetOptions{})
inCanary, err = router.kubeClient.NetworkingV1beta1().Ingresses("default").Get(canaryName, metav1.GetOptions{})
require.NoError(t, err)

// test promotion
Expand Down
2 changes: 1 addition & 1 deletion pkg/router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"go.uber.org/zap"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/api/extensions/v1beta1"
"k8s.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/client-go/kubernetes"
Expand Down
2 changes: 1 addition & 1 deletion test/e2e-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: podinfo
Expand Down
4 changes: 2 additions & 2 deletions test/e2e-nginx-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
kind: Deployment
name: podinfo
ingressRef:
apiVersion: extensions/v1beta1
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
name: podinfo
progressDeadlineSeconds: 60
Expand Down Expand Up @@ -167,7 +167,7 @@ spec:
kind: Deployment
name: podinfo
ingressRef:
apiVersion: extensions/v1beta1
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
name: podinfo
progressDeadlineSeconds: 60
Expand Down