Skip to content

Commit efda5cb

Browse files
committed
Cleanup service params
Signed-off-by: Shiva Krishna, Merla <[email protected]>
1 parent 0247c29 commit efda5cb

File tree

7 files changed

+14
-27
lines changed

7 files changed

+14
-27
lines changed

api/apps/v1alpha1/common_types.go

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ const (
2828
DefaultAPIPort = 8000
2929
// DefaultNamedPortAPI is the default name for api port
3030
DefaultNamedPortAPI = "api"
31-
// DefaultNamedPortMetrics is the default name for metrics port
32-
DefaultNamedPortMetrics = "metrics"
3331
)
3432

3533
// Expose defines attributes to expose the service

api/apps/v1alpha1/nemo_entitystore_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
3939

4040
const (
41-
// EntitystoreAPIPort is the default port that the entittystore serves on
41+
// EntitystoreAPIPort is the default port that the entitystore serves on
4242
EntitystoreAPIPort = 8000
4343
// NemoEntitystoreConditionReady indicates that the NEMO EntitystoreService is ready.
4444
NemoEntitystoreConditionReady = "Ready"

api/apps/v1alpha1/nemo_evaluator_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ func (n *NemoEvaluator) GetServiceParams() *rendertypes.ServiceParams {
709709
params.SelectorLabels = n.GetSelectorLabels()
710710

711711
// Set service type
712-
params.Type = "ClusterIP"
712+
params.Type = n.GetServiceType()
713713

714714
// Set service ports
715715
params.Ports = []corev1.ServicePort{

api/apps/v1alpha1/nimservice_types.go

+1
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ func (n *NIMService) GetServiceMonitorParams() *rendertypes.ServiceMonitorParams
783783
Selector: metav1.LabelSelector{MatchLabels: n.GetServiceLabels()},
784784
Endpoints: []monitoringv1.Endpoint{
785785
{
786+
Path: "/v1/metrics",
786787
Port: DefaultNamedPortAPI,
787788
ScrapeTimeout: serviceMonitor.ScrapeTimeout,
788789
Interval: serviceMonitor.Interval,

internal/render/render_test.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
v1 "k8s.io/api/networking/v1"
2929
"k8s.io/apimachinery/pkg/api/resource"
3030
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
31+
"k8s.io/apimachinery/pkg/util/intstr"
3132

3233
"github.com/NVIDIA/k8s-nim-operator/internal/render"
3334
"github.com/NVIDIA/k8s-nim-operator/internal/render/types"
@@ -250,11 +251,13 @@ var _ = Describe("K8s Resources Rendering", func() {
250251

251252
It("should render Service template correctly", func() {
252253
params := types.ServiceParams{
253-
Name: "test-service",
254-
Namespace: "default",
255-
Port: 80,
256-
TargetPort: 8080,
257-
Type: "ClusterIP",
254+
Name: "test-service",
255+
Namespace: "default",
256+
Ports: []corev1.ServicePort{{
257+
Port: 80,
258+
TargetPort: intstr.FromInt(8080),
259+
}},
260+
Type: "ClusterIP",
258261
}
259262
r := render.NewRenderer(templatesDir)
260263
service, err := r.Service(&params)

internal/render/types/types.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,8 @@ type StatefulSetParams struct {
119119

120120
// ServiceParams holds the parameters for rendering a Service template
121121
type ServiceParams struct {
122-
Name string
123-
Namespace string
124-
Port int32
125-
TargetPort int32
126-
PortName string
127-
Protocol string
122+
Name string
123+
Namespace string
128124
// Defines multiple ports for the service
129125
Ports []corev1.ServicePort
130126
Type string

manifests/service.yaml

+1-12
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,10 @@ spec:
1818
{{- .SelectorLabels | yaml | nindent 4 }}
1919
{{- end }}
2020
ports:
21-
{{- if .Ports }}
22-
{{- range .Ports }}
21+
{{- range .Ports }}
2322
- port: {{ .Port }}
2423
targetPort: {{ .TargetPort }}
2524
protocol: {{ .Protocol | default "TCP" }}
2625
name: {{ .Name }}
27-
{{- end }}
28-
{{- else if .Port }}
29-
- port: {{ .Port }}
30-
{{- if .TargetPort }}
31-
targetPort: {{ .TargetPort }}
32-
{{- end }}
33-
protocol: {{ .Protocol | default "TCP" }}
34-
{{- if .Name }}
35-
name: {{ .Name }}
36-
{{- end }}
3726
{{- end }}
3827

0 commit comments

Comments
 (0)