Skip to content

Latest commit

 

History

History
180 lines (129 loc) · 8.61 KB

development.md

File metadata and controls

180 lines (129 loc) · 8.61 KB

Terrakube Ready to Code.

We use Gitpod to develop the platform. You can have a complete development environment to test all the components and features with one click using the following button.

Gitpod ready-to-code

Running Terrakube in Gitpod is like running the platform in any Kubernetes distribution in Azure, Aws or GCP, so you will be able to use all the features available with one single click without installing any software in your computer and the environment should be ready in only 1 or 2 minute.

Terrakube API uses an in memory database, it will be deleted and preloaded with default information in every startup.

Gitpod Environment Information.

A file called GITPOD.md will have the information for the entire workspace

image

The configuration is generated dynamically using the following bash script. This is executed by Gitpod in the environment startup process.

./scripts/setupDevelopmentEnvironment.sh

If for some reason we need to execute the script again, it needs to be executed form the /workspace/terrakube folder

The development environment will have the following information:

Groups
TERRAKUBE_ADMIN
TERRAKUBE_DEVELOPERS
AZURE_DEVELOPERS
AWS_DEVELOPERS
GCP_DEVELOPERS
User Password Member Of
[email protected] admin TERRAKUBE_ADMIN, TERRAKUBE_DEVELOPERS
[email protected] aws AWS_DEVELOPERS
[email protected] azure AZURE_DEVELOPERS
[email protected] gcp GCP_DEVELOPERS

Start Development Environment

To run all the Terrakube components run the following task:

image

After a couple of seconds all the components will be running, you can start/stop/restart any component as needed.

image

Login Development Environment

After the application startup is completed, we can login to the development environment, to get the URL you can execute the following command:

gp url 3000

The Terrakube login will look like this example:

image

Dex Authentication.

The Gitpod environment is using an OpenLDAP tha is connected to a Dex using the LDAP connector. The OpenLDAP configuration(users and groups) can be found in the following file:

scripts/setup/dex/config-ldap.ldif

The Dex configuration file is generated dynamically and will be available in the following file:

scripts/setup/dex/config-ldap.yaml

The template that is used to generate the Dex configuration file can be found in this path:

scripts/template/dex/template-config-ldap.yaml

Dex login page should look like this example:

image

Sample Organizations

The development environment will be preloaded with 4 organizations(azure, gcp, aws and simple), this information is loaded inside the API startup and the scripts to load the information can be found in the following xml files

api/src/main/resources/db/changelog/demo-data/aws.xml
api/src/main/resources/db/changelog/demo-data/gcp.xml
api/src/main/resources/db/changelog/demo-data/azure.xml
api/src/main/resources/db/changelog/demo-data/simple.xml

image

Sample Teams

Depending of the selected organization and user you will see different information available. image

Sample Modules

Each organization is preloaded with some modules that can be found in Github like the following:

image

image

image

Templates

Each organization is preloaded with the following templates to run Terrakube jobs:

image

For more information of how to use templates please refer to the following repository

Workspaces

All the organization have different empty workspaces, the Simple organization can be used for testing because the workspace is using a basic terraform file with the following resources:

  • null_resource
  • time_sleep

Other workspaces can be created but they will be deleted on each restart unless are added inside the initialization scripts:

api/src/main/resources/db/changelog/demo-data/simple.xml

image

API Testing

Gitpod has the thunder-client installed to easily test the API without using the UI.

image

All the environment variables for the collection are generated on each Gitpod workspace startup The environment variables template can be found in the following directory:

scripts/template/thunder-tests/thunderEnvironment.json

image

To authenticate the thunder client you can use Dex Device Code Authentication using the following request image

The response should look like the following and you can use the verification_uri_complete to finish the device authentication.

{
  "device_code": "htlj4w73ftjfplinifqntp7ept6xaratvgauu2nj3nldlcgxjym",
  "user_code": "HLMH-WKXX",
  "verification_uri": "https://5556-azbuilder-terrakube-XXXXX.ws-us54.gitpod.io/dex/device",
  "verification_uri_complete": "https://5556-azbuilder-terrakube-XXXX.ws-us54.gitpod.io/dex/device?user_code=HLMH-WKXX",
  "expires_in": 300,
  "interval": 5
}

image image

Once the Dex device code authentication is completed you can use the following request to get the access token.

image

Now you can call any method available in the API without the UI

image

Terraform Login Protocol

Terraform login protocol can be tested using the thunder-client collection:

image

The response should look similar to the following:

image

Terraform Module Protocol

There is one example of terraform module protocol inside the thunder-client collection that you can be used for testing purposes executing the following two request.

image

The response should look like the following:

  • Getting versions for the module

image

  • Getting zip file for the module

image

OpenAPI Spec

The specification can be obtained using the following request:

image