Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36101 from jbeda/bootstrap-signer
Automatic merge from submit-queue (batch tested with PRs 38252, 41122, 36101, 41017, 41264) BootstrapSigner and TokenCleaner controllers This is part of kubernetes/enhancements#130 and is an implementation of kubernetes/community#189. Work that needs to be done yet in this PR: * [ ] ~~e2e tests~~ Will come in new PR. * [x] flag to disable this by default ```release-note Native support for token based bootstrap flow. This includes signing a well known ConfigMap in the `kube-public` namespace and cleaning out expired tokens. ``` @kubernetes/sig-cluster-lifecycle @dgoodwin @roberthbailey @mikedanese
- Loading branch information
Showing
30 changed files
with
1,321 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright 2016 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package app | ||
|
||
import "k8s.io/kubernetes/pkg/controller/bootstrap" | ||
|
||
func startBootstrapSignerController(ctx ControllerContext) (bool, error) { | ||
go bootstrap.NewBootstrapSigner( | ||
ctx.ClientBuilder.ClientGoClientOrDie("bootstrap-signer"), | ||
bootstrap.DefaultBootstrapSignerOptions(), | ||
).Run(ctx.Stop) | ||
return true, nil | ||
} | ||
|
||
func startTokenCleanerController(ctx ControllerContext) (bool, error) { | ||
go bootstrap.NewTokenCleaner( | ||
ctx.ClientBuilder.ClientGoClientOrDie("token-cleaner"), | ||
bootstrap.DefaultTokenCleanerOptions(), | ||
).Run(ctx.Stop) | ||
return true, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
licenses(["notice"]) | ||
|
||
load( | ||
"@io_bazel_rules_go//go:def.bzl", | ||
"go_library", | ||
) | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = [ | ||
"doc.go", | ||
"types.go", | ||
], | ||
tags = ["automanaged"], | ||
deps = ["//vendor:k8s.io/client-go/pkg/api/v1"], | ||
) | ||
|
||
filegroup( | ||
name = "package-srcs", | ||
srcs = glob(["**"]), | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
filegroup( | ||
name = "all-srcs", | ||
srcs = [":package-srcs"], | ||
tags = ["automanaged"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
// Package api (pkg/bootstrap/api) contains constants and types needed for | ||
// bootstrap tokens as maintained by the BootstrapSigner and TokenCleaner | ||
// controllers (in pkg/controller/bootstrap) | ||
package api // import "k8s.io/kubernetes/pkg/bootstrap/api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package api | ||
|
||
import ( | ||
"k8s.io/client-go/pkg/api/v1" | ||
) | ||
|
||
const ( | ||
// SecretTypeBootstrapToken is used during the automated bootstrap process (first | ||
// implemented by kubeadm). It stores tokens that are used to sign well known | ||
// ConfigMaps. They may also eventually be used for authentication. | ||
SecretTypeBootstrapToken v1.SecretType = "bootstrap.kubernetes.io/token" | ||
|
||
// BootstrapTokenIDKey is the id of this token. This can be transmitted in the | ||
// clear and encoded in the name of the secret. It should be a random 6 | ||
// character string. Required | ||
BootstrapTokenIDKey = "token-id" | ||
|
||
// BootstrapTokenSecretKey is the actual secret. Typically this is a random 16 | ||
// character string. Required. | ||
BootstrapTokenSecretKey = "token-secret" | ||
|
||
// BootstrapTokenExpirationKey is when this token should be expired and no | ||
// longer used. A controller will delete this resource after this time. This | ||
// is an absolute UTC time using RFC3339. If this cannot be parsed, the token | ||
// should be considered invalid. Optional. | ||
BootstrapTokenExpirationKey = "expiration" | ||
|
||
// BootstrapTokenUsageSigningKey signals that this token should be used to | ||
// sign configs as part of the bootstrap process. Value must be "true". Any | ||
// other value is assumed to be false. Optional. | ||
BootstrapTokenUsageSigningKey = "usage-bootstrap-signing" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package(default_visibility = ["//visibility:public"]) | ||
|
||
licenses(["notice"]) | ||
|
||
load( | ||
"@io_bazel_rules_go//go:def.bzl", | ||
"go_library", | ||
"go_test", | ||
) | ||
|
||
go_test( | ||
name = "go_default_test", | ||
srcs = [ | ||
"bootstrapsigner_test.go", | ||
"common_test.go", | ||
"jws_test.go", | ||
"tokencleaner_test.go", | ||
"util_test.go", | ||
], | ||
library = ":go_default_library", | ||
tags = ["automanaged"], | ||
deps = [ | ||
"//pkg/bootstrap/api:go_default_library", | ||
"//vendor:github.com/davecgh/go-spew/spew", | ||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1", | ||
"//vendor:k8s.io/apimachinery/pkg/runtime/schema", | ||
"//vendor:k8s.io/client-go/kubernetes/fake", | ||
"//vendor:k8s.io/client-go/pkg/api", | ||
"//vendor:k8s.io/client-go/pkg/api/v1", | ||
"//vendor:k8s.io/client-go/testing", | ||
], | ||
) | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = [ | ||
"bootstrapsigner.go", | ||
"doc.go", | ||
"jws.go", | ||
"tokencleaner.go", | ||
"util.go", | ||
], | ||
tags = ["automanaged"], | ||
deps = [ | ||
"//pkg/bootstrap/api:go_default_library", | ||
"//pkg/util/metrics:go_default_library", | ||
"//vendor:github.com/golang/glog", | ||
"//vendor:github.com/square/go-jose", | ||
"//vendor:k8s.io/apimachinery/pkg/api/errors", | ||
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1", | ||
"//vendor:k8s.io/apimachinery/pkg/fields", | ||
"//vendor:k8s.io/apimachinery/pkg/runtime", | ||
"//vendor:k8s.io/apimachinery/pkg/util/runtime", | ||
"//vendor:k8s.io/apimachinery/pkg/util/wait", | ||
"//vendor:k8s.io/apimachinery/pkg/watch", | ||
"//vendor:k8s.io/client-go/kubernetes", | ||
"//vendor:k8s.io/client-go/pkg/api", | ||
"//vendor:k8s.io/client-go/pkg/api/v1", | ||
"//vendor:k8s.io/client-go/tools/cache", | ||
"//vendor:k8s.io/client-go/util/workqueue", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "package-srcs", | ||
srcs = glob(["**"]), | ||
tags = ["automanaged"], | ||
visibility = ["//visibility:private"], | ||
) | ||
|
||
filegroup( | ||
name = "all-srcs", | ||
srcs = [":package-srcs"], | ||
tags = ["automanaged"], | ||
) |
Oops, something went wrong.