Add k8s example (#19)
This commit is contained in:
parent
514198f2e5
commit
6c946d62eb
10
examples/k8s/Makefile
Normal file
10
examples/k8s/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
SOURCES := $(shell find . -name "*.proto" -not -path ./vendor/\*)
|
||||
|
||||
TARGETS_K8S := $(foreach source, $(SOURCES), $(source)_k8s)
|
||||
|
||||
.PHONY: build
|
||||
build: $(TARGETS_K8S)
|
||||
|
||||
$(TARGETS_K8S): %_k8s:
|
||||
@mkdir -p $(dir $*)gen
|
||||
protoc $(PROTOC_OPTS) --gotemplate_out=debug=true,template_dir=./templates:$(dir $*)gen "$*"
|
18
examples/k8s/gen/nginx/dpl.yaml
Normal file
18
examples/k8s/gen/nginx/dpl.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: nginx
|
||||
labels:
|
||||
method: Hello-World-nginx
|
||||
spec:
|
||||
replicas: 3
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
10
examples/k8s/gen/nginx/svc.yaml
Normal file
10
examples/k8s/gen/nginx/svc.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: nginx
|
||||
spec:
|
||||
selector:
|
||||
app: nginx
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
11
examples/k8s/nginx.proto
Normal file
11
examples/k8s/nginx.proto
Normal file
@ -0,0 +1,11 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package nginx;
|
||||
|
||||
message Empty {
|
||||
}
|
||||
|
||||
service Nginx {
|
||||
rpc Hello(Empty) returns (Empty) {}
|
||||
rpc World(Empty) returns (Empty) {}
|
||||
}
|
18
examples/k8s/templates/{{.File.Package}}/dpl.yaml.tmpl
Normal file
18
examples/k8s/templates/{{.File.Package}}/dpl.yaml.tmpl
Normal file
@ -0,0 +1,18 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{.File.Package}}
|
||||
labels:
|
||||
method: {{range .Service.Method}}{{.Name}}-{{end}}{{.File.Package}}
|
||||
spec:
|
||||
replicas: 3
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: {{.File.Package}}
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
10
examples/k8s/templates/{{.File.Package}}/svc.yaml.tmpl
Normal file
10
examples/k8s/templates/{{.File.Package}}/svc.yaml.tmpl
Normal file
@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{.File.Package}}
|
||||
spec:
|
||||
selector:
|
||||
app: {{.File.Package}}
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
Loading…
Reference in New Issue
Block a user