generated from tomkerkhove/template
-
-
Notifications
You must be signed in to change notification settings - Fork 24
133 lines (107 loc) · 4.43 KB
/
ci-agent-resource-discovery.yml
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Helm Chart CI - Resource Discovery Agent
on:
workflow_dispatch:
push:
branches:
- 'main'
pull_request:
paths:
- '.github/workflows/ci-agent-resource-discovery.yml'
- 'promitor-agent-resource-discovery/**'
jobs:
lint-helm-3-x:
name: Lint Helm Chart
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Helm install
uses: Azure/setup-helm@v3
- name: Lint Promitor Resource Discovery Helm chart
run: helm lint promitor-agent-resource-discovery --values examples/promitor-agent-resource-discovery.config.yaml
deploy-helm-3-x:
name: Deploy to Kubernetes ${{ matrix.kubernetesVersion }} (Kind)
needs: [lint-helm-3-x]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
kubernetesVersion: [v1.27, v1.26, v1.25, v1.24]
include:
# Images are defined on every Kind release
# See https://github.com/kubernetes-sigs/kind/releases
- kubernetesVersion: v1.27
kindImage: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
- kubernetesVersion: v1.26
kindImage: kindest/node:v1.26.6@sha256:6e2d8b28a5b601defe327b98bd1c2d1930b49e5d8c512e1895099e4504007adb
- kubernetesVersion: v1.25
kindImage: kindest/node:v1.25.11@sha256:227fa11ce74ea76a0474eeefb84cb75d8dad1b08638371ecf0e86259b35be0c8
- kubernetesVersion: v1.24
kindImage: kindest/node:v1.24.15@sha256:7db4f8bea3e14b82d12e044e25e34bd53754b7f2b0e9d56df21774e6f66a70ab
env:
kubernetes_namespace: promitor
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Helm install
uses: Azure/setup-helm@v3
- name: Create k8s ${{ matrix.kubernetesVersion }} Kind Cluster
uses: helm/[email protected]
with:
node_image: ${{ matrix.kindImage }}
- name: Show Kubernetes version
run: |
kubectl version
- name: Show Kubernetes nodes
run: |
kubectl get nodes -o wide
- name: Show Helm version
run: |
helm version
- name: Create Promitor namespace
run: kubectl create ns ${{ env.kubernetes_namespace }}
- name: Change Kubernetes context to use Promitor namespace
run: kubectl config set-context --current --namespace=${{ env.kubernetes_namespace }}
- name: Template Helm chart
run: helm template promitor-agent-resource-discovery ./promitor-agent-resource-discovery/ --values examples/promitor-agent-resource-discovery.config.yaml
- name: Install Helm chart
run: helm install promitor-agent-resource-discovery ./promitor-agent-resource-discovery/ --values examples/promitor-agent-resource-discovery.config.yaml --wait
- name: Wait for Kubernetes workload to spin up
run: sleep 30s
shell: bash
- name: Show installed Helm charts
run: helm ls
if: always()
- name: Show Kubernetes resources
run: kubectl get all
if: always()
- name: Show Pod Logs
run: |
CONTAINER_RESTART_COUNT=$(kubectl get pod -l app.kubernetes.io/name=promitor-agent-resource-discovery -o=jsonpath='{.items[0].status.containerStatuses[0].restartCount}')
kubectl logs -l app.kubernetes.io/name=promitor-agent-resource-discovery
echo "Current container logs"
kubectl logs -l app.kubernetes.io/name=promitor-agent-resource-discovery
if [ "$CONTAINER_RESTART_COUNT" -gt 0 ]; then
echo "Previous container logs"
kubectl logs -l app.kubernetes.io/name=promitor-agent-resource-discovery --previous
fi
if: always()
- name: Show Pod Info
run: kubectl describe pod -l app.kubernetes.io/name=promitor-agent-resource-discovery
if: always()
- name: Verify Pod & Container Status is Running
run: |
POD_STATUS=$(kubectl get pod -l app.kubernetes.io/name=promitor-agent-resource-discovery -o=jsonpath='{.items[0].status.phase}')
echo "Pod status is ${POD_STATUS}."
CONTAINER_READY=$(kubectl get pod -l app.kubernetes.io/name=promitor-agent-resource-discovery -o=jsonpath='{.items[0].status.containerStatuses[0].ready}')
echo "Is the container ready: ${CONTAINER_READY}."
if [ "$POD_STATUS" = "Running" ]; then
if $CONTAINER_READY; then
exit 0
else
exit -1
fi
else
exit -1
fi
if: always()