CNCF Meshery Playground - Reset Non-essential Namespaces and Reboot #95
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CNCF Meshery Playground - Reset Non-essential Namespaces and Reboot | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * *' # Run the job every day at midnight UTC | |
jobs: | |
reset: | |
name: Cluster Reset | |
if: github.repository == 'meshery/meshery' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: azure/setup-kubectl@v3 | |
- name: Extract kubeconfig | |
run: mkdir ~/.kube; touch ~/.kube/config ;echo "${{ secrets.PLAYGROUND_CONFIG }}" | base64 --decode > ~/.kube/config | |
- name: Delete namespaces except the ones which are whitelisted in the if statement | |
run: | | |
for ns in $(kubectl get ns -o jsonpath="{.items[*].metadata.name}"); | |
do | |
if [[ "$ns" != "kube-system" && "$ns" != "default" && "$ns" != "monitoring" && "$ns" != "kube-flannel" && "$ns" != "kube-node-lease" && "$ns" != "kube-public" && "$ns" != "meshery" && "$ns" != "metallb-system" && "$ns" != "projectcontour" ]];then | |
echo "Deleting namespace $ns" | |
kubectl delete ns "$ns" | |
fi | |
done | |
reboot: | |
name: Reboot Metal servers | |
if: github.repository == 'meshery/meshery' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download and install Equinix Metal CLI | |
run: | | |
curl -L https://github.com/equinix/metal-cli/releases/latest/download/metal-linux-amd64 -o metal | |
chmod +x metal | |
sudo mv metal /usr/local/bin/metal | |
- name: Reboot both servers | |
env: | |
METAL_AUTH_TOKEN: ${{ secrets.METAL_AUTH_TOKEN }} | |
run: | | |
METAL_AUTH_TOKEN=$METAL_AUTH_TOKEN metal device reboot -i ${{ secrets.METAL_SERVER1 }} | |
METAL_AUTH_TOKEN=$METAL_AUTH_TOKEN metal device reboot -i ${{ secrets.METAL_SERVER2 }} |