The Cray User Access Service framework was generated by the swagger-codegen project. By using the OpenAPI-Spec from a remote server, you can easily generate the server stub. This service is an example of building a swagger-enabled Flask server.
The Cray User Access Service uses the Connexion library on top of Flask.
Python 3.5.2+
The Cray User Access Service source code is located in the UAN/uan-mgr Git repository. If you have not previously cloned this repository to a local directory on your laptop/workstation, you may do so with the following commands. Substitute your user name for in the example below.
mkdir -p UAN
cd UAN
git clone https://<username>@stash.us.cray.com/scm/uan/uan-mgr.git
cd uan-mgr
To run the service locally, please execute the following from the uan-mgr directory:
pip3 install -r requirements.txt
python3 -m swagger_server
and open your browser to here:
http://localhost:8080/v1/mgr-info
The unit tests, lint, and coverage can be checked at the shell in your development repository directory by running:
./dev_deploy.sh
This will also build you a new image that you can push to whatever
container registry you want for use. By default, this builds a
container image tagged as cray/cray-uas-mgr:latest
. You can
change the tag to whatever you want using the -t <tag>
option
to the command.
To launch the integration tests, use tox:
sudo pip install tox
tox
To run the service on a Docker container, please execute the following from the uan-mgr directory:
# building the image
docker build -t cray-user-access-service .
# starting up a container
docker run -p 8080:8080 cray-user-access-service
Optional
Tag and push the the cray-user-access-service image to a Docker image
registry ('uan-ci.us.cray.com:5000' is used in this example for
the registry and 'my_version' is used as the version tag):
# Tag the image for pushing to the Docker registry
docker tag cray-user-access-service uan-ci:5000.us.cray.com/cray-user-access-service:my_version
# Push the image to the Docker registry
docker push uan-ci:5000.us.cray.com/cray-user-access-service:my_version
To deploy the service on a Kubernetes cluster, please execute the following instructions.
Important:
This document assumes the docker image that was built under the
'Running with Docker' section above, was pushed to the
uan-ci.us.cray.com:5000 Docker image registry as described in
the Optional portion of that section.
- Copy the cray-uas-deployment.yaml file from the uan-mgr directory on your laptop/workstation to the Kubernetes master node:
scp cray-uas-deployment.yaml root@<your_kubernetes_master>:
-
Log into your Kubernetes master node as root.
-
Create a Kubernetes configmap of the /etc/kubernetes/admin.conf file. This is needed so the cray-user-access-service can use the Kubernetes API.
kubectl create configmap --from-file=/etc/kubernetes/admin.conf kube-cfg
- Edit the image: line in the cray-uas-deployment.yaml file to use the image you just created.
# Change from this:
image: uan-ci.us.cray.com:5000/cray-user-access-service:latest
# To this:
image: uan-ci.us.cray.com:5000/cray-user-access-service:my_version
- Pull the cray-user-access-service image from the local docker
registry to all kubernetes masters.
(uan-ci.us.cray.com:5000/cray-user-access-service:my_version):
Note: This download (pull) must be performed on all nodes in the Kubernetes cluster.
docker pull uan-ci.us.cray.com:5000/cray-user-access-service:my_version
- Execute the following command on the Kubernetes master to deploy and start the Cray User Access Service:
kubctl create -f cray-uas-deployment.yaml
- In a browser window, enter the following URL. You should see the Cray User Access Service screen.
http://<ip_of_your_kubernetes_master>:8063/v1/uas_access
Note: The IP address of your Kubernetes master can be found by running the following command on the Kubernetes master node:
kubectl cluster-info
To stop the Cray User Access Service, please execute the following instructions.
-
Log into the Kubernetes master node as root.
-
Run the following commands:
kubectl delete deployment cray-user-access-service
kubectl delete service cray-user-access-service