-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support authentication helper for kubectl
We create a simple exec plugin command which can create and renew short-lived admin credentials on the fly, essentially leveraging the security of the underlying cloud credentials. Co-authored-by: John Gardiner Myers <[email protected]>
- Loading branch information
1 parent
3f079cd
commit 03906b3
Showing
15 changed files
with
452 additions
and
8 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
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,8 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["exit.go"], | ||
importpath = "k8s.io/kops/pkg/commands/commandutils", | ||
visibility = ["//visibility:public"], | ||
) |
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,29 @@ | ||
/* | ||
Copyright 2020 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 commandutils | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
// ExitWithError will terminate execution with an error result | ||
// It prints the error to stderr and exits with a non-zero exit code | ||
func ExitWithError(err error) { | ||
fmt.Fprintf(os.Stderr, "\n%v\n", err) | ||
os.Exit(1) | ||
} |
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,50 @@ | ||
/* | ||
Copyright 2020 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 commands | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/spf13/cobra" | ||
"k8s.io/kops/cmd/kops/util" | ||
"k8s.io/kops/pkg/commands/helpers" | ||
"k8s.io/kubectl/pkg/util/i18n" | ||
"k8s.io/kubectl/pkg/util/templates" | ||
) | ||
|
||
var ( | ||
helpersLong = templates.LongDesc(i18n.T(` | ||
Commands intended for integration with other systems.`)) | ||
|
||
helpersShort = i18n.T(`Commands for use with other systems.`) | ||
) | ||
|
||
// NewCmdHelpers builds the cobra command tree for the `helpers` subcommand | ||
func NewCmdHelpers(f *util.Factory, out io.Writer) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "helpers", | ||
Short: helpersShort, | ||
Long: helpersLong, | ||
|
||
// We hide the command, as it is intended for internal usage | ||
Hidden: true, | ||
} | ||
|
||
cmd.AddCommand(helpers.NewCmdHelperKubectlAuth(f, out)) | ||
|
||
return cmd | ||
} |
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,19 @@ | ||
load("@io_bazel_rules_go//go:def.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = ["kubectl_auth.go"], | ||
importpath = "k8s.io/kops/pkg/commands/helpers", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//cmd/kops/util:go_default_library", | ||
"//pkg/commands/commandutils:go_default_library", | ||
"//pkg/pki:go_default_library", | ||
"//pkg/rbac:go_default_library", | ||
"//upup/pkg/fi:go_default_library", | ||
"//vendor/github.com/spf13/cobra:go_default_library", | ||
"//vendor/k8s.io/client-go/util/homedir:go_default_library", | ||
"//vendor/k8s.io/klog:go_default_library", | ||
"//vendor/k8s.io/kubectl/pkg/util/i18n:go_default_library", | ||
], | ||
) |
Oops, something went wrong.