Skip to content

Commit

Permalink
feat: update config
Browse files Browse the repository at this point in the history
  • Loading branch information
xdlbdy committed Apr 24, 2022
1 parent 48d50ff commit e0df5c2
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 80 deletions.
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,35 @@ DOCKER_BUILD_ARG= --build-arg TARGETARCH=$(GOARCH) --build-arg TARGETOS=$(GOOS)
clean :
rm -rf bin

docker-push: docker-push-controller docker-push-trigger docker-push-gateway docker-push-store
docker-build: docker-build-controller docker-build-trigger docker-build-gateway docker-build-store

build: build-controller build-trigger build-gateway build-store

docker-push-store: docker-build-store
docker push ${DOCKER_REPO}/store:${IMAGE_TAG}
docker-build-store:
docker build -t ${DOCKER_REPO}/store:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/store/Dockerfile ../

build-store:
$(GO_BUILD) -o bin/store cmd/store/main.go

docker-push-gateway: docker-build-gateway
docker push ${DOCKER_REPO}/gateway:${IMAGE_TAG}
docker-build-gateway:
docker build -t ${DOCKER_REPO}/gateway:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/gateway/Dockerfile ../

build-gateway:
$(GO_BUILD) -o bin/gateway cmd/gateway/main.go

docker-push-controller: docker-build-controller
docker push ${DOCKER_REPO}/controller:${IMAGE_TAG}
docker-build-controller:
docker build -t ${DOCKER_REPO}/controller:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/controller/Dockerfile ../

build-controller:
$(GO_BUILD) -o bin/controller cmd/controller/main.go

docker-push-trigger: docker-build-trigger
docker push ${DOCKER_REPO}/trigger:${IMAGE_TAG}
docker-build-trigger:
docker build -t ${DOCKER_REPO}/trigger:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/trigger/Dockerfile ../

build-trigger:
$(GO_BUILD) -o bin/trigger cmd/trigger/main.go

Expand Down
2 changes: 1 addition & 1 deletion build/images/store/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ FROM alpine:3.15.4
RUN mkdir -p /server
COPY --from=builder /workspace/vanus/bin/store /server/bin/store
WORKDIR /server
ENTRYPOINT ["bin/store"]
#ENTRYPOINT ["bin/store"]

2 changes: 1 addition & 1 deletion cmd/gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
func main() {
f := flag.String("config", "./config/gateway.yaml", "gateway config file path")
flag.Parse()
cfg, err := gateway.Init(*f)
cfg, err := gateway.InitConfig(*f)
if err != nil {
log.Error(nil, "init config error", map[string]interface{}{log.KeyError: err})
os.Exit(-1)
Expand Down
22 changes: 0 additions & 22 deletions config/controller.yaml

This file was deleted.

2 changes: 0 additions & 2 deletions config/gateway.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions config/trigger.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion config/trigger.yaml.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
port: 2148
ip: ""
controller:
controllers:
- 127.0.0.1:2048
76 changes: 45 additions & 31 deletions deploy/all-in-one.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,17 @@ metadata:
---
apiVersion: v1
data:
controller.yaml: |-
name: ${POD_NAME}
ip: ${POD_IP}
port: 2048
etcd:
- vanus-controller-0.vanus-controller.vanus.svc:2379
- vanus-controller-1.vanus-controller.vanus.svc:2379
- vanus-controller-2.vanus-controller.vanus.svc:2379
data_dir: /data
metadata:
key_prefix: /vanus
topology:
vanus-controller-0: vanus-controller-0.vanus-controller.vanus.svc:2048
vanus-controller-1: vanus-controller-1.vanus-controller.vanus.svc:2048
vanus-controller-2: vanus-controller-2.vanus-controller.vanus.svc:2048
embed_etcd:
# relative path to ${data_dir} above
data_dir: etcd/data
client_addr: ${POD_IP}:2379
peer_addr: ${POD_IP}:2380
clusters:
- vanus-controller-0=http://vanus-controller-0.vanus-controller.vanus.svc:2380
- vanus-controller-1=http://vanus-controller-1.vanus-controller.vanus.svc:2380
- vanus-controller-2=http://vanus-controller-2.vanus-controller.vanus.svc:2380
controller.yaml: "name: ${POD_NAME}\nip: ${POD_IP}\nport: 2048\ngrpc_reflection_enable:
true\netcd:\n - vanus-controller-0.vanus-controller.vanus.svc:2379\n - vanus-controller-1.vanus-controller.vanus.svc:2379\n
\ - vanus-controller-2.vanus-controller.vanus.svc:2379\ndata_dir: /data\nmetadata:\n
\ key_prefix: /vanus\ntopology:\n vanus-controller-0: vanus-controller-0.vanus-controller.vanus.svc:2048\n
\ vanus-controller-1: vanus-controller-1.vanus-controller.vanus.svc:2048\n vanus-controller-2:
vanus-controller-2.vanus-controller.vanus.svc:2048\nembed_etcd:\n # relative
path to ${data_dir} above\n data_dir: etcd/data\n client_addr: ${POD_IP}:2379\n
\ peer_addr: ${POD_IP}:2380\n clusters:\n - vanus-controller-0=http://vanus-controller-0.vanus-controller.vanus.svc:2380\n
\ - vanus-controller-1=http://vanus-controller-1.vanus-controller.vanus.svc:2380\n
\ - vanus-controller-2=http://vanus-controller-2.vanus-controller.vanus.svc:2380\n
\ "
kind: ConfigMap
metadata:
name: config-controller
Expand All @@ -38,7 +25,7 @@ apiVersion: v1
data:
gateway.yaml: |-
port: 8080
controller:
controllers:
- vanus-controller-0.vanus-controller.vanus.svc:2048
- vanus-controller-1.vanus-controller.vanus.svc:2048
- vanus-controller-2.vanus-controller.vanus.svc:2048
Expand All @@ -52,12 +39,12 @@ data:
store.yaml: |-
port: 11811
ip : ${POD_IP}
controller:
controllers:
- vanus-controller-0.vanus-controller.vanus.svc:2048
- vanus-controller-1.vanus-controller.vanus.svc:2048
- vanus-controller-2.vanus-controller.vanus.svc:2048
volume:
id: 123456
id: ${VOLUME_ID}
dir: /data
capacity: 1073741824
kind: ConfigMap
Expand All @@ -67,7 +54,7 @@ metadata:
---
apiVersion: v1
data:
trigger.yaml: "port: 2148\nip : ${POD_IP}\ncontroller:\n - vanus-controller-0.vanus-controller.vanus.svc:2048\n
trigger.yaml: "port: 2148\nip : ${POD_IP}\ncontrollers:\n - vanus-controller-0.vanus-controller.vanus.svc:2048\n
\ - vanus-controller-1.vanus-controller.vanus.svc:2048\n - vanus-controller-2.vanus-controller.vanus.svc:2048\n
\ "
kind: ConfigMap
Expand Down Expand Up @@ -113,6 +100,7 @@ metadata:
name: vanus-gateway
namespace: vanus
spec:
replicas: 1
selector:
matchLabels:
app: vanus-gateway
Expand Down Expand Up @@ -148,6 +136,7 @@ metadata:
name: vanus-trigger
namespace: vanus
spec:
replicas: 1
selector:
matchLabels:
app: vanus-trigger
Expand All @@ -158,12 +147,19 @@ spec:
spec:
containers:
- env:
- name: VANUS_LOG_LEVEL
value: DEBUG
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
image: public.ecr.aws/t8a4l2d7/trigger:latest
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
grpc:
port: 2148
periodSeconds: 2
name: trigger
ports:
- containerPort: 2148
Expand Down Expand Up @@ -200,6 +196,8 @@ spec:
spec:
containers:
- env:
- name: VANUS_LOG_LEVEL
value: DEBUG
- name: POD_NAME
valueFrom:
fieldRef:
Expand All @@ -210,6 +208,11 @@ spec:
fieldPath: status.podIP
image: public.ecr.aws/t8a4l2d7/controller:latest
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
grpc:
port: 2048
periodSeconds: 2
name: controller
ports:
- containerPort: 2048
Expand Down Expand Up @@ -251,7 +254,7 @@ metadata:
name: vanus-store
namespace: vanus
spec:
replicas: 1
replicas: 3
selector:
matchLabels:
app: vanus-store
Expand All @@ -262,17 +265,28 @@ spec:
app: vanus-store
spec:
containers:
- env:
- command:
- /bin/sh
- -c
- export VOLUME_ID=${HOSTNAME##*-}; /server/bin/store
env:
- name: VANUS_LOG_LEVEL
value: DEBUG
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
image: public.ecr.aws/t8a4l2d7/store:latest
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
grpc:
port: 11811
periodSeconds: 2
name: store
ports:
- containerPort: 11811
name: http
name: grpc
resources:
requests:
cpu: 100m
Expand Down
3 changes: 2 additions & 1 deletion deploy/yaml/gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ metadata:
data:
gateway.yaml: |-
port: 8080
controller:
controllers:
- vanus-controller-0.vanus-controller.vanus.svc:2048
- vanus-controller-1.vanus-controller.vanus.svc:2048
- vanus-controller-2.vanus-controller.vanus.svc:2048
Expand All @@ -52,6 +52,7 @@ spec:
selector:
matchLabels:
app: vanus-gateway
replicas: 1
template:
metadata:
labels:
Expand Down
7 changes: 4 additions & 3 deletions deploy/yaml/store.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ data:
store.yaml: |-
port: 11811
ip : ${POD_IP}
controller:
controllers:
- vanus-controller-0.vanus-controller.vanus.svc:2048
- vanus-controller-1.vanus-controller.vanus.svc:2048
- vanus-controller-2.vanus-controller.vanus.svc:2048
volume:
id: 123456
id: ${VOLUME_ID}
dir: /data
capacity: 1073741824
Expand All @@ -41,7 +41,7 @@ spec:
selector:
matchLabels:
app: vanus-store
replicas: 1
replicas: 3
serviceName: vanus-store
volumeClaimTemplates:
- metadata:
Expand All @@ -63,6 +63,7 @@ spec:
- name: store
image: public.ecr.aws/t8a4l2d7/store:latest
imagePullPolicy: Always
command: ["/bin/sh", "-c", "export VOLUME_ID=${HOSTNAME##*-}; /server/bin/store"]
resources:
requests:
cpu: 100m
Expand Down
3 changes: 2 additions & 1 deletion deploy/yaml/trigger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ data:
trigger.yaml: |-
port: 2148
ip : ${POD_IP}
controller:
controllers:
- vanus-controller-0.vanus-controller.vanus.svc:2048
- vanus-controller-1.vanus-controller.vanus.svc:2048
- vanus-controller-2.vanus-controller.vanus.svc:2048
Expand All @@ -37,6 +37,7 @@ spec:
selector:
matchLabels:
app: vanus-trigger
replicas: 1
template:
metadata:
labels:
Expand Down
6 changes: 3 additions & 3 deletions internal/gateway/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ package gateway
import "github.com/linkall-labs/vanus/internal/primitive"

type Config struct {
Port int `yaml:"port"`
ControllerAddr string `yaml:"controller_addr"`
Port int `yaml:"port"`
ControllerAddr []string `yaml:"controller"`
}

func Init(filename string) (*Config, error) {
func InitConfig(filename string) (*Config, error) {
c := new(Config)
err := primitive.LoadConfig(filename, c)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/trigger/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
type Config struct {
Port int `yaml:"port"`
Ip string `yaml:"ip"`
ControllerAddr []string `yaml:"controller"`
ControllerAddr []string `yaml:"controllers"`
TriggerAddr string
}

Expand Down
10 changes: 6 additions & 4 deletions test/shell/subscription.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/bash

ctrlAddr=127.0.0.1:2048
# create subscription
server=127.0.0.1:2048
grpcurl -d @ -plaintext $server linkall.vanus.controller.TriggerController.CreateSubscription <<EOF
grpcurl -d @ -plaintext $ctrlAddr linkall.vanus.controller.TriggerController.CreateSubscription <<EOF
{
"filters": [
{
Expand All @@ -9,12 +11,12 @@ grpcurl -d @ -plaintext $server linkall.vanus.controller.TriggerController.Crea
}
}
],
"sink": "http://127.0.0.1:18080",
"sink": "http://vance-display.default",
"eventBus": ""
}
EOF
# delete subscription
grpcurl -d @ -plaintext $server linkall.vanus.controller.TriggerController.DeleteSubscription <<EOF
grpcurl -d @ -plaintext $ctrlAddr linkall.vanus.controller.TriggerController.DeleteSubscription <<EOF
{
"id": 123
}
Expand Down

0 comments on commit e0df5c2

Please sign in to comment.