diff --git a/.env b/.env index 4f684ad77e..bcfc0722ae 100644 --- a/.env +++ b/.env @@ -30,12 +30,19 @@ MINIO_ENDPOINT=http://172.28.0.1:10005 # Base URL for the application programming interface (API). # Default: API_URL=http://172.28.0.1:10002 -API_URL=http://127.0.0.1:10002 +API_URL=http://172.28.0.1:10002 # Directory path for storing data files or related information. # Default: DATA_DIR=./ DATA_DIR=./ +# Choose the appropriate image address, the default is GITHUB image, +# you can choose docker hub, for Chinese users can choose Ali Cloud +# export IMAGE_REGISTRY="ghcr.io/openimsdk" +# export IMAGE_REGISTRY="openim" +# export IMAGE_REGISTRY="registry.cn-hangzhou.aliyuncs.com/openimsdk" +IMAGE_REGISTRY=ghcr.io/openimsdk + # ====================================== # ========= Network Configuration ====== # ====================================== diff --git a/.github/workflows/docker-buildx.yml b/.github/workflows/docker-buildx.yml index 366317b1c5..6113cfae50 100644 --- a/.github/workflows/docker-buildx.yml +++ b/.github/workflows/docker-buildx.yml @@ -54,6 +54,19 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Log in to AliYun Docker Hub + uses: docker/login-action@v3 + with: + registry: registry.cn-hangzhou.aliyuncs.com + username: ${{ secrets.ALIREGISTRY_USERNAME }} + password: ${{ secrets.ALIREGISTRY_TOKEN }} + ################################################ # build/ # └── docker @@ -89,7 +102,10 @@ jobs: id: meta1 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-api + images: | + ghcr.io/openimsdk/openim-api + openim/openim-api + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-api - name: Build and push Docker image for openim-api uses: docker/build-push-action@v5 @@ -107,7 +123,10 @@ jobs: id: meta2 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-cmdutils + images: | + ghcr.io/openimsdk/openim-cmdutils + openim/openim-cmdutils + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-cmdutils - name: Build and push Docker image for openim-cmdutils uses: docker/build-push-action@v5 @@ -125,7 +144,10 @@ jobs: id: meta3 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-crontask + images: | + ghcr.io/openimsdk/openim-crontask + openim/openim-crontask + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-crontask - name: Build and push Docker image for openim-crontask uses: docker/build-push-action@v5 @@ -143,7 +165,10 @@ jobs: id: meta4 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-msggateway + images: | + ghcr.io/openimsdk/openim-msggateway + openim/openim-msggateway + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-msggateway - name: Build and push Docker image for openim-msggateway uses: docker/build-push-action@v5 @@ -161,7 +186,10 @@ jobs: id: meta5 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-msgtransfer + images: | + ghcr.io/openimsdk/openim-msgtransfer + openim/openim-msgtransfer + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-msgtransfer - name: Build and push Docker image for openim-msgtransfer uses: docker/build-push-action@v5 @@ -179,7 +207,10 @@ jobs: id: meta6 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-push + images: | + ghcr.io/openimsdk/openim-push + openim/openim-push + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-push - name: Build and push Docker image for openim-push uses: docker/build-push-action@v5 @@ -197,7 +228,10 @@ jobs: id: meta7 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-rpc-auth + images: | + ghcr.io/openimsdk/openim-rpc-auth + openim/openim-rpc-auth + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-auth - name: Build and push Docker image for openim-rpc-auth uses: docker/build-push-action@v5 @@ -215,7 +249,10 @@ jobs: id: meta8 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-rpc-conversation + images: | + ghcr.io/openimsdk/openim-rpc-conversation + openim/openim-rpc-conversation + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-conversation - name: Build and push Docker image for openim-rpc-conversation uses: docker/build-push-action@v5 @@ -233,7 +270,10 @@ jobs: id: meta9 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-rpc-friend + images: | + ghcr.io/openimsdk/openim-rpc-friend + openim/openim-rpc-friend + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-friend - name: Build and push Docker image for openim-rpc-friend uses: docker/build-push-action@v5 @@ -251,7 +291,10 @@ jobs: id: meta10 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-rpc-group + images: | + ghcr.io/openimsdk/openim-rpc-group + openim/openim-rpc-group + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-group - name: Build and push Docker image for openim-rpc-group uses: docker/build-push-action@v5 @@ -269,7 +312,10 @@ jobs: id: meta11 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-rpc-msg + images: | + ghcr.io/openimsdk/openim-rpc-msg + openim/openim-rpc-msg + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-msg - name: Build and push Docker image for openim-rpc-msg uses: docker/build-push-action@v5 @@ -287,7 +333,10 @@ jobs: id: meta12 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-rpc-third + images: | + ghcr.io/openimsdk/openim-rpc-third + openim/openim-rpc-third + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-third - name: Build and push Docker image for openim-rpc-third uses: docker/build-push-action@v5 @@ -305,7 +354,10 @@ jobs: id: meta13 uses: docker/metadata-action@v5.0.0 with: - images: ghcr.io/openimsdk/openim-rpc-user + images: | + ghcr.io/openimsdk/openim-rpc-user + openim/openim-rpc-user + registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-rpc-user - name: Build and push Docker image for openim-rpc-user uses: docker/build-push-action@v5 @@ -318,4 +370,3 @@ jobs: labels: ${{ steps.meta13.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - diff --git a/.github/workflows/openimci.yml b/.github/workflows/openimci.yml index 347f6d762b..05a8ce5c5f 100644 --- a/.github/workflows/openimci.yml +++ b/.github/workflows/openimci.yml @@ -170,3 +170,24 @@ jobs: - name: Print OpenIM Logs run: sudo cat ./_output/logs/* 2>/dev/null continue-on-error: true + + openim-build-image: + name: Build OpenIM Docker Image + runs-on: ubuntu-latest + environment: + name: openim + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Go ${{ matrix.go_version }} + uses: actions/setup-go@v4 + with: + go-version: ${{ matrix.go_version }} + id: go + - name: Install Task + uses: arduino/setup-task@v1 + with: + version: 2.x + - name: Test Docker Build + run: | + sudo make image \ No newline at end of file diff --git a/.gitignore b/.gitignore index 92408fa56e..fa1818e2ba 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ tmp/ bin/ output/ _output/ +deployments/charts/generated-configs/ ### OpenIM Config ### config/config.yaml @@ -37,18 +38,7 @@ config/config.yaml ./.env ### OpenIM deploy ### -deploy/openim_demo -deploy/openim-api -deploy/openim-rpc-msg_gateway -deploy/openim-msgtransfer -deploy/openim-push -deploy/openim_timer_task -deploy/openim-rpc-user -deploy/openim-rpc-friend -deploy/openim-rpc-group -deploy/openim-rpc-msg -deploy/openim-rpc-auth -deploy/Open-IM-SDK-Core +deployments/openim-server/charts # files used by the developer .idea.md diff --git a/.golangci.yml b/.golangci.yml index dd68ce5a61..b129ffd685 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -715,83 +715,18 @@ linters: # enable-all: true disable-all: true enable: - - typecheck - - asciicheck - - bodyclose - - cyclop - # - depguard - - dogsled - - dupl - - durationcheck - - errcheck - - errorlint - - exhaustive - - exportloopref - # - forbidigo - - funlen - # - gci - # - gochecknoinits - - gocognit - - goconst - - gocyclo - - godot - - godox - - gofmt - - gofumpt - - goheader - - goimports - - gomoddirectives - - gomodguard - - goprintffuncname - - gosec - - gosimple - - govet - - importas - - ineffassign - - lll - - makezero - - misspell - - nakedret - - nestif - - nilerr - - nlreturn - - noctx - - nolintlint - - paralleltest - - prealloc - - predeclared - - promlinter - - revive - - rowserrcheck - - sqlclosecheck - - staticcheck - - stylecheck - - thelper - - tparallel - - unconvert - - unparam - - unused - - wastedassign - - whitespace - - bidichk - - wastedassign - - execinquery - - nosprintfhostport - - grouper - - decorder - - errchkjson - - maintidx - #- containedctx - #- tagliatelle - #- nonamedreturns - #- nilnil - #- tenv - #- varnamelen - #- contextcheck - #- errname - #- ForceTypeAssert - #- nilassign - fast: false + - typecheck # 基本的类型检查 + - gofmt # 格式检查 + - govet # Go 语言的标准检查工具 + - gosimple # 简化代码的建议 + - misspell # 拼写错误 + - staticcheck # 静态检查 + - unused # 未使用的代码检查 + - goimports # 检查导入是否正确排序和格式化 + - godot # 注释句点检查 + - bodyclose # 确保 HTTP response body 被关闭 + - errcheck # 检查是否遗漏了错误返回值 + fast: true issues: # List of regexps of issue texts to exclude, empty list by default. diff --git a/Makefile b/Makefile index 1d01409a5e..1d3544ed62 100644 --- a/Makefile +++ b/Makefile @@ -73,9 +73,9 @@ gen: demo: @$(MAKE) go.demo -## versionchecker: Check version of openim. ✨ -.PHONY: versionchecker -versionchecker: +## version: Check version of openim. ✨ +.PHONY: version +version: @$(MAKE) go.versionchecker ## build: Build binaries by default ✨ @@ -95,7 +95,7 @@ stop: ## restart: Restart openim ✨ .PHONY: restart -restart: clean stop build init start +restart: clean stop build init start check ## multiarch: Build binaries for multiple platforms. See option PLATFORMS. ✨ .PHONY: multiarch diff --git a/README-zh_CN.md b/README-zh_CN.md index 8addfe20ac..f24ee47393 100644 --- a/README-zh_CN.md +++ b/README-zh_CN.md @@ -1,5 +1,5 @@

- +

@@ -23,7 +23,7 @@

English 简体中文 • - Docs + Docs

diff --git a/README.md b/README.md index f58625fb0c..dd0a674d28 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

- +

@@ -24,7 +24,7 @@

English 简体中文 • - Docs + Docs

diff --git a/build/goreleaser.yaml b/build/goreleaser.yaml index d4e28fc2ad..ed7f7cd1b5 100644 --- a/build/goreleaser.yaml +++ b/build/goreleaser.yaml @@ -255,131 +255,6 @@ builds: - "6" - "7" - - binary: infra - id: infra - main: ./tools/infra/infra.go - goos: - - darwin - - windows - - linux - goarch: - - s390x - - mips64 - - mips64le - - amd64 - - ppc64le - - arm64 - goarm: - - "6" - - "7" - - - binary: ncpu - id: ncpu - main: ./tools/ncpu/ncpu.go - goos: - - darwin - - windows - - linux - goarch: - - s390x - - mips64 - - mips64le - - amd64 - - ppc64le - - arm64 - goarm: - - "6" - - "7" - - - binary: openim-web - id: openim-web - main: ./tools/openim-web/openim-web.go - goos: - - darwin - - windows - - linux - goarch: - - s390x - - mips64 - - mips64le - - amd64 - - ppc64le - - arm64 - goarm: - - "6" - - "7" - - - binary: component - id: component - main: ./tools/component/component.go - goos: - - darwin - - windows - - linux - goarch: - - s390x - - mips64 - - mips64le - - amd64 - - ppc64le - - arm64 - goarm: - - "6" - - "7" - - - binary: versionchecker - id: versionchecker - main: ./tools/versionchecker/versionchecker.go - goos: - - darwin - - windows - - linux - goarch: - - s390x - - mips64 - - mips64le - - amd64 - - ppc64le - - arm64 - goarm: - - "6" - - "7" - - - binary: changelog - id: changelog - main: ./tools/changelog/changelog.go - goos: - - darwin - - windows - - linux - goarch: - - s390x - - mips64 - - mips64le - - amd64 - - ppc64le - - arm64 - goarm: - - "6" - - "7" - - - binary: yamlfmt - id: yamlfmt - main: ./tools/yamlfmt/yamlfmt.go - goos: - - darwin - - windows - - linux - goarch: - - s390x - - mips64 - - mips64le - - amd64 - - ppc64le - - arm64 - goarm: - - "6" - - "7" # TODO:Need a script, such as the init - release to help binary to find the right directory # ,which can be compiled binary diff --git a/config/config.yaml b/config/config.yaml index 0f980b4e4c..81da293cb5 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -19,6 +19,9 @@ # --| target: config/config.yaml # ----------------------------------------------------------------- +envs: + discovery: zookeeper + ###################### Zookeeper ###################### # Zookeeper configuration # It's not recommended to modify the schema @@ -26,9 +29,6 @@ # Zookeeper address # Zookeeper username # Zookeeper password -envs: - discovery: zookeeper - zookeeper: schema: openim address: [ 172.28.0.1:12181 ] @@ -168,7 +168,6 @@ rpcPort: openImUserPort: [ 10110 ] openImFriendPort: [ 10120 ] openImMessagePort: [ 10130 ] - openImMessageGatewayPort: [ 10140 ] openImGroupPort: [ 10150 ] openImAuthPort: [ 10160 ] openImPushPort: [ 10170 ] @@ -199,7 +198,7 @@ rpcRegisterName: # Whether to output in json format # Whether to include stack trace in logs log: - storageLocation: ../../logs/ + storageLocation: ../logs/ rotationTime: 24 remainRotationCount: 2 remainLogLevel: 6 @@ -216,8 +215,8 @@ log: # Websocket connection handshake timeout longConnSvr: openImWsPort: [ 10001 ] - openImMessageGatewayPort: [ 10140 ] websocketMaxConnNum: 100000 + openImMessageGatewayPort: [ 10140 ] websocketMaxMsgLen: 4096 websocketTimeout: 10 diff --git a/deployments/README.md b/deployments/README.md index e070d8e1fb..a36ab4cdbe 100644 --- a/deployments/README.md +++ b/deployments/README.md @@ -1,52 +1,48 @@ -# OpenIM 应用容器化部署指南 +# OpenIM Application Containerization Deployment Guide -OpenIM 支持很多种集群化部署方式,包括但不限于 helm, sealos, kubeam, kubesphere, kubeflow, kuboard, kubespray, k3s, k3d, k3c, k3sup, k3v, k3x +OpenIM supports a variety of cluster deployment methods, including but not limited to `helm`, `sealos`, `kustomize` -**目前还在开发这个模块,预计 v3.2.0 之前会有一个集群方案。** +Various contributors, as well as previous official releases, have provided some referenceable solutions: -目前各个贡献者,以及之前的官方有出过一些可以参考的方案: ++ [k8s-jenkins Repository](https://github.com/OpenIMSDK/k8s-jenkins) ++ [open-im-server-k8s-deploy Repository](https://github.com/openimsdk/open-im-server-k8s-deploy) ++ [openim-charts Repository](https://github.com/OpenIMSDK/openim-charts) ++ [deploy-openim Repository](https://github.com/showurl/deploy-openim) -- https://github.com/OpenIMSDK/k8s-jenkins -- https://github.com/openimsdk/open-im-server-k8s-deploy -- https://github.com/OpenIMSDK/openim-charts -- https://github.com/showurl/deploy-openim - - -### 依赖检查 +### Dependency Check ```bash Kubernetes: >= 1.16.0-0 Helm: >= 3.0 ``` +### Minimum Configuration -### 最低配置 - -建议生产环境的最低配置如下: +The recommended minimum configuration for a production environment is as follows: -```bash +```yaml CPU: 4 Memory: 8G Disk: 100G ``` -## 生成配置文件 +## Configuration File Generation -我们将自动文件全部自动化处理了,所以生成配置文件对于 openim 来说是可选的,但是如果你想要自定义配置,可以参考下面的步骤: +We have automated all the files, making the generation of configuration files optional for OpenIM. However, if you desire custom configurations, you can follow the steps below: ```bash $ make init -# 或者是使用脚本: +# Alternatively, use script: # ./scripts/init-config.sh ``` -此时会帮你在 `deployments/openim/config` 目录下生成配置文件,你可以根据自己的需求进行修改。 +At this point, configuration files will be generated under `deployments/openim/config`, which you can modify as per your requirements. -## 集群搭建 +## Cluster Setup -如果你已经有了一个 `kubernetes` 集群,或者是你希望自己从头开始搭建一个 `kubernetes` 那么你可以直接跳过这一步。 +If you already have a `kubernetes` cluster, or if you wish to build a `kubernetes` cluster from scratch, you can skip this step. -为了快速开始,我使用 [sealos](https://github.com/labring/sealos) 来快速搭建集群,sealos 底层也是对 kubeadm 的封装: +For a quick start, I used [sealos](https://github.com/labring/sealos) to rapidly set up the cluster, with sealos also being a wrapper for kubeadm at its core: ```bash $ SEALOS_VERSION=`curl -s https://api.github.com/repos/labring/sealos/releases/latest | grep -oE '"tag_name": "[^"]+"' | head -n1 | cut -d'"' -f4` && \ @@ -54,21 +50,20 @@ $ SEALOS_VERSION=`curl -s https://api.github.com/repos/labring/sealos/releases/l sh -s ${SEALOS_VERSION} labring/sealos ``` -**支持的版本:** +**Supported Versions:** + docker: `labring/kubernetes-docker`:(v1.24.0~v1.27.0) + containerd: `labring/kubernetes`:(v1.24.0~v1.27.0) +#### Cluster Installation: -#### 安装集群: - -集群的信息如下: +Cluster details are as follows: -| 机器名 | IP地址 | 系统信息 | -|---------|-----------------|------------------------------------------------------------------------------------------------------------| -| master01| 10.0.0.9 | Linux VM-0-9-ubuntu 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux | -| node01 | 10.0.0.4 | Linux VM-0-9-ubuntu 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux | -| node02 | 10.0.0.10 | Linux VM-0-9-ubuntu 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux | +| Hostname | IP Address | System Info | +| -------- | ---------- | ------------------------------------------------------------ | +| master01 | 10.0.0.9 | `Linux VM-0-9-ubuntu 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux` | +| node01 | 10.0.0.4 | Similar to master01 | +| node02 | 10.0.0.10 | Similar to master01 | ```bash $ export CLUSTER_USERNAME=ubuntu @@ -80,40 +75,79 @@ $ sudo sealos run labring/kubernetes:v1.25.0 labring/helm:v3.8.2 labring/calico: -p "$CLUSTER_PASSWORD" ``` -> **Node** -> 卸载的方式:使用 `kubeadm` 卸载并不会清除 `etcd` 和 `cni` 相关,所以需要手动清除,或者使用 `sealos` 卸载。 +> **Node** Uninstallation method: using `kubeadm` for uninstallation does not remove `etcd` and `cni` related configurations. Manual clearance or using `sealos` for uninstallation is needed. +> > ```bash -> sealos reset +> $ sealos reset > ``` -### 安装 helm +If you are local, you can also use Kind and Minikube to test, for example, using Kind: -helm通过打包的方式,支持发布的版本管理和控制,很大程度上简化了Kubernetes应用的部署和管理。 +```bash +$ sGO111MODULE="on" go get sigs.k8s.io/kind@v0.11.1 +$ skind create cluster +``` + +### Installing helm +Helm simplifies the deployment and management of Kubernetes applications to a large extent by offering version control and release management through packaging. -**使用脚本:** +**Using Script:** ```bash $ curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash ``` -**添加仓库:** +**Adding Repository:** ```bash $ helm repo add brigade https://openimsdk.github.io/openim-charts ``` -### OpenIM 的镜像策略 +### OpenIM Image Strategy -自动化提供的 aliyun, ghcr, docker hub: https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md +Automated offerings include aliyun, ghcr, docker hub: [Image Documentation](https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md) -**本地化测试构建方法:** +**Local Test Build Method:** ```bash $ make image ``` +> This command assists in quickly building the required images locally. For a detailed build strategy, refer to the [Build Documentation](https://github.com/openimsdk/open-im-server/blob/main/build/README.md). + +## Installation + +Explore our Helm-Charts repository and read through: [Helm-Charts Repository](https://github.com/openimsdk/helm-charts) -### 容器化安装 -具体安装步骤如下: +Using the helm charts repository, you can ignore the following configuration, but if you want to just use the server and scale on top of it, you can go ahead: + +**Use Helmfile:** + +```bash +GO111MODULE=on go get github.com/roboll/helmfile@latest +``` + +```bash +export MYSQL_ADDRESS=im-mysql +export MYSQL_PORT=3306 +export MONGO_ADDRESS=im-mongo +export MONGO_PORT=27017 +export REDIS_ADDRESS=im-redis-master +export REDIS_PORT=6379 +export KAFKA_ADDRESS=im-kafka +export KAFKA_PORT=9092 +export OBJECT_APIURL="https://openim.server.com/api" +export MINIO_ENDPOINT="http://im-minio:9000" +export MINIO_SIGN_ENDPOINT="https://openim.server.com/im-minio-api" + +mkdir ./charts/generated-configs +../scripts/genconfig.sh ../scripts/install/environment.sh ./templates/openim.yaml > ./charts/generated-configs/config.yaml +cp ../config/notification.yaml ./charts/generated-configs/notification.yaml +../scripts/genconfig.sh ../scripts/install/environment.sh ./templates/helm-image.yaml > ./charts/generated-configs/helm-image.yaml +``` + +```bash +helmfile apply +``` \ No newline at end of file diff --git a/deployments/charts/helmfile.yaml b/deployments/charts/helmfile.yaml new file mode 100644 index 0000000000..a6a009257e --- /dev/null +++ b/deployments/charts/helmfile.yaml @@ -0,0 +1,20 @@ +{{- define "defaultValues" -}} +- ./generated-configs/helm-image.yaml +- ./generated-configs/config.yaml +- ./generated-configs/notification.yaml +{{- end -}} + +{{- define "defaultRelease" -}} +namespace: openim +chart: ./{{ .name }} +values: + - ./{{ .name }}/values.yaml + {{- template "defaultValues" . }} +{{- end -}} + +releases: +{{- $apps := list "openim-api" "openim-msggateway" "openim-msgtransfer" "openim-push" "openim-rpc-auth" "openim-rpc-conversation" "openim-rpc-friend" "openim-rpc-group" "openim-rpc-msg" "openim-rpc-third" "openim-rpc-user" }} +{{- range $app := $apps }} + - name: {{ $app }} + {{- template "defaultRelease" dict "name" $app }} +{{- end }} diff --git a/deployments/openim-server/.helmignore b/deployments/charts/openim-api/.helmignore similarity index 100% rename from deployments/openim-server/.helmignore rename to deployments/charts/openim-api/.helmignore diff --git a/deployments/charts/openim-api/Chart.yaml b/deployments/charts/openim-api/Chart.yaml new file mode 100644 index 0000000000..74779b64a8 --- /dev/null +++ b/deployments/charts/openim-api/Chart.yaml @@ -0,0 +1,39 @@ +apiVersion: v2 +name: openim-api +description: A OpenIM Api Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" + +icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg + +maintainers: + - name: "OpenIM" + url: "https://github.com/openimsdk" + +keywords: + - openim + - im + - chat + +sources: + - "https://github.com/openimsdk/open-im-server" + - "https://github.com/openimsdk/helm-charts" \ No newline at end of file diff --git a/deployments/openim-server/LICENSE b/deployments/charts/openim-api/LICENSE similarity index 100% rename from deployments/openim-server/LICENSE rename to deployments/charts/openim-api/LICENSE diff --git a/deployments/openim-server/templates/NOTES.txt b/deployments/charts/openim-api/templates/NOTES.txt similarity index 76% rename from deployments/openim-server/templates/NOTES.txt rename to deployments/charts/openim-api/templates/NOTES.txt index edb391088e..e9ce81bdb6 100644 --- a/deployments/openim-server/templates/NOTES.txt +++ b/deployments/charts/openim-api/templates/NOTES.txt @@ -6,16 +6,16 @@ {{- end }} {{- end }} {{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-server.fullname" . }}) + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-api.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT {{- else if contains "LoadBalancer" .Values.service.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-server.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-server.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-api.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-api.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") echo http://$SERVICE_IP:{{ .Values.service.port }} {{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-server.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-api.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT diff --git a/deployments/openim-server/templates/_helpers.tpl b/deployments/charts/openim-api/templates/_helpers.tpl similarity index 73% rename from deployments/openim-server/templates/_helpers.tpl rename to deployments/charts/openim-api/templates/_helpers.tpl index 79f4ebd6a5..f137492f12 100644 --- a/deployments/openim-server/templates/_helpers.tpl +++ b/deployments/charts/openim-api/templates/_helpers.tpl @@ -1,7 +1,7 @@ {{/* Expand the name of the chart. */}} -{{- define "openim-server.name" -}} +{{- define "openim-api.name" -}} {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} {{- end }} @@ -10,7 +10,7 @@ Create a default fully qualified app name. We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). If release name contains chart name it will be used as a full name. */}} -{{- define "openim-server.fullname" -}} +{{- define "openim-api.fullname" -}} {{- if .Values.fullnameOverride }} {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} {{- else }} @@ -26,16 +26,16 @@ If release name contains chart name it will be used as a full name. {{/* Create chart name and version as used by the chart label. */}} -{{- define "openim-server.chart" -}} +{{- define "openim-api.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} {{- end }} {{/* Common labels */}} -{{- define "openim-server.labels" -}} -helm.sh/chart: {{ include "openim-server.chart" . }} -{{ include "openim-server.selectorLabels" . }} +{{- define "openim-api.labels" -}} +helm.sh/chart: {{ include "openim-api.chart" . }} +{{ include "openim-api.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} @@ -45,17 +45,17 @@ app.kubernetes.io/managed-by: {{ .Release.Service }} {{/* Selector labels */}} -{{- define "openim-server.selectorLabels" -}} -app.kubernetes.io/name: {{ include "openim-server.name" . }} +{{- define "openim-api.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openim-api.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} {{/* Create the name of the service account to use */}} -{{- define "openim-server.serviceAccountName" -}} +{{- define "openim-api.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} -{{- default (include "openim-server.fullname" .) .Values.serviceAccount.name }} +{{- default (include "openim-api.fullname" .) .Values.serviceAccount.name }} {{- else }} {{- default "default" .Values.serviceAccount.name }} {{- end }} diff --git a/deployments/charts/openim-api/templates/app-cm.yaml b/deployments/charts/openim-api/templates/app-cm.yaml new file mode 100644 index 0000000000..7a6f23314f --- /dev/null +++ b/deployments/charts/openim-api/templates/app-cm.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: openim-cm +data: + config.yaml: |+ + {{- with .Values.config }} + {{- toYaml . | nindent 4 }} + {{- end }} + notification.yaml: |+ + {{- with .Values.notification }} + {{- toYaml . | nindent 4 }} + {{- end }} diff --git a/deployments/charts/openim-api/templates/deployment.yaml b/deployments/charts/openim-api/templates/deployment.yaml new file mode 100644 index 0000000000..182d90cdc2 --- /dev/null +++ b/deployments/charts/openim-api/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "openim-api.fullname" . }} + labels: + {{- include "openim-api.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "openim-api.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "openim-api.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "openim-api.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /config/config.yaml + name: config + subPath: config.yaml + - mountPath: /config/notification.yaml + name: config + subPath: notification.yaml + volumes: + - name: config + configMap: + name: openim-cm + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployments/openim-server/templates/hpa.yaml b/deployments/charts/openim-api/templates/hpa.yaml similarity index 50% rename from deployments/openim-server/templates/hpa.yaml rename to deployments/charts/openim-api/templates/hpa.yaml index c7726c969d..0e58481816 100644 --- a/deployments/openim-server/templates/hpa.yaml +++ b/deployments/charts/openim-api/templates/hpa.yaml @@ -1,29 +1,15 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - {{- if .Values.autoscaling.enabled }} apiVersion: autoscaling/v2beta1 kind: HorizontalPodAutoscaler metadata: - name: {{ include "openim-server.fullname" . }} + name: {{ include "openim-api.fullname" . }} labels: - {{- include "openim-server.labels" . | nindent 4 }} + {{- include "openim-api.labels" . | nindent 4 }} spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment - name: {{ include "openim-server.fullname" . }} + name: {{ include "openim-api.fullname" . }} minReplicas: {{ .Values.autoscaling.minReplicas }} maxReplicas: {{ .Values.autoscaling.maxReplicas }} metrics: diff --git a/deployments/openim-server/templates/ingress.yaml b/deployments/charts/openim-api/templates/ingress.yaml similarity index 73% rename from deployments/openim-server/templates/ingress.yaml rename to deployments/charts/openim-api/templates/ingress.yaml index c269ecc26c..62c66c1350 100644 --- a/deployments/openim-server/templates/ingress.yaml +++ b/deployments/charts/openim-api/templates/ingress.yaml @@ -1,19 +1,5 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - {{- if .Values.ingress.enabled -}} -{{- $fullName := include "openim-server.fullname" . -}} +{{- $fullName := include "openim-api.fullname" . -}} {{- $svcPort := .Values.service.port -}} {{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} @@ -31,7 +17,7 @@ kind: Ingress metadata: name: {{ $fullName }} labels: - {{- include "openim-server.labels" . | nindent 4 }} + {{- include "openim-api.labels" . | nindent 4 }} {{- with .Values.ingress.annotations }} annotations: {{- toYaml . | nindent 4 }} diff --git a/deployments/charts/openim-api/templates/service.yaml b/deployments/charts/openim-api/templates/service.yaml new file mode 100644 index 0000000000..eb37fa56c3 --- /dev/null +++ b/deployments/charts/openim-api/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openim-api.fullname" . }} + labels: + {{- include "openim-api.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "openim-api.selectorLabels" . | nindent 4 }} diff --git a/deployments/charts/openim-api/templates/serviceaccount.yaml b/deployments/charts/openim-api/templates/serviceaccount.yaml new file mode 100644 index 0000000000..e3e7b28493 --- /dev/null +++ b/deployments/charts/openim-api/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openim-api.serviceAccountName" . }} + labels: + {{- include "openim-api.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-api/values.yaml b/deployments/charts/openim-api/values.yaml new file mode 100644 index 0000000000..e41fb6e762 --- /dev/null +++ b/deployments/charts/openim-api/values.yaml @@ -0,0 +1,86 @@ +# Default values for openim-api. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/openimsdk/openim-api + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "nginx" + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +notification: + +config: diff --git a/deployments/charts/openim-msggateway/.helmignore b/deployments/charts/openim-msggateway/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/deployments/charts/openim-msggateway/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployments/openim-server/Chart.yaml b/deployments/charts/openim-msggateway/Chart.yaml similarity index 51% rename from deployments/openim-server/Chart.yaml rename to deployments/charts/openim-msggateway/Chart.yaml index 22a95940aa..c8c380bf9f 100644 --- a/deployments/openim-server/Chart.yaml +++ b/deployments/charts/openim-msggateway/Chart.yaml @@ -1,19 +1,5 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - apiVersion: v2 -name: openim-server +name: openim-msggateway description: A Helm chart for Kubernetes # A chart can be either an 'application' or a 'library' chart. @@ -35,7 +21,7 @@ version: 0.1.0 # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "default" +appVersion: "1.16.0" icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg @@ -50,25 +36,4 @@ keywords: sources: - "https://github.com/openimsdk/open-im-server" - - "https://github.com/openimsdk/openim-sdk-core" - - "https://github.com/openimsdk/openim-docker" - -dependencies: - - name: mysql - version: 8.0.25 - repository: https://charts.bitnami.com/bitnami - - name: redis - version: 14.6.1 - repository: https://charts.bitnami.com/bitnami - - name: mongodb - version: 10.1.0 - repository: https://charts.bitnami.com/bitnami - - name: kafka - version: 14.1.0 - repository: https://charts.bitnami.com/bitnami - - name: minio - version: 8.1.2 - repository: https://charts.bitnami.com/bitnami - - name: zookeeper - version: 5.17.0 - repository: https://charts.bitnami.com/bitnami \ No newline at end of file + - "https://github.com/openimsdk/helm-charts" \ No newline at end of file diff --git a/deployments/charts/openim-msggateway/templates/NOTES.txt b/deployments/charts/openim-msggateway/templates/NOTES.txt new file mode 100644 index 0000000000..c1f032586f --- /dev/null +++ b/deployments/charts/openim-msggateway/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-msggateway.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-msggateway.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-msggateway.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-msggateway.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deployments/charts/openim-msggateway/templates/_helpers.tpl b/deployments/charts/openim-msggateway/templates/_helpers.tpl new file mode 100644 index 0000000000..c902a1b300 --- /dev/null +++ b/deployments/charts/openim-msggateway/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "openim-msggateway.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "openim-msggateway.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "openim-msggateway.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "openim-msggateway.labels" -}} +helm.sh/chart: {{ include "openim-msggateway.chart" . }} +{{ include "openim-msggateway.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "openim-msggateway.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openim-msggateway.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "openim-msggateway.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "openim-msggateway.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/charts/openim-msggateway/templates/deployment.yaml b/deployments/charts/openim-msggateway/templates/deployment.yaml new file mode 100644 index 0000000000..bc2f45a332 --- /dev/null +++ b/deployments/charts/openim-msggateway/templates/deployment.yaml @@ -0,0 +1,75 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "openim-msggateway.fullname" . }} + labels: + {{- include "openim-msggateway.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "openim-msggateway.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "openim-msggateway.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "openim-msggateway.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + - name: rpc + containerPort: 88 + protocol: TCP + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /config/config.yaml + name: config + subPath: config.yaml + - mountPath: /config/notification.yaml + name: config + subPath: notification.yaml + volumes: + - name: config + configMap: + name: openim-cm + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployments/charts/openim-msggateway/templates/hpa.yaml b/deployments/charts/openim-msggateway/templates/hpa.yaml new file mode 100644 index 0000000000..e1fbe50a6d --- /dev/null +++ b/deployments/charts/openim-msggateway/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "openim-msggateway.fullname" . }} + labels: + {{- include "openim-msggateway.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "openim-msggateway.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-msggateway/templates/ingress.yaml b/deployments/charts/openim-msggateway/templates/ingress.yaml new file mode 100644 index 0000000000..5c1c240781 --- /dev/null +++ b/deployments/charts/openim-msggateway/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "openim-msggateway.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "openim-msggateway.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-msggateway/templates/service.yaml b/deployments/charts/openim-msggateway/templates/service.yaml new file mode 100644 index 0000000000..2ed58a8699 --- /dev/null +++ b/deployments/charts/openim-msggateway/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openim-msggateway.fullname" . }} + labels: + {{- include "openim-msggateway.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + - port: 88 + targetPort: rpc + protocol: TCP + name: rpc + selector: + {{- include "openim-msggateway.selectorLabels" . | nindent 4 }} diff --git a/deployments/charts/openim-msggateway/templates/serviceaccount.yaml b/deployments/charts/openim-msggateway/templates/serviceaccount.yaml new file mode 100644 index 0000000000..6b47c12c59 --- /dev/null +++ b/deployments/charts/openim-msggateway/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openim-msggateway.serviceAccountName" . }} + labels: + {{- include "openim-msggateway.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-msggateway/values.yaml b/deployments/charts/openim-msggateway/values.yaml new file mode 100644 index 0000000000..d82c674fc4 --- /dev/null +++ b/deployments/charts/openim-msggateway/values.yaml @@ -0,0 +1,82 @@ +# Default values for openim-msggateway. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/openimsdk/openim-msggateway + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "nginx" + annotations: + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deployments/charts/openim-msgtransfer/.helmignore b/deployments/charts/openim-msgtransfer/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/deployments/charts/openim-msgtransfer/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployments/charts/openim-msgtransfer/Chart.yaml b/deployments/charts/openim-msgtransfer/Chart.yaml new file mode 100644 index 0000000000..bba7a047fe --- /dev/null +++ b/deployments/charts/openim-msgtransfer/Chart.yaml @@ -0,0 +1,39 @@ +apiVersion: v2 +name: openim-msgtransfer +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" + +icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg + +maintainers: + - name: "OpenIM" + url: "https://github.com/openimsdk" + +keywords: + - openim + - im + - chat + +sources: + - "https://github.com/openimsdk/open-im-server" + - "https://github.com/openimsdk/helm-charts" \ No newline at end of file diff --git a/deployments/charts/openim-msgtransfer/templates/NOTES.txt b/deployments/charts/openim-msgtransfer/templates/NOTES.txt new file mode 100644 index 0000000000..a9876065d7 --- /dev/null +++ b/deployments/charts/openim-msgtransfer/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-msgtransfer.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-msgtransfer.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-msgtransfer.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-msgtransfer.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deployments/charts/openim-msgtransfer/templates/_helpers.tpl b/deployments/charts/openim-msgtransfer/templates/_helpers.tpl new file mode 100644 index 0000000000..39f7a9acf1 --- /dev/null +++ b/deployments/charts/openim-msgtransfer/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "openim-msgtransfer.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "openim-msgtransfer.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "openim-msgtransfer.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "openim-msgtransfer.labels" -}} +helm.sh/chart: {{ include "openim-msgtransfer.chart" . }} +{{ include "openim-msgtransfer.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "openim-msgtransfer.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openim-msgtransfer.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "openim-msgtransfer.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "openim-msgtransfer.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/charts/openim-msgtransfer/templates/deployment.yaml b/deployments/charts/openim-msgtransfer/templates/deployment.yaml new file mode 100644 index 0000000000..b63b74dc4b --- /dev/null +++ b/deployments/charts/openim-msgtransfer/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "openim-msgtransfer.fullname" . }} + labels: + {{- include "openim-msgtransfer.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "openim-msgtransfer.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "openim-msgtransfer.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "openim-msgtransfer.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /config/config.yaml + name: config + subPath: config.yaml + - mountPath: /config/notification.yaml + name: config + subPath: notification.yaml + volumes: + - name: config + configMap: + name: openim-cm + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployments/charts/openim-msgtransfer/templates/hpa.yaml b/deployments/charts/openim-msgtransfer/templates/hpa.yaml new file mode 100644 index 0000000000..75c7d4fef6 --- /dev/null +++ b/deployments/charts/openim-msgtransfer/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "openim-msgtransfer.fullname" . }} + labels: + {{- include "openim-msgtransfer.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "openim-msgtransfer.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-msgtransfer/templates/ingress.yaml b/deployments/charts/openim-msgtransfer/templates/ingress.yaml new file mode 100644 index 0000000000..c9968a438b --- /dev/null +++ b/deployments/charts/openim-msgtransfer/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "openim-msgtransfer.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "openim-msgtransfer.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-msgtransfer/templates/service.yaml b/deployments/charts/openim-msgtransfer/templates/service.yaml new file mode 100644 index 0000000000..839e520e52 --- /dev/null +++ b/deployments/charts/openim-msgtransfer/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openim-msgtransfer.fullname" . }} + labels: + {{- include "openim-msgtransfer.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "openim-msgtransfer.selectorLabels" . | nindent 4 }} diff --git a/deployments/charts/openim-msgtransfer/templates/serviceaccount.yaml b/deployments/charts/openim-msgtransfer/templates/serviceaccount.yaml new file mode 100644 index 0000000000..2e3ca4ee78 --- /dev/null +++ b/deployments/charts/openim-msgtransfer/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openim-msgtransfer.serviceAccountName" . }} + labels: + {{- include "openim-msgtransfer.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/openim-server/values.yaml b/deployments/charts/openim-msgtransfer/values.yaml similarity index 73% rename from deployments/openim-server/values.yaml rename to deployments/charts/openim-msgtransfer/values.yaml index 99bddb99b2..d4a792d172 100644 --- a/deployments/openim-server/values.yaml +++ b/deployments/charts/openim-msgtransfer/values.yaml @@ -1,25 +1,11 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Default values for openim-server. +# Default values for openim-msgtransfer. # This is a YAML-formatted file. # Declare variables to be passed into your templates. replicaCount: 1 image: - repository: nginx + repository: ghcr.io/openimsdk/openim-msgtransfer pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "" @@ -30,7 +16,7 @@ fullnameOverride: "" serviceAccount: # Specifies whether a service account should be created - create: true + create: false # Annotations to add to the service account annotations: {} # The name of the service account to use. diff --git a/deployments/charts/openim-push/.helmignore b/deployments/charts/openim-push/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/deployments/charts/openim-push/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployments/charts/openim-push/Chart.yaml b/deployments/charts/openim-push/Chart.yaml new file mode 100644 index 0000000000..93e134879f --- /dev/null +++ b/deployments/charts/openim-push/Chart.yaml @@ -0,0 +1,39 @@ +apiVersion: v2 +name: openim-push +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" + +icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg + +maintainers: + - name: "OpenIM" + url: "https://github.com/openimsdk" + +keywords: + - openim + - im + - chat + +sources: + - "https://github.com/openimsdk/open-im-server" + - "https://github.com/openimsdk/helm-charts" diff --git a/deployments/charts/openim-push/templates/NOTES.txt b/deployments/charts/openim-push/templates/NOTES.txt new file mode 100644 index 0000000000..625c390509 --- /dev/null +++ b/deployments/charts/openim-push/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-push.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-push.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-push.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-push.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deployments/charts/openim-push/templates/_helpers.tpl b/deployments/charts/openim-push/templates/_helpers.tpl new file mode 100644 index 0000000000..0504284719 --- /dev/null +++ b/deployments/charts/openim-push/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "openim-push.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "openim-push.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "openim-push.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "openim-push.labels" -}} +helm.sh/chart: {{ include "openim-push.chart" . }} +{{ include "openim-push.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "openim-push.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openim-push.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "openim-push.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "openim-push.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/charts/openim-push/templates/deployment.yaml b/deployments/charts/openim-push/templates/deployment.yaml new file mode 100644 index 0000000000..4a646ba0e4 --- /dev/null +++ b/deployments/charts/openim-push/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "openim-push.fullname" . }} + labels: + {{- include "openim-push.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "openim-push.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "openim-push.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "openim-push.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /config/config.yaml + name: config + subPath: config.yaml + - mountPath: /config/notification.yaml + name: config + subPath: notification.yaml + volumes: + - name: config + configMap: + name: openim-cm + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployments/charts/openim-push/templates/hpa.yaml b/deployments/charts/openim-push/templates/hpa.yaml new file mode 100644 index 0000000000..89c89c0416 --- /dev/null +++ b/deployments/charts/openim-push/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "openim-push.fullname" . }} + labels: + {{- include "openim-push.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "openim-push.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-push/templates/ingress.yaml b/deployments/charts/openim-push/templates/ingress.yaml new file mode 100644 index 0000000000..b00fda3d3a --- /dev/null +++ b/deployments/charts/openim-push/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "openim-push.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "openim-push.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-push/templates/service.yaml b/deployments/charts/openim-push/templates/service.yaml new file mode 100644 index 0000000000..4d8bb0457d --- /dev/null +++ b/deployments/charts/openim-push/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openim-push.fullname" . }} + labels: + {{- include "openim-push.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "openim-push.selectorLabels" . | nindent 4 }} diff --git a/deployments/charts/openim-push/templates/serviceaccount.yaml b/deployments/charts/openim-push/templates/serviceaccount.yaml new file mode 100644 index 0000000000..e221157241 --- /dev/null +++ b/deployments/charts/openim-push/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openim-push.serviceAccountName" . }} + labels: + {{- include "openim-push.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-push/values.yaml b/deployments/charts/openim-push/values.yaml new file mode 100644 index 0000000000..dd6f0faf66 --- /dev/null +++ b/deployments/charts/openim-push/values.yaml @@ -0,0 +1,82 @@ +# Default values for openim-push. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/openimsdk/openim-push + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deployments/charts/openim-rpc-auth/.helmignore b/deployments/charts/openim-rpc-auth/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/deployments/charts/openim-rpc-auth/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployments/charts/openim-rpc-auth/Chart.yaml b/deployments/charts/openim-rpc-auth/Chart.yaml new file mode 100644 index 0000000000..97848dbf23 --- /dev/null +++ b/deployments/charts/openim-rpc-auth/Chart.yaml @@ -0,0 +1,39 @@ +apiVersion: v2 +name: openim-rpc-auth +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" + +icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg + +maintainers: + - name: "OpenIM" + url: "https://github.com/openimsdk" + +keywords: + - openim + - im + - chat + +sources: + - "https://github.com/openimsdk/open-im-server" + - "https://github.com/openimsdk/helm-charts" \ No newline at end of file diff --git a/deployments/charts/openim-rpc-auth/templates/NOTES.txt b/deployments/charts/openim-rpc-auth/templates/NOTES.txt new file mode 100644 index 0000000000..220602077f --- /dev/null +++ b/deployments/charts/openim-rpc-auth/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-auth.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-auth.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-auth.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-auth.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deployments/charts/openim-rpc-auth/templates/_helpers.tpl b/deployments/charts/openim-rpc-auth/templates/_helpers.tpl new file mode 100644 index 0000000000..cb65758726 --- /dev/null +++ b/deployments/charts/openim-rpc-auth/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "openim-rpc-auth.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "openim-rpc-auth.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "openim-rpc-auth.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "openim-rpc-auth.labels" -}} +helm.sh/chart: {{ include "openim-rpc-auth.chart" . }} +{{ include "openim-rpc-auth.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "openim-rpc-auth.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openim-rpc-auth.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "openim-rpc-auth.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "openim-rpc-auth.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/openim-server/templates/deployment.yaml b/deployments/charts/openim-rpc-auth/templates/deployment.yaml similarity index 55% rename from deployments/openim-server/templates/deployment.yaml rename to deployments/charts/openim-rpc-auth/templates/deployment.yaml index 9c630e89a0..a5df44eada 100644 --- a/deployments/openim-server/templates/deployment.yaml +++ b/deployments/charts/openim-rpc-auth/templates/deployment.yaml @@ -1,30 +1,16 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "openim-server.fullname" . }} + name: {{ include "openim-rpc-auth.fullname" . }} labels: - {{- include "openim-server.labels" . | nindent 4 }} + {{- include "openim-rpc-auth.labels" . | nindent 4 }} spec: {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} {{- end }} selector: matchLabels: - {{- include "openim-server.selectorLabels" . | nindent 6 }} + {{- include "openim-rpc-auth.selectorLabels" . | nindent 6 }} template: metadata: {{- with .Values.podAnnotations }} @@ -32,13 +18,13 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "openim-server.selectorLabels" . | nindent 8 }} + {{- include "openim-rpc-auth.selectorLabels" . | nindent 8 }} spec: {{- with .Values.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} - serviceAccountName: {{ include "openim-server.serviceAccountName" . }} + serviceAccountName: {{ include "openim-rpc-auth.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} containers: @@ -51,16 +37,27 @@ spec: - name: http containerPort: 80 protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http resources: {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /config/config.yaml + name: config + subPath: config.yaml + - mountPath: /config/notification.yaml + name: config + subPath: notification.yaml + volumes: + - name: config + configMap: + name: openim-cm {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/deployments/charts/openim-rpc-auth/templates/hpa.yaml b/deployments/charts/openim-rpc-auth/templates/hpa.yaml new file mode 100644 index 0000000000..20108afbf0 --- /dev/null +++ b/deployments/charts/openim-rpc-auth/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "openim-rpc-auth.fullname" . }} + labels: + {{- include "openim-rpc-auth.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "openim-rpc-auth.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-auth/templates/ingress.yaml b/deployments/charts/openim-rpc-auth/templates/ingress.yaml new file mode 100644 index 0000000000..f14458c527 --- /dev/null +++ b/deployments/charts/openim-rpc-auth/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "openim-rpc-auth.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "openim-rpc-auth.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-auth/templates/service.yaml b/deployments/charts/openim-rpc-auth/templates/service.yaml new file mode 100644 index 0000000000..ef7b00b86a --- /dev/null +++ b/deployments/charts/openim-rpc-auth/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openim-rpc-auth.fullname" . }} + labels: + {{- include "openim-rpc-auth.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "openim-rpc-auth.selectorLabels" . | nindent 4 }} diff --git a/deployments/charts/openim-rpc-auth/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-auth/templates/serviceaccount.yaml new file mode 100644 index 0000000000..f13dcca817 --- /dev/null +++ b/deployments/charts/openim-rpc-auth/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openim-rpc-auth.serviceAccountName" . }} + labels: + {{- include "openim-rpc-auth.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-auth/values.yaml b/deployments/charts/openim-rpc-auth/values.yaml new file mode 100644 index 0000000000..a6db6716c5 --- /dev/null +++ b/deployments/charts/openim-rpc-auth/values.yaml @@ -0,0 +1,82 @@ +# Default values for openim-rpc-auth. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/openimsdk/openim-rpc-auth + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deployments/charts/openim-rpc-conversation/.helmignore b/deployments/charts/openim-rpc-conversation/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/deployments/charts/openim-rpc-conversation/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployments/charts/openim-rpc-conversation/Chart.yaml b/deployments/charts/openim-rpc-conversation/Chart.yaml new file mode 100644 index 0000000000..090d631279 --- /dev/null +++ b/deployments/charts/openim-rpc-conversation/Chart.yaml @@ -0,0 +1,39 @@ +apiVersion: v2 +name: openim-rpc-conversation +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" + +icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg + +maintainers: + - name: "OpenIM" + url: "https://github.com/openimsdk" + +keywords: + - openim + - im + - chat + +sources: + - "https://github.com/openimsdk/open-im-server" + - "https://github.com/openimsdk/helm-charts" diff --git a/deployments/charts/openim-rpc-conversation/templates/NOTES.txt b/deployments/charts/openim-rpc-conversation/templates/NOTES.txt new file mode 100644 index 0000000000..287f2fd640 --- /dev/null +++ b/deployments/charts/openim-rpc-conversation/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-conversation.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-conversation.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-conversation.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-conversation.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deployments/charts/openim-rpc-conversation/templates/_helpers.tpl b/deployments/charts/openim-rpc-conversation/templates/_helpers.tpl new file mode 100644 index 0000000000..184271057e --- /dev/null +++ b/deployments/charts/openim-rpc-conversation/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "openim-rpc-conversation.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "openim-rpc-conversation.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "openim-rpc-conversation.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "openim-rpc-conversation.labels" -}} +helm.sh/chart: {{ include "openim-rpc-conversation.chart" . }} +{{ include "openim-rpc-conversation.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "openim-rpc-conversation.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openim-rpc-conversation.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "openim-rpc-conversation.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "openim-rpc-conversation.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-conversation/templates/deployment.yaml b/deployments/charts/openim-rpc-conversation/templates/deployment.yaml new file mode 100644 index 0000000000..5cc8dc2aa8 --- /dev/null +++ b/deployments/charts/openim-rpc-conversation/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "openim-rpc-conversation.fullname" . }} + labels: + {{- include "openim-rpc-conversation.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "openim-rpc-conversation.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "openim-rpc-conversation.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "openim-rpc-conversation.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /config/config.yaml + name: config + subPath: config.yaml + - mountPath: /config/notification.yaml + name: config + subPath: notification.yaml + volumes: + - name: config + configMap: + name: openim-cm + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployments/charts/openim-rpc-conversation/templates/hpa.yaml b/deployments/charts/openim-rpc-conversation/templates/hpa.yaml new file mode 100644 index 0000000000..a2378bfa0c --- /dev/null +++ b/deployments/charts/openim-rpc-conversation/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "openim-rpc-conversation.fullname" . }} + labels: + {{- include "openim-rpc-conversation.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "openim-rpc-conversation.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-conversation/templates/ingress.yaml b/deployments/charts/openim-rpc-conversation/templates/ingress.yaml new file mode 100644 index 0000000000..224591f67d --- /dev/null +++ b/deployments/charts/openim-rpc-conversation/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "openim-rpc-conversation.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "openim-rpc-conversation.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-conversation/templates/service.yaml b/deployments/charts/openim-rpc-conversation/templates/service.yaml new file mode 100644 index 0000000000..be8355154f --- /dev/null +++ b/deployments/charts/openim-rpc-conversation/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openim-rpc-conversation.fullname" . }} + labels: + {{- include "openim-rpc-conversation.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "openim-rpc-conversation.selectorLabels" . | nindent 4 }} diff --git a/deployments/charts/openim-rpc-conversation/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-conversation/templates/serviceaccount.yaml new file mode 100644 index 0000000000..4e2d0e29f7 --- /dev/null +++ b/deployments/charts/openim-rpc-conversation/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openim-rpc-conversation.serviceAccountName" . }} + labels: + {{- include "openim-rpc-conversation.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-conversation/values.yaml b/deployments/charts/openim-rpc-conversation/values.yaml new file mode 100644 index 0000000000..1b3e1e3de4 --- /dev/null +++ b/deployments/charts/openim-rpc-conversation/values.yaml @@ -0,0 +1,82 @@ +# Default values for openim-rpc-conversation. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/openimsdk/openim-rpc-conversation + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deployments/charts/openim-rpc-friend/.helmignore b/deployments/charts/openim-rpc-friend/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/deployments/charts/openim-rpc-friend/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployments/charts/openim-rpc-friend/Chart.yaml b/deployments/charts/openim-rpc-friend/Chart.yaml new file mode 100644 index 0000000000..d7e4a9fef0 --- /dev/null +++ b/deployments/charts/openim-rpc-friend/Chart.yaml @@ -0,0 +1,39 @@ +apiVersion: v2 +name: openim-rpc-friend +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" + +icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg + +maintainers: + - name: "OpenIM" + url: "https://github.com/openimsdk" + +keywords: + - openim + - im + - chat + +sources: + - "https://github.com/openimsdk/open-im-server" + - "https://github.com/openimsdk/helm-charts" diff --git a/deployments/charts/openim-rpc-friend/templates/NOTES.txt b/deployments/charts/openim-rpc-friend/templates/NOTES.txt new file mode 100644 index 0000000000..004ee5c5ec --- /dev/null +++ b/deployments/charts/openim-rpc-friend/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-friend.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-friend.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-friend.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-friend.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deployments/charts/openim-rpc-friend/templates/_helpers.tpl b/deployments/charts/openim-rpc-friend/templates/_helpers.tpl new file mode 100644 index 0000000000..83719fb314 --- /dev/null +++ b/deployments/charts/openim-rpc-friend/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "openim-rpc-friend.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "openim-rpc-friend.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "openim-rpc-friend.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "openim-rpc-friend.labels" -}} +helm.sh/chart: {{ include "openim-rpc-friend.chart" . }} +{{ include "openim-rpc-friend.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "openim-rpc-friend.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openim-rpc-friend.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "openim-rpc-friend.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "openim-rpc-friend.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-friend/templates/deployment.yaml b/deployments/charts/openim-rpc-friend/templates/deployment.yaml new file mode 100644 index 0000000000..a99d541dd9 --- /dev/null +++ b/deployments/charts/openim-rpc-friend/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "openim-rpc-friend.fullname" . }} + labels: + {{- include "openim-rpc-friend.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "openim-rpc-friend.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "openim-rpc-friend.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "openim-rpc-friend.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /config/config.yaml + name: config + subPath: config.yaml + - mountPath: /config/notification.yaml + name: config + subPath: notification.yaml + volumes: + - name: config + configMap: + name: openim-cm + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployments/charts/openim-rpc-friend/templates/hpa.yaml b/deployments/charts/openim-rpc-friend/templates/hpa.yaml new file mode 100644 index 0000000000..7c4f14b7c2 --- /dev/null +++ b/deployments/charts/openim-rpc-friend/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "openim-rpc-friend.fullname" . }} + labels: + {{- include "openim-rpc-friend.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "openim-rpc-friend.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-friend/templates/ingress.yaml b/deployments/charts/openim-rpc-friend/templates/ingress.yaml new file mode 100644 index 0000000000..b5d4117431 --- /dev/null +++ b/deployments/charts/openim-rpc-friend/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "openim-rpc-friend.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "openim-rpc-friend.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-friend/templates/service.yaml b/deployments/charts/openim-rpc-friend/templates/service.yaml new file mode 100644 index 0000000000..792592d87c --- /dev/null +++ b/deployments/charts/openim-rpc-friend/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openim-rpc-friend.fullname" . }} + labels: + {{- include "openim-rpc-friend.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "openim-rpc-friend.selectorLabels" . | nindent 4 }} diff --git a/deployments/charts/openim-rpc-friend/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-friend/templates/serviceaccount.yaml new file mode 100644 index 0000000000..c81343f6be --- /dev/null +++ b/deployments/charts/openim-rpc-friend/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openim-rpc-friend.serviceAccountName" . }} + labels: + {{- include "openim-rpc-friend.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-friend/values.yaml b/deployments/charts/openim-rpc-friend/values.yaml new file mode 100644 index 0000000000..041665a811 --- /dev/null +++ b/deployments/charts/openim-rpc-friend/values.yaml @@ -0,0 +1,82 @@ +# Default values for openim-rpc-friend. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/openimsdk/openim-rpc-friend + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deployments/charts/openim-rpc-group/.helmignore b/deployments/charts/openim-rpc-group/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/deployments/charts/openim-rpc-group/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployments/charts/openim-rpc-group/Chart.yaml b/deployments/charts/openim-rpc-group/Chart.yaml new file mode 100644 index 0000000000..8e037caea7 --- /dev/null +++ b/deployments/charts/openim-rpc-group/Chart.yaml @@ -0,0 +1,39 @@ +apiVersion: v2 +name: openim-rpc-group +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" + +icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg + +maintainers: + - name: "OpenIM" + url: "https://github.com/openimsdk" + +keywords: + - openim + - im + - chat + +sources: + - "https://github.com/openimsdk/open-im-server" + - "https://github.com/openimsdk/helm-charts" \ No newline at end of file diff --git a/deployments/charts/openim-rpc-group/templates/NOTES.txt b/deployments/charts/openim-rpc-group/templates/NOTES.txt new file mode 100644 index 0000000000..0cc117a490 --- /dev/null +++ b/deployments/charts/openim-rpc-group/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-group.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-group.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-group.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-group.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deployments/charts/openim-rpc-group/templates/_helpers.tpl b/deployments/charts/openim-rpc-group/templates/_helpers.tpl new file mode 100644 index 0000000000..7835b84e1d --- /dev/null +++ b/deployments/charts/openim-rpc-group/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "openim-rpc-group.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "openim-rpc-group.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "openim-rpc-group.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "openim-rpc-group.labels" -}} +helm.sh/chart: {{ include "openim-rpc-group.chart" . }} +{{ include "openim-rpc-group.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "openim-rpc-group.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openim-rpc-group.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "openim-rpc-group.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "openim-rpc-group.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-group/templates/deployment.yaml b/deployments/charts/openim-rpc-group/templates/deployment.yaml new file mode 100644 index 0000000000..872c49ccbd --- /dev/null +++ b/deployments/charts/openim-rpc-group/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "openim-rpc-group.fullname" . }} + labels: + {{- include "openim-rpc-group.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "openim-rpc-group.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "openim-rpc-group.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "openim-rpc-group.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /config/config.yaml + name: config + subPath: config.yaml + - mountPath: /config/notification.yaml + name: config + subPath: notification.yaml + volumes: + - name: config + configMap: + name: openim-cm + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployments/charts/openim-rpc-group/templates/hpa.yaml b/deployments/charts/openim-rpc-group/templates/hpa.yaml new file mode 100644 index 0000000000..0ba0e8283a --- /dev/null +++ b/deployments/charts/openim-rpc-group/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "openim-rpc-group.fullname" . }} + labels: + {{- include "openim-rpc-group.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "openim-rpc-group.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-group/templates/ingress.yaml b/deployments/charts/openim-rpc-group/templates/ingress.yaml new file mode 100644 index 0000000000..6a744f914d --- /dev/null +++ b/deployments/charts/openim-rpc-group/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "openim-rpc-group.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "openim-rpc-group.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-group/templates/service.yaml b/deployments/charts/openim-rpc-group/templates/service.yaml new file mode 100644 index 0000000000..aa16f71b97 --- /dev/null +++ b/deployments/charts/openim-rpc-group/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openim-rpc-group.fullname" . }} + labels: + {{- include "openim-rpc-group.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "openim-rpc-group.selectorLabels" . | nindent 4 }} diff --git a/deployments/charts/openim-rpc-group/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-group/templates/serviceaccount.yaml new file mode 100644 index 0000000000..b42dfb13bb --- /dev/null +++ b/deployments/charts/openim-rpc-group/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openim-rpc-group.serviceAccountName" . }} + labels: + {{- include "openim-rpc-group.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-group/values.yaml b/deployments/charts/openim-rpc-group/values.yaml new file mode 100644 index 0000000000..ec36e256ff --- /dev/null +++ b/deployments/charts/openim-rpc-group/values.yaml @@ -0,0 +1,82 @@ +# Default values for openim-rpc-group. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/openimsdk/openim-rpc-group + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deployments/charts/openim-rpc-msg/.helmignore b/deployments/charts/openim-rpc-msg/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/deployments/charts/openim-rpc-msg/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployments/charts/openim-rpc-msg/Chart.yaml b/deployments/charts/openim-rpc-msg/Chart.yaml new file mode 100644 index 0000000000..6597674842 --- /dev/null +++ b/deployments/charts/openim-rpc-msg/Chart.yaml @@ -0,0 +1,39 @@ +apiVersion: v2 +name: openim-rpc-msg +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" + +icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg + +maintainers: + - name: "OpenIM" + url: "https://github.com/openimsdk" + +keywords: + - openim + - im + - chat + +sources: + - "https://github.com/openimsdk/open-im-server" + - "https://github.com/openimsdk/helm-charts" \ No newline at end of file diff --git a/deployments/charts/openim-rpc-msg/templates/NOTES.txt b/deployments/charts/openim-rpc-msg/templates/NOTES.txt new file mode 100644 index 0000000000..65033b1075 --- /dev/null +++ b/deployments/charts/openim-rpc-msg/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-msg.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-msg.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-msg.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-msg.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deployments/charts/openim-rpc-msg/templates/_helpers.tpl b/deployments/charts/openim-rpc-msg/templates/_helpers.tpl new file mode 100644 index 0000000000..da69568222 --- /dev/null +++ b/deployments/charts/openim-rpc-msg/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "openim-rpc-msg.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "openim-rpc-msg.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "openim-rpc-msg.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "openim-rpc-msg.labels" -}} +helm.sh/chart: {{ include "openim-rpc-msg.chart" . }} +{{ include "openim-rpc-msg.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "openim-rpc-msg.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openim-rpc-msg.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "openim-rpc-msg.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "openim-rpc-msg.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-msg/templates/deployment.yaml b/deployments/charts/openim-rpc-msg/templates/deployment.yaml new file mode 100644 index 0000000000..a4da7e2b4a --- /dev/null +++ b/deployments/charts/openim-rpc-msg/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "openim-rpc-msg.fullname" . }} + labels: + {{- include "openim-rpc-msg.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "openim-rpc-msg.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "openim-rpc-msg.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "openim-rpc-msg.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /config/config.yaml + name: config + subPath: config.yaml + - mountPath: /config/notification.yaml + name: config + subPath: notification.yaml + volumes: + - name: config + configMap: + name: openim-cm + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployments/charts/openim-rpc-msg/templates/hpa.yaml b/deployments/charts/openim-rpc-msg/templates/hpa.yaml new file mode 100644 index 0000000000..c01e07294d --- /dev/null +++ b/deployments/charts/openim-rpc-msg/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "openim-rpc-msg.fullname" . }} + labels: + {{- include "openim-rpc-msg.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "openim-rpc-msg.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-msg/templates/ingress.yaml b/deployments/charts/openim-rpc-msg/templates/ingress.yaml new file mode 100644 index 0000000000..2f5ad9d155 --- /dev/null +++ b/deployments/charts/openim-rpc-msg/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "openim-rpc-msg.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "openim-rpc-msg.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-msg/templates/service.yaml b/deployments/charts/openim-rpc-msg/templates/service.yaml new file mode 100644 index 0000000000..9afd55a8c7 --- /dev/null +++ b/deployments/charts/openim-rpc-msg/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openim-rpc-msg.fullname" . }} + labels: + {{- include "openim-rpc-msg.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "openim-rpc-msg.selectorLabels" . | nindent 4 }} diff --git a/deployments/charts/openim-rpc-msg/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-msg/templates/serviceaccount.yaml new file mode 100644 index 0000000000..da69e5ce85 --- /dev/null +++ b/deployments/charts/openim-rpc-msg/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openim-rpc-msg.serviceAccountName" . }} + labels: + {{- include "openim-rpc-msg.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-msg/values.yaml b/deployments/charts/openim-rpc-msg/values.yaml new file mode 100644 index 0000000000..22cfd61f17 --- /dev/null +++ b/deployments/charts/openim-rpc-msg/values.yaml @@ -0,0 +1,82 @@ +# Default values for openim-rpc-msg. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/openimsdk/openim-rpc-msg + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deployments/charts/openim-rpc-third/.helmignore b/deployments/charts/openim-rpc-third/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/deployments/charts/openim-rpc-third/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployments/charts/openim-rpc-third/Chart.yaml b/deployments/charts/openim-rpc-third/Chart.yaml new file mode 100644 index 0000000000..d7763d70af --- /dev/null +++ b/deployments/charts/openim-rpc-third/Chart.yaml @@ -0,0 +1,39 @@ +apiVersion: v2 +name: openim-rpc-third +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" + +icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg + +maintainers: + - name: "OpenIM" + url: "https://github.com/openimsdk" + +keywords: + - openim + - im + - chat + +sources: + - "https://github.com/openimsdk/open-im-server" + - "https://github.com/openimsdk/helm-charts" \ No newline at end of file diff --git a/deployments/charts/openim-rpc-third/templates/NOTES.txt b/deployments/charts/openim-rpc-third/templates/NOTES.txt new file mode 100644 index 0000000000..a2228c84d9 --- /dev/null +++ b/deployments/charts/openim-rpc-third/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-third.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-third.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-third.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-third.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deployments/charts/openim-rpc-third/templates/_helpers.tpl b/deployments/charts/openim-rpc-third/templates/_helpers.tpl new file mode 100644 index 0000000000..46039ce2ce --- /dev/null +++ b/deployments/charts/openim-rpc-third/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "openim-rpc-third.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "openim-rpc-third.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "openim-rpc-third.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "openim-rpc-third.labels" -}} +helm.sh/chart: {{ include "openim-rpc-third.chart" . }} +{{ include "openim-rpc-third.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "openim-rpc-third.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openim-rpc-third.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "openim-rpc-third.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "openim-rpc-third.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-third/templates/deployment.yaml b/deployments/charts/openim-rpc-third/templates/deployment.yaml new file mode 100644 index 0000000000..07bac7fcfd --- /dev/null +++ b/deployments/charts/openim-rpc-third/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "openim-rpc-third.fullname" . }} + labels: + {{- include "openim-rpc-third.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "openim-rpc-third.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "openim-rpc-third.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "openim-rpc-third.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /config/config.yaml + name: config + subPath: config.yaml + - mountPath: /config/notification.yaml + name: config + subPath: notification.yaml + volumes: + - name: config + configMap: + name: openim-cm + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployments/charts/openim-rpc-third/templates/hpa.yaml b/deployments/charts/openim-rpc-third/templates/hpa.yaml new file mode 100644 index 0000000000..2197e21a57 --- /dev/null +++ b/deployments/charts/openim-rpc-third/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "openim-rpc-third.fullname" . }} + labels: + {{- include "openim-rpc-third.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "openim-rpc-third.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-third/templates/ingress.yaml b/deployments/charts/openim-rpc-third/templates/ingress.yaml new file mode 100644 index 0000000000..3ba50cf337 --- /dev/null +++ b/deployments/charts/openim-rpc-third/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "openim-rpc-third.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "openim-rpc-third.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-third/templates/service.yaml b/deployments/charts/openim-rpc-third/templates/service.yaml new file mode 100644 index 0000000000..866b5cda2b --- /dev/null +++ b/deployments/charts/openim-rpc-third/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openim-rpc-third.fullname" . }} + labels: + {{- include "openim-rpc-third.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "openim-rpc-third.selectorLabels" . | nindent 4 }} diff --git a/deployments/charts/openim-rpc-third/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-third/templates/serviceaccount.yaml new file mode 100644 index 0000000000..8a45872ce7 --- /dev/null +++ b/deployments/charts/openim-rpc-third/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openim-rpc-third.serviceAccountName" . }} + labels: + {{- include "openim-rpc-third.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-third/values.yaml b/deployments/charts/openim-rpc-third/values.yaml new file mode 100644 index 0000000000..8a92566a9f --- /dev/null +++ b/deployments/charts/openim-rpc-third/values.yaml @@ -0,0 +1,82 @@ +# Default values for openim-rpc-third. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/openimsdk/openim-rpc-third + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deployments/charts/openim-rpc-user/.helmignore b/deployments/charts/openim-rpc-user/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/deployments/charts/openim-rpc-user/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/deployments/charts/openim-rpc-user/Chart.yaml b/deployments/charts/openim-rpc-user/Chart.yaml new file mode 100644 index 0000000000..7a2118e465 --- /dev/null +++ b/deployments/charts/openim-rpc-user/Chart.yaml @@ -0,0 +1,39 @@ +apiVersion: v2 +name: openim-rpc-user +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" + +icon: https://raw.githubusercontent.com/openimsdk/open-im-server/main/assets/openim-logo-gradient.svg + +maintainers: + - name: "OpenIM" + url: "https://github.com/openimsdk" + +keywords: + - openim + - im + - chat + +sources: + - "https://github.com/openimsdk/open-im-server" + - "https://github.com/openimsdk/helm-charts" \ No newline at end of file diff --git a/deployments/charts/openim-rpc-user/templates/NOTES.txt b/deployments/charts/openim-rpc-user/templates/NOTES.txt new file mode 100644 index 0000000000..9928bd1620 --- /dev/null +++ b/deployments/charts/openim-rpc-user/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "openim-rpc-user.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "openim-rpc-user.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "openim-rpc-user.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "openim-rpc-user.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/deployments/charts/openim-rpc-user/templates/_helpers.tpl b/deployments/charts/openim-rpc-user/templates/_helpers.tpl new file mode 100644 index 0000000000..473f66556f --- /dev/null +++ b/deployments/charts/openim-rpc-user/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "openim-rpc-user.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "openim-rpc-user.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "openim-rpc-user.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "openim-rpc-user.labels" -}} +helm.sh/chart: {{ include "openim-rpc-user.chart" . }} +{{ include "openim-rpc-user.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "openim-rpc-user.selectorLabels" -}} +app.kubernetes.io/name: {{ include "openim-rpc-user.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "openim-rpc-user.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "openim-rpc-user.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-user/templates/deployment.yaml b/deployments/charts/openim-rpc-user/templates/deployment.yaml new file mode 100644 index 0000000000..4517f9b724 --- /dev/null +++ b/deployments/charts/openim-rpc-user/templates/deployment.yaml @@ -0,0 +1,72 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "openim-rpc-user.fullname" . }} + labels: + {{- include "openim-rpc-user.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "openim-rpc-user.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "openim-rpc-user.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "openim-rpc-user.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + #livenessProbe: + # httpGet: + # path: / + # port: http + #readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - mountPath: /config/config.yaml + name: config + subPath: config.yaml + - mountPath: /config/notification.yaml + name: config + subPath: notification.yaml + volumes: + - name: config + configMap: + name: openim-cm + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/deployments/charts/openim-rpc-user/templates/hpa.yaml b/deployments/charts/openim-rpc-user/templates/hpa.yaml new file mode 100644 index 0000000000..7c00c9d648 --- /dev/null +++ b/deployments/charts/openim-rpc-user/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "openim-rpc-user.fullname" . }} + labels: + {{- include "openim-rpc-user.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "openim-rpc-user.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-user/templates/ingress.yaml b/deployments/charts/openim-rpc-user/templates/ingress.yaml new file mode 100644 index 0000000000..7ed5a03289 --- /dev/null +++ b/deployments/charts/openim-rpc-user/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "openim-rpc-user.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "openim-rpc-user.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-user/templates/service.yaml b/deployments/charts/openim-rpc-user/templates/service.yaml new file mode 100644 index 0000000000..728c5de92b --- /dev/null +++ b/deployments/charts/openim-rpc-user/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "openim-rpc-user.fullname" . }} + labels: + {{- include "openim-rpc-user.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "openim-rpc-user.selectorLabels" . | nindent 4 }} diff --git a/deployments/charts/openim-rpc-user/templates/serviceaccount.yaml b/deployments/charts/openim-rpc-user/templates/serviceaccount.yaml new file mode 100644 index 0000000000..d3395f00da --- /dev/null +++ b/deployments/charts/openim-rpc-user/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "openim-rpc-user.serviceAccountName" . }} + labels: + {{- include "openim-rpc-user.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/charts/openim-rpc-user/values.yaml b/deployments/charts/openim-rpc-user/values.yaml new file mode 100644 index 0000000000..d137f0ad79 --- /dev/null +++ b/deployments/charts/openim-rpc-user/values.yaml @@ -0,0 +1,82 @@ +# Default values for openim-rpc-user. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/openimsdk/openim-rpc-user + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/deployments/openim-server/README.md b/deployments/openim-server/README.md deleted file mode 100644 index dd6eb759af..0000000000 --- a/deployments/openim-server/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# OpenIM Server Chat - -## 目录结构 - -```bash -openim-server/ - Chart.yaml # 包含了chart信息的YAML文件 - LICENSE # 包含OpenIM Chart许可证的纯文本文件 - README.md # OpenIM 可读的README文件 - values.yaml # chart 默认的配置值 - charts/ # 包含chart依赖的其他chart - crds/ # 自定义资源的定义 - templates/ # 模板目录, 当和values 结合时,可生成有效的Kubernetes manifest文件 - templates/NOTES.txt # 包含简要使用说明的纯文本文件 -``` \ No newline at end of file diff --git a/deployments/openim-server/templates/service.yaml b/deployments/openim-server/templates/service.yaml deleted file mode 100644 index a12825bfb1..0000000000 --- a/deployments/openim-server/templates/service.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -apiVersion: v1 -kind: Service -metadata: - name: {{ include "openim-server.fullname" . }} - labels: - {{- include "openim-server.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - {{- include "openim-server.selectorLabels" . | nindent 4 }} diff --git a/deployments/openim-server/templates/serviceaccount.yaml b/deployments/openim-server/templates/serviceaccount.yaml deleted file mode 100644 index 6e31d9c83d..0000000000 --- a/deployments/openim-server/templates/serviceaccount.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright © 2023 OpenIM. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -{{- if .Values.serviceAccount.create -}} -apiVersion: v1 -kind: ServiceAccount -metadata: - name: {{ include "openim-server.serviceAccountName" . }} - labels: - {{- include "openim-server.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -{{- end }} diff --git a/deployments/templates/charts-value.yaml b/deployments/templates/charts-value.yaml new file mode 100644 index 0000000000..274d9b8d1d --- /dev/null +++ b/deployments/templates/charts-value.yaml @@ -0,0 +1,96 @@ +#This configuration file is used to override the use of the value.yaml variable. +#Currently, only the configuration with ingressName as nginx is provided. +#If it is another gateway such as istio or treafik, please modify the corresponding gateway requirements + +global: + commonRepository: ghcr.io/openimsdk + commonTag: "latest" + pullPolicy: Always + +openim-api: + image: + repository: ghcr.io/openimsdk/openim-api + pullPolicy: Always + tag: "latest" + ingress: + enabled: true + className: "nginx" + annotations: + nginx.ingress.kubernetes.io/use-regex: "true" + nginx.ingress.kubernetes.io/rewrite-target: /$2 + hosts: + - host: openim.server.com # your hostname + paths: + - path: /api(/|$)(.*) + pathType: ImplementationSpecific + tls: + - secretName: webapitls #your hostname tls + hosts: + - openim.server.com + +openim-msggateway: + image: + repository: ghcr.io/openimsdk/openim-msggateway + tag: "latest" + pullPolicy: Always + ingress: + enabled: true + className: "nginx" + annotations: + nginx.ingress.kubernetes.io/use-regex: "true" + nginx.ingress.kubernetes.io/rewrite-target: /$2 + hosts: + - host: openim.server.com # your hostname + paths: + - path: /msg_gateway(/|$)(.*) + pathType: ImplementationSpecific + tls: + - secretName: webapitls #your hostname tls + hosts: + - openim.server.com + +openim-msgtransfer: + image: + repository: ghcr.io/openimsdk/openim-msgtransfer + tag: "latest" + pullPolicy: Always +openim-push: + image: + repository: ghcr.io/openimsdk/openim-push + tag: "latest" + pullPolicy: Always +openim-rpc-auth: + image: + repository: ghcr.io/openimsdk/openim-rpc-auth + tag: "latest" + pullPolicy: Always +openim-rpc-conversation: + image: + repository: ghcr.io/openimsdk/openim-rpc-conversation + tag: "latest" + pullPolicy: Always +openim-rpc-friend: + image: + repository: ghcr.io/openimsdk/openim-rpc-friend + tag: "latest" + pullPolicy: Always +openim-rpc-group: + image: + repository: ghcr.io/openimsdk/openim-rpc-group + tag: "latest" + pullPolicy: Always +openim-rpc-msg: + image: + repository: ghcr.io/openimsdk/openim-rpc-msg + tag: "latest" + pullPolicy: Always +openim-rpc-third: + image: + repository: ghcr.io/openimsdk/openim-rpc-third + tag: "latest" + pullPolicy: Always +openim-rpc-user: + image: + repository: ghcr.io/openimsdk/openim-rpc-user + tag: "latest" + pullPolicy: Always diff --git a/deployments/templates/helm-image.yaml b/deployments/templates/helm-image.yaml new file mode 100644 index 0000000000..317bc34acb --- /dev/null +++ b/deployments/templates/helm-image.yaml @@ -0,0 +1,89 @@ +#This configuration file is used to override the use of the value.yaml variable. +#Currently, only the configuration with ingressName as nginx is provided. +#If it is another gateway such as istio or treafik, please modify the corresponding gateway requirements +image: + repository: ${IMAGE_REGISTRY}/openim-api + pullPolicy: Always + tag: "${SERVER_IMAGE_TAG}" +ingress: + enabled: true + className: "nginx" + annotations: + nginx.ingress.kubernetes.io/use-regex: "true" + nginx.ingress.kubernetes.io/rewrite-target: /$2 + hosts: + - host: openim.server.com # your hostname + paths: + - path: /api(/|$)(.*) + pathType: ImplementationSpecific + tls: + - secretName: webapitls #your hostname tls + hosts: + - openim.server.com + +openim-msggateway: + image: + repository: ${IMAGE_REGISTRY}/openim-msggateway + tag: "${SERVER_IMAGE_TAG}" + pullPolicy: Always + ingress: + enabled: true + className: "nginx" + annotations: + nginx.ingress.kubernetes.io/use-regex: "true" + nginx.ingress.kubernetes.io/rewrite-target: /$2 + hosts: + - host: openim.server.com # your hostname + paths: + - path: /msg_gateway(/|$)(.*) + pathType: ImplementationSpecific + tls: + - secretName: webapitls #your hostname tls + hosts: + - openim.server.com + +openim-msgtransfer: + image: + repository: ${IMAGE_REGISTRY}/openim-msgtransfer + tag: "${SERVER_IMAGE_TAG}" + pullPolicy: Always +openim-push: + image: + repository: ${IMAGE_REGISTRY}/openim-push + tag: "${SERVER_IMAGE_TAG}" + pullPolicy: Always +openim-rpc-auth: + image: + repository: ${IMAGE_REGISTRY}/openim-rpc-auth + tag: "${SERVER_IMAGE_TAG}" + pullPolicy: Always +openim-rpc-conversation: + image: + repository: ${IMAGE_REGISTRY}/openim-rpc-conversation + tag: "${SERVER_IMAGE_TAG}" + pullPolicy: Always +openim-rpc-friend: + image: + repository: ${IMAGE_REGISTRY}/openim-rpc-friend + tag: "${SERVER_IMAGE_TAG}" + pullPolicy: Always +openim-rpc-group: + image: + repository: ${IMAGE_REGISTRY}/openim-rpc-group + tag: "${SERVER_IMAGE_TAG}" + pullPolicy: Always +openim-rpc-msg: + image: + repository: ${IMAGE_REGISTRY}/openim-rpc-msg + tag: "${SERVER_IMAGE_TAG}" + pullPolicy: Always +openim-rpc-third: + image: + repository: ${IMAGE_REGISTRY}/openim-rpc-third + tag: "${SERVER_IMAGE_TAG}" + pullPolicy: Always +openim-rpc-user: + image: + repository: ${IMAGE_REGISTRY}/openim-rpc-user + tag: "${SERVER_IMAGE_TAG}" + pullPolicy: Always \ No newline at end of file diff --git a/deployments/templates/init/README.md b/deployments/templates/init/README.md deleted file mode 100644 index b9957dadc1..0000000000 --- a/deployments/templates/init/README.md +++ /dev/null @@ -1,220 +0,0 @@ -# Systemd Configuration, Installation, and Startup - -- [Systemd Configuration, Installation, and Startup](#systemd-configuration-installation-and-startup) - - [1. Introduction](#1-introduction) - - [2. Prerequisites (Requires root permissions)](#2-prerequisites-requires-root-permissions) - - [3. Create `openim-api` systemd unit template file](#3-create-openim-api-systemd-unit-template-file) - - [4. Copy systemd unit template file to systemd config directory (Requires root permissions)](#4-copy-systemd-unit-template-file-to-systemd-config-directory-requires-root-permissions) - - [5. Start systemd service](#5-start-systemd-service) - -## 1. Introduction - -Systemd is the default service management form for the latest Linux distributions, replacing the original init. - -Format introduction: - -```bash -[Unit] : Unit of the service - -Description: Brief description of the service - -[Service]: Configuration of the service's runtime behavior - -ExecStart: Complete path of the program - -Restart: Restart configurations like no, always, on-success, on-failure, on-abnormal, on-abort, on-watchdog - -[Install]: Installation configuration - -WantedBy: Multi-user, etc. -``` - -For more details, refer to: [Systemd Service Manual](https://www.freedesktop.org/software/systemd/man/systemd.service.html) - -Starting command: - -```bash -systemctl daemon-reload && systemctl enable openim-api && systemctl restart openim-api -``` - -Service status: - -```bash -systemctl status openim-api -``` - -Stop command: - -```bash -systemctl stop openim-api -``` - -More command: -```bash -# 列出正在运行的Unit,可以直接使用systemctl -systemctl list-units - -# 列出所有Unit,包括没有找到配置文件的或者启动失败的 -systemctl list-units --all - -# 列出所有没有运行的 Unit -systemctl list-units --all --state=inactive - -# 列出所有加载失败的 Unit -systemctl list-units --failed - -# 列出所有正在运行的、类型为service的Unit -systemctl list-units --type=service - -# 显示某个 Unit 是否正在运行 -systemctl is-active application.service - -# 显示某个 Unit 是否处于启动失败状态 -systemctl is-failed application.service - -# 显示某个 Unit 服务是否建立了启动链接 -systemctl is-enabled application.service - -# 立即启动一个服务 -sudo systemctl start apache.service - -# 立即停止一个服务 -sudo systemctl stop apache.service - -# 重启一个服务 -sudo systemctl restart apache.service - -# 重新加载一个服务的配置文件 -sudo systemctl reload apache.service - -# 重载所有修改过的配置文件 -sudo systemctl daemon-reload -``` - -**Why choose systemd?** - -**Advanced requirements:** - -- Convenient service runtime log recording for problem analysis -- Service management logs -- Option to restart upon abnormal exit - -The daemon does not meet these advanced requirements. - -`nohup` only logs the service's runtime outputs and errors. - -Only systemd can fulfill all of the above requirements. - -> The default logs are enhanced with timestamps, usernames, service names, PIDs, etc., making them user-friendly. You can view logs of abnormal service exits. Advanced customization is possible through the configuration files in `/lib/systemd/system/`. - -In short, systemd is the current mainstream way to manage backend services on Linux, so I've abandoned `nohup` in my new versions of bash scripts, opting instead for systemd. - -## 2. Prerequisites (Requires root permissions) - -1. Configure `environment.sh` based on the comments. -2. Create a data directory: - -```bash -mkdir -p ${OPENIM_DATA_DIR}/{openim-api,openim-crontask} -``` - -3. Create a bin directory and copy `openim-api` and `openim-crontask` executable files: - -```bash -source ./environment.sh -mkdir -p ${OPENIM_INSTALL_DIR}/bin -cp openim-api openim-crontask ${OPENIM_INSTALL_DIR}/bin -``` - -4. Copy the configuration files of `openim-api` and `openim-crontask` to the `${OPENIM_CONFIG_DIR}` directory: - -```bash -mkdir -p ${OPENIM_CONFIG_DIR} -cp openim-api.yaml openim-crontask.yaml ${OPENIM_CONFIG_DIR} -``` - -## 3. Create `openim-api` systemd unit template file - -For each OpenIM service, we will create a systemd unit template. Follow the steps below for each service: - -Run the following shell script to generate the `openim-api.service.template`: - -```bash -source ./environment.sh -cat > openim-api.service.template < $service.service.template < +* 1. [1. Introduction](#Introduction) +* 2. [2. Prerequisites (Requires root permissions)](#PrerequisitesRequiresrootpermissions) +* 3. [3. Create `openim-api` systemd unit template file](#Createopenim-apisystemdunittemplatefile) +* 4. [4. Copy systemd unit template file to systemd config directory (Requires root permissions)](#CopysystemdunittemplatefiletosystemdconfigdirectoryRequiresrootpermissions) +* 5. [5. Start systemd service](#Startsystemdservice) + + +## 0. 0. Introduction + +Systemd is the default service management form for the latest Linux distributions, replacing the original init. + +The OpenIM system is a comprehensive suite of services tailored to address a wide variety of messaging needs. This guide will walk you through the steps of setting up the OpenIM system services and provide insights into its usage. + +**Prerequisites:** + ++ A Linux server with necessary privileges. ++ Ensure you have `systemctl` installed and running. + + +## 1. 1. Deployment + +1. **Retrieve the Installation Script**: + + Begin by obtaining the OpenIM installation script which will be utilized to deploy the entire OpenIM system. + +2. **Install OpenIM**: + + To install all the components of OpenIM, run: + + ```bash + ./scripts/install/install.sh -i + ``` + + or + + ```bash + ./scripts/install/install.sh --install + ``` + + This will initiate the installation process for all OpenIM components. + +3. **Check the Status**: + + Post installation, it is good practice to verify if all the services are running as expected: + + ```bash + systemctl status openim.target + ``` + + This will list the status of all related services of OpenIM. + +**Maintenance & Management:** + +1. **Checking Individual Service Status**: + + You can monitor the status of individual services with the following command: + + ```bash + systemctl status + ``` + + For instance: + + ```bash + systemctl status openim-api.service + `` + +2. **Starting and Stopping Services**: + + If you wish to start or stop any specific service, you can do so with `systemctl start` or `systemctl stop` followed by the service name: + + ```bash + systemctl start openim-api.service + systemctl stop openim-api.service + ``` + +3. **Uninstalling OpenIM**: + + In case you wish to remove the OpenIM components from your server, utilize: + + ```bash + ./scripts/install/install.sh -u + ``` + + or + + ```bash + ./scripts/install/install.sh --uninstall + ``` + + Ensure you take a backup of any important data before executing the uninstall command. + +4. **Logs & Troubleshooting**: + + Logs play a pivotal role in understanding the system's operation and troubleshooting any issues. OpenIM logs can typically be found in the directory specified during installation, usually `${OPENIM_LOG_DIR}`. + + Always refer to the logs when troubleshooting. Look for any error messages or warnings that might give insights into the issue at hand. + + +**Note:** + ++ `openim-api.service`: Manages the main API gateways for OpenIM communication. ++ `openim-crontask.service`: Manages scheduled tasks and jobs. ++ `openim-msggateway.service`: Takes care of message gateway operations. ++ `openim-msgtransfer.service`: Handles message transfer functionalities. ++ `openim-push.service`: Responsible for push notification services. ++ `openim-rpc-auth.service`: Manages RPC (Remote Procedure Call) for authentication. ++ `openim-rpc-conversation.service`: Manages RPC for conversations. ++ `openim-rpc-friend.service`: Handles RPC for friend-related operations. ++ `openim-rpc-group.service`: Manages group-related RPC operations. ++ `openim-rpc-msg.service`: Takes care of message RPCs. ++ `openim-rpc-third.service`: Deals with third-party integrations using RPC. ++ `openim-rpc-user.service`: Manages user-related RPC operations. ++ `openim.target`: A target that bundles all the above services for collective operations. + + +**Viewing Logs with `journalctl`:** + +`systemctl` services usually log their output to the systemd journal, which you can access using the `journalctl` command. + +1. **View Logs for a Specific Service**: + + To view the logs for a particular service, you can use: + + ```bash + journalctl -u + ``` + + For example, to see the logs for the `openim-api.service`, you would use: + + ```bash + journalctl -u openim-api.service + ``` + +2. **Filtering Logs**: + + + By Time + + : If you wish to see logs since a specific time: + + ```bash + journalctl -u openim-api.service --since "2023-10-28 12:00:00" + ``` + + + Most Recent Logs + + : To view the most recent logs, you can combine +`tail` functionality with `journalctl`: + + ```bash + journalctl -u openim-api.service -n 100 + ``` + +3. **Continuous Monitoring of Logs**: + + To see new log messages in real-time, you can use the `-f` flag, which mimics the behavior of `tail -f`: + + ```bash + journalctl -u openim-api.service -f + ``` + +### Continued Maintenance: + +1. **Regularly Check Service Status**: + + It's good practice to routinely verify that all services are active and running. This can be done with: + + ```bash + systemctl status openim-api.service openim-push.service openim-rpc-group.service openim-crontask.service openim-rpc-auth.service openim-rpc-msg.service openim-msggateway.service openim-rpc-conversation.service openim-rpc-third.service openim-msgtransfer.service openim-rpc-friend.service openim-rpc-user.service + ``` + +2. **Update Services**: + + Periodically, there might be updates or patches to the OpenIM system or its components. Make sure you keep the system updated. After updating any service, always reload the daemon and restart the service: + + ```bash + systemctl daemon-reload + systemctl restart openim-api.service + ``` + +3. **Backup Important Data**: + + Regularly backup any configuration files, user data, and other essential data. This ensures that you can restore the system to a working state in case of failures. + +### Important `systemctl` and Logging Commands to Learn: + +1. **Start/Stop/Restart Services**: + + ```bash + systemctl start + systemctl stop + systemctl restart + ``` + +2. **Enable/Disable Services**: + + If you want a service to start automatically at boot: + + ```bash + systemctl enable + ``` + + To prevent it from starting at boot: + + ```bash + systemctl disable + ``` + +3. **Check Failed Services**: + + To quickly check if any service has failed: + + ```bash + systemctl --failed + ``` + +4. **Log Rotation**: + + `journalctl` logs can grow large. To clear all archived journal entries, use: + + ```bash + journalctl --vacuum-time=1d + ``` + + +**Advanced requirements:** + +- Convenient service runtime log recording for problem analysis +- Service management logs +- Option to restart upon abnormal exit + +The daemon does not meet these advanced requirements. + +`nohup` only logs the service's runtime outputs and errors. + +Only systemd can fulfill all of the above requirements. + +> The default logs are enhanced with timestamps, usernames, service names, PIDs, etc., making them user-friendly. You can view logs of abnormal service exits. Advanced customization is possible through the configuration files in `/lib/systemd/system/`. + +In short, systemd is the current mainstream way to manage backend services on Linux, so I've abandoned `nohup` in my new versions of bash scripts, opting instead for systemd. + +## 2. Prerequisites (Requires root permissions) + +1. Configure `environment.sh` based on the comments. +2. Create a data directory: + +```bash +mkdir -p ${OPENIM_DATA_DIR}/{openim-api,openim-crontask} +``` + +3. Create a bin directory and copy `openim-api` and `openim-crontask` executable files: + +```bash +source ./environment.sh +mkdir -p ${OPENIM_INSTALL_DIR}/bin +cp openim-api openim-crontask ${OPENIM_INSTALL_DIR}/bin +``` + +4. Copy the configuration files of `openim-api` and `openim-crontask` to the `${OPENIM_CONFIG_DIR}` directory: + +```bash +mkdir -p ${OPENIM_CONFIG_DIR} +cp openim-api.yaml openim-crontask.yaml ${OPENIM_CONFIG_DIR} +``` + +## 3. Create `openim-api` systemd unit template file + +For each OpenIM service, we will create a systemd unit template. Follow the steps below for each service: + +Run the following shell script to generate the `openim-api.service.template`: + +```bash +source ./environment.sh +cat > openim-api.service.template < $service.service.template <Copy systemd unit template file to systemd config directory (Requires root permissions) + +Ensure you have root permissions to perform this operation: + +```bash +for service in "${services[@]}" +do + sudo cp $service.service.template /etc/systemd/system/$service.service +done +... +``` + +## 5. Start systemd service + +To start the OpenIM services: + +```bash +for service in "${services[@]}" +do + sudo systemctl daemon-reload + sudo systemctl enable $service + sudo systemctl restart $service +done +``` diff --git a/docs/conversions/version.md b/docs/conversions/version.md index 0980eaa275..95f736be48 100644 --- a/docs/conversions/version.md +++ b/docs/conversions/version.md @@ -7,6 +7,7 @@ - [Tag Management: The Cornerstone of Version Control](#tag-management-the-cornerstone-of-version-control) - [Release Management: A Guided Tour](#release-management-a-guided-tour) - [Milestones, Branching, and Addressing Major Bugs](#milestones-branching-and-addressing-major-bugs) + - [Version Skew Policy](#version-skew-policy) - [Applying Principles: A Git Workflow Example](#applying-principles-a-git-workflow-example) - [Docker Images Version Management](#docker-images-version-management) @@ -77,6 +78,97 @@ When dealing with major bugs, we selectively merge the fix into the affected ver We reinforce our approach to branch management and versioning with stringent testing protocols. Automated tests and code review sessions form vital components of maintaining a robust and reliable codebase. +## Version Skew Policy + +This document describes the maximum version skew supported between various openim components. Specific cluster deployment tools may place additional restrictions on version skew. + + +### Supported version skew + +In highly-available (HA) clusters, the newest and oldest `openim-api` instances must be within one minor version. + +### OpenIM Versioning, Branching, and Tag Strategy + +Similar to Kubernetes, OpenIM has a strict versioning, branching, and tag strategy to ensure compatibility among its various services and components. This document outlines the policies, especially focusing on the version skew supported between OpenIM's components. Given that the current version is v3.3, the policy references will be centered around this version. + +#### Supported Version Skew + +##### openim-api + +In highly-available (HA) clusters, the newest and oldest `openim-api` instances must be within one minor version. + +Example: + ++ Newest `openim-api` is at v3.3 ++ Other `openim-api` instances are supported at v3.3 and v3.2 + +##### openim-rpc-* Components + +All `openim-rpc-*` components (e.g., `openim-rpc-auth`, `openim-rpc-conversation`, etc.) should adhere to the following rules: + +1. They must not be newer than `openim-api`. +2. They may be up to one minor version older than `openim-api`. + +Example: + ++ `openim-api` is at v3.3 ++ All `openim-rpc-*` components are supported at v3.3 and v3.2 + +Note: If version skew exists between `openim-api` instances in an HA cluster, this narrows the allowed `openim-rpc-*` components versions. + +##### Other OpenIM Services + +Other OpenIM services such as `openim-cmdutils`, `openim-crontask`, `openim-msggateway`, etc. should adhere to the following rules: + +1. These services must not be newer than `openim-api`. +2. They are expected to match the `openim-api` minor version but may be up to one minor version older (to allow live upgrades). + +Example: + ++ `openim-api` is at v3.3 ++ `openim-msggateway`, `openim-cmdutils`, and other services are supported at v3.3 and v3.2 + +#### Supported Component Upgrade Order + +The version skew policy has implications on the order in which components should be upgraded. Below is the recommended order to transition an existing cluster from version v3.2 to v3.3: + +##### openim-api + +Pre-requisites: + +1. In a single-instance cluster, the existing `openim-api` instance is v3.2. +2. In an HA cluster, all `openim-api` instances are at v3.2 or v3.3. +3. All `openim-rpc-*` and other OpenIM services communicating with this server are at version v3.2. + +Upgrade Procedure: + +1. Upgrade `openim-api` to v3.3. + +##### openim-rpc-* Components + +Pre-requisites: + +1. The `openim-api` instances these components communicate with are at v3.3. + +Upgrade Procedure: + +2. Upgrade all `openim-rpc-*` components to v3.3. + +##### Other OpenIM Services + +Pre-requisites: + +1. The `openim-api` instances these services communicate with are at v3.3. + +Upgrade Procedure: + +2. Upgrade other OpenIM services such as `openim-msggateway`, `openim-cmdutils`, etc., to v3.3. + +#### Conclusion + +Just like Kubernetes, it's essential for OpenIM to have a strict versioning and upgrade policy to ensure seamless operation and compatibility among its various services. Adhering to the policies outlined above will help in achieving this goal. + + ## Applying Principles: A Git Workflow Example The workflow to address a bug fix might follow these steps: diff --git a/go.mod b/go.mod index 4d4ed879b7..82e38e8e35 100644 --- a/go.mod +++ b/go.mod @@ -44,6 +44,7 @@ require ( github.com/go-sql-driver/mysql v1.7.1 github.com/redis/go-redis/v9 v9.2.1 github.com/tencentyun/cos-go-sdk-v5 v0.7.45 + gopkg.in/src-d/go-git.v4 v4.13.1 ) require ( @@ -65,6 +66,7 @@ require ( github.com/eapache/go-resiliency v1.4.0 // indirect github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 // indirect github.com/eapache/queue v1.1.0 // indirect + github.com/emirpasic/gods v1.12.0 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect @@ -79,6 +81,7 @@ require ( github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect github.com/jcmturner/gofork v1.7.6 // indirect @@ -87,6 +90,7 @@ require ( github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect github.com/json-iterator/go v1.1.12 // indirect + github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect github.com/klauspost/compress v1.16.7 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect github.com/leodido/go-urn v1.2.4 // indirect @@ -94,6 +98,7 @@ require ( github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/minio/md5-simd v1.1.2 // indirect github.com/minio/sha256-simd v1.0.1 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect @@ -108,8 +113,11 @@ require ( github.com/prometheus/procfs v0.11.1 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rs/xid v1.5.0 // indirect + github.com/sergi/go-diff v1.0.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/src-d/gcfg v1.4.0 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/xanzy/ssh-agent v0.2.1 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect @@ -129,6 +137,8 @@ require ( google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a // indirect + gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect ) require ( diff --git a/go.sum b/go.sum index 0dd6cc940d..c64fc8d681 100644 --- a/go.sum +++ b/go.sum @@ -20,11 +20,17 @@ github.com/IBM/sarama v1.41.3 h1:MWBEJ12vHC8coMjdEXFq/6ftO6DUZnQlFYcxtOJFa7c= github.com/IBM/sarama v1.41.3/go.mod h1:Xxho9HkHd4K/MDUo/T/sOqwtX/17D33++E9Wib6hUdQ= github.com/OpenIMSDK/protocol v0.0.30 h1:MiHO6PyQMR9ojBHNnSFxCHLmsoE2xZqaiYj975JiZnM= github.com/OpenIMSDK/protocol v0.0.30/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y= -github.com/OpenIMSDK/tools v0.0.14 h1:WLof/+WxyPyRST+QkoTKubYCiV73uCLiL8pgnpH/yKQ= -github.com/OpenIMSDK/tools v0.0.14/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI= +github.com/OpenIMSDK/tools v0.0.15 h1:FF3m0TQUG56pJC15a11jmBG6Y1EjXarEW4JV3CBF/Jc= +github.com/OpenIMSDK/tools v0.0.15/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI= github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM= +github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs= +github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs= github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible h1:Sg/2xHwDrioHpxTN6WMiwbXTpUEinBpHsN7mG21Rc2k= github.com/aliyun/aliyun-oss-go-sdk v2.2.9+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= +github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= +github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= @@ -49,6 +55,7 @@ github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5P github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -65,10 +72,13 @@ github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3 h1:Oy0F4A github.com/eapache/go-xerial-snappy v0.0.0-20230731223053-c322873962e3/go.mod h1:YvSRo5mw33fLEx1+DlK6L2VV43tJt5Eyel9n9XBcR+0= github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= +github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= @@ -79,6 +89,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= +github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= @@ -165,6 +177,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= +github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jcmturner/aescts/v2 v2.0.0 h1:9YKLH6ey7H4eDBXW8khjYslgyqG2xZikXP0EQFKrle8= github.com/jcmturner/aescts/v2 v2.0.0/go.mod h1:AiaICIRyfYg35RUkr8yESTqvSy7csK90qZ5xfvvsoNs= github.com/jcmturner/dnsutils/v2 v2.0.0 h1:lltnkeZGL0wILNvrNiVCR6Ro5PGU/SeBvVO/8c/iPbo= @@ -177,6 +191,7 @@ github.com/jcmturner/gokrb5/v8 v8.4.4 h1:x1Sv4HaTpepFkXbt2IkL29DXRf8sOfZXo8eRKh6 github.com/jcmturner/gokrb5/v8 v8.4.4/go.mod h1:1btQEpgT6k+unzCwX1KdWMEwPPkkgBtP+F6aCACiMrs= github.com/jcmturner/rpc/v2 v2.0.3 h1:7FXXj8Ti1IaVFpSAziCZWNzbNuZmnvw/i6CqLNdWfZY= github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJki3ELg/Hc= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8= github.com/jinzhu/copier v0.4.0/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= @@ -186,6 +201,8 @@ github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/ github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v2wtGp9Gmz1Ze3eVRAWJMLokvN3QjdzCHLY= +github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= @@ -195,7 +212,11 @@ github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02 github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= @@ -217,6 +238,8 @@ github.com/minio/minio-go/v7 v7.0.63 h1:GbZ2oCvaUdgT5640WJOpyDhhDxvknAJU2/T3yurw github.com/minio/minio-go/v7 v7.0.63/go.mod h1:Q6X7Qjb7WMhvG65qKf4gUgA5XaiSox74kR1uAEjxRS4= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= @@ -246,10 +269,12 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= +github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ= github.com/pierrec/lz4/v4 v4.1.18/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -273,13 +298,18 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/src-d/gcfg v1.4.0 h1:xXbNR5AlLSA315x2UO+fTSSAXCDf+Ar38/6oyGbDKQ4= +github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -301,6 +331,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= +github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= @@ -326,7 +358,9 @@ go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= @@ -351,6 +385,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= @@ -379,7 +414,9 @@ golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190221075227-b4e8571b14e0/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -401,6 +438,7 @@ golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -417,6 +455,7 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190729092621-ff9f1409240a/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -464,12 +503,21 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/src-d/go-billy.v4 v4.3.2 h1:0SQA1pRztfTFx2miS8sA97XvooFeNOmvUenF4o0EcVg= +gopkg.in/src-d/go-billy.v4 v4.3.2/go.mod h1:nDjArDMp+XMs1aFAESLRjfGSgfvoYN0hDfzEk0GjC98= +gopkg.in/src-d/go-git-fixtures.v3 v3.5.0 h1:ivZFOIltbce2Mo8IjzUHAFoq/IylO9WHhNOAJK+LsJg= +gopkg.in/src-d/go-git-fixtures.v3 v3.5.0/go.mod h1:dLBcvytrw/TYZsNTWCnkNF2DSIlzWYqTe3rJR56Ac7g= +gopkg.in/src-d/go-git.v4 v4.13.1 h1:SRtFyV8Kxc0UP7aCHcijOMQGPxHSmMOPrzulQWolkYE= +gopkg.in/src-d/go-git.v4 v4.13.1/go.mod h1:nx5NYcxdKxq5fpltdHnPa2Exj4Sx0EclMWZQbYDu2z8= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/manifest/build-docker.sh b/manifest/build-docker.sh deleted file mode 100755 index 648e6370d5..0000000000 --- a/manifest/build-docker.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -IMAGEHUB="registry.cn-shenzhen.aliyuncs.com/huanglin_hub" -PROJECT=$1 -ALLPRO="all" -servers=(openim-api openim-crontask openim-msggateway openim-msgtransfer openim-push openim-rpc-auth openim-rpc-conversation openim-rpc-friend openim-rpc-group openim-rpc-msg openim-rpc-third openim-rpc-user) - - -if [ "$1" != "" ] -then - if [[ "${servers[@]}" =~ "${1}" ]] - then - echo "building ${PROJECT}" - DOCKER_PUSHIMG=${IMAGEHUB}/${PROJECT}:dev - docker rmi ${DOCKER_PUSHIMG} - docker build -f manifest/dockerfiles/${PROJECT}/Dockerfile -t ${DOCKER_PUSHIMG} . - docker push ${DOCKER_PUSHIMG} - elif [[ ! "${servers[@]}" =~ "${1}" ]] - then - if [ ${PROJECT} == ${ALLPRO} ] - then - echo "building allproject" - for element in ${servers[@]} - do - SUB_IMG=${element} - SUB_PUSHIMG=${IMAGEHUB}/${element}:dev - docker rmi ${SUB_PUSHIMG} - docker build -f manifest/dockerfiles/${SUB_IMG}/Dockerfile -t ${SUB_PUSHIMG} . - docker push ${SUB_PUSHIMG} - done - else - echo "输入的项目名称不正确" - fi - fi -else - echo "请传入一个参数" -fi \ No newline at end of file diff --git a/manifest/dockerfiles/openim-api/Dockerfile b/manifest/dockerfiles/openim-api/Dockerfile deleted file mode 100644 index c5198d2ad9..0000000000 --- a/manifest/dockerfiles/openim-api/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-api/openim-api cmd/openim-api/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-api/openim-api /app/bin/ -ENTRYPOINT ["/app/bin/openim-api"] diff --git a/manifest/dockerfiles/openim-crontask/Dockerfile b/manifest/dockerfiles/openim-crontask/Dockerfile deleted file mode 100644 index bba54b2e2b..0000000000 --- a/manifest/dockerfiles/openim-crontask/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-crontask/openim-crontask cmd/openim-crontask/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-crontask/openim-crontask /app/bin/ -ENTRYPOINT ["/app/bin/openim-crontask"] diff --git a/manifest/dockerfiles/openim-msggateway/Dockerfile b/manifest/dockerfiles/openim-msggateway/Dockerfile deleted file mode 100644 index 5821780138..0000000000 --- a/manifest/dockerfiles/openim-msggateway/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-msggateway/openim-msggateway cmd/openim-msggateway/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-msggateway/openim-msggateway /app/bin/ -ENTRYPOINT ["/app/bin/openim-msggateway"] diff --git a/manifest/dockerfiles/openim-msgtransfer/Dockerfile b/manifest/dockerfiles/openim-msgtransfer/Dockerfile deleted file mode 100644 index 1e08eb38a5..0000000000 --- a/manifest/dockerfiles/openim-msgtransfer/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-msgtransfer/openim-msgtransfer cmd/openim-msgtransfer/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-msgtransfer/openim-msgtransfer /app/bin/ -ENTRYPOINT ["/app/bin/openim-msgtransfer"] diff --git a/manifest/dockerfiles/openim-push/Dockerfile b/manifest/dockerfiles/openim-push/Dockerfile deleted file mode 100644 index c1ae3ed84e..0000000000 --- a/manifest/dockerfiles/openim-push/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-push/openim-push cmd/openim-push/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-push/openim-push /app/bin/ -ENTRYPOINT ["/app/bin/openim-push"] diff --git a/manifest/dockerfiles/openim-rpc-auth/Dockerfile b/manifest/dockerfiles/openim-rpc-auth/Dockerfile deleted file mode 100644 index 5124da7a19..0000000000 --- a/manifest/dockerfiles/openim-rpc-auth/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-rpc/openim-rpc-auth/openim-rpc-auth cmd/openim-rpc/openim-rpc-auth/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-rpc/openim-rpc-auth/openim-rpc-auth /app/bin/ -ENTRYPOINT ["/app/bin/openim-rpc-auth"] diff --git a/manifest/dockerfiles/openim-rpc-conversation/Dockerfile b/manifest/dockerfiles/openim-rpc-conversation/Dockerfile deleted file mode 100644 index 539d441b94..0000000000 --- a/manifest/dockerfiles/openim-rpc-conversation/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-rpc/openim-rpc-conversation/openim-rpc-conversation cmd/openim-rpc/openim-rpc-conversation/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-rpc/openim-rpc-conversation/openim-rpc-conversation /app/bin/ -ENTRYPOINT ["/app/bin/openim-rpc-conversation"] diff --git a/manifest/dockerfiles/openim-rpc-friend/Dockerfile b/manifest/dockerfiles/openim-rpc-friend/Dockerfile deleted file mode 100644 index 9927c1d30e..0000000000 --- a/manifest/dockerfiles/openim-rpc-friend/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-rpc/openim-rpc-friend/openim-rpc-friend cmd/openim-rpc/openim-rpc-friend/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-rpc/openim-rpc-friend/openim-rpc-friend /app/bin/ -ENTRYPOINT ["/app/bin/openim-rpc-friend"] diff --git a/manifest/dockerfiles/openim-rpc-group/Dockerfile b/manifest/dockerfiles/openim-rpc-group/Dockerfile deleted file mode 100644 index 754151156a..0000000000 --- a/manifest/dockerfiles/openim-rpc-group/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-rpc/openim-rpc-group/openim-rpc-group cmd/openim-rpc/openim-rpc-group/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-rpc/openim-rpc-group/openim-rpc-group /app/bin/ -ENTRYPOINT ["/app/bin/openim-rpc-group"] diff --git a/manifest/dockerfiles/openim-rpc-msg/Dockerfile b/manifest/dockerfiles/openim-rpc-msg/Dockerfile deleted file mode 100644 index 0f942ba8e2..0000000000 --- a/manifest/dockerfiles/openim-rpc-msg/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-rpc/openim-rpc-msg/openim-rpc-msg cmd/openim-rpc/openim-rpc-msg/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-rpc/openim-rpc-msg/openim-rpc-msg /app/bin/ -ENTRYPOINT ["/app/bin/openim-rpc-msg"] diff --git a/manifest/dockerfiles/openim-rpc-third/Dockerfile b/manifest/dockerfiles/openim-rpc-third/Dockerfile deleted file mode 100644 index a1391c0c3f..0000000000 --- a/manifest/dockerfiles/openim-rpc-third/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-rpc/openim-rpc-third/openim-rpc-third cmd/openim-rpc/openim-rpc-third/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-rpc/openim-rpc-third/openim-rpc-third /app/bin/ -ENTRYPOINT ["/app/bin/openim-rpc-third"] diff --git a/manifest/dockerfiles/openim-rpc-user/Dockerfile b/manifest/dockerfiles/openim-rpc-user/Dockerfile deleted file mode 100644 index b45b4aa2f3..0000000000 --- a/manifest/dockerfiles/openim-rpc-user/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ - -# build container -FROM golang:1.20-alpine3.18 AS builder -ENV GOPROXY https://goproxy.cn,direct -ENV GOSUMDB=sum.golang.google.cn -ENV GO111MODULE=on - -WORKDIR /app -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add git pkgconfig build-base -ADD go.mod . -ADD go.sum . -RUN go mod download -ADD . . -RUN go build -o cmd/openim-rpc/openim-rpc-user/openim-rpc-user cmd/openim-rpc/openim-rpc-user/main.go - -# archive container -FROM alpine:3.18 -RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk --no-cache add ca-certificates libdrm -RUN apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ - && echo "Asia/Shanghai" > /etc/timezone \ - && apk del tzdata - -WORKDIR /app/bin -COPY --from=builder /app/cmd/openim-rpc/openim-rpc-user/openim-rpc-user /app/bin/ -ENTRYPOINT ["/app/bin/openim-rpc-user"] diff --git a/pkg/common/cmd/msg_gateway.go b/pkg/common/cmd/msg_gateway.go index c96bbd7afa..358b79f9b7 100644 --- a/pkg/common/cmd/msg_gateway.go +++ b/pkg/common/cmd/msg_gateway.go @@ -15,10 +15,11 @@ package cmd import ( + "log" + "github.com/openimsdk/open-im-server/v3/internal/msggateway" - config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config" + v3config "github.com/openimsdk/open-im-server/v3/pkg/common/config" - //"github.com/openimsdk/open-im-server/internal/msggateway". "github.com/spf13/cobra" "github.com/OpenIMSDK/protocol/constant" @@ -39,7 +40,10 @@ func (m *MsgGatewayCmd) AddWsPortFlag() { } func (m *MsgGatewayCmd) getWsPortFlag(cmd *cobra.Command) int { - port, _ := cmd.Flags().GetInt(constant.FlagWsPort) + port, err := cmd.Flags().GetInt(constant.FlagWsPort) + if err != nil { + log.Println("Error getting ws port flag:", err) + } if port == 0 { port = m.PortFromConfig(constant.FlagWsPort) } @@ -58,9 +62,9 @@ func (m *MsgGatewayCmd) Exec() error { } func (m *MsgGatewayCmd) GetPortFromConfig(portType string) int { if portType == constant.FlagWsPort { - return config2.Config.LongConnSvr.OpenImWsPort[0] + return v3config.Config.LongConnSvr.OpenImWsPort[0] } else if portType == constant.FlagPort { - return config2.Config.LongConnSvr.OpenImMessageGatewayPort[0] + return v3config.Config.LongConnSvr.OpenImMessageGatewayPort[0] } else if portType == constant.FlagPrometheusPort { return 0 } else { diff --git a/pkg/common/cmd/root.go b/pkg/common/cmd/root.go index 7bff0f7980..d2d2b50099 100644 --- a/pkg/common/cmd/root.go +++ b/pkg/common/cmd/root.go @@ -131,7 +131,10 @@ func (r *RootCmd) AddPortFlag() { } func (r *RootCmd) getPortFlag(cmd *cobra.Command) int { - port, _ := cmd.Flags().GetInt(constant.FlagPort) + port, err := cmd.Flags().GetInt(constant.FlagPort) + if err != nil { + fmt.Println("Error getting ws port flag:", err) + } if port == 0 { port = r.PortFromConfig(constant.FlagPort) } diff --git a/pkg/common/version/base.go b/pkg/common/version/base.go new file mode 100644 index 0000000000..4161107c16 --- /dev/null +++ b/pkg/common/version/base.go @@ -0,0 +1,47 @@ +package version + +// Base version information. +// +// This is the fallback data used when version information from git is not +// provided via go ldflags. It provides an approximation of the Kubernetes +// version for ad-hoc builds (e.g. `go build`) that cannot get the version +// information from git. +// +// If you are looking at these fields in the git tree, they look +// strange. They are modified on the fly by the build process. The +// in-tree values are dummy values used for "git archive", which also +// works for GitHub tar downloads. +// +// When releasing a new Kubernetes version, this file is updated by +// build/mark_new_version.sh to reflect the new version, and then a +// git annotated tag (using format vX.Y where X == Major version and Y +// == Minor version) is created to point to the commit that updates +var ( + // TODO: Deprecate gitMajor and gitMinor, use only gitVersion + // instead. First step in deprecation, keep the fields but make + // them irrelevant. (Next we'll take it out, which may muck with + // scripts consuming the kubectl version output - but most of + // these should be looking at gitVersion already anyways.) + gitMajor string = "" // major version, always numeric + gitMinor string = "" // minor version, numeric possibly followed by "+" + + // semantic version, derived by build scripts (see + // https://github.com/kubernetes/sig-release/blob/master/release-engineering/versioning.md#kubernetes-release-versioning + // https://kubernetes.io/releases/version-skew-policy/ + // for a detailed discussion of this field) + // + // TODO: This field is still called "gitVersion" for legacy + // reasons. For prerelease versions, the build metadata on the + // semantic version is a git hash, but the version itself is no + // longer the direct output of "git describe", but a slight + // translation to be semver compliant. + + // NOTE: The $Format strings are replaced during 'git archive' thanks to the + // companion .gitattributes file containing 'export-subst' in this same + // directory. See also https://git-scm.com/docs/gitattributes + gitVersion string = "latest" + gitCommit string = "" // sha1 from git, output of $(git rev-parse HEAD) + gitTreeState string = "" // state of git tree, either "clean" or "dirty" + + buildDate string = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') +) \ No newline at end of file diff --git a/pkg/common/version/types.go b/pkg/common/version/types.go new file mode 100644 index 0000000000..3512640cc9 --- /dev/null +++ b/pkg/common/version/types.go @@ -0,0 +1,30 @@ +package version + +// Info contains versioning information. +// TODO: Add []string of api versions supported? It's still unclear +// how we'll want to distribute that information. +type Info struct { + Major string `json:"major,omitempty"` + Minor string `json:"minor,omitempty"` + GitVersion string `json:"gitVersion"` + GitTreeState string `json:"gitTreeState,omitempty"` + GitCommit string `json:"gitCommit,omitempty"` + BuildDate string `json:"buildDate"` + GoVersion string `json:"goVersion"` + Compiler string `json:"compiler"` + Platform string `json:"platform"` +} + +type Output struct { + OpenIMServerVersion Info `json:"OpenIMServerVersion,omitempty" yaml:"OpenIMServerVersion,omitempty"` + OpenIMClientVersion *OpenIMClientVersion `json:"OpenIMClientVersion,omitempty" yaml:"OpenIMClientVersion,omitempty"` +} + +type OpenIMClientVersion struct { + ClientVersion string `json:"clientVersion,omitempty" yaml:"clientVersion,omitempty"` //sdk core version +} + +// String returns info as a human-friendly version string. +func (info Info) String() string { + return info.GitVersion +} diff --git a/pkg/common/version/version.go b/pkg/common/version/version.go new file mode 100644 index 0000000000..b841c3f657 --- /dev/null +++ b/pkg/common/version/version.go @@ -0,0 +1,58 @@ +package version + +import ( + "fmt" + "runtime" + + "gopkg.in/src-d/go-git.v4" +) + +// Get returns the overall codebase version. It's for detecting +// what code a binary was built from. +func Get() Info { + // These variables typically come from -ldflags settings and in + // their absence fallback to the settings in ./base.go + return Info{ + Major: gitMajor, + Minor: gitMinor, + GitVersion: gitVersion, + GitTreeState: gitTreeState, + GitCommit: gitCommit, + BuildDate: buildDate, + GoVersion: runtime.Version(), + Compiler: runtime.Compiler, + Platform: fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH), + } +} + +// GetClientVersion returns the git version of the OpenIM client repository +func GetClientVersion() (*OpenIMClientVersion, error) { + clientVersion, err := getClientVersion() + if err != nil { + return nil, err + } + return &OpenIMClientVersion{ + ClientVersion: clientVersion, + }, nil +} + +func getClientVersion() (string, error) { + repo, err := git.PlainClone("/tmp/openim-sdk-core", false, &git.CloneOptions{ + URL: "https://github.com/OpenIMSDK/openim-sdk-core", + }) + if err != nil { + return "", fmt.Errorf("error cloning repository: %w", err) + } + + ref, err := repo.Head() + if err != nil { + return "", fmt.Errorf("error getting head reference: %w", err) + } + + return ref.Hash().String(), nil +} + +// GetSingleVersion returns single version of sealer +func GetSingleVersion() string { + return gitVersion +} diff --git a/scripts/check-all.sh b/scripts/check-all.sh index 0d849dd504..23e2119d45 100755 --- a/scripts/check-all.sh +++ b/scripts/check-all.sh @@ -33,8 +33,9 @@ openim::log::info "\n# Begin to check all openim service" # OpenIM status # Elegant printing function print_services_and_ports() { - local -n service_names=$1 - local -n service_ports=$2 + # 获取数组 + declare -g service_names=("${!1}") + declare -g service_ports=("${!2}") echo "+-------------------------+----------+" echo "| Service Name | Port |" diff --git a/scripts/install/environment.sh b/scripts/install/environment.sh index c5407f5e38..f3f53e49ef 100755 --- a/scripts/install/environment.sh +++ b/scripts/install/environment.sh @@ -69,7 +69,7 @@ def "ENV_FILE" ""${OPENIM_ROOT}"/scripts/install/environment.sh" def "CHAT_BRANCH" "main" def "SERVER_BRANCH" "main" -# Choose the appropriate image address, the default is GITHUB image, +# Choose the appropriate image address, the default is GITHUB image, # you can choose docker hub, for Chinese users can choose Ali Cloud # export IMAGE_REGISTRY="ghcr.io/openimsdk" # export IMAGE_REGISTRY="openim" @@ -78,6 +78,9 @@ def "IMAGE_REGISTRY" "ghcr.io/openimsdk" # def "IMAGE_REGISTRY" "openim" # def "IMAGE_REGISTRY" "registry.cn-hangzhou.aliyuncs.com/openimsdk" +# Choose the appropriate image tag, the default is the latest version +def "SERVER_IMAGE_TAG" "latest" + ###################### OpenIM Docker Network ###################### # 设置 Docker 网络的网段 readonly DOCKER_BRIDGE_SUBNET=${DOCKER_BRIDGE_SUBNET:-'172.28.0.0/16'} @@ -115,10 +118,10 @@ LAST_OCTET=$((LAST_OCTET + 1)) GRAFANA_NETWORK_ADDRESS=$(generate_ip) ###################### openim 配置 ###################### -# read: https://github.com/openimsdk/open-im-server/blob/main/deployment/init/README.md +# read: https://github.com/openimsdk/open-im-server/blob/main/deployment/README.md def "OPENIM_DATA_DIR" "/data/openim" def "OPENIM_INSTALL_DIR" "/opt/openim" -def "OPENIM_CONFIG_DIR" "/etc/openim" +def "OPENIM_CONFIG_DIR" "/etc/openim/config" def "OPENIM_LOG_DIR" "/var/log/openim" def "CA_FILE" "${OPENIM_CONFIG_DIR}/cert/ca.pem" @@ -138,14 +141,14 @@ def "OPENIM_CHAT_ADDRESS" "${DOCKER_BRIDGE_GATEWAY}" # OpenIM服务地址 def "OPENIM_CHAT_API_PORT" "10008" # OpenIM API端口 def "CHAT_API_LISTEN_IP" "" # OpenIM API的监听IP -def "OPENIM_ADMIN_API_PORT" "10009" # OpenIM Admin API端口 -def "ADMIN_API_LISTEN_IP" "" # OpenIM Admin API的监听IP +def "OPENIM_ADMIN_API_PORT" "10009" # OpenIM Admin API端口 +def "ADMIN_API_LISTEN_IP" "" # OpenIM Admin API的监听IP -def "OPENIM_ADMIN_PORT" "30200" # OpenIM chat Admin端口 -def "OPENIM_CHAT_PORT" "30300" # OpenIM chat Admin的监听IP +def "OPENIM_ADMIN_PORT" "30200" # OpenIM chat Admin端口 +def "OPENIM_CHAT_PORT" "30300" # OpenIM chat Admin的监听IP -def "OPENIM_ADMIN_NAME" "admin" # openim-chat Admin用户名 -def "OPENIM_CHAT_NAME" "chat" # openim-chat chat用户名 +def "OPENIM_ADMIN_NAME" "admin" # openim-chat Admin用户名 +def "OPENIM_CHAT_NAME" "chat" # openim-chat chat用户名 # TODO 注意: 一般的配置都可以使用 def 函数来定义,如果是包含特殊字符,比如说: # TODO readonly MSG_DESTRUCT_TIME=${MSG_DESTRUCT_TIME:-'0 2 * * *'} @@ -306,10 +309,10 @@ def "GETUI_INTENT" "" # GeTui推送意图 def "GETUI_CHANNEL_ID" "" # GeTui渠道ID def "GETUI_CHANNEL_NAME" "" # GeTui渠道名称 def "FCM_SERVICE_ACCOUNT" "x.json" # FCM服务账户 -def "JPNS_APP_KEY" "" # JPNS应用密钥 -def "JPNS_MASTER_SECRET" "" # JPNS主密钥 -def "JPNS_PUSH_URL" "" # JPNS推送URL -def "JPNS_PUSH_INTENT" "" # JPNS推送意图 +def "JPNS_APP_KEY" "" # JPNS应用密钥 +def "JPNS_MASTER_SECRET" "" # JPNS主密钥 +def "JPNS_PUSH_URL" "" # JPNS推送URL +def "JPNS_PUSH_INTENT" "" # JPNS推送意图 def "MANAGER_USERID_1" "openIM123456" # 管理员ID 1 def "MANAGER_USERID_2" "openIM654321" # 管理员ID 2 def "MANAGER_USERID_3" "openIMAdmin" # 管理员ID 3 diff --git a/scripts/install/install.sh b/scripts/install/install.sh index 9f1698a5b3..915eef3f6b 100755 --- a/scripts/install/install.sh +++ b/scripts/install/install.sh @@ -51,15 +51,9 @@ OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/../.. && pwd -P) [[ -z ${COMMON_SOURCED} ]] && source "${OPENIM_ROOT}"/scripts/install/common.sh -source "${OPENIM_ROOT}"/scripts/install/openim-msggateway.sh -source "${OPENIM_ROOT}"/scripts/install/openim-msgtransfer.sh -source "${OPENIM_ROOT}"/scripts/install/openim-push.sh -source "${OPENIM_ROOT}"/scripts/install/openim-rpc.sh -source "${OPENIM_ROOT}"/scripts/install/openim-crontask.sh -source "${OPENIM_ROOT}"/scripts/install/openim-api.sh -source "${OPENIM_ROOT}"/scripts/install/openim-man.sh -source "${OPENIM_ROOT}"/scripts/install/openim-tools.sh -source "${OPENIM_ROOT}"/scripts/install/test.sh +${OPENIM_ROOT}/scripts/install/openim-man.sh +${OPENIM_ROOT}/scripts/install/openim-tools.sh +${OPENIM_ROOT}/scripts/install/test.sh # Detailed help function function openim::install::show_help() { @@ -79,16 +73,26 @@ function openim::install::show_help() { function openim::install::install_openim() { + openim::common::sudo "mkdir -p ${OPENIM_DATA_DIR} ${OPENIM_INSTALL_DIR} ${OPENIM_CONFIG_DIR} ${OPENIM_LOG_DIR}" openim::log::info "check openim dependency" + openim::common::sudo "cp -r ${OPENIM_ROOT}/config/* ${OPENIM_CONFIG_DIR}/" + + echo ${LINUX_PASSWORD} | sudo -S bash -c \ + "${OPENIM_ROOT}/scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.yaml > ${OPENIM_CONFIG_DIR}/config.yaml" + openim::util::check_ports ${OPENIM_DEPENDENCY_PORT_LISTARIES[@]} - openim::msggateway::install || return 1 - openim::msgtransfer::install || return 1 - openim::push::install || return 1 - openim::rpc::install || return 1 - openim::crontask::install || return 1 - openim::api::install || return 1 + ${OPENIM_ROOT}/scripts/install/openim-msggateway.sh openim::msggateway::install || return 1 + ${OPENIM_ROOT}/scripts/install/openim-msgtransfer.sh openim::msgtransfer::install || return 1 + ${OPENIM_ROOT}/scripts/install/openim-push.sh openim::push::install || return 1 + ${OPENIM_ROOT}/scripts/install/openim-crontask.sh openim::crontask::install || return 1 + ${OPENIM_ROOT}/scripts/install/openim-rpc.sh openim::rpc::install || return 1 + ${OPENIM_ROOT}/scripts/install/openim-api.sh openim::api::install || return 1 + openim::common::sudo "cp -r ${OPENIM_ROOT}/deployments/templates/openim.target /etc/systemd/system/openim.target" + openim::common::sudo "systemctl daemon-reload" + openim::common::sudo "systemctl restart openim.target" + openim::common::sudo "systemctl enable openim.target" openim::log::success "openim install success" } @@ -96,13 +100,18 @@ function openim::uninstall::uninstall_openim() { openim::log::info "uninstall openim" - openim::msggateway::uninstall || return 1 - openim::msgtransfer::uninstall || return 1 - openim::push::uninstall || return 1 - openim::rpc::uninstall || return 1 - openim::crontask::uninstall || return 1 - openim::api::uninstall || return 1 + ${OPENIM_ROOT}/scripts/install/openim-msggateway.sh openim::msggateway::uninstall || return 1 + ${OPENIM_ROOT}/scripts/install/openim-msgtransfer.sh openim::msgtransfer::uninstall || return 1 + ${OPENIM_ROOT}/scripts/install/openim-push.sh openim::push::uninstall || return 1 + ${OPENIM_ROOT}/scripts/install/openim-crontask.sh openim::crontask::uninstall || return 1 + ${OPENIM_ROOT}/scripts/install/openim-rpc.sh openim::rpc::uninstall || return 1 + ${OPENIM_ROOT}/scripts/install/openim-api.sh openim::api::uninstall || return 1 + set +o errexit + openim::common::sudo "systemctl stop openim.target" + openim::common::sudo "systemctl disable openim.target" + openim::common::sudo "rm -f /etc/systemd/system/openim.target" + set -o errexit openim::log::success "openim uninstall success" } @@ -110,12 +119,12 @@ function openim::install::status() { openim::log::info "check openim status" - openim::msggateway::status || return 1 - openim::msgtransfer::status || return 1 - openim::push::status || return 1 - openim::rpc::status || return 1 - openim::crontask::status || return 1 - openim::api::status || return 1 + ${OPENIM_ROOT}/scripts/install/openim-msggateway.sh openim::msggateway::status || return 1 + ${OPENIM_ROOT}/scripts/install/openim-msgtransfer.sh openim::msgtransfer::status || return 1 + ${OPENIM_ROOT}/scripts/install/openim-push.sh openim::push::status || return 1 + ${OPENIM_ROOT}/scripts/install/openim-crontask.sh openim::crontask::status || return 1 + ${OPENIM_ROOT}/scripts/install/openim-rpc.sh openim::rpc::status || return 1 + ${OPENIM_ROOT}/scripts/install/openim-api.sh openim::api::status || return 1 openim::log::success "openim status success" } diff --git a/scripts/install/openim-api.sh b/scripts/install/openim-api.sh index 5239b95e7d..a2d40b7774 100755 --- a/scripts/install/openim-api.sh +++ b/scripts/install/openim-api.sh @@ -92,21 +92,70 @@ function openim::api::start_service() { ###################################### Linux Systemd ###################################### SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service" +# Print the necessary information after installation +function openim::api::info() { +cat << EOF +openim-api listen on: ${OPENIM_API_HOST}:${API_OPENIM_PORT} +EOF +} + +# install openim-api function openim::api::install() { openim::log::info "Installing ${SERVER_NAME} ..." + + pushd "${OPENIM_ROOT}" + + # 1. Build openim-api + make build BINS=${SERVER_NAME} + openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" + openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}" + + # 2. Generate and install the openim-api configuration file (config) + openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/config.yaml" + + # 3. Create and install the ${SERVER_NAME} systemd unit file + echo ${LINUX_PASSWORD} | sudo -S bash -c \ + "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}" + openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}" + + # 4. Start the openim-api service + openim::common::sudo "systemctl daemon-reload" + openim::common::sudo "systemctl restart ${SERVER_NAME}" + openim::common::sudo "systemctl enable ${SERVER_NAME}" + openim::api::status || return 1 + openim::api::info + + openim::log::info "install ${SERVER_NAME} successfully" + popd } +# Unload function openim::api::uninstall() { openim::log::info "Uninstalling ${SERVER_NAME} ..." + set +o errexit + openim::common::sudo "systemctl stop ${SERVER_NAME}" + openim::common::sudo "systemctl disable ${SERVER_NAME}" + openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" + openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" + openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" + set -o errexit + openim::log::info "uninstall ${SERVER_NAME} successfully" } +# Status Check function openim::api::status() { openim::log::info "Checking ${SERVER_NAME} status ..." + # Check the running status of the ${SERVER_NAME}. If active (running) is displayed, the ${SERVER_NAME} is started successfully. + systemctl status ${SERVER_NAME}|grep -q 'active' || { + openim::log::error "${SERVER_NAME} failed to start, maybe not installed properly" + return 1 + } + openim::util::check_ports ${OPENIM_API_PORT_LISTARIES[@]} } if [[ "$*" =~ openim::api:: ]];then - eval $* -fi \ No newline at end of file + eval $* +fi diff --git a/scripts/install/openim-crontask.sh b/scripts/install/openim-crontask.sh index 455dafa8bc..49e018ad19 100755 --- a/scripts/install/openim-crontask.sh +++ b/scripts/install/openim-crontask.sh @@ -51,7 +51,7 @@ function openim::crontask::start() openim::util::stop_services_with_name ${OPENIM_CRONTASK_BINARY} openim::log::status "start cron_task process, path: ${OPENIM_CRONTASK_BINARY}" - nohup ${OPENIM_CRONTASK_BINARY} >> ${LOG_FILE} 2>&1 & + nohup ${OPENIM_CRONTASK_BINARY} -c ${OPENIM_PUSH_CONFIG} >> ${LOG_FILE} 2>&1 & openim::util::check_process_names ${SERVER_NAME} } @@ -72,18 +72,16 @@ function openim::crontask::install() # 1. Build openim-crontask make build BINS=${SERVER_NAME} - openim::common::sudo "cp ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin" - openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}" + openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" + openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}" # 2. Generate and install the openim-crontask configuration file (openim-crontask.yaml) - echo ${LINUX_PASSWORD} | sudo -S bash -c \ - "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" - openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" + openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/config.yaml" # 3. Create and install the ${SERVER_NAME} systemd unit file echo ${LINUX_PASSWORD} | sudo -S bash -c \ - "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}" + "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}" openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}" # 4. Start the openim-crontask service @@ -104,7 +102,7 @@ function openim::crontask::uninstall() set +o errexit openim::common::sudo "systemctl stop ${SERVER_NAME}" openim::common::sudo "systemctl disable ${SERVER_NAME}" - openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}" + openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" set -o errexit @@ -115,15 +113,11 @@ function openim::crontask::uninstall() function openim::crontask::status() { # Check the running status of the ${SERVER_NAME}. If active (running) is displayed, the ${SERVER_NAME} is started successfully. - systemctl status ${SERVER_NAME}|grep -q 'active' || { + if systemctl is-active --quiet "${SERVER_NAME}"; then + openim::log::info "${SERVER_NAME} is running successfully." + else openim::log::error "${SERVER_NAME} failed to start, maybe not installed properly" return 1 - } - - # The listening port is hardcode in the configuration file - if echo | telnet 127.0.0.1 7070 2>&1|grep refused &>/dev/null;then - openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup" - return 1 fi } diff --git a/scripts/install/openim-man.sh b/scripts/install/openim-man.sh index 4cf8e385de..6dda4bfe10 100755 --- a/scripts/install/openim-man.sh +++ b/scripts/install/openim-man.sh @@ -48,7 +48,7 @@ OPENIM_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd) function openim::man::info() { cat <<- EOF Usage: - man openim-server # Display the man page for openim-server + man openim-server to see openim-server help # Display the man page for openim-server EOF } diff --git a/scripts/install/openim-msggateway.sh b/scripts/install/openim-msggateway.sh index 612b7ae16a..79aa6fa15b 100755 --- a/scripts/install/openim-msggateway.sh +++ b/scripts/install/openim-msggateway.sh @@ -74,7 +74,7 @@ SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service" # Print the necessary information after installation function openim::msggateway::info() { cat << EOF -openim-msggateway listen on: ${OPENIM_MSGGATEWAY_HOST} +openim-msggateway listen on: ${OPENIM_MSGGATEWAY_HOST}:${OPENIM_MESSAGE_GATEWAY_PORT} EOF } @@ -85,18 +85,15 @@ function openim::msggateway::install() # 1. Build openim-msggateway make build BINS=${SERVER_NAME} - openim::common::sudo "cp ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin" - - openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}" + openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" + openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" # 2. Generate and install the openim-msggateway configuration file (openim-msggateway.yaml) - echo ${LINUX_PASSWORD} | sudo -S bash -c \ - "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" - openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" + # nono # 3. Create and install the ${SERVER_NAME} systemd unit file echo ${LINUX_PASSWORD} | sudo -S bash -c \ - "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}" + "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}" openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}" # 4. Start the openim-msggateway service @@ -117,7 +114,7 @@ function openim::msggateway::uninstall() set +o errexit openim::common::sudo "systemctl stop ${SERVER_NAME}" openim::common::sudo "systemctl disable ${SERVER_NAME}" - openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}" + openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" set -o errexit @@ -134,7 +131,7 @@ function openim::msggateway::status() } # The listening port is hardcode in the configuration file - if echo | telnet 127.0.0.1 7070 2>&1|grep refused &>/dev/null;then + if echo | telnet ${OPENIM_MSGGATEWAY_HOST} ${OPENIM_MESSAGE_GATEWAY_PORT} 2>&1|grep refused &>/dev/null;then openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup" return 1 fi diff --git a/scripts/install/openim-msgtransfer.sh b/scripts/install/openim-msgtransfer.sh index 51ac788508..b28ca7efab 100755 --- a/scripts/install/openim-msgtransfer.sh +++ b/scripts/install/openim-msgtransfer.sh @@ -95,18 +95,18 @@ function openim::msgtransfer::install() # 1. Build openim-msgtransfer make build BINS=${SERVER_NAME} - openim::common::sudo "cp ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin" + + openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" + openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}" openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}" # 2. Generate and install the openim-msgtransfer configuration file (openim-msgtransfer.yaml) - echo ${LINUX_PASSWORD} | sudo -S bash -c \ - "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" - openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" + # nono # 3. Create and install the ${SERVER_NAME} systemd unit file echo ${LINUX_PASSWORD} | sudo -S bash -c \ - "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}" + "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}" openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}" # 4. Start the openim-msgtransfer service @@ -127,7 +127,7 @@ function openim::msgtransfer::uninstall() set +o errexit openim::common::sudo "systemctl stop ${SERVER_NAME}" openim::common::sudo "systemctl disable ${SERVER_NAME}" - openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}" + openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" set -o errexit @@ -138,15 +138,11 @@ function openim::msgtransfer::uninstall() function openim::msgtransfer::status() { # Check the running status of the ${SERVER_NAME}. If active (running) is displayed, the ${SERVER_NAME} is started successfully. - systemctl status ${SERVER_NAME}|grep -q 'active' || { + if systemctl is-active --quiet "${SERVER_NAME}"; then + openim::log::info "${SERVER_NAME} is running successfully." + else openim::log::error "${SERVER_NAME} failed to start, maybe not installed properly" return 1 - } - - # The listening port is hardcode in the configuration file - if echo | telnet 127.0.0.1 7070 2>&1|grep refused &>/dev/null;then - openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup" - return 1 fi } diff --git a/scripts/install/openim-push.sh b/scripts/install/openim-push.sh index 9b1d4d53f1..5197c9948f 100755 --- a/scripts/install/openim-push.sh +++ b/scripts/install/openim-push.sh @@ -83,7 +83,7 @@ SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service" # Print the necessary information after installation function openim::push::info() { cat << EOF -openim-push listen on: ${OPENIM_PUSH_HOST} +openim-push listen on: ${OPENIM_PUSH_HOST}:${OPENIM_PUSH_PORT} EOF } @@ -94,18 +94,15 @@ function openim::push::install() # 1. Build openim-push make build BINS=${SERVER_NAME} - openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/bin" + openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${SERVER_NAME} ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" + openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/${SERVER_NAME}/${SERVER_NAME}" - openim::log::status "${SERVER_NAME} binary: ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}" - - # 2. Generate and install the openim-push configuration file (openim-push.yaml) - echo ${LINUX_PASSWORD} | sudo -S bash -c \ - "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/${SERVER_NAME}.yaml > ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" - openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" + # 2. Generate and install the openim-push configuration file (config) + openim::log::status "${SERVER_NAME} config file: ${OPENIM_CONFIG_DIR}/config.yaml" # 3. Create and install the ${SERVER_NAME} systemd unit file echo ${LINUX_PASSWORD} | sudo -S bash -c \ - "./scripts/genconfig.sh ${ENV_FILE} deployments/templates/init/${SERVER_NAME}.service > ${SYSTEM_FILE_PATH}" + "SERVER_NAME=${SERVER_NAME} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATH}" openim::log::status "${SERVER_NAME} systemd file: ${SYSTEM_FILE_PATH}" # 4. Start the openim-push service @@ -125,7 +122,7 @@ function openim::push::uninstall() set +o errexit openim::common::sudo "systemctl stop ${SERVER_NAME}" openim::common::sudo "systemctl disable ${SERVER_NAME}" - openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/bin/${SERVER_NAME}" + openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${SERVER_NAME}" openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${SERVER_NAME}.yaml" openim::common::sudo "rm -f /etc/systemd/system/${SERVER_NAME}.service" set -o errexit @@ -142,7 +139,7 @@ function openim::push::status() } # The listening port is hardcode in the configuration file - if echo | telnet 127.0.0.1 7071 2>&1|grep refused &>/dev/null;then # Assuming a different port for push + if echo | telnet ${OPENIM_MSGGATEWAY_HOST} ${OPENIM_PUSH_PORT} 2>&1|grep refused &>/dev/null;then # Assuming a different port for push openim::log::error "cannot access health check port, ${SERVER_NAME} maybe not startup" return 1 fi diff --git a/scripts/install/openim-rpc.sh b/scripts/install/openim-rpc.sh index a0a7868f1b..d6000b0932 100755 --- a/scripts/install/openim-rpc.sh +++ b/scripts/install/openim-rpc.sh @@ -160,26 +160,86 @@ function openim::rpc::start_service() { } ###################################### Linux Systemd ###################################### -SYSTEM_FILE_PATH="/etc/systemd/system/${SERVER_NAME}.service" - -function openim::rpc::install() { - openim::log::info "Installing ${SERVER_NAME} ..." +declare -A SYSTEM_FILE_PATHS +for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do + SYSTEM_FILE_PATHS["$service"]="/etc/systemd/system/${service}.service" +done + +# Print the necessary information after installation +function openim::rpc::info() { + for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do + echo "${service} listen on: ${OPENIM_RPC_PORT_LISTARIES[@]}" + done } -function openim::rpc::uninstall() { - openim::log::info "Uninstalling ${SERVER_NAME} ..." +# install openim-rpc +function openim::rpc::install() +{ + pushd "${OPENIM_ROOT}" -} + # 1. Build openim-rpc + for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do + make build BINS=${service} + openim::common::sudo "cp -r ${OPENIM_OUTPUT_HOSTBIN}/${service} ${OPENIM_INSTALL_DIR}/${service}" + openim::log::status "${service} binary: ${OPENIM_INSTALL_DIR}/${service}/${service}" + done -function openim::rpc::status() { - openim::log::info "Checking ${SERVER_NAME} status ..." + # 2. Generate and install the openim-rpc configuration file (config) + openim::log::status "openim-rpc config file: ${OPENIM_CONFIG_DIR}/config.yaml" - openim::util::check_ports ${OPENIM_RPC_PORT_TARGETS[@]} - # openim::util::check_ports ${OPENIM_RPC_PROM_PORT_TARGETS[@]} + # 3. Create and install the systemd unit files + for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do + echo ${LINUX_PASSWORD} | sudo -S bash -c \ + "SERVER_NAME=${service} ./scripts/genconfig.sh ${ENV_FILE} deployments/templates/openim.service > ${SYSTEM_FILE_PATHS[$service]}" + openim::log::status "${service} systemd file: ${SYSTEM_FILE_PATHS[$service]}" + done - openim::util::check_process_names ${SERVER_NAME} + # 4. Start the openim-rpc services + openim::common::sudo "systemctl daemon-reload" + for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do + openim::common::sudo "systemctl restart ${service}" + openim::common::sudo "systemctl enable ${service}" + done + openim::rpc::status || return 1 + openim::rpc::info + + openim::log::info "install openim-rpc successfully" + popd +} + +# Unload +function openim::rpc::uninstall() +{ + set +o errexit + for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do + openim::common::sudo "systemctl stop ${service}" + openim::common::sudo "systemctl disable ${service}" + openim::common::sudo "rm -f ${OPENIM_INSTALL_DIR}/${service}" + openim::common::sudo "rm -f ${OPENIM_CONFIG_DIR}/${service}.yaml" + openim::common::sudo "rm -f ${SYSTEM_FILE_PATHS[$service]}" + done + set -o errexit + openim::log::info "uninstall openim-rpc successfully" +} + +# Status Check +function openim::rpc::status() +{ + for service in "${OPENIM_RPC_SERVICE_LISTARIES[@]}"; do + # Check the running status of the ${service}. If active (running) is displayed, the ${service} is started successfully. + systemctl status ${service}|grep -q 'active' || { + openim::log::error "${service} failed to start, maybe not installed properly" + return 1 + } + + # The listening port is hardcoded in the configuration file + if echo | telnet ${OPENIM_MSGGATEWAY_HOST} ${OPENIM_RPC_PORT_LISTARIES[@]} 2>&1|grep refused &>/dev/null;then + openim::log::error "cannot access health check port, ${service} maybe not startup" + return 1 + fi + done } if [[ "$*" =~ openim::rpc:: ]];then - eval $* -fi \ No newline at end of file + eval $* +fi diff --git a/scripts/install/vimrc b/scripts/install/vimrc deleted file mode 100644 index b128951c6a..0000000000 --- a/scripts/install/vimrc +++ /dev/null @@ -1,300 +0,0 @@ -" learn: https://github.com/cubxxw/awesome-cs-course/tree/master/linux -" Read: https://github.com/cubxxw/awesome-cs-course/blob/master/linux/markdown/my_vim.md - -"vim的配置关于鼠标滚动滑动""" -if has("autocmd") - au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif - set mouse=a -endif -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -"C,C++ 按F5编译运行 -map :call CompileRunGcc() -func! CompileRunGcc() - exec "w" - if &filetype == 'c' - exec "!g++ % -o %<" - exec "! ./%<" - elseif &filetype == 'cpp' - exec "!g++ % -o %<" - exec "! ./%<" - elseif &filetype == 'java' - exec "!javac %" - exec "!java %<" - elseif &filetype == 'sh' - :!./% - endif -endfunc -"配置命令" -"C,C++的调试 -"''''''''''''''''""""""""""""""""""""""""""""""""""''''''''''''''''''''' -map :call Rungdb() -func! Rungdb() - exec "w" - exec "!g++ % -g -o %<" - exec "!gdb ./%<" -endfunc - -""实用设置 -" 设置当文件被改动时自动载入 -set autoread -" quickfix模式 -autocmd FileType c,cpp map :w:make -"代码补全 -set completeopt=preview,menu - -" common configure -"set noswapfile -set mouse=a " 激活鼠标使用 -set wrap " 自动换行 -set sw=4 " 设置软宽度 -set gdefault " 行内替换 -set nu -set showmatch " 高亮显示括号匹配 -set expandtab " 使用空格来替换 Tab -set tabstop=4 " 设置 Tab 长度为 4 空格 -set shiftwidth=4 " 设置自动缩进长度为 4 空格 -set autoindent " 继承前一行的缩进方式,适用于多行注释" -set autowrite " 自动保存 -set nocompatible " 关闭 vi 兼容模式 -set history=1000 " 设置历史记录步数 -set confirm " 在处理未保存或只读文件时,弹出确认 - -" 搜索逐字符高亮 -set hlsearch -set incsearch - -" 从不备份 -set nobackup -set noswapfile - -let g:indentLine_enabled=0 - -" golang configure ====> start -let g:go_highlight_methods = 1 -let g:go_highlight_operators = 1 -let g:go_highlight_build_constraints = 1 -let g:go_fmt_autosave = 1 -let g:go_version_warning = 1 -let g:go_autodetect_gopath = 1 -let g:go_highlight_types = 1 -let g:go_highlight_fields = 1 -let g:go_highlight_functions = 1 -let g:go_highlight_function_calls = 1 -let g:go_highlight_extra_types = 1 -let g:go_highlight_generate_tags = 1 -let g:go_def_mode = 'gopls' -let g:go_gopls_enabled = 1 -let g:go_guru_enabled = 1 -let g:go_fmt_experimental = 1 -let g:go_def_mapping_enabled = 1 -let g:go_build_tags = '-v' -let g:go_fmt_command = "goimports" -let g:go_list_type = "quickfix" -let g:go_def_mapping_enable = 1 - -map <2-LeftMouse> :GoDef -map :GoDefPop -map :GoCallers -map :GoCallees -map -map -unmap -map :GoDef -map :GoDefPop -map :GoDoc -map :GoInfo -map :GoDefType -map :GoAddTag -map :GoImplements -map :GoRename -map :GoFillStruct -map :GoCallers -map :GoSameIdsToggle - -augroup go - autocmd! - - " Show by default 4 spaces for a tab - autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 - - " :GoDef but opens in a vertical split - autocmd FileType go nmap v (go-def-vertical) - " :GoDef but opens in a horizontal split - autocmd FileType go nmap s (go-def-split) - - " :GoAlternate commands :A, :AV, :AS and :AT - autocmd Filetype go command! -bang A call go#alternate#Switch(0, 'edit') - autocmd Filetype go command! -bang AV call go#alternate#Switch(0, 'vsplit') - autocmd Filetype go command! -bang AS call go#alternate#Switch(0, 'split') - autocmd Filetype go command! -bang AT call go#alternate#Switch(0, 'tabe') -augroup END - -" build_go_files is a custom function that builds or compiles the test file. -" It calls :GoBuild if its a Go file, or :GoTestCompile if it's a test file -function! s:build_go_files() - let l:file = expand('%') - if l:file =~# '^\f\+_test\.go$' - call go#test#Test(0, 1) - elseif l:file =~# '^\f\+\.go$' - call go#cmd#Build(0) - endif -endfunction -" golang configure ====> end - -:inoremap ( ()i -:inoremap ) =ClosePair(')') -:inoremap { {}O -:inoremap } =ClosePair('}') -:inoremap [ []i -:inoremap ] =ClosePair(']') -:inoremap " ""i -:inoremap ' ''i -function! ClosePair(char) - if getline('.')[col('.') - 1] == a:char - return "\" - else - return a:char - endif -endfunction -filetype plugin indent on -"打开文件类型检测, 加了这句才可以用智能补全 - -set completeopt=longest,menu - -""""""""""""""""""""""""""""""""""""""""""""""" - noremap :set nu - noremap :!python3 a - noremap :set ai - noremap :syntax on - set cursorline " 突出显示当前行 - set magic " 设置魔术 - "" noremap :! g++ -o a -nnoremap -nnoremap -nnoremap -nnoremap -nmap wj :resize -3 -nmap wk :resize +3 -nmap wh :vertical resize -3 -nmap wl :vertical resize +3 -set guifont=Droid\ Sans\ Mono\ Nerd\ Font\ Complete:h18 " 设置字体 -set guicursor=n-v-c:ver5 " 设置光标为竖线 -set number ""# 显示行号 -set autowrite "" # 自动保存 -set ruler ""# 显示打开状态栏标尺 -set cursorline "" # 突出显示当前行 - -set showmatch "" # 匹配光标所经过的括号等. -set showcmd ""# 命令行显示输入的命令 -set showmode ""命令行显示vim当前模式 -set showtabline=0 " 隐藏Tab栏 -set laststatus=2 """"'vim 窗口底部显示永久状态栏,显示文件名,行号,列号等. -let mapleader = "," " 定义键 -set nocompatible " 设置不兼容原始vi模式 -filetype on " 设置开启文件类型侦测 -filetype plugin on " 设置加载对应文件类型的插件 -set noeb " 关闭错误的提示 -syntax enable " 开启语法高亮功能 -syntax on " 自动语法高亮 -set cmdheight=2 " 设置命令行的高度 -set showcmd " select模式下显示选中的行数 -set ruler " 总是显示光标位置 -set laststatus=2 " 总是显示状态栏 -set number " 开启行号显示 -set cursorline " 高亮显示当前行 -set whichwrap+=<,>,h,l " 设置光标键跨行 -set ttimeoutlen=0 " 设置键响应时间 -set virtualedit=block,onemore " 允许光标出现在最后一个字符的后面 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" 代码缩进和排版 -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set autoindent " 设置自动缩进 -set cindent " 设置使用C/C++语言的自动缩进方式 -set cinoptions=g0,:0,N-s,(0 " 设置C/C++语言的具体缩进方式 -set smartindent " 智能的选择对其方式 -filetype indent on " 自适应不同语言的智能缩进 -set expandtab " 将制表符扩展为空格 -set tabstop=4 " 设置编辑时制表符占用空格数 -set shiftwidth=4 " 设置格式化时制表符占用空格数 -set softtabstop=4 " 设置4个空格为制表符 -set smarttab " 在行和段开始处使用制表符 -set nowrap " 禁止折行 -set backspace=2 " 使用回车键正常处理indent,eol,start等 -set sidescroll=10 " 设置向右滚动字符数 -set nofoldenable " 禁用折叠代码 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" 代码补全 -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set wildmenu " vim自身命名行模式智能补全 -set completeopt-=preview " 补全时不显示窗口,只显示补全列表 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" 搜索设置 -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set hlsearch " 高亮显示搜索结果 -set incsearch " 开启实时搜索功能 -set ignorecase " 搜索时大小写不敏感 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" 缓存设置 -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set nobackup " 设置不备份 -set noswapfile " 禁止生成临时文件 -set autoread " 文件在vim之外修改过,自动重新读入 -set autowrite " 设置自动保存 -set confirm " 在处理未保存或只读文件的时候,弹出确认 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -"调整窗 -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -nmap wj :resize -3 -nmap wk :resize +3 -nmap wh :vertical resize -3 -nmap wl :vertical resize +3 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -"编码" -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set langmenu=zh_CN.UTF-8 -set helplang=cn -set termencoding=utf-8 -set encoding=utf8 -set fileencodings=utf8,ucs-bom,gbk,cp936,gb2312,gb18030 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -"代码补全“ -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -inoremap ' ''i -inoremap " ""i -inoremap ( ()i -inoremap [ []i -inoremap { {}O - : set nu - : set ai - : syntax on - : filetype on - set tabstop=4 - set ignorecase -noremap h -noremap j -noremap r -noremap l -" Specify a directory for plugins -" - For Neovim: stdpath('data') . '/plugged' -" - Avoid using standard Vim directory names like 'plugin' -let g:coc_disable_startup_warning = 1 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -"tmux" -"复用终端、分屏" -"let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -map h (easymotion-linebackward) -map j (easymotion-j) -map k (easymotion-k) -map l (easymotion-lineforward) -" 重复上一次操作, 类似repeat插件, 很强大 -map . (easymotion-repeat) -nmap s (easymotion-s) diff --git a/scripts/lib/util.sh b/scripts/lib/util.sh index d7c274c56c..6fd9a5cfd0 100755 --- a/scripts/lib/util.sh +++ b/scripts/lib/util.sh @@ -268,6 +268,7 @@ openim::util::check_docker_and_compose_versions() { # Check if the docker compose sub-command is available if ! docker compose version &> /dev/null; then echo "Docker does not support the docker compose sub-command" + echo "You need to upgrade Docker to the right version" return 1 fi diff --git a/scripts/make-rules/golang.mk b/scripts/make-rules/golang.mk index cc2c985441..29f527028b 100644 --- a/scripts/make-rules/golang.mk +++ b/scripts/make-rules/golang.mk @@ -137,6 +137,7 @@ ifneq ($(shell $(GO) version | grep -q -E '\bgo($(GO_SUPPORTED_VERSIONS))\b' && endif ## go.build.%: Build binaries for a specific platform +# CGO_ENABLED=0 https://wiki.musl-libc.org/functional-differences-from-glibc.html .PHONY: go.build.% go.build.%: $(eval COMMAND := $(word 2,$(subst ., ,$*))) diff --git a/scripts/make-rules/image.mk b/scripts/make-rules/image.mk index 09e92126bc..fa7f8ee9cf 100644 --- a/scripts/make-rules/image.mk +++ b/scripts/make-rules/image.mk @@ -23,7 +23,8 @@ DOCKER := docker # read: https://github.com/openimsdk/open-im-server/blob/main/docs/conversions/images.md -REGISTRY_PREFIX ?= ghcr.io/openimsdk +REGISTRY_PREFIX ?= registry.cn-hangzhou.aliyuncs.com/openimsdk +# REGISTRY_PREFIX ?= ghcr.io/openimsdk BASE_IMAGE ?= ghcr.io/openim-sigs/openim-bash-image @@ -43,6 +44,7 @@ endif # Determine image files by looking into build/images/*/Dockerfile IMAGES_DIR ?= $(wildcard ${ROOT_DIR}/build/images/*) # Determine images names by stripping out the dir names, and filter out the undesired directories +# IMAGES ?= $(filter-out Dockerfile,$(foreach image,${IMAGES_DIR},$(notdir ${image}))) IMAGES ?= $(filter-out Dockerfile openim-tools openim-cmdutils,$(foreach image,${IMAGES_DIR},$(notdir ${image}))) ifeq (${IMAGES},) @@ -105,6 +107,7 @@ image.build.%: go.build.% | sed "s#BINARY_NAME#$(IMAGE)#g" >$(TMP_DIR)/$(IMAGE)/Dockerfile @cp $(BIN_DIR)/platforms/$(IMAGE_PLAT)/$(IMAGE) $(TMP_DIR)/$(IMAGE) $(eval BUILD_SUFFIX := $(_DOCKER_BUILD_EXTRA_ARGS) --pull -t $(REGISTRY_PREFIX)/$(IMAGE)-$(ARCH):$(VERSION) $(TMP_DIR)/$(IMAGE)) + @echo $(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX) @if [ $(shell $(GO) env GOARCH) != $(ARCH) ] ; then \ $(MAKE) image.daemon.verify ;\ $(DOCKER) build --platform $(IMAGE_PLAT) $(BUILD_SUFFIX) ; \ diff --git a/scripts/template/head.md.tmpl b/scripts/template/head.md.tmpl index 4aba975561..41dac30ef2 100644 --- a/scripts/template/head.md.tmpl +++ b/scripts/template/head.md.tmpl @@ -16,7 +16,7 @@ Learn more about versions of OpenIM: - + diff --git a/scripts/update-generated-docs.sh b/scripts/update-generated-docs.sh index bd2ebb268e..008cf63ed1 100755 --- a/scripts/update-generated-docs.sh +++ b/scripts/update-generated-docs.sh @@ -28,10 +28,10 @@ source "${OPENIM_ROOT}/hack/lib/init.sh" openim::golang::setup_env BINS=( - cmd/gendocs - cmd/genopenimdocs - cmd/genman - cmd/genyaml + gendocs + genopenimdocs + genman + genyaml ) make -C "${OPENIM_ROOT}" WHAT="${BINS[*]}" diff --git a/tools/infra/go.mod b/tools/infra/go.mod index a6cf16c77c..8c66e2654d 100644 --- a/tools/infra/go.mod +++ b/tools/infra/go.mod @@ -1,3 +1,11 @@ module github.com/openimsdk/open-im-server/v3/tools/infra go 1.19 + +require github.com/fatih/color v1.15.0 + +require ( + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect + golang.org/x/sys v0.6.0 // indirect +) diff --git a/tools/infra/go.sum b/tools/infra/go.sum new file mode 100644 index 0000000000..2624c9db06 --- /dev/null +++ b/tools/infra/go.sum @@ -0,0 +1,10 @@ +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/tools/infra/infra.go b/tools/infra/infra.go index cc20a17c7f..f8d8c75223 100644 --- a/tools/infra/infra.go +++ b/tools/infra/infra.go @@ -1,29 +1,25 @@ -// Copyright © 2023 OpenIM. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - package main import ( "fmt" - "log" + + "github.com/fatih/color" ) +// 定义一个函数以打印重要的链接信息 +func printLinks() { + blue := color.New(color.FgBlue).SprintFunc() + fmt.Printf("OpenIM Github: %s\n", blue("https://github.com/OpenIMSDK/Open-IM-Server")) + fmt.Printf("Slack Invitation: %s\n", blue("https://openimsdk.slack.com")) +} + func main() { - log.Println("Current module is still under development.") - message := ` -Current module is still under development. + yellow := color.New(color.FgYellow) + blue := color.New(color.FgBlue, color.Bold) + + yellow.Println("Current module is still under development.") + message := ` ____ _____ __ __ / __ \ |_ _|| \/ | | | | | _ __ ___ _ __ | | | \ / | @@ -36,5 +32,6 @@ ____ _____ __ __ Keep checking for updates! ` - fmt.Println(message) + blue.Println(message) + printLinks() // 调用函数以打印链接信息 } diff --git a/tools/versionchecker/go.mod b/tools/versionchecker/go.mod index 619bcdb5b2..7c274fcf9b 100644 --- a/tools/versionchecker/go.mod +++ b/tools/versionchecker/go.mod @@ -1,3 +1,11 @@ module github.com/openimsdk/open-im-server/v3/tools/versionchecker go 1.19 + +require github.com/fatih/color v1.15.0 + +require ( + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect + golang.org/x/sys v0.6.0 // indirect +) diff --git a/tools/versionchecker/go.sum b/tools/versionchecker/go.sum new file mode 100644 index 0000000000..2624c9db06 --- /dev/null +++ b/tools/versionchecker/go.sum @@ -0,0 +1,10 @@ +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng= +github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/tools/versionchecker/versionchecker.go b/tools/versionchecker/versionchecker.go index e7bc3e3791..12254b58e8 100644 --- a/tools/versionchecker/versionchecker.go +++ b/tools/versionchecker/versionchecker.go @@ -20,9 +20,12 @@ import ( "os/exec" "runtime" "time" + + "github.com/fatih/color" + //"github.com/openimsdk/open-im-server/v3/pkg/common/version" ) -func executeCommand(cmdName string, args ...string) (string, error) { +func ExecuteCommand(cmdName string, args ...string) (string, error) { cmd := exec.Command(cmdName, args...) var out bytes.Buffer var stderr bytes.Buffer @@ -31,19 +34,15 @@ func executeCommand(cmdName string, args ...string) (string, error) { err := cmd.Run() if err != nil { - return "", fmt.Errorf("Error executing %s: %v", cmdName, err) + return "", fmt.Errorf("error executing %s: %v, stderr: %s", cmdName, err, stderr.String()) } return out.String(), nil } func printTime() string { currentTime := time.Now() - - // 使用 Format 函数以优雅的方式格式化日期和时间 - // 2006-01-02 15:04:05 是 Go 中的标准时间格式 formattedTime := currentTime.Format("2006-01-02 15:04:05") - - return fmt.Sprintf("Current Date & Time:", formattedTime) + return fmt.Sprintf("Current Date & Time: %s", formattedTime) } func getGoVersion() string { @@ -54,7 +53,7 @@ func getGoVersion() string { } func getDockerVersion() string { - version, err := executeCommand("docker", "--version") + version, err := ExecuteCommand("docker", "--version") if err != nil { return "Docker is not installed. Please install it to get the version." } @@ -62,7 +61,7 @@ func getDockerVersion() string { } func getDockerComposeVersion() string { - version, err := executeCommand("docker-compose", "--version") + version, err := ExecuteCommand("docker-compose", "--version") if err != nil { return "Docker Compose is not installed. Please install it to get the version." } @@ -70,7 +69,7 @@ func getDockerComposeVersion() string { } func getKubernetesVersion() string { - version, err := executeCommand("kubectl", "version", "--client", "--short") + version, err := ExecuteCommand("kubectl", "version", "--client", "--short") if err != nil { return "Kubernetes is not installed. Please install it to get the version." } @@ -78,38 +77,52 @@ func getKubernetesVersion() string { } func getGitVersion() string { - version, err := executeCommand("git", "branch", "--show-current") + version, err := ExecuteCommand("git", "branch", "--show-current") if err != nil { return "Git is not installed. Please install it to get the version." } return version } -// NOTE: You'll need to provide appropriate commands for OpenIM versions. -func getOpenIMServerVersion() string { - // Placeholder - return "OpenIM Server: v3.2" -} +// // NOTE: You'll need to provide appropriate commands for OpenIM versions. +// func getOpenIMServerVersion() string { +// // Placeholder +// openimVersion := version.GetSingleVersion() +// return "OpenIM Server: " + openimVersion + "\n" +// } -func getOpenIMClientVersion() string { - // Placeholder - return "OpenIM Client: v3.2" -} +// func getOpenIMClientVersion() (string, error) { +// openIMClientVersion, err := version.GetClientVersion() +// if err != nil { +// return "", err +// } +// return "OpenIM Client: " + openIMClientVersion.ClientVersion + "\n", nil +// } func main() { - fmt.Println(printTime()) - fmt.Println("# Diagnostic Tool Result\n") - fmt.Println("## Go Version") + // red := color.New(color.FgRed).SprintFunc() + green := color.New(color.FgGreen).SprintFunc() + blue := color.New(color.FgBlue).SprintFunc() + yellow := color.New(color.FgYellow).SprintFunc() + + fmt.Println(green(printTime())) + fmt.Println(yellow("# Diagnostic Tool Result\n")) + fmt.Println(blue("## Go Version")) fmt.Println(getGoVersion()) - fmt.Println("## Branch Type") + fmt.Println(blue("## Branch Type")) fmt.Println(getGitVersion()) - fmt.Println("## Docker Version") + fmt.Println(blue("## Docker Version")) fmt.Println(getDockerVersion()) - fmt.Println("## Docker Compose Version") + fmt.Println(blue("## Docker Compose Version")) fmt.Println(getDockerComposeVersion()) - fmt.Println("## Kubernetes Version") + fmt.Println(blue("## Kubernetes Version")) fmt.Println(getKubernetesVersion()) - fmt.Println("## OpenIM Versions") - fmt.Println(getOpenIMServerVersion()) - fmt.Println(getOpenIMClientVersion()) + // fmt.Println(blue("## OpenIM Versions")) + // fmt.Println(getOpenIMServerVersion()) + // clientVersion, err := getOpenIMClientVersion() + // if err != nil { + // fmt.Println(red("Error getting OpenIM Client Version: "), err) + // } else { + // fmt.Println(clientVersion) + // } }