Skip to content

Commit

Permalink
Enable org creation (#132)
Browse files Browse the repository at this point in the history
* add org CRD in helm chart

* layout foundations for CRD with kubebuilder

* remove useless files

* update CRD names

* add generated crd

* applying suggestions

* fix naming issues

* update Dockerfile with copy command for the api package

* update changelog

* add symlink to crd in helm chart and updated crd

* fix symlink

* fix symlink

* Update main.go

Co-authored-by: Quentin Bisson <[email protected]>

* add symlink back

* add finalizer

* Apply suggestions from code review

Co-authored-by: Théo Brigitte <[email protected]>

* regenerate crd

* update sample

* add logic to grafana organization reconciler

* fix build

* Split grafana client creation in its own folder

* add exclusions to golangci

* add crds template in chart

* Apply suggestions from code review

Co-authored-by: Quentin Bisson <[email protected]>

* update const names in files

* Update pkg/grafana/client/client.go

Co-authored-by: Quentin Bisson <[email protected]>

* fix const name in client

* rework getAdminCredentials function

* remove unused variable in client

* fix missing return statement error

* add authorizations for grafanaorganizations in operator rbac

* Apply suggestions from code review

Co-authored-by: Quentin Bisson <[email protected]>

* fix merging errors

* rename main org

* sort imports

* Enable grafanaOrganization creation

* first draft for org creation

* refactor code

* Apply suggestions from code review

Co-authored-by: Quentin Bisson <[email protected]>

* make orgID and dataSource ID int

* try out dirty trick

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Jose Armesto <[email protected]>

* update error handling

* Apply suggestions from code review

Co-authored-by: Théo Brigitte <[email protected]>

* fix errors in code

* remove connection to Grafana check

* enhance error handling

* rename variables

* add back deleted code

* changelog

* update crd sample

* add debug logs to solve current issue

* fix grafana admin secret name for admin-user

* remove debug logs

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Quentin Bisson <[email protected]>

* Apply suggestions from code review

Co-authored-by: Quentin Bisson <[email protected]>

* fix name error

* refacto code

* refactor code

* refactor code for better readability

* fix grafana isNotFound error handling

* add organization type

* remove one level of indentation

* improve status update handling

* add and fix comments

* remove unecessary type casting

* refacto and add todos to make the code cleaner

* add initial org mapping (#133)

* add org CRD in helm chart

* layout foundations for CRD with kubebuilder

* remove useless files

* update CRD names

* add generated crd

* applying suggestions

* fix naming issues

* update Dockerfile with copy command for the api package

* update changelog

* add symlink to crd in helm chart and updated crd

* fix symlink

* fix symlink

* Update main.go

Co-authored-by: Quentin Bisson <[email protected]>

* add symlink back

* add finalizer

* Apply suggestions from code review

Co-authored-by: Théo Brigitte <[email protected]>

* regenerate crd

* update sample

* add logic to grafana organization reconciler

* fix build

* Split grafana client creation in its own folder

* add exclusions to golangci

* add crds template in chart

* Apply suggestions from code review

Co-authored-by: Quentin Bisson <[email protected]>

* update const names in files

* Update pkg/grafana/client/client.go

Co-authored-by: Quentin Bisson <[email protected]>

* fix const name in client

* rework getAdminCredentials function

* remove unused variable in client

* fix missing return statement error

* add authorizations for grafanaorganizations in operator rbac

* Apply suggestions from code review

Co-authored-by: Quentin Bisson <[email protected]>

* fix merging errors

* rename main org

* sort imports

* add initial org mapping

* move crds to helm official repo to respect installation order

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Théo Brigitte <[email protected]>

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Théo Brigitte <[email protected]>

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Théo Brigitte <[email protected]>

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Quentin Bisson <[email protected]>

* Set alloy wal truncate_frequency to 15m (#130)

* try truncate frequency

* Add flag to be able to set truncate_frequency

* set default monitoring agent to alloy (#134)

* Release v0.8.0 (#135)

* fix flag redefined error (#136)

* Release v0.8.1 (#137)

* add logic to grafana organization reconciler (#129)

* add org CRD in helm chart

* layout foundations for CRD with kubebuilder

* remove useless files

* update CRD names

* add generated crd

* applying suggestions

* fix naming issues

* update Dockerfile with copy command for the api package

* update changelog

* add symlink to crd in helm chart and updated crd

* fix symlink

* fix symlink

* Update main.go

Co-authored-by: Quentin Bisson <[email protected]>

* add symlink back

* add finalizer

* Apply suggestions from code review

Co-authored-by: Théo Brigitte <[email protected]>

* regenerate crd

* update sample

* add logic to grafana organization reconciler

* fix build

* Split grafana client creation in its own folder

* add exclusions to golangci

* add crds template in chart

* Apply suggestions from code review

Co-authored-by: Quentin Bisson <[email protected]>

* update const names in files

* Update pkg/grafana/client/client.go

Co-authored-by: Quentin Bisson <[email protected]>

* fix const name in client

* rework getAdminCredentials function

* remove unused variable in client

* fix missing return statement error

* add authorizations for grafanaorganizations in operator rbac

* Apply suggestions from code review

Co-authored-by: Quentin Bisson <[email protected]>

* fix merging errors

* rename main org

* sort imports

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Jose Armesto <[email protected]>

* Apply suggestions from code review

Co-authored-by: Théo Brigitte <[email protected]>

* fix errors in code

* address reviews

* address reviews

---------

Co-authored-by: QuentinBisson <[email protected]>
Co-authored-by: Théo Brigitte <[email protected]>
Co-authored-by: Jose Armesto <[email protected]>

* Update github.com/grafana/grafana-openapi-client-go digest to 9d96c20 (#138)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update module github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring to v0.77.2 (#139)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update internal/controller/grafanaorganization_controller.go

---------

Co-authored-by: QuantumEnigmaa <[email protected]>
Co-authored-by: Zirko <[email protected]>
Co-authored-by: Théo Brigitte <[email protected]>
Co-authored-by: Taylor Bot <[email protected]>
Co-authored-by: Jose Armesto <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* fix grafana admin password in deployment

* fix grafana admin password in deployment

* Update CHANGELOG.md

* fix go build

* add deletion

* move grafana templating to another pkg

* make datasources field in the CR optional

* add watches over the grafana pod

* add rule for watching & listing pods in clusterrole

* reduce scope of grafana pod watch

* disable configureGrafana function for testing

* fix grafana pod reconciliation

* add configureGrafana back

* fix watch

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Hervé Nicol <[email protected]>

* fix comment

* fix comment

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Théo Brigitte <[email protected]>

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Théo Brigitte <[email protected]>

* Update pkg/grafana/grafana.go

Co-authored-by: Théo Brigitte <[email protected]>

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Théo Brigitte <[email protected]>

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Théo Brigitte <[email protected]>

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Théo Brigitte <[email protected]>

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Théo Brigitte <[email protected]>

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Théo Brigitte <[email protected]>

* Update internal/controller/grafanaorganization_controller.go

* Update internal/controller/grafanaorganization_controller.go

Co-authored-by: Théo Brigitte <[email protected]>

* address-reviews

---------

Co-authored-by: QuentinBisson <[email protected]>
Co-authored-by: Théo Brigitte <[email protected]>
Co-authored-by: Jose Armesto <[email protected]>
Co-authored-by: Taylor Bot <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Hervé Nicol <[email protected]>
  • Loading branch information
7 people authored Nov 5, 2024
1 parent 1687306 commit d2774a3
Show file tree
Hide file tree
Showing 12 changed files with 455 additions and 67 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add Grafana Organization creation logic in reconciler.
- Add creation and update of Grafana organizations.
- Add configuration of the Grafana org_mapping via user-values.

### Fixed

- Disable crd installation from alloy-metrics as this is causing issues with the new v29 releases.
Expand All @@ -24,7 +30,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Add wal `truncate_frequency` configuration to alloy-metrics with a default set to 15m.
- Add grafanaOrganization CRD in helm chart.
- Add logic to grafanaOrganization reconciler.

### Changed

Expand Down
5 changes: 3 additions & 2 deletions api/v1alpha1/grafanaorganization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ type RBAC struct {
// GrafanaOrganizationStatus defines the observed state of GrafanaOrganization
type GrafanaOrganizationStatus struct {
// OrgID is the actual organisation ID in grafana.
OrgID string `json:"orgID"`
OrgID int64 `json:"orgID"`

// DataSources is a list of grafana data sources that are available to the Grafana organization.
// +optional
DataSources []DataSources `json:"dataSources"`
}

Expand All @@ -74,7 +75,7 @@ type DataSources struct {
Name string `json:"name"`

// ID is the unique id of the data source.
ID string `json:"id"`
ID int64 `json:"id"`
}

//+kubebuilder:object:root=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.16.4
controller-gen.kubebuilder.io/version: v0.16.3
name: grafanaorganizations.observability.giantswarm.io
spec:
group: observability.giantswarm.io
Expand Down Expand Up @@ -83,7 +83,8 @@ spec:
properties:
id:
description: ID is the unique id of the data source.
type: string
format: int64
type: integer
name:
description: Name is the name of the data source.
type: string
Expand All @@ -94,9 +95,9 @@ spec:
type: array
orgID:
description: OrgID is the actual organisation ID in grafana.
type: string
format: int64
type: integer
required:
- dataSources
- orgID
type: object
type: object
Expand Down
31 changes: 2 additions & 29 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,10 @@ spec:
labels:
control-plane: controller-manager
spec:
# TODO(user): Uncomment the following code to configure the nodeAffinity expression
# according to the platforms which are supported by your solution.
# It is considered best practice to support multiple architectures. You can
# build your manager image using the makefile target docker-buildx.
# affinity:
# nodeAffinity:
# requiredDuringSchedulingIgnoredDuringExecution:
# nodeSelectorTerms:
# - matchExpressions:
# - key: kubernetes.io/arch
# operator: In
# values:
# - amd64
# - arm64
# - ppc64le
# - s390x
# - key: kubernetes.io/os
# operator: In
# values:
# - linux
securityContext:
runAsNonRoot: true
# TODO(user): For common cases that do not require escalating privileges
# it is recommended to ensure that all your Pods/Containers are restrictive.
# More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted
# Please uncomment the following code if your project does NOT have to work on old Kubernetes
# versions < 1.19 or on vendors versions which do NOT support this field by default (i.e. Openshift < 4.11 ).
# seccompProfile:
# type: RuntimeDefault
seccompProfile:
type: RuntimeDefault
containers:
- command:
- /manager
Expand All @@ -89,8 +64,6 @@ spec:
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
# TODO(user): Configure the resources accordingly based on the project requirements.
# More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
resources:
limits:
cpu: 500m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ spec:
- my-awesome-viewers
- other-viewers
status:
orgID: "2"
orgID: 2
dataSources:
- name: "mimir"
id: "1"
id: 1
- name: "loki"
id: "2"
id: 2
1 change: 1 addition & 0 deletions helm/observability-operator/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ rules:
- ""
resources:
- namespaces
- pods
verbs:
- list
- watch
Expand Down
Loading

0 comments on commit d2774a3

Please sign in to comment.