Skip to content

seanchann/sample-apiserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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文档

About

implement a api server with apimaster

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published