Solution
- Nginx containers are tested with simple
tests/nginx/nginx.robot
tests which checks that the default homepage is shown on addres specified in envWEBSITE_URL
- Tests are run as a
kind: CronJob
andkind: Job
inside the namespace report.html
(the output html of robot framework) is pushed to Minio object storage- The report is sered on another nginx container with sidecar updating the report all the time with
cronTab
Commands work on default namespace in K8
- Start kubernetes locally and switch context to it, e.g. with Docker
- Add bitnami registry with `make add-registrY``
- Install Minio
make install-minio
- Install Nginx
make install-nginx
- Install jobs
make create-jobs
- Install Nginx to serve report.html
make install-nginx-reports
You can view the cluster with Lens or whatever.
To view Minio bucket use kubectl port-forward deployments/minio 9001:9001
and then navigate to https://localhost:9001 and accept the scary window of insecure certificate. Credentials can be found from secrets with name minio
.
To view the report.html
robot report you can use kubectl port-forward deployment/nginx-reports-deployment 8080:80
and navigate to http://localhost:8080.
helm
folder contains some default values to run Minio with helm template. Commands can be run with make add-registry
and
make install-minio
to default namespace.
You can use make install-nginx
to install the default nginx to be tested with robot to the default namespace.
Jobs can be installed with make create-jobs
which installs a batchjob and a cronjob to test previously installed nginx. The container uses run.sh
as a baseline which calls robot .
to run robot testes and then runs a python script called uploader.py
from the root of the project to upload the generated robot.html
to Minio.
Report is generated to the workdir WORKDIR /home/pwuser/
defined in Dockerfile
. This is then uploaded to a bucket called
robot-reports
on Minio with the filename report.html
.
Idea is to serve the previously generated report.html
as a static web page which is updated with a sidecar container downloading it from Minio service. It has a simple Nginx container configured with files under /page/
and Dockerfile Reportpage.Dockerfile
and the downloader sidecar is defined with Downloader.Dockerfile
and downloader.py
script.
Downloader is a Apline container running the script as a crontab. It connects to minio within downloader.py
script and downloads the defined value from there and writes it into a volumeMount workdir
. The same volume is mounted to Nginx path /usr/share/nginx/html/
which is served with maintenance.conf
configuration.
The default minio chart is configured to use TLS under helm/minio-bitnami-values.yaml
with
tls:
enabled: true
autoGenerated: true
and it is mounted with
volumeMounts:
- name: cert
mountPath: "/certs/ca.crt"
subPath: ca.crt
and for the Minio clients used in uploader.py
and downloader.py
scripts it needs to be handled with customizing the httpClient` as there seems to be no other way to hande self-signed certs with the library. With correctly signed certificates the code is not needed.
httpClient = urllib3.PoolManager(
timeout=urllib3.Timeout.DEFAULT_TIMEOUT,
cert_reqs='CERT_REQUIRED',
ca_certs='/certs/ca.crt', # Mounted here
retries=urllib3.Retry(
total=5,
backoff_factor=0.2,
status_forcelist=[500, 502, 503, 504]
)
)