Skip to content

Commit c95b19f

Browse files
authored
feat: add support for httproute management (#85)
* feat: integrate gateway API and simplify HTTPBin deployment configuration Signed-off-by: Bastian Echterhölter <bastian.echterhoelter@sap.com> On-behalf-of: @SAP <bastian.echterhoelter@sap.com> * feat: simplify HttpBin configuration by removing HTTPS support and adjusting service port Signed-off-by: Bastian Echterhölter <bastian.echterhoelter@sap.com> On-behalf-of: @SAP <bastian.echterhoelter@sap.com> * feat: add support for Gateway API in HttpBin deployment tests Signed-off-by: Bastian Echterhölter <bastian.echterhoelter@sap.com> On-behalf-of: @SAP <bastian.echterhoelter@sap.com> --------- Signed-off-by: Bastian Echterhölter <bastian.echterhoelter@sap.com>
1 parent 7ca748b commit c95b19f

13 files changed

Lines changed: 7661 additions & 80 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ charts/**/*.tar.gz
3737
charts/**/*.tgz
3838
/dist
3939
.helm-charts
40+
.claude
4041
CLAUDE.md
4142
CLAUDE.local.md
4243
/convo

api/v1alpha1/httpbin_types.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ const (
4545

4646
// HttpBinSpec defines the desired state of HttpBin
4747
type HttpBinSpec struct {
48-
// EnableHTTPS determines if HTTPS should be enabled
49-
// If true, service port will be 8443
50-
// If false or not set, service port will be 443
51-
// +optional
52-
// +kubebuilder:default=false
53-
EnableHTTPS bool `json:"enableHTTPS,omitempty"`
54-
55-
// Foo is an example field of HttpBin. Edit httpbin_types.go to remove/update
56-
Foo string `json:"foo,omitempty"`
5748
// Region can be used to filter which HttpBin should be served
5849
Region string `json:"region,omitempty"`
5950
}

cmd/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"
3838
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3939
"sigs.k8s.io/controller-runtime/pkg/webhook"
40+
gatewayApi "sigs.k8s.io/gateway-api/apis/v1"
4041

4142
orchestratev1alpha1 "http-operator/api/v1alpha1"
4243
"http-operator/internal/controller"
@@ -52,6 +53,7 @@ func init() {
5253
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
5354

5455
utilruntime.Must(orchestratev1alpha1.AddToScheme(scheme))
56+
utilruntime.Must(gatewayApi.Install(scheme))
5557
// +kubebuilder:scaffold:scheme
5658
}
5759

config/crd/bases/orchestrate.platform-mesh.io_httpbins.yaml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,6 @@ spec:
3939
spec:
4040
description: HttpBinSpec defines the desired state of HttpBin
4141
properties:
42-
enableHTTPS:
43-
default: false
44-
description: |-
45-
EnableHTTPS determines if HTTPS should be enabled
46-
If true, service port will be 8443
47-
If false or not set, service port will be 443
48-
type: boolean
49-
foo:
50-
description: Foo is an example field of HttpBin. Edit httpbin_types.go
51-
to remove/update
52-
type: string
5342
region:
5443
description: Region can be used to filter which HttpBin should be
5544
served

config/crd/gateway-api/gateway-api-crds.yaml

Lines changed: 7166 additions & 0 deletions
Large diffs are not rendered by default.

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ require (
1919
k8s.io/client-go v0.34.2
2020
sigs.k8s.io/controller-runtime v0.22.1
2121
sigs.k8s.io/e2e-framework v0.6.0
22+
sigs.k8s.io/gateway-api v1.4.0
2223
)
2324

2425
require (
@@ -314,7 +315,7 @@ require (
314315
k8s.io/apiserver v0.34.1 // indirect
315316
k8s.io/code-generator v0.34.1 // indirect
316317
k8s.io/component-base v0.34.1 // indirect
317-
k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f // indirect
318+
k8s.io/gengo/v2 v2.0.0-20250820003526-c297c0c1eb9d // indirect
318319
k8s.io/klog/v2 v2.130.1 // indirect
319320
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
320321
k8s.io/utils v0.0.0-20250820121507-0af2bda4dd1d // indirect

go.sum

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -815,28 +815,22 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
815815
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
816816
honnef.co/go/tools v0.6.1 h1:R094WgE8K4JirYjBaOpz/AvTyUu/3wbmAoskKN/pxTI=
817817
honnef.co/go/tools v0.6.1/go.mod h1:3puzxxljPCe8RGJX7BIy1plGbxEOZni5mR2aXe3/uk4=
818-
k8s.io/api v0.34.1 h1:jC+153630BMdlFukegoEL8E/yT7aLyQkIVuwhmwDgJM=
819-
k8s.io/api v0.34.1/go.mod h1:SB80FxFtXn5/gwzCoN6QCtPD7Vbu5w2n1S0J5gFfTYk=
820818
k8s.io/api v0.34.2 h1:fsSUNZhV+bnL6Aqrp6O7lMTy6o5x2C4XLjnh//8SLYY=
821819
k8s.io/api v0.34.2/go.mod h1:MMBPaWlED2a8w4RSeanD76f7opUoypY8TFYkSM+3XHw=
822820
k8s.io/apiextensions-apiserver v0.34.1 h1:NNPBva8FNAPt1iSVwIE0FsdrVriRXMsaWFMqJbII2CI=
823821
k8s.io/apiextensions-apiserver v0.34.1/go.mod h1:hP9Rld3zF5Ay2Of3BeEpLAToP+l4s5UlxiHfqRaRcMc=
824-
k8s.io/apimachinery v0.34.1 h1:dTlxFls/eikpJxmAC7MVE8oOeP1zryV7iRyIjB0gky4=
825-
k8s.io/apimachinery v0.34.1/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
826822
k8s.io/apimachinery v0.34.2 h1:zQ12Uk3eMHPxrsbUJgNF8bTauTVR2WgqJsTmwTE/NW4=
827823
k8s.io/apimachinery v0.34.2/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
828824
k8s.io/apiserver v0.34.1 h1:U3JBGdgANK3dfFcyknWde1G6X1F4bg7PXuvlqt8lITA=
829825
k8s.io/apiserver v0.34.1/go.mod h1:eOOc9nrVqlBI1AFCvVzsob0OxtPZUCPiUJL45JOTBG0=
830-
k8s.io/client-go v0.34.1 h1:ZUPJKgXsnKwVwmKKdPfw4tB58+7/Ik3CrjOEhsiZ7mY=
831-
k8s.io/client-go v0.34.1/go.mod h1:kA8v0FP+tk6sZA0yKLRG67LWjqufAoSHA2xVGKw9Of8=
832826
k8s.io/client-go v0.34.2 h1:Co6XiknN+uUZqiddlfAjT68184/37PS4QAzYvQvDR8M=
833827
k8s.io/client-go v0.34.2/go.mod h1:2VYDl1XXJsdcAxw7BenFslRQX28Dxz91U9MWKjX97fE=
834828
k8s.io/code-generator v0.34.1 h1:WpphT26E+j7tEgIUfFr5WfbJrktCGzB3JoJH9149xYc=
835829
k8s.io/code-generator v0.34.1/go.mod h1:DeWjekbDnJWRwpw3s0Jat87c+e0TgkxoR4ar608yqvg=
836830
k8s.io/component-base v0.34.1 h1:v7xFgG+ONhytZNFpIz5/kecwD+sUhVE6HU7qQUiRM4A=
837831
k8s.io/component-base v0.34.1/go.mod h1:mknCpLlTSKHzAQJJnnHVKqjxR7gBeHRv0rPXA7gdtQ0=
838-
k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f h1:SLb+kxmzfA87x4E4brQzB33VBbT2+x7Zq9ROIHmGn9Q=
839-
k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU=
832+
k8s.io/gengo/v2 v2.0.0-20250820003526-c297c0c1eb9d h1:qUrYOinhdAUL0xxhA4gPqogPBaS9nIq2l2kTb6pmeB0=
833+
k8s.io/gengo/v2 v2.0.0-20250820003526-c297c0c1eb9d/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU=
840834
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
841835
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
842836
k8s.io/kms v0.34.1 h1:iCFOvewDPzWM9fMTfyIPO+4MeuZ0tcZbugxLNSHFG4w=
@@ -859,6 +853,8 @@ sigs.k8s.io/controller-tools v0.19.0 h1:OU7jrPPiZusryu6YK0jYSjPqg8Vhf8cAzluP9XGI
859853
sigs.k8s.io/controller-tools v0.19.0/go.mod h1:y5HY/iNDFkmFla2CfQoVb2AQXMsBk4ad84iR1PLANB0=
860854
sigs.k8s.io/e2e-framework v0.6.0 h1:p7hFzHnLKO7eNsWGI2AbC1Mo2IYxidg49BiT4njxkrM=
861855
sigs.k8s.io/e2e-framework v0.6.0/go.mod h1:IREnCHnKgRCioLRmNi0hxSJ1kJ+aAdjEKK/gokcZu4k=
856+
sigs.k8s.io/gateway-api v1.4.0 h1:ZwlNM6zOHq0h3WUX2gfByPs2yAEsy/EenYJB78jpQfQ=
857+
sigs.k8s.io/gateway-api v1.4.0/go.mod h1:AR5RSqciWP98OPckEjOjh2XJhAe2Na4LHyXD2FUY7Qk=
862858
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
863859
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
864860
sigs.k8s.io/kubebuilder/v4 v4.9.0 h1:9e9LnQy/wQ24IZDIqye6iZZFOB9aKNyNfjnfsy3S8cw=

internal/controller/httpbin_controller.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func (r *HttpBinReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
9191
"HttpBin.Spec", httpBin.Spec)
9292

9393
// Define a new HttpBinDeployment object
94+
// Service port is always 80 for backend pods, SSL is terminated at ingress/httproute level
9495
httpBinDeployment := &orchestratev1alpha1.HttpBinDeployment{
9596
ObjectMeta: metav1.ObjectMeta{
9697
Name: httpBin.Name,
@@ -100,12 +101,7 @@ func (r *HttpBinReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
100101
Spec: orchestratev1alpha1.HttpBinDeploymentSpec{
101102
Service: orchestratev1alpha1.ServiceConfig{
102103
Type: *fDeploymentServiceType,
103-
Port: func() int32 {
104-
if httpBin.Spec.EnableHTTPS {
105-
return 8443
106-
}
107-
return 443
108-
}(),
104+
Port: 80,
109105
},
110106
Deployment: orchestratev1alpha1.DeploymentConfig{
111107
Labels: map[string]string{

internal/controller/httpbin_controller_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ var _ = Describe("HttpBin Controller", func() {
5757
Namespace: "default",
5858
},
5959
Spec: orchestratev1alpha1.HttpBinSpec{
60-
EnableHTTPS: false,
61-
Region: "us-east-1",
60+
Region: "us-east-1",
6261
},
6362
}
6463
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
@@ -100,11 +99,11 @@ var _ = Describe("HttpBin Controller", func() {
10099
return k8sClient.Get(ctx, typeNamespacedName, httpBinDeployment)
101100
}, timeout, interval).Should(Succeed())
102101

103-
Expect(httpBinDeployment.Spec.Service.Port).To(Equal(int32(443)))
102+
Expect(httpBinDeployment.Spec.Service.Port).To(Equal(int32(80)))
104103
})
105104

106-
It("should set correct port when EnableHTTPS is true", func() {
107-
By("Creating HttpBin with EnableHTTPS=true")
105+
It("should always use backend port 80 for service", func() {
106+
By("Creating HttpBin resource")
108107
httpsResourceName := "test-httpbin-https"
109108
httpsNamespacedName := types.NamespacedName{
110109
Name: httpsResourceName,
@@ -117,7 +116,7 @@ var _ = Describe("HttpBin Controller", func() {
117116
Namespace: "default",
118117
},
119118
Spec: orchestratev1alpha1.HttpBinSpec{
120-
EnableHTTPS: true,
119+
Region: "us-west-1",
121120
},
122121
}
123122
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
@@ -141,13 +140,13 @@ var _ = Describe("HttpBin Controller", func() {
141140
})
142141
Expect(err).NotTo(HaveOccurred())
143142

144-
By("Verifying HttpBinDeployment has HTTPS port")
143+
By("Verifying HttpBinDeployment service port is 80 (SSL terminated at ingress/httproute)")
145144
httpBinDeployment := &orchestratev1alpha1.HttpBinDeployment{}
146145
Eventually(func() error {
147146
return k8sClient.Get(ctx, httpsNamespacedName, httpBinDeployment)
148147
}, timeout, interval).Should(Succeed())
149148

150-
Expect(httpBinDeployment.Spec.Service.Port).To(Equal(int32(8443)))
149+
Expect(httpBinDeployment.Spec.Service.Port).To(Equal(int32(80)))
151150
})
152151

153152
It("should handle not found resource gracefully", func() {

0 commit comments

Comments
 (0)