diff --git a/controllers/model/grafanaService.go b/controllers/model/grafanaService.go index 8bedf305c..c7e1ac7ac 100644 --- a/controllers/model/grafanaService.go +++ b/controllers/model/grafanaService.go @@ -70,9 +70,11 @@ 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 + if cr.Spec.Service != nil { + for _, nPort := range cr.Spec.Service.Ports { + if nPort.Port == 3000 { + nodePort = nPort.NodePort + } } } defaultPorts := []v1.ServicePort{