Skip to content

Commit

Permalink
Merge pull request #699 from Moulick/add-deployment-annotations
Browse files Browse the repository at this point in the history
correct spec.deployment.annotations
  • Loading branch information
pb82 committed Mar 22, 2022
2 parents 219fa25 + 0c12504 commit aa20ca0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -208,4 +208,4 @@ catalog-build: opm

.PHONY: catalog-push
catalog-push: ## Push the catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)
$(MAKE) docker-push IMG=$(CATALOG_IMG)
27 changes: 21 additions & 6 deletions controllers/model/grafanaDeployment.go
Expand Up @@ -3,15 +3,16 @@ package model
import (
"fmt"

"github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1"
"github.com/grafana-operator/grafana-operator/v4/controllers/config"
"github.com/grafana-operator/grafana-operator/v4/controllers/constants"
v1 "k8s.io/api/apps/v1"
v13 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
v12 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/grafana-operator/grafana-operator/v4/api/integreatly/v1alpha1"
"github.com/grafana-operator/grafana-operator/v4/controllers/config"
"github.com/grafana-operator/grafana-operator/v4/controllers/constants"
)

const (
Expand Down Expand Up @@ -124,6 +125,19 @@ func getDeploymentLabels(cr *v1alpha1.Grafana) map[string]string {
return labels
}

func getDeploymentAnnotations(cr *v1alpha1.Grafana, existing map[string]string) map[string]string {
var annotations = map[string]string{}
// Add fixed annotations
annotations["prometheus.io/scrape"] = "true"
annotations["prometheus.io/port"] = fmt.Sprintf("%v", GetGrafanaPort(cr))
annotations = MergeAnnotations(annotations, existing)

if cr.Spec.Deployment != nil {
annotations = MergeAnnotations(cr.Spec.Deployment.Annotations, annotations)
}
return annotations
}

func getRollingUpdateStrategy() *v1.RollingUpdateDeployment {
var maxUnaval intstr.IntOrString = intstr.FromInt(25)
var maxSurge intstr.IntOrString = intstr.FromInt(25)
Expand Down Expand Up @@ -720,9 +734,10 @@ func getDeploymentSpec(cr *v1alpha1.Grafana, annotations map[string]string, conf
func GrafanaDeployment(cr *v1alpha1.Grafana, configHash, dsHash string) *v1.Deployment {
return &v1.Deployment{
ObjectMeta: v12.ObjectMeta{
Name: constants.GrafanaDeploymentName,
Namespace: cr.Namespace,
Labels: getDeploymentLabels(cr),
Name: constants.GrafanaDeploymentName,
Namespace: cr.Namespace,
Labels: getDeploymentLabels(cr),
Annotations: getDeploymentAnnotations(cr, nil),
},
Spec: getDeploymentSpec(cr, nil, configHash, "", dsHash),
}
Expand Down

0 comments on commit aa20ca0

Please sign in to comment.