-
Notifications
You must be signed in to change notification settings - Fork 58
77 lines (66 loc) · 2.93 KB
/
k8s.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: k8s deployment validation
on:
pull_request:
paths:
- "k8s/*"
- ".github/workflows/k8s.yaml"
jobs:
check-k8s:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: test
uses: vetyy/kubeval-action@master
with:
strict: true
files: ./k8s
ignore_missing_schemas: false
additional_schema_locations: https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/
run-k8s-deployment:
runs-on: ubuntu-latest
env:
namespace: monocle
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Start minikube
uses: medyagh/[email protected]
with:
minikube-version: latest
kubernetes-version: stable
- name: run k8s deployment on the cluster
run: |
echo CRAWLERS_API_KEY=$(uuidgen) > .secrets
kubectl create namespace "${namespace}"
kubectl -n "${namespace}" create secret generic monocle-secrets --from-file=.secrets
kubectl create --namespace "${namespace}" --filename ./k8s/
- name: validate components have been deployed successfuly
run: |
deploy_pod_labels_raw=$(kubectl get --namespace "${namespace}" --filename ./k8s/elastic-deployment.yaml --output go-template='{{ range $k, $v :=.spec.selector.matchLabels }}{{$k}}={{$v}},{{ end }}')
deploy_pod_labels_elastic=$(echo "${deploy_pod_labels_raw}" | rev | cut --delimiter=',' --fields='2-' | rev)
while [[ $(kubectl get po --namespace "${namespace}" --no-headers 2>/dev/null | wc -l) -eq 0 ]]; do
echo -n "."
sleep 1s
done
echo
kubectl wait --for=condition=Ready --namespace "${namespace}" pods --selector "${deploy_pod_labels_elastic}" --timeout=2m
kubectl wait --for=condition=Ready --namespace "${namespace}" pods --all
kubectl get po --namespace "${namespace}"
- name: Display indexes
run: |
kubectl port-forward --namespace "${namespace}" $( kubectl get --namespace "${namespace}" -f k8s/elastic-service.yaml --output name) 9200:9200 &
sleep 30s
curl -s -I -X GET http://localhost:9200/_cat/indices
kill %1
- name: Check api service
run: |
kubectl port-forward --namespace "${namespace}" $( kubectl get --namespace "${namespace}" -f k8s/api-service.yaml --output name) 8080:8080 &
sleep 30s
curl -s --fail -H 'Content-type: application/json' http://localhost:8080/api/2/get_workspaces -d '{}' | grep 'workspaces'
kill %1
- name: Check web service to fetch web app
run: |
kubectl port-forward --namespace "${namespace}" $( kubectl get --namespace "${namespace}" -f k8s/api-service.yaml --output name) 8080:8080 &
sleep 30s
curl -s http://localhost:8080/index.html | grep 'window.document.title'
kill %1