Skip to content

Commit

Permalink
Adding support for creating ingress for NIM Deployment (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
visheshtanksale authored Aug 1, 2024
1 parent 45edafa commit 4379241
Show file tree
Hide file tree
Showing 12 changed files with 1,634 additions and 336 deletions.
6 changes: 2 additions & 4 deletions api/v1alpha1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ type Image struct {
// Ingress defines attributes to enable ingress for the service
type Ingress struct {
// ingress, or virtualService - not both
Enabled *bool `json:"enabled,omitempty"`
ClassName string `json:"className,omitempty"`
Hosts []IngressHost `json:"hosts,omitempty"`
TLS []networkingv1.IngressTLS `json:"tls,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Spec networkingv1.IngressSpec `json:"spec,omitempty"`
}

// IngressHost defines attributes for ingress host
Expand Down
10 changes: 8 additions & 2 deletions api/v1alpha1/nimservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
utils "github.com/NVIDIA/k8s-nim-operator/internal/utils"
autoscalingv2 "k8s.io/api/autoscaling/v2"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down Expand Up @@ -351,6 +352,7 @@ func (n *NIMService) GetExternalPVC() *string {
return n.Spec.Storage.PVC.Name
}

// GetHPASpec returns the HPA spec for the NIMService deployment
func (n *NIMService) GetHPASpec() autoscalingv2.HorizontalPodAutoscalerSpec {
return n.Spec.Scale.HPASpec
}
Expand Down Expand Up @@ -378,6 +380,11 @@ func (n *NIMService) IsIngressEnabled() bool {
return n.Spec.Expose.Ingress.Enabled != nil && *n.Spec.Expose.Ingress.Enabled
}

// GetIngressSpec returns the Ingress spec NIMService deployment
func (n *NIMService) GetIngressSpec() networkingv1.IngressSpec {
return n.Spec.Expose.Ingress.Spec
}

// IsServiceMonitorEnabled returns true if servicemonitor is enabled for NIMService deployment
func (n *NIMService) IsServiceMonitorEnabled() bool {
return n.Spec.Metrics.Enabled != nil && *n.Spec.Metrics.Enabled
Expand Down Expand Up @@ -512,8 +519,7 @@ func (n *NIMService) GetIngressParams() *rendertypes.IngressParams {
params.Namespace = n.GetNamespace()
params.Labels = n.GetServiceLabels()
params.Annotations = n.GetServiceAnnotations()

// TODO: set ingress rules
params.Spec = n.GetIngressSpec()
return params
}

Expand Down
34 changes: 10 additions & 24 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4379241

Please sign in to comment.