sample-apiserver

module
v0.0.0-...-1c98ef4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2018 License: Apache-2.0

README

sample-apiserver

基于apimaster工程所创建的apiserver.

  1. 首先我们需要创建CA证书
openssl req -nodes -new -x509 -keyout ca.key -out ca.crt
  1. 创建给客户端使用的证书
openssl req -out client.csr -new -newkey rsa:4096 -nodes -keyout client.key -subj "/CN=development/O=system:masters"
openssl x509 -req -days 365 -in client.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out client.crt
  1. 创建curl需要的证书
openssl pkcs12 -export -in ./client.crt -inkey ./client.key -out client.p12 -passout pass:password
  1. 放置前面生成的证书在合适的位置,然后启动服务
go run cmd/sample-apiserver/main.go --insecure-bind-address="127.0.0.1" --insecure-port=8080 \
  --secure-port=8443 --tls-private-key-file="./keys/ca.key" --tls-cert-file="./keys/ca.crt" \
  --enable-swagger-ui=true  --swagger-ui-file-path="./third_party/swagger-ui" \
  --mysql-servers="root:123456@tcp(127.0.0.1:3306)/sample"

至此,你已经创建了一个k8s风格的API Server, 访问127.0.0.1:8080

开发流程

  • 增加APIS
  • 调用cd hack && ./update-codegen.sh生成代码
  • 调用cd hack && ./update-swagger-doc.sh生成swagger文档

Directories

Path Synopsis
cmd
pkg
apis/sample
Package api is the internal version of the API.
Package api is the internal version of the API.
apis/sample/v1alpha1
Package v1alpha1 is the v1alpha1 version of the API.
Package v1alpha1 is the v1alpha1 version of the API.
app
client/clientset/internalversion
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/internalversion/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/internalversion/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/internalversion/typed/sample/internalversion
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/internalversion/typed/sample/internalversion/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
client/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
client/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
client/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
client/clientset/versioned/typed/sample/v1alpha1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
client/clientset/versioned/typed/sample/v1alpha1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
third_party
code-generator/_examples/apiserver/apis/example
+k8s:deepcopy-gen=package +groupName=example.apiserver.code-generator.k8s.io
+k8s:deepcopy-gen=package +groupName=example.apiserver.code-generator.k8s.io
code-generator/_examples/apiserver/apis/example/install
Package install installs the experimental API group, making it available as an option to all of the API encoding/decoding machinery.
Package install installs the experimental API group, making it available as an option to all of the API encoding/decoding machinery.
code-generator/_examples/apiserver/apis/example/v1
+k8s:deepcopy-gen=package +k8s:defaulter-gen=TypeMeta +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example +groupName=example.apiserver.code-generator.k8s.io
+k8s:deepcopy-gen=package +k8s:defaulter-gen=TypeMeta +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example +groupName=example.apiserver.code-generator.k8s.io
code-generator/_examples/apiserver/apis/example2
+k8s:deepcopy-gen=package +groupName=example.test.apiserver.code-generator.k8s.io +groupGoName=SecondExample
+k8s:deepcopy-gen=package +groupName=example.test.apiserver.code-generator.k8s.io +groupGoName=SecondExample
code-generator/_examples/apiserver/apis/example2/install
Package install installs the experimental API group, making it available as an option to all of the API encoding/decoding machinery.
Package install installs the experimental API group, making it available as an option to all of the API encoding/decoding machinery.
code-generator/_examples/apiserver/apis/example2/v1
+k8s:deepcopy-gen=package +k8s:defaulter-gen=TypeMeta +groupName=example.test.apiserver.code-generator.k8s.io +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example2 +groupGoName=SecondExample
+k8s:deepcopy-gen=package +k8s:defaulter-gen=TypeMeta +groupName=example.test.apiserver.code-generator.k8s.io +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example2 +groupGoName=SecondExample
code-generator/_examples/apiserver/clientset/internalversion
This package has the automatically generated clientset.
This package has the automatically generated clientset.
code-generator/_examples/apiserver/clientset/internalversion/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
code-generator/_examples/apiserver/clientset/internalversion/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
code-generator/_examples/apiserver/clientset/internalversion/typed/example/internalversion
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
Package fake has the automatically generated clients.
code-generator/_examples/apiserver/clientset/internalversion/typed/example2/internalversion
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
Package fake has the automatically generated clients.
code-generator/_examples/apiserver/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
code-generator/_examples/apiserver/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
code-generator/_examples/apiserver/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
code-generator/_examples/apiserver/clientset/versioned/typed/example/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
code-generator/_examples/apiserver/clientset/versioned/typed/example/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
code-generator/_examples/apiserver/clientset/versioned/typed/example2/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
code-generator/_examples/crd/apis/example/v1
+k8s:deepcopy-gen=package +k8s:defaulter-gen=TypeMeta +groupName=example.crd.code-generator.k8s.io
+k8s:deepcopy-gen=package +k8s:defaulter-gen=TypeMeta +groupName=example.crd.code-generator.k8s.io
code-generator/_examples/crd/apis/example2/v1
+k8s:deepcopy-gen=package +k8s:defaulter-gen=TypeMeta +groupName=example.test.crd.code-generator.k8s.io +groupGoName=SecondExample
+k8s:deepcopy-gen=package +k8s:defaulter-gen=TypeMeta +groupName=example.test.crd.code-generator.k8s.io +groupGoName=SecondExample
code-generator/_examples/crd/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
code-generator/_examples/crd/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
code-generator/_examples/crd/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
code-generator/_examples/crd/clientset/versioned/typed/example/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
code-generator/_examples/crd/clientset/versioned/typed/example/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
code-generator/_examples/crd/clientset/versioned/typed/example2/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
code-generator/_examples/crd/clientset/versioned/typed/example2/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
code-generator/cmd/client-gen
client-gen makes the individual typed clients using gengo.
client-gen makes the individual typed clients using gengo.
code-generator/cmd/client-gen/generators
Package generators has the generators for the client-gen utility.
Package generators has the generators for the client-gen utility.
code-generator/cmd/conversion-gen
conversion-gen is a tool for auto-generating Conversion functions.
conversion-gen is a tool for auto-generating Conversion functions.
code-generator/cmd/deepcopy-gen
deepcopy-gen is a tool for auto-generating DeepCopy functions.
deepcopy-gen is a tool for auto-generating DeepCopy functions.
code-generator/cmd/defaulter-gen
defaulter-gen is a tool for auto-generating Defaulter functions.
defaulter-gen is a tool for auto-generating Defaulter functions.
code-generator/cmd/go-to-protobuf
go-to-protobuf generates a Protobuf IDL from a Go struct, respecting any existing IDL tags on the Go struct.
go-to-protobuf generates a Protobuf IDL from a Go struct, respecting any existing IDL tags on the Go struct.
code-generator/cmd/go-to-protobuf/protobuf
go-to-protobuf generates a Protobuf IDL from a Go struct, respecting any existing IDL tags on the Go struct.
go-to-protobuf generates a Protobuf IDL from a Go struct, respecting any existing IDL tags on the Go struct.
code-generator/cmd/go-to-protobuf/protoc-gen-gogo
Package main defines the protoc-gen-gogo binary we use to generate our proto go files, as well as takes dependencies on the correct gogo/protobuf packages for godeps.
Package main defines the protoc-gen-gogo binary we use to generate our proto go files, as well as takes dependencies on the correct gogo/protobuf packages for godeps.
code-generator/cmd/import-boss
import-boss enforces import restrictions in a given repository.
import-boss enforces import restrictions in a given repository.
code-generator/cmd/openapi-gen
This package generates openAPI definition file to be used in open API spec generation on API servers.
This package generates openAPI definition file to be used in open API spec generation on API servers.
code-generator/cmd/set-gen
set-gen is an example usage of gengo.
set-gen is an example usage of gengo.
code-generator/third_party/forked/golang/reflect
This package is copied from Go library reflect/type.go.
This package is copied from Go library reflect/type.go.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL