Skip to content

Commit

Permalink
Add default service port for NIM as 8000
Browse files Browse the repository at this point in the history
Signed-off-by: Shiva Krishna, Merla <[email protected]>
  • Loading branch information
shivamerla committed Aug 16, 2024
1 parent cdb8b9b commit 6a718df
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 14 deletions.
5 changes: 3 additions & 2 deletions api/apps/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ type Expose struct {
type Service struct {
Type corev1.ServiceType `json:"type,omitempty"`
// override the default service name
Name string `json:"name,omitempty"`
OpenAIPort int32 `json:"openaiPort"`
Name string `json:"name,omitempty"`
// +kubebuilder:default=8000
OpenAIPort int32 `json:"openaiPort"`
}

// Metrics defines attributes to setup metrics collection
Expand Down
18 changes: 9 additions & 9 deletions api/apps/v1alpha1/nimservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,13 @@ func IsProbeEnabled(probe Probe) bool {
// GetLivenessProbe returns liveness probe for the NIMService container
func (n *NIMService) GetLivenessProbe() *corev1.Probe {
if n.Spec.LivenessProbe.Probe == nil {
return GetDefaultLivenessProbe()
return n.GetDefaultLivenessProbe()
}
return n.Spec.LivenessProbe.Probe
}

// GetDefaultLivenessProbe returns the default liveness probe for the NIMService container
func GetDefaultLivenessProbe() *corev1.Probe {
func (n *NIMService) GetDefaultLivenessProbe() *corev1.Probe {
probe := corev1.Probe{
InitialDelaySeconds: 15,
TimeoutSeconds: 1,
Expand All @@ -303,7 +303,7 @@ func GetDefaultLivenessProbe() *corev1.Probe {
Path: "/v1/health/live",
Port: intstr.IntOrString{
Type: intstr.Type(0),
IntVal: 8000,
IntVal: n.Spec.Expose.Service.OpenAIPort,
},
},
},
Expand All @@ -315,13 +315,13 @@ func GetDefaultLivenessProbe() *corev1.Probe {
// GetReadinessProbe returns readiness probe for the NIMService container
func (n *NIMService) GetReadinessProbe() *corev1.Probe {
if n.Spec.ReadinessProbe.Probe == nil {
return GetDefaultReadinessProbe()
return n.GetDefaultReadinessProbe()
}
return n.Spec.ReadinessProbe.Probe
}

// GetDefaultReadinessProbe returns the default readiness probe for the NIMService container
func GetDefaultReadinessProbe() *corev1.Probe {
func (n *NIMService) GetDefaultReadinessProbe() *corev1.Probe {
probe := corev1.Probe{
InitialDelaySeconds: 15,
TimeoutSeconds: 1,
Expand All @@ -333,7 +333,7 @@ func GetDefaultReadinessProbe() *corev1.Probe {
Path: "/v1/health/ready",
Port: intstr.IntOrString{
Type: intstr.Type(0),
IntVal: 8000,
IntVal: n.Spec.Expose.Service.OpenAIPort,
},
},
},
Expand All @@ -345,13 +345,13 @@ func GetDefaultReadinessProbe() *corev1.Probe {
// GetStartupProbe returns startup probe for the NIMService container
func (n *NIMService) GetStartupProbe() *corev1.Probe {
if n.Spec.StartupProbe.Probe == nil {
return GetDefaultStartupProbe()
return n.GetDefaultStartupProbe()
}
return n.Spec.StartupProbe.Probe
}

// GetDefaultStartupProbe returns the default startup probe for the NIMService container
func GetDefaultStartupProbe() *corev1.Probe {
func (n *NIMService) GetDefaultStartupProbe() *corev1.Probe {
probe := corev1.Probe{
InitialDelaySeconds: 40,
TimeoutSeconds: 1,
Expand All @@ -363,7 +363,7 @@ func GetDefaultStartupProbe() *corev1.Probe {
Path: "/v1/health/ready",
Port: intstr.IntOrString{
Type: intstr.Type(0),
IntVal: 8000,
IntVal: n.Spec.Expose.Service.OpenAIPort,
},
},
},
Expand Down
1 change: 1 addition & 0 deletions bundle/manifests/apps.nvidia.com_nimpipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ spec:
description: override the default service name
type: string
openaiPort:
default: 8000
format: int32
type: integer
type:
Expand Down
1 change: 1 addition & 0 deletions bundle/manifests/apps.nvidia.com_nimservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ spec:
description: override the default service name
type: string
openaiPort:
default: 8000
format: int32
type: integer
type:
Expand Down
1 change: 1 addition & 0 deletions config/crd/bases/apps.nvidia.com_nimpipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ spec:
description: override the default service name
type: string
openaiPort:
default: 8000
format: int32
type: integer
type:
Expand Down
1 change: 1 addition & 0 deletions config/crd/bases/apps.nvidia.com_nimservices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ spec:
description: override the default service name
type: string
openaiPort:
default: 8000
format: int32
type: integer
type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ spec:
description: override the default service name
type: string
openaiPort:
default: 8000
format: int32
type: integer
type:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ spec:
description: override the default service name
type: string
openaiPort:
default: 8000
format: int32
type: integer
type:
Expand Down
6 changes: 3 additions & 3 deletions internal/controller/platform/standalone/nimservice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ var _ = Describe("NIMServiceReconciler for a standalone platform", func() {
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/ready",
Port: intstr.IntOrString{IntVal: 8080},
Port: intstr.IntOrString{IntVal: 8000},
},
},
},
Expand All @@ -190,7 +190,7 @@ var _ = Describe("NIMServiceReconciler for a standalone platform", func() {
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/live",
Port: intstr.IntOrString{IntVal: 8080},
Port: intstr.IntOrString{IntVal: 8000},
},
},
},
Expand All @@ -201,7 +201,7 @@ var _ = Describe("NIMServiceReconciler for a standalone platform", func() {
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/start",
Port: intstr.IntOrString{IntVal: 8080},
Port: intstr.IntOrString{IntVal: 8000},
},
},
},
Expand Down

0 comments on commit 6a718df

Please sign in to comment.