Skip to content

Commit 9a5e6c4

Browse files
Andrew Farriesroboquat
Andrew Farries
authored andcommitted
Add a service for the toxiproxy deployment
1 parent 117bb9b commit 9a5e6c4

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

install/installer/pkg/components/toxiproxy/constants.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
package toxiproxy
55

66
const (
7-
Component = "toxiproxy"
8-
HttpPort = 8474
7+
Component = "toxiproxy"
8+
HttpContainerPort = 8474
9+
HttpServicePort = 8474
10+
HttpPortName = "http"
911
)

install/installer/pkg/components/toxiproxy/deployment.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ func deployment(ctx *common.RenderContext) ([]runtime.Object, error) {
9191
},
9292
}),
9393
Ports: []corev1.ContainerPort{{
94-
Name: "http",
95-
ContainerPort: HttpPort,
94+
Name: HttpPortName,
95+
ContainerPort: HttpContainerPort,
9696
}},
9797
SecurityContext: &corev1.SecurityContext{
9898
Privileged: pointer.Bool(false),

install/installer/pkg/components/toxiproxy/objects.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func Objects(ctx *common.RenderContext) ([]runtime.Object, error) {
1717

1818
return common.CompositeRenderFunc(
1919
deployment,
20+
service,
2021
configmap,
2122
common.DefaultServiceAccount(Component),
2223
)(ctx)

install/installer/pkg/components/toxiproxy/objects_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestObjects_RenderedWhenExperimentalConfigSet(t *testing.T) {
2828
objects, err := Objects(ctx)
2929
require.NoError(t, err)
3030
require.NotEmpty(t, objects, "must render objects because experimental config is specified")
31-
require.Len(t, objects, 3, "should render expected k8s objects")
31+
require.Len(t, objects, 4, "should render expected k8s objects")
3232
}
3333

3434
func renderContextWithSlowDatabaseEnabled(t *testing.T) *common.RenderContext {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2+
// Licensed under the MIT License. See License-MIT.txt in the project root for license information.
3+
4+
package toxiproxy
5+
6+
import (
7+
"github.com/gitpod-io/gitpod/installer/pkg/common"
8+
"k8s.io/apimachinery/pkg/runtime"
9+
)
10+
11+
func service(ctx *common.RenderContext) ([]runtime.Object, error) {
12+
servicePorts := []common.ServicePort{
13+
{
14+
Name: HttpPortName,
15+
ContainerPort: HttpContainerPort,
16+
ServicePort: HttpServicePort,
17+
},
18+
}
19+
20+
return common.GenerateService(Component, servicePorts)(ctx)
21+
}

0 commit comments

Comments
 (0)