Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCP Experiment Pipeline #311

Merged
merged 8 commits into from
Sep 25, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
193 changes: 193 additions & 0 deletions .github/workflows/gcp-experiment-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
---
name: GCP-Experiment-Pipeline
on:
workflow_dispatch:
inputs:
goExperimentImage:
default: "litmuschaos/go-runner:ci"
operatorImage:
default: "litmuschaos/chaos-operator:ci"
runnerImage:
default: "litmuschaos/chaos-runner:ci"
chaosNamespace:
default: "default"
experimentImagePullPolicy:
default: "Always"

jobs:
GCP_VM_Instance_Stop:
runs-on: ubuntu-latest
steps:

#Install and configure a k3s cluster
- name: Installing Prerequisites (K3S Cluster)
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
curl -sfL https://get.k3s.io | sh -s - --docker --write-kubeconfig-mode 664
kubectl wait node --all --for condition=ready --timeout=90s
mkdir -p $HOME/.kube && cat /etc/rancher/k3s/k3s.yaml > $HOME/.kube/config
kubectl get nodes

- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.14'

- name: Create Kubernetes secret for gcp experiment
if: always()
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: cloud-secret
type: Opaque
stringData:
type: "service_account"
project_id: "${{ secrets.GCP_PROJECT_ID }}"
private_key_id: "${{ secrets.PRIVATE_KEY_ID }}"
private_key: ${{ secrets.PRIVATE_KEY }}
client_email: "${{ secrets.CLIENT_EMAIL }}"
client_id: "${{ secrets.CLIENT_ID }}"
auth_uri: "${{ secrets.AUTH_URI }}"
token_uri: "${{ secrets.TOKEN_URI }}"
auth_provider_x509_cert_url: "${{ secrets.AUTH_PROVIDER_CERT_URL }}"
client_x509_cert_url: "${{ secrets.CLIENT_CERT_URL }}"
EOF

- name: Set up Google Cloud SDK
if: always()
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true

- name: Create target GCP VM Instances
if: always()
run: |
gcloud compute instances create ${{ secrets.INSTANCE_ONE }} ${{ secrets.INSTANCE_TWO }} \
neelanjan00 marked this conversation as resolved.
Show resolved Hide resolved
--machine-type=${{ secrets.MACHINE_TYPE }} \
--zone=${{ secrets.ZONE }}

- name: Litmus Infra Setup
if: always()
run: make build-litmus
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
OPERATOR_IMAGE: "${{ github.event.inputs.operatorImage }}"
RUNNER_IMAGE: "${{ github.event.inputs.runnerImage }}"

- name: Run GCP VM Instance Stop experiment in serial & parallel mode
if: always()
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
VM_INSTANCE_NAMES: "${{ secrets.INSTANCE_ONE }},${{ secrets.INSTANCE_TWO }}"
INSTANCE_ZONES: "${{ secrets.ZONE }},${{ secrets.ZONE }}"
GO_EXPERIMENT_IMAGE: "${{ github.event.inputs.goExperimentImage }}"
EXPERIMENT_IMAGE_PULL_POLICY: "${{ github.event.inputs.experimentImagePullPolicy }}"
CHAOS_NAMESPACE: "${{ github.event.inputs.chaosNamespace }}"
run: make gcp-vm-instance-stop

- name: Delete target GCP VM Instances
if: always()
run: |
gcloud compute instances delete ${{ secrets.INSTANCE_ONE }} ${{ secrets.INSTANCE_TWO }} \
--zone=${{ secrets.ZONE }} \
--quiet

GCP_VM_Disk_Loss:
runs-on: ubuntu-latest
needs: GCP_VM_Instance_Stop
steps:

#Install and configure a k3s cluster
- name: Installing Prerequisites (K3S Cluster)
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
curl -sfL https://get.k3s.io | sh -s - --docker --write-kubeconfig-mode 664
kubectl wait node --all --for condition=ready --timeout=90s
mkdir -p $HOME/.kube && cat /etc/rancher/k3s/k3s.yaml > $HOME/.kube/config
kubectl get nodes

- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.14'

- name: Create Kubernetes secret for gcp experiment
if: always()
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: cloud-secret
type: Opaque
stringData:
type: "service_account"
project_id: "${{ secrets.GCP_PROJECT_ID }}"
private_key_id: "${{ secrets.PRIVATE_KEY_ID }}"
private_key: ${{ secrets.PRIVATE_KEY }}
client_email: "${{ secrets.CLIENT_EMAIL }}"
client_id: "${{ secrets.CLIENT_ID }}"
auth_uri: "${{ secrets.AUTH_URI }}"
token_uri: "${{ secrets.TOKEN_URI }}"
auth_provider_x509_cert_url: "${{ secrets.AUTH_PROVIDER_CERT_URL }}"
client_x509_cert_url: "${{ secrets.CLIENT_CERT_URL }}"
EOF

- name: Set up Google Cloud SDK
if: always()
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true

- name: Create a GCP VM Instance with target Disk Volumes
if: always()
run: |
gcloud compute instances create ${{ secrets.INSTANCE_ONE }} \
--machine-type=${{ secrets.MACHINE_TYPE }} \
--zone=${{ secrets.ZONE }} \
--create-disk name=${{ secrets.DISK_ONE }},size=1GB,device-name=${{ secrets.DISK_ONE }} \
--create-disk name=${{ secrets.DISK_TWO }},size=1GB,device-name=${{ secrets.DISK_TWO }}

- name: Litmus Infra Setup
if: always()
run: make build-litmus
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
OPERATOR_IMAGE: "${{ github.event.inputs.operatorImage }}"
RUNNER_IMAGE: "${{ github.event.inputs.runnerImage }}"

- name: Run GCP VM Disk Loss experiment in serial & parallel mode
if: always()
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
DISK_VOLUME_NAMES: "${{ secrets.DISK_ONE }},${{ secrets.DISK_TWO }}"
DISK_ZONES: "${{ secrets.ZONE }},${{ secrets.ZONE }}"
DEVICE_NAMES: "${{ secrets.DISK_ONE }},${{ secrets.DISK_TWO }}"
GO_EXPERIMENT_IMAGE: "${{ github.event.inputs.goExperimentImage }}"
EXPERIMENT_IMAGE_PULL_POLICY: "${{ github.event.inputs.experimentImagePullPolicy }}"
CHAOS_NAMESPACE: "${{ github.event.inputs.chaosNamespace }}"
run: make gcp-vm-disk-loss

- name: Delete the VM Instance and target Disk Volumes
if: always()
run: |
gcloud compute instances delete ${{ secrets.INSTANCE_ONE }} \
--zone=${{ secrets.ZONE }} \
--delete-disks=all \
--quiet
183 changes: 183 additions & 0 deletions .github/workflows/scheduled-gcp-experiment-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
---
name: Scheduled-GCP-Experiment-Pipeline
on:
schedule:
- cron: "30 22 * * *" # Daily 02:30 AM in midnight

jobs:
GCP_VM_Instance_Stop:
runs-on: ubuntu-latest
steps:

#Install and configure a k3s cluster
- name: Installing Prerequisites (K3S Cluster)
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
curl -sfL https://get.k3s.io | sh -s - --docker --write-kubeconfig-mode 664
kubectl wait node --all --for condition=ready --timeout=90s
mkdir -p $HOME/.kube && cat /etc/rancher/k3s/k3s.yaml > $HOME/.kube/config
kubectl get nodes

- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.14'

- name: Create Kubernetes secret for gcp experiment
if: always()
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: cloud-secret
type: Opaque
stringData:
type: service_account
project_id: ${{ secrets.GCP_PROJECT_ID }}
private_key_id: ${{ secrets.PRIVATE_KEY_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
client_email: ${{ secrets.CLIENT_EMAIL }}
client_id: ${{ secrets.CLIENT_ID }}
auth_uri: ${{ secrets.AUTH_URI }}
token_uri: ${{ secrets.TOKEN_URI }}
auth_provider_x509_cert_url: ${{ secrets.AUTH_PROVIDER_CERT_URL }}
client_x509_cert_url: ${{ secrets.CLIENT_CERT_URL }}
EOF

- name: Set up Google Cloud SDK
if: always()
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true

- name: Create target GCP VM Instances
if: always()
run: |
gcloud compute instances create ${{ secrets.INSTANCE_ONE }} ${{ secrets.INSTANCE_TWO }} \
--machine-type=${{ secrets.MACHINE_TYPE }} \
--zone=${{ secrets.ZONE }}

- name: Litmus Infra Setup
if: always()
run: make build-litmus
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
OPERATOR_IMAGE: "${{ github.event.inputs.operatorImage }}"
RUNNER_IMAGE: "${{ github.event.inputs.runnerImage }}"

- name: Run GCP VM Instance Stop experiment in serial & parallel mode
if: always()
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
VM_INSTANCE_NAMES: "${{ secrets.INSTANCE_ONE }},${{ secrets.INSTANCE_TWO }}"
INSTANCE_ZONES: "${{ secrets.ZONE }},${{ secrets.ZONE }}"
GO_EXPERIMENT_IMAGE: "${{ github.event.inputs.goExperimentImage }}"
EXPERIMENT_IMAGE_PULL_POLICY: "${{ github.event.inputs.experimentImagePullPolicy }}"
CHAOS_NAMESPACE: "${{ github.event.inputs.chaosNamespace }}"
run: make gcp-vm-instance-stop

- name: Delete target GCP VM Instances
if: always()
run: |
gcloud compute instances delete ${{ secrets.INSTANCE_ONE }} ${{ secrets.INSTANCE_TWO }} \
--zone=${{ secrets.ZONE }} \
--quiet

GCP_VM_Disk_Loss:
runs-on: ubuntu-latest
needs: GCP_VM_Instance_Stop
steps:

#Install and configure a k3s cluster
- name: Installing Prerequisites (K3S Cluster)
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
curl -sfL https://get.k3s.io | sh -s - --docker --write-kubeconfig-mode 664
kubectl wait node --all --for condition=ready --timeout=90s
mkdir -p $HOME/.kube && cat /etc/rancher/k3s/k3s.yaml > $HOME/.kube/config
kubectl get nodes

- uses: actions/checkout@v2

- uses: actions/setup-go@v2
with:
go-version: '1.14'

- name: Create Kubernetes secret for gcp experiment
if: always()
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
run: |
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Secret
metadata:
name: cloud-secret
type: Opaque
stringData:
type: service_account
project_id: ${{ secrets.GCP_PROJECT_ID }}
private_key_id: ${{ secrets.PRIVATE_KEY_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
client_email: ${{ secrets.CLIENT_EMAIL }}
client_id: ${{ secrets.CLIENT_ID }}
auth_uri: ${{ secrets.AUTH_URI }}
token_uri: ${{ secrets.TOKEN_URI }}
auth_provider_x509_cert_url: ${{ secrets.AUTH_PROVIDER_CERT_URL }}
client_x509_cert_url: ${{ secrets.CLIENT_CERT_URL }}
EOF

- name: Set up Google Cloud SDK
if: always()
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true

- name: Create a GCP VM Instance with target Disk Volumes
if: always()
run: |
gcloud compute instances create ${{ secrets.INSTANCE_ONE }} \
--machine-type=${{ secrets.MACHINE_TYPE }} \
--zone=${{ secrets.ZONE }} \
--create-disk name=${{ secrets.DISK_ONE }},size=1GB,device-name=${{ secrets.DISK_ONE }} \
uditgaurav marked this conversation as resolved.
Show resolved Hide resolved
--create-disk name=${{ secrets.DISK_TWO }},size=1GB,device-name=${{ secrets.DISK_TWO }}

- name: Litmus Infra Setup
if: always()
run: make build-litmus
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
OPERATOR_IMAGE: "${{ github.event.inputs.operatorImage }}"
RUNNER_IMAGE: "${{ github.event.inputs.runnerImage }}"

- name: Run GCP VM Disk Loss experiment in serial & parallel mode
if: always()
env:
KUBECONFIG: /etc/rancher/k3s/k3s.yaml
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
DISK_VOLUME_NAMES: "${{ secrets.DISK_ONE }},${{ secrets.DISK_TWO }}"
DISK_ZONES: "${{ secrets.ZONE }},${{ secrets.ZONE }}"
DEVICE_NAMES: "${{ secrets.DISK_ONE }},${{ secrets.DISK_TWO }}"
GO_EXPERIMENT_IMAGE: "${{ github.event.inputs.goExperimentImage }}"
uditgaurav marked this conversation as resolved.
Show resolved Hide resolved
EXPERIMENT_IMAGE_PULL_POLICY: "${{ github.event.inputs.experimentImagePullPolicy }}"
CHAOS_NAMESPACE: "${{ github.event.inputs.chaosNamespace }}"
run: make gcp-vm-disk-loss

- name: Delete the VM Instance and target Disk Volumes
if: always()
run: |
gcloud compute instances delete ${{ secrets.INSTANCE_ONE }} \
--zone=${{ secrets.ZONE }} \
--delete-disks=all \
--quiet
Loading