Skip to content

Commit

Permalink
Merge pull request #108 from goodrain/master
Browse files Browse the repository at this point in the history
upgrade ingress version
  • Loading branch information
barnettZQG authored Aug 16, 2021
2 parents 04c33a3 + 19ff317 commit 600bf49
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ testbin/*
*.swp
*.swo
*~

vendor
30 changes: 19 additions & 11 deletions controllers/handler/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/goodrain/rainbond-operator/util/probeutil"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -388,7 +388,7 @@ func (a *api) secretAndConfigMapForAPI() []client.Object {
}

func (a *api) ingressForAPI() client.Object {
ing := &extensions.Ingress{
ing := &networkingv1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: APIName,
Namespace: a.component.Namespace,
Expand All @@ -399,10 +399,14 @@ func (a *api) ingressForAPI() client.Object {
},
Labels: a.labels,
},
Spec: extensions.IngressSpec{
Backend: &extensions.IngressBackend{
ServiceName: APIName + "-api",
ServicePort: intstr.FromString("https"),
Spec: networkingv1.IngressSpec{
DefaultBackend: &networkingv1.IngressBackend{
Service: &networkingv1.IngressServiceBackend{
Name: APIName + "-api",
Port: networkingv1.ServiceBackendPort{
Name: "https",
},
},
},
},
}
Expand All @@ -411,7 +415,7 @@ func (a *api) ingressForAPI() client.Object {
}

func (a *api) ingressForWebsocket() client.Object {
ing := &extensions.Ingress{
ing := &networkingv1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: APIName + "-websocket",
Namespace: a.component.Namespace,
Expand All @@ -422,10 +426,14 @@ func (a *api) ingressForWebsocket() client.Object {
},
Labels: a.labels,
},
Spec: extensions.IngressSpec{
Backend: &extensions.IngressBackend{
ServiceName: APIName + "-websocket",
ServicePort: intstr.FromString("ws"),
Spec: networkingv1.IngressSpec{
DefaultBackend: &networkingv1.IngressBackend{
Service: &networkingv1.IngressServiceBackend{
Name: APIName + "-websocket",
Port: networkingv1.ServiceBackendPort{
Name: "ws",
},
},
},
},
}
Expand Down
20 changes: 11 additions & 9 deletions controllers/handler/app-ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ import (
"fmt"
"strconv"

"github.com/goodrain/rainbond-operator/util/probeutil"

rainbondv1alpha1 "github.com/goodrain/rainbond-operator/api/v1alpha1"
"github.com/goodrain/rainbond-operator/util/commonutil"

"github.com/goodrain/rainbond-operator/util/probeutil"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down Expand Up @@ -283,7 +281,7 @@ func (a *appui) serviceForAppUI() client.Object {
}

func (a *appui) ingressForAppUI() client.Object {
ing := &extensions.Ingress{
ing := &networkingv1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: AppUIName,
Namespace: a.component.Namespace,
Expand All @@ -294,10 +292,14 @@ func (a *appui) ingressForAppUI() client.Object {
},
Labels: a.labels,
},
Spec: extensions.IngressSpec{
Backend: &extensions.IngressBackend{
ServiceName: AppUIName,
ServicePort: intstr.FromString("http"),
Spec: networkingv1.IngressSpec{
DefaultBackend: &networkingv1.IngressBackend{
Service: &networkingv1.IngressServiceBackend{
Name: AppUIName,
Port: networkingv1.ServiceBackendPort{
Name: "http",
},
},
},
},
}
Expand Down
30 changes: 18 additions & 12 deletions controllers/handler/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
rainbondv1alpha1 "github.com/goodrain/rainbond-operator/api/v1alpha1"
"github.com/goodrain/rainbond-operator/util/commonutil"
"github.com/goodrain/rainbond-operator/util/constants"
"github.com/goodrain/rainbond-operator/util/k8sutil"
"github.com/goodrain/rainbond-operator/util/rbdutil"
"github.com/sirupsen/logrus"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
extensions "k8s.io/api/extensions/v1beta1"
networkingv1 "k8s.io/api/networking/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand Down Expand Up @@ -221,7 +222,7 @@ func (h *hub) persistentVolumeClaimForHub() *corev1.PersistentVolumeClaim {
}

func (h *hub) ingressForHub() client.Object {
ing := &extensions.Ingress{
ing := &networkingv1.Ingress{
ObjectMeta: metav1.ObjectMeta{
Name: HubName,
Namespace: h.component.Namespace,
Expand All @@ -236,26 +237,31 @@ func (h *hub) ingressForHub() client.Object {
},
Labels: h.labels,
},
Spec: extensions.IngressSpec{
Rules: []extensions.IngressRule{
Spec: networkingv1.IngressSpec{
Rules: []networkingv1.IngressRule{
{
Host: constants.DefImageRepository,
IngressRuleValue: extensions.IngressRuleValue{
HTTP: &extensions.HTTPIngressRuleValue{
Paths: []extensions.HTTPIngressPath{
IngressRuleValue: networkingv1.IngressRuleValue{
HTTP: &networkingv1.HTTPIngressRuleValue{
Paths: []networkingv1.HTTPIngressPath{
{
Path: "/v2/",
Backend: extensions.IngressBackend{
ServiceName: HubName,
ServicePort: intstr.FromInt(5000),
Path: "/v2/",
PathType: k8sutil.IngressPathType(networkingv1.PathTypeExact),
Backend: networkingv1.IngressBackend{
Service: &networkingv1.IngressServiceBackend{
Name: HubName,
Port: networkingv1.ServiceBackendPort{
Number: 5000,
},
},
},
},
},
},
},
},
},
TLS: []extensions.IngressTLS{
TLS: []networkingv1.IngressTLS{
{
Hosts: []string{rbdutil.GetImageRepository(h.cluster)},
SecretName: hubImageRepository,
Expand Down
6 changes: 6 additions & 0 deletions util/k8sutil/k8sutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/goodrain/rainbond-operator/util/commonutil"
"github.com/goodrain/rainbond-operator/util/constants"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
k8sErrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -97,6 +98,11 @@ func HostPath(hostpath corev1.HostPathType) *corev1.HostPathType {
return &hostpath
}

// IngressPathType returns a pointer to the PathType value passed in.
func IngressPathType(pathType networkingv1.PathType) *networkingv1.PathType {
return &pathType
}

// HostPathDirectoryOrCreate returns a pointer to the HostPathType value passed in.
func HostPathDirectoryOrCreate() *corev1.HostPathType {
var hpdoc = corev1.HostPathDirectoryOrCreate
Expand Down

0 comments on commit 600bf49

Please sign in to comment.