Skip to content

Commit

Permalink
Update grafanaService.go (#735)
Browse files Browse the repository at this point in the history
* Update grafanaService.go

fix: the nodeport setting does not take effect #730
  • Loading branch information
gxg001 committed May 6, 2022
1 parent 03acb04 commit bc9d62a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion controllers/model/grafanaService.go
Expand Up @@ -69,13 +69,19 @@ func GetGrafanaPort(cr *v1alpha1.Grafana) int {

func getServicePorts(cr *v1alpha1.Grafana, currentState *v1.Service) []v1.ServicePort {
intPort := int32(GetGrafanaPort(cr))

nodePort := int32(0)
for _, nPort := range cr.Spec.Service.Ports {
if nPort.Port == 3000 {
nodePort = nPort.NodePort
}
}
defaultPorts := []v1.ServicePort{
{
Name: constants.GrafanaHttpPortName,
Protocol: "TCP",
Port: intPort,
TargetPort: intstr.FromString("grafana-http"),
NodePort: nodePort,
},
}

Expand Down

0 comments on commit bc9d62a

Please sign in to comment.