Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions api/nvidia/v1/clusterpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,21 @@ type DCGMExporterServiceConfig struct {
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text"
Type corev1.ServiceType `json:"type,omitempty"`

// NodePort allows setting a custom port number for the NodePort service.
// Must be within the range configured in the Kubernetes API server (usually 30000-32767).
// +kubebuilder:validation:Minimum=30000
// +kubebuilder:validation:Maximum=32767
// +optional
NodePort *int32 `json:"nodePort,omitempty"`

// ExternalTrafficPolicy controls how external traffic is handled by the Kubernetes service.
// Acceptable values are "Cluster" and "Local". This setting only applies when service type is NodePort or LoadBalancer.
// +kubebuilder:validation:Enum=Cluster;Local
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="External Traffic Policy"
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:select:Cluster,Local"
ExternalTrafficPolicy *corev1.ServiceExternalTrafficPolicyType `json:"externalTrafficPolicy,omitempty"`

// InternalTrafficPolicy describes how nodes distribute service traffic they receive on the ClusterIP.
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true
// +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Internal Traffic Policy for the DCGM Exporter K8s Service"
Expand Down
10 changes: 10 additions & 0 deletions api/nvidia/v1/zz_generated.deepcopy.go

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

15 changes: 15 additions & 0 deletions bundle/manifests/nvidia.com_clusterpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,25 @@ spec:
description: 'Optional: Service configuration for NVIDIA DCGM
Exporter'
properties:
externalTrafficPolicy:
description: |-
Controls how external traffic is routed to the service.
Valid values are "Cluster" (default) and "Local". Applies to NodePort and LoadBalancer service types only.
enum:
- Cluster
- Local
type: string
internalTrafficPolicy:
description: InternalTrafficPolicy describes how nodes distribute
service traffic they receive on the ClusterIP.
type: string
nodePort:
description: |-
Custom port number to expose for the NodePort service.
Must be between 30000 and 32767.
minimum: 30000
maximum: 32767
type: integer
type:
description: Type represents the ServiceType which describes
ingress methods for a service
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/nvidia.com_clusterpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,25 @@ spec:
description: 'Optional: Service configuration for NVIDIA DCGM
Exporter'
properties:
externalTrafficPolicy:
description: |-
Controls how external traffic is routed to the service.
Valid values are "Cluster" (default) and "Local". Applies to NodePort and LoadBalancer service types only.
enum:
- Cluster
- Local
type: string
internalTrafficPolicy:
description: InternalTrafficPolicy describes how nodes distribute
service traffic they receive on the ClusterIP.
type: string
nodePort:
description: |-
Custom port number to expose for the NodePort service.
Must be between 30000 and 32767.
minimum: 30000
maximum: 32767
type: integer
type:
description: Type represents the ServiceType which describes
ingress methods for a service
Expand Down
8 changes: 8 additions & 0 deletions controllers/object_controls.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,9 +995,17 @@ func TransformDCGMExporterService(obj *corev1.Service, config *gpuv1.ClusterPoli
obj.Spec.Type = serviceConfig.Type
}

if serviceConfig.NodePort != nil && len(obj.Spec.Ports) > 0 {
obj.Spec.Ports[0].NodePort = *serviceConfig.NodePort
}

if serviceConfig.InternalTrafficPolicy != nil {
obj.Spec.InternalTrafficPolicy = serviceConfig.InternalTrafficPolicy
}

if serviceConfig.ExternalTrafficPolicy != nil {
obj.Spec.ExternalTrafficPolicy = *serviceConfig.ExternalTrafficPolicy
}
}
return nil
}
Expand Down
15 changes: 15 additions & 0 deletions deployments/gpu-operator/crds/nvidia.com_clusterpolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,25 @@ spec:
description: 'Optional: Service configuration for NVIDIA DCGM
Exporter'
properties:
externalTrafficPolicy:
description: |-
Controls how external traffic is routed to the service.
Valid values are "Cluster" (default) and "Local". Applies to NodePort and LoadBalancer service types only.
enum:
- Cluster
- Local
type: string
internalTrafficPolicy:
description: InternalTrafficPolicy describes how nodes distribute
service traffic they receive on the ClusterIP.
type: string
nodePort:
description: |-
Custom port number to expose for the NodePort service.
Must be between 30000 and 32767.
minimum: 30000
maximum: 32767
type: integer
type:
description: Type represents the ServiceType which describes
ingress methods for a service
Expand Down
3 changes: 3 additions & 0 deletions deployments/gpu-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ dcgmExporter:
value: "/etc/dcgm-exporter/dcp-metrics-included.csv"
resources: {}
service:
type: ClusterIP
nodePort: null
externalTrafficPolicy: Cluster
internalTrafficPolicy: Cluster
serviceMonitor:
enabled: false
Expand Down