diff --git a/.github/workflows/services.yml b/.github/workflows/services.yml index f2542946137..cafd8d442eb 100644 --- a/.github/workflows/services.yml +++ b/.github/workflows/services.yml @@ -73,7 +73,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - module: [ hub, database ] + ## TODO: add more modules + module: [ database ] steps: - name: Checkout uses: actions/checkout@v3 @@ -159,102 +160,103 @@ jobs: save-sealos: uses: ./.github/workflows/import-save-sealos.yml -# build-cluster-image: -# if: ${{ (github.event_name == 'push') ||(github.event_name == 'create') || (inputs.push_image == true) }} -# needs: -# - image-build -# - save-sealos -# runs-on: ubuntu-latest -# strategy: -# matrix: -# module: [ ] -# steps: -# - name: Checkout -# uses: actions/checkout@v3 -# with: -# fetch-depth: 0 -# -# - name: Expose git commit data -# uses: rlespinasse/git-commit-data-action@v1 -# - name: Check if tag -# id: check_tag -# run: | -# if [[ "${{ github.ref }}" == refs/tags/* ]]; then -# echo "isTag=true" >> "$GITHUB_OUTPUT" -# else -# echo "isTag=false" >> "$GITHUB_OUTPUT" -# fi -# - name: Prepare -# id: prepare -# run: | -# bash ./scripts/resolve-tag-image.sh "${{ inputs.push_image }}" "${{ steps.check_tag.outputs.isTag }}" "${{ inputs.push_image_tag }}" -# echo old_docker_repo=ghcr.io/labring/sealos-${{ matrix.module }}-service >> $GITHUB_OUTPUT -# echo new_docker_repo=ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-service >> $GITHUB_OUTPUT -# echo cluster_repo=ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service >> $GITHUB_OUTPUT -# -# - name: Download sealos -# uses: actions/download-artifact@v3 -# with: -# name: sealos -# path: /tmp/ -# - name: Verify sealos -# run: | -# sudo chmod a+x /tmp/sealos -# sudo mv /tmp/sealos /usr/bin/sealos -# sudo sealos version -# -# - name: Sealos login to ghcr.io -# # if push to master, then login to ghcr.io -# run: | -# sudo sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GH_PAT }} --debug ghcr.io -# -# - name: Mutate image tag in deploy files -# working-directory: service/${{ matrix.module }}/deploy -# run: | -# OLD_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.old_docker_repo }}:latest -# NEW_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.new_docker_repo }}:${{ steps.prepare.outputs.tag_name }} -# sed -i "s;${OLD_DOCKER_IMAGE_NAME};${NEW_DOCKER_IMAGE_NAME};" manifests/* -# -# - name: Build ${{ matrix.module }}-service cluster image -# working-directory: service/${{ matrix.module }}/deploy -# run: | -# CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }} -# sudo sealos build -t ${CLUSTER_IMAGE_NAME}-amd64 --platform linux/amd64 -f Kubefile -# sudo sealos build -t ${CLUSTER_IMAGE_NAME}-arm64 --platform linux/arm64 -f Kubefile -# sudo sealos images -# - name: Build ${{ matrix.module }}-service cluster image for latest -# run: | -# CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }} -# CLUSTER_IMAGE_NAME_LATEST=${{ steps.prepare.outputs.cluster_repo }}:latest -# sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64 -# sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64 -# sudo sealos images -# bash docker/patch/manifest-cluster-images.sh $CLUSTER_IMAGE_NAME_LATEST -# - name: Renew issue and Sync Images -# uses: labring/gh-rebot@v0.0.6 -# if: ${{ github.repository_owner == env.DEFAULT_OWNER }} -# with: -# version: v0.0.8-rc1 -# env: -# GH_TOKEN: "${{ secrets.GH_PAT }}" -# SEALOS_TYPE: "issue_renew" -# SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos" -# SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md" -# SEALOS_ISSUE_LABEL: "dayly-report" -# SEALOS_ISSUE_TYPE: "day" -# SEALOS_ISSUE_REPO: "labring-actions/cluster-image" -# SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:${{ steps.prepare.outputs.tag_name }}" -# - name: Renew issue and Sync Images for latest -# uses: labring/gh-rebot@v0.0.6 -# if: ${{ github.repository_owner == env.DEFAULT_OWNER }} -# with: -# version: v0.0.8-rc1 -# env: -# GH_TOKEN: "${{ secrets.GH_PAT }}" -# SEALOS_TYPE: "issue_renew" -# SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos" -# SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md" -# SEALOS_ISSUE_LABEL: "dayly-report" -# SEALOS_ISSUE_TYPE: "day" -# SEALOS_ISSUE_REPO: "labring-actions/cluster-image" -# SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:latest" + build-cluster-image: + if: ${{ (github.event_name == 'push') ||(github.event_name == 'create') || (inputs.push_image == true) }} + needs: + - image-build + - save-sealos + runs-on: ubuntu-latest + strategy: + matrix: + ## TODO: add more modules + module: [ database ] + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Expose git commit data + uses: rlespinasse/git-commit-data-action@v1 + - name: Check if tag + id: check_tag + run: | + if [[ "${{ github.ref }}" == refs/tags/* ]]; then + echo "isTag=true" >> "$GITHUB_OUTPUT" + else + echo "isTag=false" >> "$GITHUB_OUTPUT" + fi + - name: Prepare + id: prepare + run: | + bash ./scripts/resolve-tag-image.sh "${{ inputs.push_image }}" "${{ steps.check_tag.outputs.isTag }}" "${{ inputs.push_image_tag }}" + echo old_docker_repo=ghcr.io/labring/sealos-${{ matrix.module }}-service >> $GITHUB_OUTPUT + echo new_docker_repo=ghcr.io/${{ github.repository_owner }}/sealos-${{ matrix.module }}-service >> $GITHUB_OUTPUT + echo cluster_repo=ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service >> $GITHUB_OUTPUT + + - name: Download sealos + uses: actions/download-artifact@v3 + with: + name: sealos + path: /tmp/ + - name: Verify sealos + run: | + sudo chmod a+x /tmp/sealos + sudo mv /tmp/sealos /usr/bin/sealos + sudo sealos version + + - name: Sealos login to ghcr.io + # if push to master, then login to ghcr.io + run: | + sudo sealos login -u ${{ github.repository_owner }} -p ${{ secrets.GH_PAT }} --debug ghcr.io + + - name: Mutate image tag in deploy files + working-directory: service/${{ matrix.module }}/deploy + run: | + OLD_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.old_docker_repo }}:latest + NEW_DOCKER_IMAGE_NAME=${{ steps.prepare.outputs.new_docker_repo }}:${{ steps.prepare.outputs.tag_name }} + sed -i "s;${OLD_DOCKER_IMAGE_NAME};${NEW_DOCKER_IMAGE_NAME};" manifests/* + + - name: Build ${{ matrix.module }}-service cluster image + working-directory: service/${{ matrix.module }}/deploy + run: | + CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }} + sudo sealos build -t ${CLUSTER_IMAGE_NAME}-amd64 --platform linux/amd64 -f Kubefile + sudo sealos build -t ${CLUSTER_IMAGE_NAME}-arm64 --platform linux/arm64 -f Kubefile + sudo sealos images + - name: Build ${{ matrix.module }}-service cluster image for latest + run: | + CLUSTER_IMAGE_NAME=${{ steps.prepare.outputs.cluster_repo }}:${{ steps.prepare.outputs.tag_name }} + CLUSTER_IMAGE_NAME_LATEST=${{ steps.prepare.outputs.cluster_repo }}:latest + sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64 + sudo sealos tag ${CLUSTER_IMAGE_NAME}-amd64 ${CLUSTER_IMAGE_NAME_LATEST}-amd64 + sudo sealos images + bash docker/patch/manifest-cluster-images.sh $CLUSTER_IMAGE_NAME_LATEST + - name: Renew issue and Sync Images + uses: labring/gh-rebot@v0.0.6 + if: ${{ github.repository_owner == env.DEFAULT_OWNER }} + with: + version: v0.0.8-rc1 + env: + GH_TOKEN: "${{ secrets.GH_PAT }}" + SEALOS_TYPE: "issue_renew" + SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos" + SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md" + SEALOS_ISSUE_LABEL: "dayly-report" + SEALOS_ISSUE_TYPE: "day" + SEALOS_ISSUE_REPO: "labring-actions/cluster-image" + SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:${{ steps.prepare.outputs.tag_name }}" + - name: Renew issue and Sync Images for latest + uses: labring/gh-rebot@v0.0.6 + if: ${{ github.repository_owner == env.DEFAULT_OWNER }} + with: + version: v0.0.8-rc1 + env: + GH_TOKEN: "${{ secrets.GH_PAT }}" + SEALOS_TYPE: "issue_renew" + SEALOS_ISSUE_TITLE: "[DaylyReport] Auto build for sealos" + SEALOS_ISSUE_BODYFILE: "scripts/ISSUE_RENEW.md" + SEALOS_ISSUE_LABEL: "dayly-report" + SEALOS_ISSUE_TYPE: "day" + SEALOS_ISSUE_REPO: "labring-actions/cluster-image" + SEALOS_COMMENT_BODY: "/imagesync ghcr.io/${{ github.repository_owner }}/sealos-cloud-${{ matrix.module }}-service:latest" diff --git a/deploy/cloud/init.sh b/deploy/cloud/init.sh index a0ca4f99867..69c3ffbd53d 100644 --- a/deploy/cloud/init.sh +++ b/deploy/cloud/init.sh @@ -13,6 +13,7 @@ sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cl sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-costcenter-frontend:latest sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-licenseissuer-controller:latest sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-template-frontend:latest +sealos pull --policy=always --platform=linux/"${ARCH}" ghcr.io/labring/sealos-cloud-database-service:latest sealos save -o tars/user.tar ghcr.io/labring/sealos-cloud-user-controller:latest sealos save -o tars/terminal.tar ghcr.io/labring/sealos-cloud-terminal-controller:latest @@ -28,3 +29,4 @@ sealos save -o tars/frontend-dbprovider.tar ghcr.io/labring/sealos-cloud-dbprovi sealos save -o tars/frontend-costcenter.tar ghcr.io/labring/sealos-cloud-costcenter-frontend:latest sealos save -o tars/frontend-applaunchpad.tar ghcr.io/labring/sealos-cloud-applaunchpad-frontend:latest sealos save -o tars/frontend-template.tar ghcr.io/labring/sealos-cloud-template-frontend:latest +sealos save -o tars/database-service.tar ghcr.io/labring/sealos-cloud-database-service:latest \ No newline at end of file diff --git a/deploy/cloud/manifests/db-metrics.yaml b/deploy/cloud/manifests/db-metrics.yaml deleted file mode 100644 index 1ce223e654a..00000000000 --- a/deploy/cloud/manifests/db-metrics.yaml +++ /dev/null @@ -1,83 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - labels: - app: database-monitor - name: database-monitor-config - namespace: sealos -data: - config.yml: | - server: - addr: ":9090" ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: database-monitor - name: database-monitor-deployment - namespace: sealos -spec: - replicas: 1 - selector: - matchLabels: - app: database-monitor - strategy: - type: Recreate - template: - metadata: - labels: - app: database-monitor - spec: - containers: - - args: - - /config/config.yml - command: - - /manager - env: - - name: PROMETHEUS_SERVICE_HOST - value: http://kb-addon-prometheus-server. - image: ghcr.io/labring/sealos-cloud-database-monitor:latest - imagePullPolicy: Always - name: database-monitor - ports: - - containerPort: 9090 - protocol: TCP - resources: - requests: - cpu: 1m - memory: 500M - securityContext: - allowPrivilegeEscalation: false - capabilities: - drop: - - ALL - runAsNonRoot: true - terminationMessagePath: /dev/termination-log - terminationMessagePolicy: File - volumeMounts: - - mountPath: /config - name: config-vol - dnsPolicy: ClusterFirst - restartPolicy: Always - volumes: - - configMap: - defaultMode: 420 - name: database-monitor-config - name: config-vol ---- -apiVersion: v1 -kind: Service -metadata: - labels: - app: database-monitor - name: database-monitor - namespace: sealos -spec: - ports: - - name: http - port: 9090 - protocol: TCP - targetPort: 9090 - selector: - app: database-monitor diff --git a/deploy/cloud/scripts/init.sh b/deploy/cloud/scripts/init.sh index 858272c27e4..aecee27d541 100644 --- a/deploy/cloud/scripts/init.sh +++ b/deploy/cloud/scripts/init.sh @@ -19,9 +19,6 @@ function prepare { # apply notifications crd kubectl apply -f manifests/notifications_crd.yaml - # apply kb database metrics - kubectl apply -f manifests/db-metrics.yaml - # gen mongodb uri gen_mongodbUri @@ -162,6 +159,9 @@ function sealos_run_frontend { --env cloudDomain=$cloudDomain \ --env cloudPort=$cloudPort \ --env certSecretName="wildcard-cert" + + echo "run db monitoring" + sealos run tars/database-service.tar } function resource_exists { diff --git a/service/database/deploy/Kubefile b/service/database/deploy/Kubefile new file mode 100644 index 00000000000..035ec02f5a0 --- /dev/null +++ b/service/database/deploy/Kubefile @@ -0,0 +1,5 @@ +FROM scratch +COPY registry registry +COPY manifests manifests + +CMD ["kubectl apply -f manifests/deploy.yaml"] \ No newline at end of file diff --git a/service/database/deploy/manifests/deploy.yaml b/service/database/deploy/manifests/deploy.yaml index 1ce223e654a..43d7906dfc9 100644 --- a/service/database/deploy/manifests/deploy.yaml +++ b/service/database/deploy/manifests/deploy.yaml @@ -37,7 +37,7 @@ spec: env: - name: PROMETHEUS_SERVICE_HOST value: http://kb-addon-prometheus-server. - image: ghcr.io/labring/sealos-cloud-database-monitor:latest + image: ghcr.io/labring/sealos-database-service:latest imagePullPolicy: Always name: database-monitor ports: diff --git a/service/database/deploy/manifests/victoriaMetrics/cm.yaml b/service/database/deploy/victoriaMetrics/cm.yaml similarity index 100% rename from service/database/deploy/manifests/victoriaMetrics/cm.yaml rename to service/database/deploy/victoriaMetrics/cm.yaml diff --git a/service/database/deploy/manifests/victoriaMetrics/rbac.yaml b/service/database/deploy/victoriaMetrics/rbac.yaml similarity index 100% rename from service/database/deploy/manifests/victoriaMetrics/rbac.yaml rename to service/database/deploy/victoriaMetrics/rbac.yaml diff --git a/service/database/deploy/manifests/victoriaMetrics/vmagent.yaml b/service/database/deploy/victoriaMetrics/vmagent.yaml similarity index 100% rename from service/database/deploy/manifests/victoriaMetrics/vmagent.yaml rename to service/database/deploy/victoriaMetrics/vmagent.yaml diff --git a/service/database/deploy/manifests/victoriaMetrics/vminsert.yaml b/service/database/deploy/victoriaMetrics/vminsert.yaml similarity index 100% rename from service/database/deploy/manifests/victoriaMetrics/vminsert.yaml rename to service/database/deploy/victoriaMetrics/vminsert.yaml diff --git a/service/database/deploy/manifests/victoriaMetrics/vmselect.yaml b/service/database/deploy/victoriaMetrics/vmselect.yaml similarity index 100% rename from service/database/deploy/manifests/victoriaMetrics/vmselect.yaml rename to service/database/deploy/victoriaMetrics/vmselect.yaml diff --git a/service/database/deploy/manifests/victoriaMetrics/vmstorage.yaml b/service/database/deploy/victoriaMetrics/vmstorage.yaml similarity index 100% rename from service/database/deploy/manifests/victoriaMetrics/vmstorage.yaml rename to service/database/deploy/victoriaMetrics/vmstorage.yaml