Skip to content

Commit

Permalink
Merge pull request #124 from mayurilahane/mlahane/clouwash_readme
Browse files Browse the repository at this point in the history
Adding a block for how to run the cloudwash setup locally
  • Loading branch information
jyejare authored Jul 9, 2024
2 parents 40024b8 + 3e9795c commit cd91c39
Show file tree
Hide file tree
Showing 2 changed files with 161 additions and 1 deletion.
159 changes: 159 additions & 0 deletions Docs/Run_cloudwash_locally.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# How to run the cloudwash setup locally


You will need a pod spec file, config map file (optional) and a secrets file. Create files locally named:

* cloudwash.testpod.yaml:
```
apiVersion: v1
kind: Pod
metadata:
name: cloudwash-test-pod
spec:
containers:
- name: cloudwash
image: quay.io/redhatqe/cloudwash
command: ["/bin/sh"]
args: ["-c", "sleep 5000"]
volumeMounts:
- name: config-volume
mountPath: /opt/app-root/src/cloudwash/settings.yaml
subPath: settings.yaml
env:
- name: CLEANUP_AZURE__AUTH__CLIENT_ID
valueFrom:
secretKeyRef:
key: azure_client_id
name: cloudwash-secret
- name: CLEANUP_AZURE__AUTH__SECRET_ID
valueFrom:
secretKeyRef:
key: azure_client_secret
name: cloudwash-secret
- name: CLEANUP_AZURE__AUTH__TENANT_ID
valueFrom:
secretKeyRef:
key: azure_tenant_id
name: cloudwash-secret
- name: CLEANUP_AZURE__AUTH__SUBSCRIPTION_ID
valueFrom:
secretKeyRef:
key: subscription_id
name: cloudwash-secret
volumes:
- name: config-volume
configMap:
name: cloudwash-config
restartPolicy: Never
```
* cloudwash.configmap.yaml
```
apiVersion: v1
kind: ConfigMap
metadata:
name: cloudwash-config
data:
settings.yaml: |
AZURE:
AUTH:
CLIENT_ID: ""
SECRET_ID: ""
TENANT_ID: ""
SUBSCRIPTION_ID: ""
RESOURCE_GROUPS: []
REGIONS: []
CRITERIA:
VM:
DELETE_VM: ''
SLA_MINUTES: 120
DISC:
UNASSIGNED: True
NIC:
UNASSIGNED: True
IMAGE:
DELETE_IMAGE: ''
UNASSIGNED: True
PUBLIC_IP:
UNASSIGNED: True
RESOURCE_GROUP:
LOGIC: AND
DELETE_GROUP:
RESOURCES_SLA_MINUTES: 120
EXCEPTIONS:
VM:
VM_LIST: []
STOP_LIST: []
GROUP:
RG_LIST: []
IMAGES: []
```
* cloudwash.secrets.yaml
```
apiVersion: v1
kind: Secret
metadata:
name: cloudwash-secret
namespace: default
type: Opaque
stringData:
azure_client_id: "XXXXXXXX"
azure_client_secret: "XXXXXXX"
azure_tenant_id: "XXXXXXXXX"
subscription_id: "XXXXXXXXX"
```

After creating the files run these commands


Note: Ensure you have minikube installed:
https://minikube.sigs.k8s.io/docs/start/

* Check minikube status
```
minikube status
```
* If the status is stopped then start it
```
minikube start
```

* Now create all yaml files in minikube cluster:
```
minikube kubectl -- create -f cloudwash.testpod.yaml
minikube kubectl -- create -f cloudwash.configmap.yaml
minikube kubectl -- create -f Cloudwash.secrets.yaml
```

* You can check already created yaml files:
```
minikube kubectl -- get configmap
minikube kubectl -- get pods
minikube kubectl -- get secrets
```

* If required, to delete any of the yaml files:
```
minikube kubectl -- delete pod <podname>
minikube kubectl -- delete configmap <configmap name>
minikube kubectl -- delete secrets <secret name>
```
* Verify the container is running; check the below line from the pod yaml file
```
containers:
- name: cloudwash
image: quay.io/redhatqe/cloudwash
command: ["/bin/sh"]
args: ["-c", "sleep 5000"]
```
* Here the lines say to stop the cloud wash container for 5000 seconds so we can run the “swach” commands in the shell
After getting the container in a running state, run this command to enter the bash shell
```
minikube kubectl -- exec -it cloudwash-test-pod -- /bin/bash
```

* Where “cloudwash-test-pod” is the name of the pod we defined in the pod spec file.
Now it will prompt you with the shell command line. Run the cloudwash commands here:
```
pip install cloudwash
swach -d azure -- all
```
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ cloudwash supports following cloud providers:

* RedHat Enterprize Virtualization Manager - RHEV (_Support yet To be added_)
* RedHat Openstack (_Support yet To be added_)
* VMWare vCenter (_Support yet To be added_)
* OCP Clusters deplyed on Public clouds (_Support yet To be added_)

NOTE: You can use `--all` flag with all the cloud providers to clean all supported resources.
Expand Down Expand Up @@ -172,3 +171,5 @@ Removed following and all unused discs from Azure Cloud.
Removed following and all unused pips from Azure Cloud.
['test-axodawttrw-pip0']
```

### [How to run the cloudwash setup locally using Minikube](https://github.com/RedHatQE/cloudwash/blob/master/Docs/Run_cloudwash_locally.md)

0 comments on commit cd91c39

Please sign in to comment.