YAML files have been provided for deployment on Kubernetes in the yaml
directory.
They are split by whether they pertain to the APEL REST interface, APEL Server or to the persistant MySQL database. These are then further divided into files for the service itself and the service's replication controller, which is responsible for keeping the service containers running.
There are, therefore, six YAML files.
yaml/accounting-mysql-rc.yaml
- This configures the replication controller for the MySQL serviceyaml/accounting-mysql-service.yaml
- This is the MySQL serviceyaml/accounting-server-rc.yaml
- This configures the replication controller for the APEL Server serviceyaml/accounting-server-service.yaml
- This is the APEL server serviceyaml/accounting-rest-interface-rc.yaml
- This configures the replication controller for the APEL REST interface serviceyaml/accounting-rest-interface-service.yaml
- This is the APEL REST interface service
80 - all traffic to this port is forwarded to port 443 by the Apache server.
443 - the Apache server forwards (HTTPS) traffic to the APEL REST interface, which returns a Django view for recognised URL patterns.
3306 - used by the APEL REST interface and APEL Server service to communitcate with the MySQL
To do this, you must first install kubectl
(See Setting up kubectl for a guide how to do this)
-
List the "pods". You are looking for something of the form
accounting-server-rc-XXXXX
oraccounting-rest-interface-rc-XXXXX
kubectl -s kubernetes_ip --user="kubectl" --token="auth_token" --insecure-skip-tls-verify=true get pods --namespace=kube-system
Note, you will need to replace
kubernetes_ip
andauth_token
with there proper values. -
Open a terminal running on the Indigo Datacloud APEL Accounting Server
kubectl -s kubernetes_ip --user="kubectl" --token="auth_token" --insecure-skip-tls-verify=true exec -it accounting-server-rc-XXXXX --namespace=kube-system bash
Note, you will need to replace
accounting-server-rc-XXXXX
with its true value.
You should now have terminal access to the Accounting Server.
httpd
: The Apache webserver hosting the REST interfacecron
: Necessary to periodically update IGTF Trust Bundle and CRLs
apeldbloader-cloud
: Loads received messages into the MySQL imageddcron
: Necessary to periodically run the Summariser
-
/etc/init.d/apeldbloader-cloud
: Registers the cloud loader as a service -
/etc/apel/cloudloader.cfg
: Configures the cloud loader -
/etc/apel/cloudsummariser.cfg
: Configures the cloud summariser
-
/etc/httpd/conf.d/apel_rest_api.conf
: Enforces HTTPS -
/etc/httpd/conf.d/ssl.conf
: Handles the HTTPS
-
/etc/cron.d/cloudsummariser
: Cron job that runsrun_cloud_summariser.sh
-
/usr/bin/run_cloud_summariser.sh
: Stops the loader service, summarises the database and restarts the loader
-
On the IAM homepage:
- click "MitreID Dashboard"
- click "Self Service Protected Resource Registration"
- click "New Resource".
-
On the "Main" tab, give this resource an appropriate Client Name.
-
Click Save.
-
Store the ClientID, Client Secret, and Registration Access Token; as the ID and Secret will need to be put into the appropriate yaml file later, and the token will be needed to make further modifications to this registration.
- In
yaml/accounting-rest-interface-rc.yaml
, add the IAM registered ID corresponding to the service in the env variableALLOWED_FOR_GET
. It should be of form below, quotes included. Python needs to be able to interpret this variable as a list of strings, the outer quotes prevent kubernetes interpreting it as something meaningful in YAML. The accounting-rest-interface-rc on kubernetes will have to be restarted for that to take effect. This can be done by deleting the accounting-rest-interface-service pod.
"['XXXXXXXXXXXX','XXXXXXXXXXXXXXXX']".
These instructions assume the containers were previously deployed with docker-compose and they use docker-compose to upgrade to the new version
- Stop the APEL REST Interface container
docker-compose -f yaml/docker-compose.yaml stop apel_rest_interface
- In
yaml/apel_rest_interface.env
, change
IAM_URL=https://example-iam.example.url.eu/introspect
to
IAM_URLS=[\'example-iam.example.url.eu\']
- In
yaml/docker-compose.yaml
, change
indigodatacloud/accounting:1.4.0-1
to
indigodatacloud/accounting:1.5.0-1
- Now, start the APEL Rest Interface Container
docker-compose -f yaml/docker-compose.yaml up -d apel_rest_interface
This section assumes previous deployment via the docker/run_container.sh
script.
- Determine the Accounting container ID using
docker ps
. Expected output is below.
CONTAINER ID IMAGE ...
<server_container_id> indigodatacloud/accounting:1.3.2-1 ...
<database_container_id> mysql:5.6 ...
... ... ...
-
Run
docker exec -it <container_id>
to open an interactive shell from within the docker image. -
Run
service httpd stop
-
Ensure all messages have been loaded. I.e.
tail /var/log/cloud/loader.log
shows "INFO - Found 0 messages" as the last message -
Run
service apeldbloader-cloud stop
-
Comment out the summariser cron in
/etc/cron.d/cloudsummariser
-
Ensure the summariser is not running. I.e.
tail /var/log/cloud/summariser.log
. The last lines in the log should be as below:
summariser - INFO - Summarising complete.
summariser - INFO - ========================================
-
Exit the container with the
exit
command -
Stop and delete the Server and Database container.
docker stop <server_container_id> <database_container_id>
docker rm <server_container_id> <database_container_id>
- Follow README.md to deploy version 1.4.0. You will need to use the same mysql passwords as in the previous deployment.
This section assumes deployment via the docker/run_container.sh
script.
- Determine the Accounting container ID using
docker ps
. Expected output is below.
CONTAINER ID IMAGE ...
<server_container_id> indigodatacloud/accounting:1.2.1-1 ...
<database_container_id> mysql:5.6 ...
... ... ...
-
Run
docker exec -it <container_id>
to open an interactive shell from within the docker image. -
While in the container, download the update_schema.sql.
-
Run
service httpd stop
-
Ensure all messages have been loaded. I.e.
tail /var/log/cloud/loader.log
shows "INFO - Found 0 messages" as the last message -
Run
service apeldbloader-cloud stop
-
Comment out the summariser cron in
/etc/cron.d/cloudsummariser
-
Ensure the summariser is not running. I.e.
tail /var/log/cloud/summariser.log
. The last lines in the log should be as below:
summariser - INFO - Summarising complete.
summariser - INFO - ========================================
-
Exit the container with the
exit
command -
From the host, make a database dump. This is necessary to preserve data.
mysqldump -h 0.0.0.0 -u root -p apel_rest > apel_rest.sql
- Stop and Delete all the Server and Database container.
docker stop <server_container_id> <database_container_id>
docker rm <server_container_id> <database_container_id>
- Re-launch the database container with
docker run -v /var/lib/mysql:/var/lib/mysql --name apel-mysql -v `pwd`/docker/etc/mysql/conf.d:/etc/mysql/conf.d -p 3306:3306 -e "MYSQL_ROOT_PASSWORD=****" -e "MYSQL_DATABASE=apel_rest" -e "MYSQL_USER=apel" -e "MYSQL_PASSWORD=****" -d mysql:5.6
- Load the database dump.
mysql -h 0.0.0.0 -u root -p apel_rest < apel_rest.sql
- Apply the
update_schema.sql
to upgrade the schema to support Cloud Usage Record v0.4.
mysql -h 0.0.0.0 -u root -p apel_rest < scripts/update_schema.sql
- Launch tne new version of the APEL REST container. You may wish to edit this command to mount a certificate.
docker run -d --link apel-mysql:mysql -p 80:80 -p 443:443 -v /var/spool/apel/cloud:/var/spool/apel/cloud -e "MYSQL_PASSWORD=****" -e "ALLOWED_FOR_GET=****" -e "SERVER_IAM_ID=****" -e "SERVER_IAM_SECRET=****" -e "DJANGO_SECRET_KEY=****" indigodatacloud/accounting:X.X.X-X
- Confirm the new container is up and running by going to
https://\<hostname\>/api/v1/cloud/record/summary/
-
Run
docker exec -it apel_server_container_id bash
to open an interactive shell from within the docker image. -
Disable the summariser cron job,
/etc/cron.d/cloudsummariser
, and if running, wait for the summariser to stop. -
Stop the apache server with
service httpd stop
. -
Ensure all messages have been loaded, i.e.
/var/spool/apel/cloud/incoming/
contains no unloaded messages. -
Because this update does not alter any interactions between the container and other services/components/containers, the old Accounting container can now simply be deleted and the new version launched in it's place.