-
Notifications
You must be signed in to change notification settings - Fork 234
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 #402 from yue9944882/chore/example-pod-exec
Chore: Example pod exec
- Loading branch information
Showing
79 changed files
with
12,435 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,12 @@ | ||
bin/ | ||
default.etcd/ | ||
kubeconfig | ||
apiserver.local.config/ | ||
zz_generated* | ||
pkg/client/*_generated | ||
pkg/openapi/openapi_generated.go | ||
.crt | ||
.key | ||
vendor/** | ||
Gopkg.* | ||
violations.report |
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,15 @@ | ||
|
||
# gazelle:proto disable | ||
# gazelle:exclude vendor | ||
load("@io_bazel_rules_go//go:def.bzl", "gazelle") | ||
|
||
gazelle( | ||
name = "gazelle", | ||
command = "fix", | ||
prefix = "sigs.k8s.io/apiserver-builder-alpha/example/podexec", | ||
external = "vendored", | ||
args = [ | ||
"-build_file_name", | ||
"BUILD,BUILD.bazel", | ||
], | ||
) |
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,4 @@ | ||
|
||
version: "1" | ||
domain: example.com | ||
repo: sigs.k8s.io/apiserver-builder-alpha/example/podexec |
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,12 @@ | ||
|
||
http_archive( | ||
name = "io_bazel_rules_go", | ||
url = "https://github.com/bazelbuild/rules_go/releases/download/0.6.0/rules_go-0.6.0.tar.gz", | ||
sha256 = "ba6feabc94a5d205013e70792accb6cce989169476668fbaf98ea9b342e13b59", | ||
) | ||
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains") | ||
go_rules_dependencies() | ||
go_register_toolchains() | ||
|
||
load("@io_bazel_rules_go//proto:def.bzl", "proto_register_toolchains") | ||
proto_register_toolchains() |
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,16 @@ | ||
/* | ||
Copyright 2019 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. | ||
*/ | ||
|
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 2019 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 main | ||
|
||
import ( | ||
// Make sure dep tools picks up these dependencies | ||
_ "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
_ "github.com/go-openapi/loads" | ||
|
||
"sigs.k8s.io/apiserver-builder-alpha/pkg/cmd/server" | ||
_ "k8s.io/client-go/plugin/pkg/client/auth" // Enable cloud provider auth | ||
|
||
"sigs.k8s.io/apiserver-builder-alpha/example/podexec/pkg/apis" | ||
"sigs.k8s.io/apiserver-builder-alpha/example/podexec/pkg/openapi" | ||
) | ||
|
||
func main() { | ||
version := "v0" | ||
|
||
err := server.StartApiServerWithOptions(&server.StartOptions{ | ||
EtcdPath: "/registry/example.com", | ||
Apis: apis.GetAllApiBuilders(), | ||
Openapidefs: openapi.GetOpenAPIDefinitions, | ||
Title: "Api", | ||
Version: version, | ||
|
||
// TweakConfigFuncs []func(apiServer *apiserver.Config) error | ||
// FlagConfigFuncs []func(*cobra.Command) error | ||
}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} |
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,84 @@ | ||
/* | ||
Copyright 2019 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 main | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
|
||
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp" | ||
"sigs.k8s.io/apiserver-builder-alpha/example/podexec/pkg/apis" | ||
"sigs.k8s.io/apiserver-builder-alpha/example/podexec/pkg/controller" | ||
"sigs.k8s.io/apiserver-builder-alpha/example/podexec/pkg/webhook" | ||
"sigs.k8s.io/controller-runtime/pkg/client/config" | ||
"sigs.k8s.io/controller-runtime/pkg/manager" | ||
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" | ||
"sigs.k8s.io/controller-runtime/pkg/runtime/signals" | ||
) | ||
|
||
func main() { | ||
var metricsAddr string | ||
flag.StringVar(&metricsAddr, "metrics-addr", ":8080", "The address the metric endpoint binds to.") | ||
flag.Parse() | ||
logf.SetLogger(logf.ZapLogger(false)) | ||
log := logf.Log.WithName("entrypoint") | ||
|
||
// Get a config to talk to the apiserver | ||
log.Info("setting up client for manager") | ||
cfg, err := config.GetConfig() | ||
if err != nil { | ||
log.Error(err, "unable to set up client config") | ||
os.Exit(1) | ||
} | ||
|
||
// Create a new Cmd to provide shared dependencies and start components | ||
log.Info("setting up manager") | ||
mgr, err := manager.New(cfg, manager.Options{MetricsBindAddress: metricsAddr}) | ||
if err != nil { | ||
log.Error(err, "unable to set up overall controller manager") | ||
os.Exit(1) | ||
} | ||
|
||
log.Info("Registering Components.") | ||
|
||
// Setup Scheme for all resources | ||
log.Info("setting up scheme") | ||
if err := apis.AddToScheme(mgr.GetScheme()); err != nil { | ||
log.Error(err, "unable add APIs to scheme") | ||
os.Exit(1) | ||
} | ||
|
||
// Setup all Controllers | ||
log.Info("Setting up controller") | ||
if err := controller.AddToManager(mgr); err != nil { | ||
log.Error(err, "unable to register controllers to the manager") | ||
os.Exit(1) | ||
} | ||
|
||
log.Info("setting up webhooks") | ||
if err := webhook.AddToManager(mgr); err != nil { | ||
log.Error(err, "unable to register webhooks to the manager") | ||
os.Exit(1) | ||
} | ||
|
||
// Start the Cmd | ||
log.Info("Starting the Cmd.") | ||
if err := mgr.Start(signals.SetupSignalHandler()); err != nil { | ||
log.Error(err, "unable to run the manager") | ||
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,7 @@ | ||
note: Pod Example | ||
sample: | | ||
apiVersion: podexec.example.com/v1 | ||
kind: Pod | ||
metadata: | ||
name: pod-example | ||
spec: |
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,25 @@ | ||
|
||
/* | ||
Copyright 2019 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. | ||
*/ | ||
|
||
|
||
|
||
|
||
// | ||
// +domain=example.com | ||
|
||
package apis | ||
|
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,26 @@ | ||
|
||
/* | ||
Copyright 2019 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. | ||
*/ | ||
|
||
|
||
|
||
|
||
// +k8s:deepcopy-gen=package,register | ||
// +groupName=podexec.example.com | ||
|
||
// Package api is the internal version of the API. | ||
package podexec | ||
|
Oops, something went wrong.