Skip to content

get meshery logs

get meshery logs #111

Workflow file for this run

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