Skip to content

Commit

Permalink
node bootstrap api (#451)
Browse files Browse the repository at this point in the history
This PR adds the /api/v1/cluster/:name/bootstrap endpoint to get configuration to manually onboard a node (Kubelet).
In the process this PR also introduces a kluster informer to that apiserver and all GET api calls are fulfilled from the local cache instead of forwarding the request to the control plane api.
  • Loading branch information
databus23 committed Aug 16, 2019
1 parent 56e8f92 commit 9c4a699
Show file tree
Hide file tree
Showing 34 changed files with 2,263 additions and 43 deletions.
22 changes: 14 additions & 8 deletions cmd/apiserver/main.go
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/spf13/pflag"
"k8s.io/client-go/tools/cache"

apipkg "github.com/sapcc/kubernikus/pkg/api"
"github.com/sapcc/kubernikus/pkg/api/rest"
Expand Down Expand Up @@ -59,10 +60,14 @@ func main() {

api := operations.NewKubernikusAPI(swaggerSpec)

rt := &apipkg.Runtime{
Namespace: namespace,
Logger: logger,
kubernikusClient, k8sclient, err := rest.NewKubeClients(logger)
if err != nil {
logger.Log(
"msg", "failed to create kubernetes clients",
"err", err)
os.Exit(1)
}
rt := apipkg.NewRuntime(namespace, kubernikusClient, k8sclient, logger)
if imagesFile != "" {
if rt.Images, err = version.NewImageRegistry(imagesFile); err != nil {
logger.Log(
Expand All @@ -73,11 +78,11 @@ func main() {
os.Exit(1)
}
}
rt.Kubernikus, rt.Kubernetes, err = rest.NewKubeClients(logger)
if err != nil {
logger.Log(
"msg", "failed to create kubernetes clients",
"err", err)

stopInformer := make(chan struct{})
go rt.Informer.Run(stopInformer)
if !cache.WaitForCacheSync(nil, rt.Informer.HasSynced) {
logger.Log("err", "Cache not synced")
os.Exit(1)
}

Expand Down Expand Up @@ -108,6 +113,7 @@ func main() {
go http.Serve(metricsListener, promhttp.Handler())
api.ServerShutdown = func() {
metricsListener.Close()
close(stopInformer)
}
}

Expand Down
1 change: 1 addition & 0 deletions etc/policy-ccadmin.json
Expand Up @@ -12,5 +12,6 @@
"GetClusterCredentials": "rule:kubernetes_user",
"GetClusterEvents": "rule:kubernetes_user",
"GetClusterInfo": "rule:kubernetes_user",
"GetBootstrapConfig": "rule:kubernetes_admin",
"GetClusterValues": "rule:kubernetes_cloud_admin"
}
1 change: 1 addition & 0 deletions etc/policy.json
Expand Up @@ -12,5 +12,6 @@
"GetClusterCredentials": "rule:kubernetes_user",
"GetClusterEvents": "rule:kubernetes_user",
"GetClusterInfo": "rule:kubernetes_user",
"GetBootstrapConfig": "rule:kubernetes_admin",
"GetClusterValues": "rule:kubernetes_cloud_admin"
}
7 changes: 6 additions & 1 deletion glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

133 changes: 133 additions & 0 deletions pkg/api/client/operations/get_boostrap_config_parameters.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 112 additions & 0 deletions pkg/api/client/operations/get_boostrap_config_responses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c4a699

Please sign in to comment.