Skip to content

Commit

Permalink
fix: listern use port
Browse files Browse the repository at this point in the history
  • Loading branch information
xdlbdy committed Apr 20, 2022
1 parent d84ac3a commit b813da5
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GOOS ?= linux
GOARCH ?= amd64

GO_BUILD= GO111MODULE=on CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -trimpath
DOCKER_BUILD_ARG= --build-arg=TARGETARCH=$(GOARCH) --build-arg=TARGETOS=$(GOOS)
DOCKER_BUILD_ARG= --build-arg TARGETARCH=$(GOARCH) --build-arg TARGETOS=$(GOOS)

clean :
rm -rf bin
Expand Down Expand Up @@ -51,7 +51,7 @@ controller-start:
build-ctrl-bin:
$(GO_BUILD) -o bin/ctrl cmd/controller/eventbus/main.go

controller-start: check-module-env
controller-start:
go run ${VANUS_ROOT}/cmd/controller/${module}/main.go

controller-api-test:
Expand Down
2 changes: 1 addition & 1 deletion build/images/controller/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ARG TARGETOS
ARG TARGETARCH
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make build-controller

FROM alpine:3.15.4
FROM centos:8.4.2105
RUN mkdir -p /server
COPY --from=builder /workspace/vanus/bin/controller /server/bin/controller
WORKDIR /server
Expand Down
2 changes: 1 addition & 1 deletion cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func main() {
os.Exit(-1)
}

listen, err := net.Listen("tcp", fmt.Sprintf("%s:%d", cfg.IP, cfg.Port))
listen, err := net.Listen("tcp", fmt.Sprintf("%d", cfg.Port))
if err != nil {
log.Error(ctx, "failed to listen", map[string]interface{}{
"error": err,
Expand Down
36 changes: 24 additions & 12 deletions deploy/yaml/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,30 @@ metadata:
namespace: vanus
data:
controller.yaml: |-
name: "test-1"
ip: "127.0.0.1"
name: ${POD_NAME}
ip: ${POD_IP}
port: 2049
etcd:
- "127.0.0.1:2379"
data_dir: "/data/vanus"
topology:
service_a: "127.0.0.1:2049"
- "vanus-controller-0.vanus-controller.vanus.svc.cluster.local:2379"
- "vanus-controller-1.vanus-controller.vanus.svc.cluster.local:2379"
- "vanus-controller-2.vanus-controller.vanus.svc.cluster.local:2379"
data_dir: "/data"
metadata:
key_prefix: "/wenfeng"
key_prefix: "/vanus"
embed_etcd:
name: "etcd-1"
data_dir: "etcd/node1"
name: ${POD_NAME}
# relative path to ${data_dir} above
data_dir: "etcd/data"
client_addr: "127.0.0.1:2379"
peer_addr: "127.0.0.1:2380"
clusters:
- "etcd-1=http://127.0.0.1:2380"
- vanus-controller-0=http://vanus-controller-0.vanus-controller.vanus.svc.cluster.local:2380
- vanus-controller-1=http://vanus-controller-1.vanus-controller.vanus.svc.cluster.local:2380
- vanus-controller-2=http://vanus-controller-2.vanus-controller.vanus.svc.cluster.local:2380
#eventbus:
trigger:
storage:
keyPrefix: "/xdl"
keyPrefix: "/vanus"
serverList: [ "127.0.0.1:2379" ]
---
Expand All @@ -54,7 +58,6 @@ spec:
clusterIP: None
ports:
- port: 2049
targetPort: 2049
name: vanus-controller
---
apiVersion: apps/v1
Expand Down Expand Up @@ -100,6 +103,15 @@ spec:
containerPort: 2379
- name: etcd-peer
containerPort: 2380
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_ID
valueFrom:
fieldRef:
fieldPath: status.podIP
volumeMounts:
- name: config-controller
mountPath: /server/config
Expand Down
4 changes: 3 additions & 1 deletion internal/primitive/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package primitive
import (
"gopkg.in/yaml.v3"
"io/ioutil"
"os"
)

type StorageKeyPrefix string
Expand All @@ -41,7 +42,8 @@ func LoadConfig(filename string, config interface{}) error {
if err != nil {
return err
}
err = yaml.Unmarshal(b, config)
str := os.ExpandEnv(string(b))
err = yaml.Unmarshal([]byte(str), config)
if err != nil {
return err
}
Expand Down

0 comments on commit b813da5

Please sign in to comment.