K8s: Implement partial folders api with k8s client (#93089)

* Add kubernetes folder feature toggle
* Add kubernetes routes for getting and creating a folder
* Add documentation for interacting with k8s folders
This commit is contained in:
Arati R.
2024-09-10 11:22:08 +02:00
committed by GitHub
parent 442bb1d35f
commit b12a29a1da
10 changed files with 219 additions and 18 deletions
+55 -1
View File
@@ -13,7 +13,7 @@ There are 2 main tables, the `resource` table stores a "current" view of the obj
## Running Unified Storage
### Baseline configuration
### Playlists: baseline configuration
The minimum config settings required are:
@@ -34,6 +34,32 @@ kubernetesPlaylists = true
storage_type = unified
```
### Folders: baseline configuration
NOTE: allowing folders to be backed by Unified Storage is under development and so are these instructions.
The minimum config settings required are:
```ini
; need to specify target here for override to work later
target = all
[server]
; https is required for kubectl
protocol = https
[feature_toggles]
; store folders in k8s
kubernetesFolders = true
grafanaAPIServerWithExperimentalAPIs = true
[grafana-apiserver]
; use unified storage for k8s apiserver
storage_type = unified
```
### Setting up a kubeconfig
With this configuration, you can run everything in-process. Run the Grafana backend with:
```sh
@@ -75,6 +101,8 @@ Where `<username>` and `<password>` are credentials for basic auth against Grafa
password: admin
```
### Playlists: interacting with the k8s API
In this mode, you can interact with the k8s api. Make sure you are in the directory where you created `grafana.kubeconfig`. Then run:
```sh
kubectl --kubeconfig=./grafana.kubeconfig get playlist
@@ -132,6 +160,32 @@ kubectl --kubeconfig=./grafana.kubeconfig patch playlist <NAME> --patch-file pla
In the example, `<NAME>` would be `u394j4d3-s63j-2d74-g8hf-958773jtybf2`.
### Folders: interacting with the k8s API
Make sure you are in the directory where you created `grafana.kubeconfig`. Then run:
```sh
kubectl --kubeconfig=./grafana.kubeconfig get folder
```
If this is your first time running the command, a successful response would be:
```sh
No resources found in default namespace.
```
To create a folder, create a file `folder-generate.yaml`:
```yaml
apiVersion: folder.grafana.app/v0alpha1
kind: Folder
metadata:
generateName: x # anything is ok here... except yes or true -- they become boolean!
spec:
title: Example folder
```
then run:
```sh
kubectl --kubeconfig=./grafana.kubeconfig create -f folder-generate.yaml
```
### Use a separate database
By default Unified Storage uses the Grafana database. To run against a separate database, update `custom.ini` by adding the following section to it: