Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding example project that using hostpath as storage #533

Merged
merged 1 commit into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions example/non-etcd/.gitignore
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
9 changes: 9 additions & 0 deletions example/non-etcd/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

load("@bazel_gazelle//:def.bzl", "gazelle")

# gazelle:proto disable_global
# gazelle:prefix sigs.k8s.io/apiserver-builder-alpha/example/non-etcd
gazelle(
name = "gazelle",
command = "fix",
)
4 changes: 4 additions & 0 deletions example/non-etcd/PROJECT
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/non-etcd
24 changes: 24 additions & 0 deletions example/non-etcd/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_k8s_repo_infra",
sha256 = "5ee2a8e306af0aaf2844b5e2c79b5f3f53fc9ce3532233f0615b8d0265902b2a",
strip_prefix = "repo-infra-0.0.1-alpha.1",
urls = [
"https://github.com/kubernetes/repo-infra/archive/v0.0.1-alpha.1.tar.gz",
],
)

load("@io_k8s_repo_infra//:load.bzl", _repo_infra_repos = "repositories")

_repo_infra_repos()

load("@io_k8s_repo_infra//:repos.bzl", "configure")

# use k8s.io/repo-infra to configure go and bazel
# default minimum_bazel_version is 0.29.1
configure(
go_version = "1.13",
rbe_name = None,
)
15 changes: 15 additions & 0 deletions example/non-etcd/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
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.
*/
51 changes: 51 additions & 0 deletions example/non-etcd/cmd/apiserver/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

/*
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 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/non-etcd/pkg/apis"
"sigs.k8s.io/apiserver-builder-alpha/example/non-etcd/pkg/openapi"
_ "sigs.k8s.io/apiserver-builder-alpha/example/non-etcd/plugin/admission/install"
)

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)
}
}
84 changes: 84 additions & 0 deletions example/non-etcd/cmd/manager/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
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 main

import (
"flag"
"os"

_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"sigs.k8s.io/apiserver-builder-alpha/example/non-etcd/pkg/apis"
"sigs.k8s.io/apiserver-builder-alpha/example/non-etcd/pkg/controller"
"sigs.k8s.io/apiserver-builder-alpha/example/non-etcd/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)
}
}
7 changes: 7 additions & 0 deletions example/non-etcd/docs/examples/burger/burger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
note: Burger Example
sample: |
apiVersion: filepath.example.com/v1
kind: Burger
metadata:
name: burger-example
spec:
45 changes: 45 additions & 0 deletions example/non-etcd/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
module sigs.k8s.io/apiserver-builder-alpha/example/non-etcd

go 1.13

require (
github.com/go-logr/zapr v0.1.1 // indirect
github.com/go-openapi/loads v0.19.4
github.com/go-openapi/spec v0.19.3
github.com/golang/protobuf v1.3.4 // indirect
github.com/google/go-cmp v0.3.1 // indirect
github.com/gorilla/websocket v1.4.1 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190723091251-e0797f438f94 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kubernetes-incubator/reference-docs v0.0.0 // indirect
github.com/markbates/inflect v1.0.4 // indirect
github.com/onsi/ginkgo v1.11.0
github.com/onsi/gomega v1.8.1
github.com/pkg/errors v0.8.1 // indirect
github.com/spf13/cobra v0.0.5 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect
k8s.io/api v0.18.4 // indirect
k8s.io/apimachinery v0.18.4
k8s.io/apiserver v0.18.4
k8s.io/client-go v0.18.4
k8s.io/gengo v0.0.0-20200114144118-36b2048a9120 // indirect
k8s.io/klog v1.0.0
k8s.io/kube-aggregator v0.18.4 // indirect
k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6
k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 // indirect
sigs.k8s.io/apiserver-builder-alpha v1.18.0
sigs.k8s.io/controller-runtime v0.6.0
sigs.k8s.io/controller-tools v0.1.12 // indirect
sigs.k8s.io/kubebuilder v1.0.8 // indirect
sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06 // indirect
sigs.k8s.io/testing_frameworks v0.1.1 // indirect
)

replace github.com/kubernetes-incubator/reference-docs => github.com/kubernetes-incubator/reference-docs v0.0.0-20170929004150-fcf65347b256

replace github.com/markbates/inflect => github.com/markbates/inflect v1.0.4

replace sigs.k8s.io/apiserver-builder-alpha => ../../../apiserver-builder-alpha
Loading