apache / kvrocks-controller

Apache Kvrocks Controller is a cluster management tool for Apache Kvrocks.
https://kvrocks.apache.org/
Apache License 2.0
84 stars 42 forks source link

fix: support dynamic server addr #75

Closed rfyiamcool closed 1 year ago

rfyiamcool commented 1 year ago

change

When deploying multiple instances, we usually use the same configuration file, but the IP address of each instance is different, so we need to get local addr dynamically.

in addition, when using k8s to deploy kvrocks-controller, we can directly inject pod information into the environment variables of the container.

https://kubernetes.io/zh-cn/docs/tasks/inject-data-application/environment-variable-expose-pod-information/

apiVersion: v1
kind: Pod
metadata:
  name: xxx
spec:
  containers:
    - name: kvrocks-controller
      image: kvrocks-controller
      ...
      env:
        - name: KVROCKS_CONTROLLER_HTTP_HOST
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
         - name: KVROCKS_CONTROLLER_HTTP_PORT
           value: 8080
  restartPolicy: Never
image
git-hulk commented 1 year ago

@rfyiamcool Thanks for your contribution, this sounds really reasonable. Can you help to fix the lint error?

rfyiamcool commented 1 year ago

😅 I run unit test successfully locally,i don't know why test fail.

Running tool: /usr/local/go/bin/go test -timeout 120s -run ^TestNamespace$ github.com/RocksLabs/kvrocks_controller/server -v -count=1

=== RUN   TestNamespace
=== RUN   TestNamespace/Create_namespace
=== RUN   TestNamespace/Create_duplicate_namespace
=== RUN   TestNamespace/List_namespaces
=== RUN   TestNamespace/Delete_namespace
--- PASS: TestNamespace (0.61s)
    --- PASS: TestNamespace/Create_namespace (0.23s)
    --- PASS: TestNamespace/Create_duplicate_namespace (0.11s)
    --- PASS: TestNamespace/List_namespaces (0.11s)
    --- PASS: TestNamespace/Delete_namespace (0.15s)
PASS
ok      github.com/RocksLabs/kvrocks_controller/server  0.833s
git-hulk commented 1 year ago

Thanks @rfyiamcool, I will have a look later.