diff --git a/apiserver/pkg/util/cluster.go b/apiserver/pkg/util/cluster.go index 2b08c0cca1..7db60207d7 100644 --- a/apiserver/pkg/util/cluster.go +++ b/apiserver/pkg/util/cluster.go @@ -141,6 +141,10 @@ func buildHeadPodTemplate(cluster *api.Cluster, spec *api.HeadGroupSpec, compute Name: "dashboard", ContainerPort: 8265, }, + { + Name: "metrics", + ContainerPort: 8080, + }, }, Resources: v1.ResourceRequirements{ Limits: v1.ResourceList{ diff --git a/ray-operator/controllers/ray/common/pod.go b/ray-operator/controllers/ray/common/pod.go index ac5773c287..ba36658bd3 100644 --- a/ray-operator/controllers/ray/common/pod.go +++ b/ray-operator/controllers/ray/common/pod.go @@ -66,7 +66,18 @@ func DefaultHeadPodTemplate(instance rayiov1alpha1.RayCluster, headSpec rayiov1a Name: "metrics", ContainerPort: int32(DefaultMetricsPort), } - podTemplate.Spec.Containers[0].Ports = append(podTemplate.Spec.Containers[0].Ports, metricsPort) + dupIndex := -1 + for i, port := range podTemplate.Spec.Containers[0].Ports { + if port.Name == metricsPort.Name { + dupIndex = i + break + } + } + if dupIndex < 0 { + podTemplate.Spec.Containers[0].Ports = append(podTemplate.Spec.Containers[0].Ports, metricsPort) + } else { + podTemplate.Spec.Containers[0].Ports[dupIndex] = metricsPort + } return podTemplate }