Skip to content

Commit 98e12f9

Browse files
authored
add support for profiling service and ingress in armada components (#330)
Signed-off-by: Dejan Zele Pejchev <pejcev.dejan@gmail.com>
1 parent 9bc9036 commit 98e12f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1935
-1558
lines changed

api/install/v1alpha1/armadaserver_types.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ type ArmadaServerSpec struct {
2929
Replicas *int32 `json:"replicas,omitempty"`
3030
// NodeSelector restricts the ArmadaServer pod to run on nodes matching the configured selectors
3131
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
32-
// Ingress defines labels and annotations for the Ingress controller of ArmadaServer
32+
// Ingress defines configuration for the Ingress resource
3333
Ingress *IngressConfig `json:"ingress,omitempty"`
34+
// ProfilingIngressConfig defines configuration for the profiling Ingress resource
35+
ProfilingIngressConfig *IngressConfig `json:"profilingIngressConfig,omitempty"`
3436
// An array of host names to build ingress rules for
3537
HostNames []string `json:"hostNames,omitempty"`
3638
// Who is issuing certificates for CA

api/install/v1alpha1/binoculars_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ type BinocularsSpec struct {
5555
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
5656
// Ingress for this component. Used to inject labels/annotations into ingress
5757
Ingress *IngressConfig `json:"ingress,omitempty"`
58+
// ProfilingIngressConfig defines configuration for the profiling Ingress resource
59+
ProfilingIngressConfig *IngressConfig `json:"profilingIngressConfig,omitempty"`
5860
// An array of host names to build ingress rules for
5961
HostNames []string `json:"hostNames,omitempty"`
6062
// Who is issuing certificates for CA

api/install/v1alpha1/common.go

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
"k8s.io/apimachinery/pkg/runtime"
23-
"sigs.k8s.io/yaml"
24-
)
25-
26-
const (
27-
defaultHTTPPort = 8080
28-
defaultGRPCPort = 50051
29-
defaultMetricsPort = 9000
3023
)
3124

3225
type Image struct {
@@ -62,23 +55,17 @@ type IngressConfig struct {
6255
Annotations map[string]string `json:"annotations,omitempty"`
6356
// The type of ingress that is used
6457
IngressClass string `json:"ingressClass,omitempty"`
65-
// Overide name for ingress
66-
NameOverride string `json:"nameOverride,omitempty"`
58+
// An array of host names to build ingress rules for
59+
Hostnames []string `json:"hostNames,omitempty"`
60+
// Who is issuing certificates for CA
61+
ClusterIssuer string `json:"clusterIssuer,omitempty"`
6762
}
6863

6964
type AdditionalClusterRoleBinding struct {
7065
NameSuffix string `json:"nameSuffix"`
7166
ClusterRoleName string `json:"clusterRoleName"`
7267
}
7368

74-
type PortConfig struct {
75-
HttpPort int32 `json:"httpPort"`
76-
HttpNodePort int32 `json:"httpNodePort,omitempty"`
77-
GrpcPort int32 `json:"grpcPort"`
78-
GrpcNodePort int32 `json:"grpcNodePort,omitempty"`
79-
MetricsPort int32 `json:"metricsPort"`
80-
}
81-
8269
// CommonSpecBase is the common configuration for all services.
8370
// NOTE(Clif): You must label this with `json:""` when using it as an embedded
8471
// struct in order for controller-gen to use the promoted fields as expected.
@@ -109,37 +96,6 @@ type CommonSpecBase struct {
10996
AdditionalVolumes []corev1.Volume `json:"additionalVolumes,omitempty"`
11097
// Additional volume mounts that are added as volumes
11198
AdditionalVolumeMounts []corev1.VolumeMount `json:"additionalVolumeMounts,omitempty"`
112-
// PortConfig is automatically populated with defaults and overlaid by values in ApplicationConfig.
113-
PortConfig PortConfig `json:"portConfig,omitempty"`
114-
}
115-
116-
// BuildPortConfig extracts ports from the ApplicationConfig and returns a PortConfig
117-
func BuildPortConfig(rawAppConfig runtime.RawExtension) (PortConfig, error) {
118-
appConfig, err := ConvertRawExtensionToYaml(rawAppConfig)
119-
if err != nil {
120-
return PortConfig{}, err
121-
}
122-
// defaults
123-
portConfig := PortConfig{
124-
HttpPort: defaultHTTPPort,
125-
GrpcPort: defaultGRPCPort,
126-
MetricsPort: defaultMetricsPort,
127-
}
128-
err = yaml.Unmarshal([]byte(appConfig), &portConfig)
129-
if err != nil {
130-
return PortConfig{}, err
131-
}
132-
return portConfig, nil
133-
}
134-
135-
// ConvertRawExtensionToYaml converts a RawExtension input to Yaml
136-
func ConvertRawExtensionToYaml(config runtime.RawExtension) (string, error) {
137-
yamlConfig, err := yaml.JSONToYAML(config.Raw)
138-
if err != nil {
139-
return "", err
140-
}
141-
142-
return string(yamlConfig), nil
14399
}
144100

145101
func GetDefaultSecurityContext() *corev1.SecurityContext {
Lines changed: 0 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1 @@
11
package v1alpha1
2-
3-
import (
4-
"testing"
5-
6-
"github.com/stretchr/testify/assert"
7-
8-
"k8s.io/apimachinery/pkg/runtime"
9-
)
10-
11-
func TestBuildPortConfig(t *testing.T) {
12-
tests := []struct {
13-
name string
14-
input runtime.RawExtension
15-
expected PortConfig
16-
wantErr bool
17-
}{
18-
{
19-
name: "it provides some reasonable defaults",
20-
input: runtime.RawExtension{Raw: []byte(`{ }`)},
21-
expected: PortConfig{
22-
HttpPort: 8080,
23-
GrpcPort: 50051,
24-
MetricsPort: 9000,
25-
},
26-
},
27-
{
28-
name: "it errors with bad json (so does everything else in the app)",
29-
input: runtime.RawExtension{Raw: []byte(`{"httpPort": 8081`)},
30-
expected: PortConfig{},
31-
wantErr: true,
32-
},
33-
{
34-
name: "it accepts partial overrides from the config",
35-
input: runtime.RawExtension{Raw: []byte(`{"httpPort": 8081}`)},
36-
expected: PortConfig{
37-
HttpPort: 8081,
38-
GrpcPort: 50051,
39-
MetricsPort: 9000,
40-
},
41-
},
42-
{
43-
name: "it accepts complete override from the config",
44-
input: runtime.RawExtension{
45-
Raw: []byte(`{"httpPort": 8081, "grpcPort": 50052, "metricsPort": 9001 }`),
46-
},
47-
expected: PortConfig{
48-
HttpPort: 8081,
49-
GrpcPort: 50052,
50-
MetricsPort: 9001,
51-
},
52-
},
53-
}
54-
55-
for _, tt := range tests {
56-
t.Run(tt.name, func(t *testing.T) {
57-
pc, err := BuildPortConfig(tt.input)
58-
if tt.wantErr {
59-
assert.Error(t, err)
60-
} else {
61-
assert.Nil(t, err)
62-
}
63-
assert.Equal(t, tt.expected, pc)
64-
})
65-
}
66-
}
67-
68-
func TestConvertRawExtensionToYaml(t *testing.T) {
69-
70-
tests := []struct {
71-
name string
72-
input runtime.RawExtension
73-
expected string
74-
wantErr bool
75-
}{
76-
{
77-
name: "it converts runtime.RawExtension json to yaml",
78-
input: runtime.RawExtension{Raw: []byte(`{ "test": { "foo": "bar" }}`)},
79-
expected: "test:\n foo: bar\n",
80-
},
81-
{
82-
name: "it converts complex runtime.RawExtension json to yaml",
83-
input: runtime.RawExtension{Raw: []byte(`{ "test": {"foo": "bar"}, "test1": {"foo1": { "foo2": "bar2" }}}`)},
84-
expected: "test:\n foo: bar\ntest1:\n foo1:\n foo2: bar2\n",
85-
},
86-
{
87-
name: "it errors if runtime.RawExtension raw is malformed json",
88-
input: runtime.RawExtension{Raw: []byte(`{ "foo": "bar" `)},
89-
expected: "",
90-
wantErr: true,
91-
},
92-
}
93-
94-
for _, tt := range tests {
95-
t.Run(tt.name, func(t *testing.T) {
96-
output, err := ConvertRawExtensionToYaml(tt.input)
97-
if tt.wantErr {
98-
assert.Error(t, err)
99-
} else {
100-
assert.Nil(t, err)
101-
}
102-
assert.Equal(t, tt.expected, output)
103-
})
104-
}
105-
}

api/install/v1alpha1/eventingester_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ type EventIngesterSpec struct {
3333
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
3434
// PodSecurityContext defines the security options the pod should be run with
3535
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
36+
// ProfilingIngressConfig defines configuration for the profiling Ingress resource
37+
ProfilingIngressConfig *IngressConfig `json:"profilingIngressConfig,omitempty"`
3638
}
3739

3840
// EventIngesterStatus defines the observed state of EventIngester

api/install/v1alpha1/executor_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ type ExecutorSpec struct {
6262
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
6363
// PodSecurityContext defines the security options the pod should be run with
6464
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
65+
// ProfilingIngressConfig defines configuration for the profiling Ingress resource
66+
ProfilingIngressConfig *IngressConfig `json:"profilingIngressConfig,omitempty"`
6567
}
6668

6769
// ExecutorStatus defines the observed state of Executor

api/install/v1alpha1/lookout_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ type LookoutSpec struct {
6969
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
7070
// PodSecurityContext defines the security options the pod should be run with
7171
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
72+
// ProfilingIngressConfig defines configuration for the profiling Ingress resource
73+
ProfilingIngressConfig *IngressConfig `json:"profilingIngressConfig,omitempty"`
7274
}
7375

7476
// LookoutStatus defines the observed state of lookout

api/install/v1alpha1/lookoutingester_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ type LookoutIngesterSpec struct {
3131
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
3232
// PodSecurityContext defines the security options the pod should be run with
3333
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
34+
// ProfilingIngressConfig defines configuration for the profiling Ingress resource
35+
ProfilingIngressConfig *IngressConfig `json:"profilingIngressConfig,omitempty"`
3436
}
3537

3638
// LookoutIngesterStatus defines the observed state of LookoutIngester

api/install/v1alpha1/scheduler_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ type SchedulerSpec struct {
5353
Replicas *int32 `json:"replicas,omitempty"`
5454
// Ingress defines labels and annotations for the Ingress controller of Scheduler
5555
Ingress *IngressConfig `json:"ingress,omitempty"`
56+
// ProfilingIngressConfig defines configuration for the profiling Ingress resource
57+
ProfilingIngressConfig *IngressConfig `json:"profilingIngressConfig,omitempty"`
5658
// An array of host names to build ingress rules for
5759
HostNames []string `json:"hostNames,omitempty"`
5860
// Who is issuing certificates for CA

api/install/v1alpha1/scheduleringester_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ type SchedulerIngesterSpec struct {
3131
SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"`
3232
// PodSecurityContext defines the security options the pod should be run with
3333
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
34+
// ProfilingIngressConfig defines configuration for the profiling Ingress resource
35+
ProfilingIngressConfig *IngressConfig `json:"profilingIngressConfig,omitempty"`
3436
}
3537

3638
// SchedulerIngesterStatus defines the observed state of SchedulerIngester

0 commit comments

Comments
 (0)