nameczz %!s(int64=3) %!d(string=hai) anos
pai
achega
9218b44af3

+ 22 - 0
.github/workflows/check.yml

@@ -0,0 +1,22 @@
+name: Milvus insight check insight status
+
+on:
+  push:
+    branches: [feat/check-insight]
+
+jobs:
+  dev:
+    runs-on: ubuntu-latest
+    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
+          node checkInsight.js

+ 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

+ 33 - 0
.github/workflows/dev.yml

@@ -27,3 +27,36 @@ jobs:
 
       - name: Docker Push Dev
         run: docker push milvusdb/milvus-insight:dev
+
+      - 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
+          kubectl -n ued rollout status deploy milvus-insight
+          sleep 60
+
+      - name: Check insight status
+        run: |
+          yarn add axios
+          node checkInsight.js

+ 32 - 0
checkInsight.js

@@ -0,0 +1,32 @@
+const axios = require('axios');
+
+const BASE_URL = process.env.INSIGHT_URL;
+console.log('---- check start ----- ', BASE_URL);
+
+axios
+  .get(`${BASE_URL}/api/v1/healthy`)
+  .then(res => {
+    console.log(res.data);
+    if (res.data.statusCode === 200) {
+      console.log('---- Server OK -----');
+    } else {
+      throw new Error('');
+    }
+  })
+  .then(err => {
+    throw new Error(err.message || '---- Server has some error ----');
+  });
+
+axios
+  .get(`${BASE_URL}/connect`)
+  .then(res => {
+    // if return statusCode mean it's failed. Otherwise it will return html
+    if (res.data.includes('<html')) {
+      console.log('---- Client OK -----');
+    } else {
+      throw new Error('---- Client has some error ----');
+    }
+  })
+  .catch(err => {
+    throw new Error(err.message || '---- Client has some error ----');
+  });

+ 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 };
+  }
 }