Skip to content

Commit

Permalink
Merge pull request #16 from RedHatQE/cloudwash_container
Browse files Browse the repository at this point in the history
The Dockerfile and buildConfig of cloudwash for OCP
  • Loading branch information
jyejare authored Jun 21, 2022
2 parents 4d25089 + cf94d2e commit 5081b2b
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 19 deletions.
32 changes: 32 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM registry.access.redhat.com/ubi8/python-38:latest
MAINTAINER "https://github.com/RedHatQE"

ENV VIRTUAL_ENV="/opt/app-root" \
HOME="/opt/app-root/src" \
CLOUDWASH_DIR="/opt/app-root/src/cloudwash" \
PYCURL_SSL_LIBRARY=openssl

USER 0
RUN yum -y clean all

# Installing cloudwash
USER 1001
WORKDIR "${HOME}"
RUN git clone https://github.com/RedHatQE/cloudwash.git && \
cd ${CLOUDWASH_DIR} && \
pip install --upgrade pip && \
pip install -r requirements.txt
# Workaround for the issue DistributionNotFound: The 'azure-mgmt-media~=1.0.0rc2' distribution was not found and is required by azure-mgmt
# RUN pip install azure-mgmt-media==1.0.0rc2

# Download conf file
RUN curl -o ${CLOUDWASH_DIR}/settings.yaml https://raw.githubusercontent.com/RedHatQE/cloudwash/master/settings.yaml.template

# arbitrary UID handling starting from virtualenv directory for pip permissions
USER 0
RUN chgrp -R 0 ${VIRTUAL_ENV} && \
chmod -R g+rwX ${VIRTUAL_ENV} && \
fix-permissions ${VIRTUAL_ENV} -P

USER 1001
WORKDIR "${CLOUDWASH_DIR}"
29 changes: 29 additions & 0 deletions Dockerfile.stable
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM registry.access.redhat.com/ubi8/python-38:latest
MAINTAINER "https://github.com/RedHatQE"

ENV VIRTUAL_ENV="/opt/app-root" \
CLOUDWASH_DIR="/opt/app-root/src/cloudwash" \
PYCURL_SSL_LIBRARY=openssl

USER 0
RUN yum -y clean all

# Installing cloudwash
USER 1001
RUN pip install --upgrade pip
RUN pip install cloudwash
# Workaround for the issue DistributionNotFound: The 'azure-mgmt-media~=1.0.0rc2' distribution was not found and is required by azure-mgmt
RUN pip install azure-mgmt-media==1.0.0rc2

# Download conf file
RUN mkdir -p ${CLOUDWASH_DIR}
RUN curl -o ${CLOUDWASH_DIR}/settings.yaml https://raw.githubusercontent.com/RedHatQE/cloudwash/master/settings.yaml.template

# arbitrary UID handling starting from virtualenv directory for pip permissions
USER 0
RUN chgrp -R 0 ${VIRTUAL_ENV} && \
chmod -R g+rwX ${VIRTUAL_ENV} && \
fix-permissions ${VIRTUAL_ENV} -P

USER 1001
WORKDIR "${CLOUDWASH_DIR}"
60 changes: 41 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cloudwash
# Cloudwash

## Introduction

Expand All @@ -11,22 +11,23 @@ cloudwash supports following cloud providers:
* Amazon EC2
* Google Cloud
* Microsoft Azure
* RedHat Enterprize Virtualization Manager - RHEV (Provisioned)
* RedHat Openstack (Provisioned)
* VMWare vCenter (Provisioned)
* 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_)

The list of resources it helps to clean are:

* VMs
* Network Interfaces
* Public IPs
* Disks

> VMs, Network Interfaces, Public IPs, Disks, Azure Resource group and more.
## Installation

`cloudwash` can be installed via `pip` once you clone this git repository locally.
It is always a good idea to use virtualenv to install pip packages.
User can run `cloudwash` multiple ways:
- [PiP Package Installation](#pip-package-installation)
- [Docker Image Installation](#docker-image-installation)
- [OC BuildConfig Installation](#oc-buildconfig-installation)

### PiP Package Installation

For Linux Users, Depending on the distribution you are using, you may need to install following packages
(or similar for your distribution of linux):
Expand All @@ -43,27 +44,48 @@ Read more about it http://pycurl.io/docs/latest/install.html
Installation:

```
# git clone https://github.com/RedHatQE/cloudwash.git
# cd cloudwash
# pip install .
# cp settings.yaml.template settings.yaml
$ mkdir ~/cloudwash && cd ~/cloudwash
$ pip install cloudwash
```

### Docker Image Installation

## Configuration
#### From Container image registry
The [container image](https://quay.io/repository/redhatqe/cloudwash) for cloudwash is available in quay. This image provides the cloudwash installed from released python package.

#### Build from local DockerFile
This github repo contains two set of docker files, use any container building service to build from the dockerfile:

1. **Stable Dockerfile** - Build container from `Dockerfile.stable` that should build a container from released python package of cloudwash. This would be very similar to quiy.io image above.
2. **Development Dockerfile** - Build container from `Dockerfile.dev` that should build a container from the cloudwash github master branch giving the access to pre-released features.

To use this tool one needs to copy the `settings.yaml.template` to `settings.yaml` as instructed in Installation section above.
Then, edit the `settings.yaml` and feed all the configuration needed to connect with the cloud providers as clients.

`cloudwash` uses the `DynaConf` configuration python module to access the data in `settings.yaml` and it allows an unique way of declaring secrets via Environment variables instead of putting in plain `settings.yaml`.
### OC BuildConfig Installation
This github repo provides the ready to use BuildConfig on OCP / Kubernetes. The build config should create buildconfigs to build stable and dev container images. Use those image to build cloudwash pod.


## Configuration

The `cloudwash` uses the `DynaConf` configuration python module to access the data in `settings.yaml`, it also allows an unique way of declaring secrets via Environment variables instead of putting in plain `settings.yaml`.

e.g: The Azure password field can be set via environment variable by exporting the environment variable

```
# export CLEANUP_PROVIDERS__AZURE__PASSWORD = myPa$$worb"
```

#### Configuration with PyPi package:

Copy `settings.yaml.template` to local `~/cloudwash` directory as `settings.yaml`, update it with the cloud provider credentials and other configuration details for successful resource reporting and cleanup.


#### Configuration with cloudwash container images:

_Either_ - The docker images have `settings.yaml` added from Dockerfile. Build the container from the image, access the container and update the `settings.yaml` with real values and commit the changes to the image. Use the commited image for cleanup activity.

_Or_ - Export/Set the environment variables for all or only sensitive credentials as shown above. The dynaconf in cloudwash container should read these credentials from environment variable.


## Usage Examples


Expand Down
60 changes: 60 additions & 0 deletions cloudwash_openshift_buildconfig.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: v1
kind: List
items:
- kind: ImageStream
apiVersion: image.openshift.io/v1
metadata:
labels:
name: cloudwash
name: cloudwash
spec:
lookupPolicy:
local: true

- kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
creationTimestamp:
labels:
name: cloudwash-stable
name: cloudwash-stable
spec:
output:
to:
kind: ImageStreamTag
name: cloudwash:stable
resources: {}
runPolicy: Serial
source:
git:
uri: https://github.com/RedHatQE/cloudwash.git
ref: master
type: Git
strategy:
dockerStrategy:
dockerfilePath: Dockerfile.stable
type: Docker

- kind: BuildConfig
apiVersion: build.openshift.io/v1
metadata:
creationTimestamp:
labels:
name: cloudwash-dev
name: cloudwash-dev
spec:
output:
to:
kind: ImageStreamTag
name: cloudwash:dev
resources: {}
runPolicy: Serial
source:
git:
uri: https://github.com/RedHatQE/cloudwash.git
ref: master
type: Git
strategy:
dockerStrategy:
dockerfilePath: Dockerfile.dev
type: Docker

0 comments on commit 5081b2b

Please sign in to comment.