Skip to content

Commit

Permalink
Merge pull request #1525 from grafana/feat/immutable-instance-selectors
Browse files Browse the repository at this point in the history
feat(controllers): make instanceSelector immutable
  • Loading branch information
theSuess authored May 13, 2024
2 parents d8cd864 + 13fdaaf commit 27144ee
Show file tree
Hide file tree
Showing 30 changed files with 100 additions and 10 deletions.
1 change: 1 addition & 0 deletions api/v1beta1/grafanaalertrulegroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type GrafanaAlertRuleGroupSpec struct {
ResyncPeriod metav1.Duration `json:"resyncPeriod,omitempty"`

// selects Grafanas for import
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
InstanceSelector *metav1.LabelSelector `json:"instanceSelector"`

// UID of the folder containing this rule group
Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/grafanacontactpoint_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type GrafanaContactPointSpec struct {
ResyncPeriod metav1.Duration `json:"resyncPeriod,omitempty"`

// selects Grafanas for import
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
InstanceSelector *metav1.LabelSelector `json:"instanceSelector"`

// +optional
Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/grafanadashboard_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ type GrafanaDashboardSpec struct {
ConfigMapRef *v1.ConfigMapKeySelector `json:"configMapRef,omitempty"`

// selects Grafanas for import
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
InstanceSelector *metav1.LabelSelector `json:"instanceSelector"`

// folder assignment for dashboard
Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/grafanadatasource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type GrafanaDatasourceSpec struct {
Datasource *GrafanaDatasourceInternal `json:"datasource"`

// selects Grafana instances for import
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
InstanceSelector *metav1.LabelSelector `json:"instanceSelector"`

// plugins
Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/grafanafolder_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type GrafanaFolderSpec struct {
Permissions string `json:"permissions,omitempty"`

// selects Grafanas for import
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
InstanceSelector *metav1.LabelSelector `json:"instanceSelector"`

// allow to import this resources from an operator in a different namespace
Expand Down
10 changes: 5 additions & 5 deletions bundle/manifests/grafana-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ metadata:
capabilities: Basic Install
categories: Monitoring
containerImage: ghcr.io/grafana/grafana-operator@sha256:97561cef949b58f55ec67d133c02ac205e2ec3fb77388aeb868dacfcebad0752
createdAt: "2024-04-23T12:57:39Z"
createdAt: "2024-05-09T08:55:59Z"
description: Deploys and manages Grafana instances, dashboards and data sources
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/grafana/grafana-operator
support: Grafana Labs
name: grafana-operator.v5.8.1
name: grafana-operator.v5.9.0
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -510,7 +510,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.annotations['olm.targetNamespaces']
image: ghcr.io/grafana/grafana-operator@sha256:34229f59e1609764196870aa2672aa1b784e88583ec445ff04e810a8333b72a7
image: ghcr.io/grafana/grafana-operator@sha256:48cbc5e4e361e80f27d054fb986762109c199678b12f8b1baf63cfbafc69fc82
imagePullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -604,7 +604,7 @@ spec:
relatedImages:
- image: docker.io/grafana/grafana@sha256:9a2acaa26a0b302a56d8e113068a1297cf0726fcaff5e6bb77344888e5f1c976
name: grafana
- image: ghcr.io/grafana/grafana-operator@sha256:34229f59e1609764196870aa2672aa1b784e88583ec445ff04e810a8333b72a7
- image: ghcr.io/grafana/grafana-operator@sha256:48cbc5e4e361e80f27d054fb986762109c199678b12f8b1baf63cfbafc69fc82
name: manager
- image: ghcr.io/grafana/grafana-operator@sha256:97561cef949b58f55ec67d133c02ac205e2ec3fb77388aeb868dacfcebad0752
name: grafana-operator-97561cef949b58f55ec67d133c02ac205e2ec3fb77388aeb868dacfcebad0752-annotation
Expand All @@ -615,4 +615,4 @@ spec:
- grafana-operator.v5.6.3
- grafana-operator.v5.7.0
- grafana-operator.v5.8.0
version: 5.8.1
version: 5.9.0
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
interval:
format: duration
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
name:
type: string
resyncPeriod:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
json:
type: string
jsonnet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
plugins:
items:
properties:
Expand Down
3 changes: 3 additions & 0 deletions bundle/manifests/grafana.integreatly.org_grafanafolders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
permissions:
type: string
resyncPeriod:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
interval:
format: duration
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
name:
type: string
resyncPeriod:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
json:
type: string
jsonnet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
plugins:
items:
properties:
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/grafana.integreatly.org_grafanafolders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
permissions:
type: string
resyncPeriod:
Expand Down
3 changes: 3 additions & 0 deletions config/grafana.integreatly.org_grafanaalertrulegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
interval:
format: duration
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
Expand Down
3 changes: 3 additions & 0 deletions config/grafana.integreatly.org_grafanacontactpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
name:
type: string
resyncPeriod:
Expand Down
3 changes: 3 additions & 0 deletions config/grafana.integreatly.org_grafanadashboards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
json:
description: dashboard json
type: string
Expand Down
3 changes: 3 additions & 0 deletions config/grafana.integreatly.org_grafanadatasources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
plugins:
description: plugins
items:
Expand Down
3 changes: 3 additions & 0 deletions config/grafana.integreatly.org_grafanafolders.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
permissions:
description: raw json with folder permissions
type: string
Expand Down
4 changes: 2 additions & 2 deletions deploy/helm/grafana-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.3
version: 0.1.4

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v5.8.1"
appVersion: "v5.9.0"
6 changes: 3 additions & 3 deletions deploy/helm/grafana-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ linkTitle: "Helm installation"

[grafana-operator](https://github.com/grafana/grafana-operator) for Kubernetes to manage Grafana instances and grafana resources.

![Version: 0.1.3](https://img.shields.io/badge/Version-0.1.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v5.8.1](https://img.shields.io/badge/AppVersion-v5.8.1-informational?style=flat-square)
![Version: 0.1.4](https://img.shields.io/badge/Version-0.1.4-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v5.9.0](https://img.shields.io/badge/AppVersion-v5.9.0-informational?style=flat-square)

## Installation

This is a OCI helm chart, helm started support OCI in version 3.8.0.

```shell
helm upgrade -i grafana-operator oci://ghcr.io/grafana/helm-charts/grafana-operator --version v5.8.1
helm upgrade -i grafana-operator oci://ghcr.io/grafana/helm-charts/grafana-operator --version v5.9.0
```

Sadly helm OCI charts currently don't support searching for available versions of a helm [oci registry](https://github.com/helm/helm/issues/11000).
Expand All @@ -25,7 +25,7 @@ Helm does not provide functionality to update custom resource definitions. This
To avoid issues due to outdated or missing definitions, run the following command before updating an existing installation:

```shell
kubectl apply --server-side --force-conflicts -f https://github.com/grafana/grafana-operator/releases/download/v5.8.1/crds.yaml
kubectl apply --server-side --force-conflicts -f https://github.com/grafana/grafana-operator/releases/download/v5.9.0/crds.yaml
```

The `--server-side` and `--force-conflict` flags are required to avoid running into issues with the `kubectl.kubernetes.io/last-applied-configuration` annotation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
interval:
format: duration
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
name:
type: string
resyncPeriod:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
json:
type: string
jsonnet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
plugins:
items:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
permissions:
type: string
resyncPeriod:
Expand Down
15 changes: 15 additions & 0 deletions deploy/kustomize/base/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
interval:
format: duration
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
Expand Down Expand Up @@ -246,6 +249,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
name:
type: string
resyncPeriod:
Expand Down Expand Up @@ -499,6 +505,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
json:
type: string
jsonnet:
Expand Down Expand Up @@ -664,6 +673,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
plugins:
items:
properties:
Expand Down Expand Up @@ -802,6 +814,9 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
x-kubernetes-validations:
- message: Value is immutable
rule: self == oldSelf
permissions:
type: string
resyncPeriod:
Expand Down
Loading

0 comments on commit 27144ee

Please sign in to comment.