Browse Source

Merge pull request #188 from milvus-io/feat/check-insight

Feat/check insight
ryjiang 3 years ago
parent
commit
10b3b0d54b
4 changed files with 98 additions and 2 deletions
  1. 14 0
      .github/workflows/client.ovpn
  2. 56 1
      .github/workflows/dev.yml
  3. 22 0
      checkInsight.js
  4. 6 1
      server/src/app.controller.ts

+ 14 - 0
.github/workflows/client.ovpn

@@ -0,0 +1,14 @@
+client
+dev tun
+proto udp
+remote sssd.cvpn-endpoint-0dee3f0de72d9b0a5.prod.clientvpn.us-west-2.amazonaws.com 443
+resolv-retry infinite
+nobind
+remote-cert-tls server
+cipher AES-256-GCM
+verb 3
+ca ca.crt
+cert user.crt
+key user.key
+
+reneg-sec 0

+ 56 - 1
.github/workflows/dev.yml

@@ -6,7 +6,7 @@ on:
     types: [closed]
 
 jobs:
-  dev:
+  build:
     runs-on: ubuntu-latest
     if: github.event.pull_request.merged == true
     steps:
@@ -27,3 +27,58 @@ jobs:
 
       - name: Docker Push Dev
         run: docker push milvusdb/milvus-insight:dev
+
+  k8s:
+    runs-on: ubuntu-latest
+    needs: build
+    steps:
+      - uses: actions/checkout@v2
+      - name: Setup Node.js
+        uses: actions/setup-node@v1
+        with:
+          node-version: 12
+
+      - name: Install OpenVPN and kubectl
+        run: |
+          sudo apt-get update
+          sudo apt-get install openvpn -y
+          sudo apt-get install -y apt-transport-https ca-certificates curl
+          sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
+          echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
+          sudo apt-get update
+          sudo apt-get install kubectl -y
+
+      - name: Connect VPN
+        uses: golfzaptw/action-connect-ovpn@master
+        id: connect_vpn
+        with:
+          FILE_OVPN: '.github/workflows/client.ovpn'
+        env:
+          CA_CRT: ${{ secrets.VPN_CA}}
+          USER_CRT: ${{ secrets.VPN_CRT }}
+          USER_KEY: ${{ secrets.VPN_KEY }}
+
+      - name: Deploy to cluster
+        run: |
+          echo ${{ secrets.kubeconfig }} > config64
+          base64 -d config64 > kubeconfig
+          kubectl set image deployment/milvus-insight milvus-insight=milvusdb/milvus-insight:dev-${{ github.sha }} -n ued --kubeconfig=kubeconfig
+          sleep 120
+
+  check:
+    runs-on: ubuntu-latest
+    needs: [build, k8s]
+    steps:
+      - uses: actions/checkout@v2
+      - name: Setup Node.js
+        uses: actions/setup-node@v1
+        with:
+          node-version: 12
+
+      - name: Check insight status
+        env:
+          INSIGHT_URL: ${{ secrets.INSIGHT_URL }}
+        run: |
+          yarn add axios
+          yarn add @actions/core
+          node checkInsight.js

+ 22 - 0
checkInsight.js

@@ -0,0 +1,22 @@
+const axios = require('axios');
+const core = require('@actions/core');
+
+const BASE_URL = process.env.INSIGHT_URL;
+
+const check = async () => {
+  const clientRes = await axios.get(`${BASE_URL}/connect`);
+  const serverRes = await axios.get(`${BASE_URL}/api/v1/healthy`);
+  if (serverRes.data.statusCode === 200) {
+    console.log('---- Server OK -----');
+  } else {
+    core.setFailed('---- Server has some error ----');
+  }
+
+  if (clientRes.data.includes('<html')) {
+    console.log('---- Client OK -----');
+  } else {
+    core.setFailed('---- Client has some error ----');
+  }
+};
+
+check();

+ 6 - 1
server/src/app.controller.ts

@@ -1,4 +1,4 @@
-import { Controller, Request, Post, UseGuards } from '@nestjs/common';
+import { Controller, Request, Post, UseGuards, Get } from '@nestjs/common';
 import { AuthGuard } from '@nestjs/passport';
 import { AuthService } from './auth/auth.service';
 
@@ -11,4 +11,9 @@ export class AppController {
   async login(@Request() req) {
     return this.authService.login(req.user);
   }
+
+  @Get('healthy')
+  async checkServer() {
+    return { status: 200 };
+  }
 }