forked from meshery/meshsync
-
Notifications
You must be signed in to change notification settings - Fork 0
174 lines (168 loc) · 7.75 KB
/
e2etests.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: E2E tests for MeshSync
on: [push]
# push:
# branches:
# - "*"
# pull_request:
# branches:
# - "*"
jobs:
image-build:
name: Image Build Job
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export
uses: docker/build-push-action@v5
with:
context: .
tags: meshery-meshsync:test
outputs: type=docker,dest=/tmp/meshery-meshsync.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: meshery-meshsync
path: /tmp/meshery-meshsync.tar
e2e-test:
name: End to End
runs-on: ubuntu-22.04
needs: image-build
strategy:
fail-fast: false
matrix:
k8s_version: ["v1.21.5", "v1.22.2", "v1.23.9", "v1.25.2", "v1.26.11", "v1.27.8", "v1.28.4", "v1.29.0"]
steps:
- name: Install JQ
run: |
sudo apt-get install jq
- name: Setup Kubernetes
uses: manusa/[email protected]
with:
minikube version: 'v1.30.1'
kubernetes version: ${{matrix.k8s_version}}
driver: docker
- name: Retrieve kubeconfig
run: |
echo "Before flattening"
cat ~/.kube/config
kubectl config view --minify --flatten > ~/.kube/configtemp
mv ~/.kube/configtemp ~/.kube/config
echo "After flattening"
cat ~/.kube/config
# Setup meshery config.yaml and auth.json
- name: Setup meshery config and infinite token for use
env:
provider_token: ${{ secrets.PROVIDER_TOKEN }}
provider: "Meshery"
run: |
echo $provider_token
mkdir ~/.meshery
config='{"contexts":{"local":{"endpoint":"http://localhost:9081","token":"default","platform":"kubernetes","components":[],"channel":"stable","version":"latest"}},"current-context":"local","tokens":[{"location":"auth.json","name":"default"}]}'
echo $config > ~/.meshery/config.yaml
cat ~/.meshery/config.yaml
echo "Using provider": $provider
if [ $provider = "Meshery" ] && [ "$provider_token" != "" ] ;then
echo '{ "meshery-provider": "Meshery", "token": null }' | jq -c '.token = "'$provider_token'"' > ~/.meshery/auth.json
else
echo '{ "meshery-provider": "None", "token": "" }' > ~/.meshery/auth.json
fi
cat ~/.meshery/auth.json
- name: Cluster info for debugging before starting Meshery
run: kubectl get all -A
# Start Meshery Server (Assuming that this step will create the meshery namespace)
- name: Start Meshery Server using mesheryctl
run: |
curl -L https://meshery.io/install | PLATFORM=kubernetes bash -
# wait for Meshery constituent parts to become operational
kubectl wait --for=condition=Ready pod --all --all-namespaces --timeout=300s
- name: Run minikube tunnel
run: |
echo 'Running minikube tunnel'
minikube tunnel $> /dev/null &
shell: bash
# If external IP has not been allotted then server is unreachable, exit here in that case
- name: Check if Meshery has been allotted external IP
run: |
svcstatus=$(kubectl get svc -n meshery| grep meshery | tr -s ' ' | cut -d " " -f 4)
echo $svcstatus
if [ "$svcstatus" = "<pending>" ];then
exit 1
fi
# Reset meshery's address to the external IP in config.yaml such that mesheryctl can reach it
- name: Reset Meshery address
run: |
kubectl get svc -n meshery
svcip="http://$(kubectl get svc -n meshery | grep "meshery " | tr -s ' ' | cut -d " " -f 3):9081"
echo "this is $svcip"
config='{"contexts":{"local":{"endpoint":'$svcip',"token":"default","platform":"kubernetes","adapters":["name":"meshery-istio","location":"10000"],"channel":"stable","version":"latest"}},"current-context":"local","tokens":[{"location":"auth.json","name":"default"}]}'
echo $config > ~/.meshery/config.yam
mesheryctl mesh deploy meshery-istio
- name: System Checks
run: |
mesheryctl system check --preflight
mesheryctl system check --operator
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: meshery-meshsync
path: /tmp
- name: Load MeshSync Docker image
run: |
docker load --input /tmp/meshery-meshsync.tar
docker image ls -a
minikube image load meshery-meshsync:test
# Ensure Meshery Components are running.
- name: Check Meshery Components
run: |
kubectl rollout status deployment -n meshery
- name: Replace MeshSync
run: |
# # Set your deployment name, container name, new image version, and new image pull policy
DEPLOYMENT_NAME="meshery-meshsync"
CONTAINER_NAME="meshsync"
NEW_IMAGE_VERSION="meshery-meshsync:test"
NEW_IMAGE_PULL_POLICY="IfNotPresent"
NAMESPACE="meshery"
## Update the deployment with the new image and pull policy
kubectl scale --replicas=0 deployment ${DEPLOYMENT_NAME} -n meshery
kubectl rollout status deployment ${DEPLOYMENT_NAME} -n $NAMESPACE
kubectl set image deployment/${DEPLOYMENT_NAME} ${CONTAINER_NAME}=${NEW_IMAGE_VERSION} -n $NAMESPACE
kubectl patch -n meshery deployment meshery-meshsync -p '{"spec":{"template":{"spec":{"containers":[{"name":"meshsync","imagePullPolicy":"IfNotPresent", "image":"meshery-meshsync:test"}]}}}}'
kubectl scale --replicas=1 deployment ${DEPLOYMENT_NAME} -n meshery
kubectl rollout status deployment ${DEPLOYMENT_NAME} -n $NAMESPACE
kubectl get pods -A
kubectl wait --for=condition=Ready pod --all --all-namespaces --timeout=300s
# Deploy pod
kubectl run nginx-pod --image=nginx --labels=app=web,tier=frontend,purpose=meshsync-test
kubectl wait --for=condition=Ready pod --all --all-namespaces --timeout=300s
kubectl get pods -A
mesheryctl system logs meshery
mesheryctl system logs meshsync
CLUSTER_ID=$(kubectl get ns kube-system -o jsonpath='{.metadata.uid}')
echo $CLUSTER_ID
podname=$(kubectl get pods -n meshery | grep meshery | tr -s ' ' | cut -d " " -f 1)
kubectl logs pod/$podname -n meshery
svcip="http://$(kubectl get svc -n meshery | grep "meshery " | tr -s ' ' | cut -d " " -f 3):9081"
echo "this is $svcip"
SECONDS=0
end=$((SECONDS+300))
while [ $SECONDS -lt $end ]; do
echo $(kubectl logs pod/$podname -n meshery)
result=$(curl -s --location "${svcip}/api/system/meshsync/resources?kind=Pod&spec=true&annotations=true&labels=true&clusterIds=%5B\"${CLUSTER_ID}\"%5D&page=0&pagesize=25&search=&order=&sort=desc" \
--header "meshery-token: ${{ secrets.PROVIDER_TOKEN }}" \
--header "Cookie: meshery-provider=Meshery; token=${{ secrets.PROVIDER_TOKEN }}" | jq '.resources[].metadata.labels[] | select(.key == "purpose" and .value == "meshsync-test")')
# Check if the variable is empty (no match found)
if [ -n "$result" ]; then
echo "Match found: $result"
break
fi
done
# Check if the loop completed its iterations without finding a match
if [ -z "$result" ]; then
echo "Error: MeshSync unable to discover resources."
exit 1
fi
shell: bash