grafana/pkg/cmd/grafana-example-apiserver
2023-11-08 10:57:32 -08:00
..
deploy Grafana App Platform: provide an example-apiserver to easily deploy aggregated APIservers (#77826) 2023-11-07 22:35:15 -08:00
main.go Grafana app platform: drop etcd requirement in example-apiserver (#77886) 2023-11-08 10:57:32 -08:00
README.md Grafana app platform: drop etcd requirement in example-apiserver (#77886) 2023-11-08 10:57:32 -08:00
server.go Grafana app platform: drop etcd requirement in example-apiserver (#77886) 2023-11-08 10:57:32 -08:00

grafana-example-apiserver

The example-apiserver closely resembles the sample-apiserver project in code and thus allows the same CLI flags as kube-apiserver. It is currently used for testing our deployment pipelines for aggregated servers.

Prerequisites:

  1. kind: you will need kind (or another local K8s setup) if you want to test aggregation.
go install sigs.k8s.io/kind@v0.20.0 && kind create cluster

Usage

You can start the example-apiserver with an invocation as shown below. The Authn / Authz flags are set up so that the kind cluster can be used as a root server for this example-apiserver (in aggregated mode). Here, it's assumed that you have a local kind cluster and that you can provide its kubeconfig in the parameters to the example-apiserver.

go run ./pkg/cmd/grafana-example-apiserver \
  --authentication-kubeconfig ~/.kube/config \
  --authorization-kubeconfig ~/.kube/config \
  --kubeconfig ~/.kube/config \
  --secure-port 8443

Once, the example-apiserver is running, you can configure aggregation against your kind cluster by applying a APIService and it's corresponding Service object. Sample kustomizations are provided for local development on Linux and macOS.

kubectl deploy -k ./deploy/darwin # or /linux

Verify that all works

With kubectl configured against kind-kind context, you can run the following:

kubectl get --raw /apis/example.grafana.app/v0alpha1 | jq -r
{
  "kind": "APIResourceList",
  "apiVersion": "v1",
  "groupVersion": "example.grafana.app/v0alpha1",
  "resources": [
    {
      "name": "runtime",
      "singularName": "runtime",
      "namespaced": false,
      "kind": "RuntimeInfo",
      "verbs": [
        "list"
      ]
    }
  ]
}
kubectl get apiservice v0alpha1.example.grafana.app
NAME                           SERVICE                     AVAILABLE   AGE
v0alpha1.example.grafana.app   grafana/example-apiserver   True        4h1m