-
Notifications
You must be signed in to change notification settings - Fork 27
GCP Experiment Pipeline #311
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
Merged
uditgaurav
merged 8 commits into
litmuschaos:master
from
neelanjan00:gcp-experiment-pipeline
Sep 25, 2021
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5ed0a72
added gcp-experiment-pipeline for gcp-vm-instance-stop and gcp-vm-dis…
14103bf
updated function identifiers
833516e
updated gcp vm disk loss test/status
8d259fe
added envs for gcp pipeline
3623e46
uppdated GCP experiment pipeline experiments secret
ea845b9
set GCP experiments envs
62e9854
randomized gcp target resource names, hard-coded vm-type and zone
57e3372
modified scheduled pipeline, updated go version, added debug and clea…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
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 }} \ | ||
--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
183
.github/workflows/scheduled-gcp-experiment-pipeline.yml
This file contains hidden or 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
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.