Browse Source

improve docker support

pull/50/head
Nicolas Massé 7 years ago
parent
commit
7e26c3750c
  1. 60
      support/docker/README.md
  2. 55
      support/docker/openshift-template.yaml

60
support/docker/README.md

@ -0,0 +1,60 @@
# Using this Ansible role from Docker
You can use this Ansible role as a container image and provision an API in
3scale very quickly.
You would first need to provision your 3scale Admin Portal hostname, access token
and optionally the Red Hat SSO Issuer Endpoint in the same format as a Kubernetes
secret:
```sh
mkdir -p /tmp/secrets
cat > /tmp/secrets/hostname <<EOF
TENANT-admin.3scale.net
EOF
cat > /tmp/secrets/access_token <<EOF
1234..5678
EOF
```
If your API is secured with OpenID Connect, you will need to provision the Red Hat
SSO Issuer Endpoint as well:
```sh
cat > /tmp/secrets/sso_issuer_endpoint <<EOF
https://CLIENT_ID:CLIENT_SECRET@HOSTNAME/auth/realms/REALM
EOF
```
You can then run this Ansible role as a Docker container:
```sh
docker run -it --rm --name threescale-cicd -v /tmp/secrets:/tmp/secrets:ro docker.io/nmasse/threescale-cicd:stable -e git_repository=https://github.com/nmasse-itix/rhte-api.git -e git_ref=master -e threescale_cicd_openapi_file=openapi-spec.yaml -e threescale_cicd_api_base_system_name=echo-api -e threescale_cicd_private_base_url=https://echo-api.3scale.net
```
This command is composed of the following arguments:
- `-it` will run the Ansible command interactively
- `--rm` will remove the container once finished
- `--name threescale-cicd` will give a friendly name to the created container
- `-v /tmp/secrets:/tmp/secrets:ro` will mount the secrets created above inside the container
- `docker.io/nmasse/threescale-cicd:stable` is the name of the pre-built docker image.
`stable` is the latest released version. `master` is the development version.
You can also target a specific version with for instance `1.0.0`.
- `-e git_repository=https://github.com/nmasse-itix/rhte-api.git` will checkout the
forementioned GIT repository to extract the OpenAPI Specification file.
- `-e git_ref=master` will checkout this specific branch or tag of the GIT repository.
- `-e threescale_cicd_openapi_file=openapi-spec.yaml` sets the path to the OpenAPI
Specification file inside the GIT repository.
- `-e threescale_cicd_api_base_system_name=echo-api` sets the base name that will be used
to generate the 3scale system_name.
- `-e threescale_cicd_private_base_url=https://echo-api.3scale.net` sets the 3scale
Private Base URL.
If your GIT repository is already checked out somewhere, you can re-use your
local copy by removing the `-e git_*` arguments and mounting your GIT repository
under `/opt/ansible/threescale-cicd/support/docker/api`.
```sh
docker run -it --rm --name threescale-cicd -v /path/to/git:/opt/ansible/threescale-cicd/support/docker/api:ro -v /tmp/secrets:/tmp/secrets:ro docker.io/nmasse/threescale-cicd:stable -e threescale_cicd_openapi_file=path/to/openapi-spec.yaml -e threescale_cicd_api_base_system_name=echo-api -e threescale_cicd_private_base_url=https://echo-api.3scale.net
```

55
support/docker/openshift-template.yaml

@ -46,8 +46,43 @@ parameters:
description: For OpenID Connect APIs only, the Red Hat SSO OIDC Issuer Endpoint (https://client_id:client_secret@sso.hostname/auth/realms/my-realm)
required: false
- name: THREESCALE_CICD_VERSION
description: The version of the Ansible playbooks to use
value: stable
required: true
- name: THREESCALE_CICD_API_SYSTEM_NAME
description: Override the 3scale Service system_name
required: false
- name: THREESCALE_CICD_API_BASE_SYSTEM_NAME
description: Define the base name to compute the final system_name
required: false
- name: THREESCALE_CICD_WILDCARD_DOMAIN
description: Automatically defines the APIcast public URLs based on a scheme
required: false
- name: THREESCALE_CICD_API_BASEPATH
description: Overrides the OpenAPI basePath field
required: false
- name: THREESCALE_CICD_PRIVATE_BASE_URL
description: The 3scale private base URL
required: false
- name: THREESCALE_CICD_APICAST_POLICIES_CORS
description: Allows to enable the CORS policy onto APICast gateway
required: false
- name: THREESCALE_CICD_OPENAPI_SMOKETEST_OPERATION
description: Defines the OpenAPI Specification method to use for smoke tests
required: false
- name: THREESCALE_CICD_API_ENVIRONMENT_NAME
description: Prefixes all services with an environment name to prevent any name collision when deploying the same API multiple times on the same 3scale instance
required: false
- name: THREESCALE_CICD_VALIDATE_OPENAPI
description: Validates the OpenAPI Specification file against the official schema
required: false
- name: THREESCALE_CICD_APICAST_SANDBOX_ENDPOINT
description: Defines the Public Staging Base URL
required: false
- name: THREESCALE_CICD_APICAST_PRODUCTION_ENDPOINT
description: Defines the Public Production Base URL
required: false
objects:
- apiVersion: v1
kind: ImageStream
@ -95,6 +130,26 @@ objects:
value: ${API_OPENAPI_FILE}
- name: THREESCALE_CICD_API_BASE_SYSTEM_NAME
value: ${API_NAME}
- name: THREESCALE_CICD_API_SYSTEM_NAME
value: ${THREESCALE_CICD_API_SYSTEM_NAME}
- name: THREESCALE_CICD_WILDCARD_DOMAIN
value: ${THREESCALE_CICD_WILDCARD_DOMAIN}
- name: THREESCALE_CICD_API_BASEPATH
value: ${THREESCALE_CICD_API_BASEPATH}
- name: THREESCALE_CICD_PRIVATE_BASE_URL
value: ${THREESCALE_CICD_PRIVATE_BASE_URL}
- name: THREESCALE_CICD_APICAST_POLICIES_CORS
value: ${THREESCALE_CICD_APICAST_POLICIES_CORS}
- name: THREESCALE_CICD_OPENAPI_SMOKETEST_OPERATION
value: ${THREESCALE_CICD_OPENAPI_SMOKETEST_OPERATION}
- name: THREESCALE_CICD_API_ENVIRONMENT_NAME
value: ${THREESCALE_CICD_API_ENVIRONMENT_NAME}
- name: THREESCALE_CICD_VALIDATE_OPENAPI
value: ${THREESCALE_CICD_VALIDATE_OPENAPI}
- name: THREESCALE_CICD_APICAST_SANDBOX_ENDPOINT
value: ${THREESCALE_CICD_APICAST_SANDBOX_ENDPOINT}
- name: THREESCALE_CICD_APICAST_PRODUCTION_ENDPOINT
value: ${THREESCALE_CICD_APICAST_PRODUCTION_ENDPOINT}
secrets:
- secretSource:
name: "3scale-admin-portal-${API_NAME}"

Loading…
Cancel
Save