Grafana app platform: drop etcd requirement in example-apiserver (#77886)

This commit is contained in:
Charandas 2023-11-08 10:57:32 -08:00 committed by GitHub
parent 4159f47df0
commit 28e58c1725
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 19 deletions

View File

@ -7,7 +7,7 @@ WIRE_TAGS = "oss"
-include local/Makefile -include local/Makefile
include .bingo/Variables.mk include .bingo/Variables.mk
.PHONY: all deps-go deps-js deps build-go build-backend build-server build-cli build-js build build-docker-full build-docker-full-ubuntu lint-go golangci-lint test-go test-js gen-ts test run run-frontend clean devenv devenv-down protobuf drone help gen-go gen-cue fix-cue .PHONY: all deps-go deps-js deps build-go build-backend build-example-apiserver build-server build-cli build-js build build-docker-full build-docker-full-ubuntu lint-go golangci-lint test-go test-js gen-ts test run run-frontend clean devenv devenv-down protobuf drone help gen-go gen-cue fix-cue
GO = go GO = go
GO_FILES ?= ./pkg/... GO_FILES ?= ./pkg/...

View File

@ -3,34 +3,23 @@
The example-apiserver closely resembles the The example-apiserver closely resembles the
[sample-apiserver](https://github.com/kubernetes/sample-apiserver/tree/master) project in code and thus [sample-apiserver](https://github.com/kubernetes/sample-apiserver/tree/master) project in code and thus
allows the same allows the same
[CLI flags](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/) as kube-apiserver [CLI flags](https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/) as kube-apiserver.
It is currently used for testing our deployment pipelines for aggregated servers. It is currently used for testing our deployment pipelines for aggregated servers.
## Prerequisites: ## Prerequisites:
1. etcd 1. kind: you will need kind (or another local K8s setup) if you want to test aggregation.
```shell
brew install etcd
```
2. 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 go install sigs.k8s.io/kind@v0.20.0 && kind create cluster
``` ```
## Usage ## Usage
Have `etcd` running in your environment: You can start the example-apiserver with an invocation as shown below. The Authn / Authz flags are set up so that the kind cluster
```shell
etcd &
```
With etcd running, you can now start the example-apiserver. 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 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. kind cluster and that you can provide its kubeconfig in the parameters to the example-apiserver.
```shell ```shell
go run ./pkg/cmd/grafana-example-apiserver \ go run ./pkg/cmd/grafana-example-apiserver \
--etcd-servers=http://127.0.0.1:2379 \
--authentication-kubeconfig ~/.kube/config \ --authentication-kubeconfig ~/.kube/config \
--authorization-kubeconfig ~/.kube/config \ --authorization-kubeconfig ~/.kube/config \
--kubeconfig ~/.kube/config \ --kubeconfig ~/.kube/config \

View File

@ -18,10 +18,6 @@ func NewCommandStartExampleAPIServer(defaults *ExampleServerOptions, stopCh <-ch
return err return err
} }
if err := o.Validate(args); err != nil {
return err
}
config, err := o.Config() config, err := o.Config()
if err != nil { if err != nil {
return err return err

View File

@ -80,6 +80,7 @@ func (o ExampleServerOptions) Config() (*genericapiserver.RecommendedConfig, err
o.RecommendedOptions.Admission = nil o.RecommendedOptions.Admission = nil
o.RecommendedOptions.CoreAPI = nil o.RecommendedOptions.CoreAPI = nil
o.RecommendedOptions.Etcd = nil
serverConfig := genericapiserver.NewRecommendedConfig(Codecs) serverConfig := genericapiserver.NewRecommendedConfig(Codecs)
@ -91,6 +92,8 @@ func (o ExampleServerOptions) Config() (*genericapiserver.RecommendedConfig, err
} }
// Validate validates ExampleServerOptions // Validate validates ExampleServerOptions
// NOTE: we don't call validate on the top level recommended options as it doesn't like skipping etcd-servers
// the function is left here for troubleshooting any other config issues
func (o ExampleServerOptions) Validate(args []string) error { func (o ExampleServerOptions) Validate(args []string) error {
errors := []error{} errors := []error{}
errors = append(errors, o.RecommendedOptions.Validate()...) errors = append(errors, o.RecommendedOptions.Validate()...)