Skip to content

Commit

Permalink
guide
Browse files Browse the repository at this point in the history
  • Loading branch information
milesstoetzner committed Nov 26, 2024
1 parent 7738658 commit 1b031f8
Show file tree
Hide file tree
Showing 20 changed files with 2,261 additions and 84 deletions.
134 changes: 86 additions & 48 deletions docs/docs/variability4tosca/guides/technology/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tags:

# Conditional Deployment Technologies

This document holds the step-by-step guide to deploy the Kubernetes deployment variant of the web shop application to showcase the conditional deployment technologies.
This document holds the step-by-step guide to deploy the Kubernetes deployment variant of the [Online Boutique application](https://github.com/OpenTOSCA/opentosca-vintner-boutique-demo){target=_blank} to showcase the automated selection of deployment technologies.
The application can be deployed in the following deployment variants.

- static on a single virtual machine on a local OpenStack (OS) instance
Expand All @@ -21,8 +21,7 @@ The application can be deployed in the following deployment variants.
We need to fulfill the following requirements to follow this step-by-step tutorial.

- Linux machine, e.g., Ubuntu 22.04
- Access to a Kubernetes instance

- Access to a Kubernetes cluster, e.g., [minikube](https://minikube.sigs.k8s.io){target=_blank}

## Preparation

Expand Down Expand Up @@ -51,107 +50,146 @@ vintner orchestrators attest --orchestrator unfurl
```


## Import the Template
## Enrich the Template

Next, we import the Variability4TOSCA template.
Next, we clone the repository.

```shell linenums="1"
vintner templates import --template aware --path examples/unfurl-technology---shop---plus-maintenance-automated
git clone https://github.com/OpenTOSCA/opentosca-vintner.git
cd opentosca-vintner
git lfs install
git lfs pull
```

Then, we initialize an application instance.
Next, we make a copy of the Variability4TOSCA template.

```shell linenums="1"
vintner instances init --instance unfurl-technology --template unfurl-technology
cp -R examples/unfurl-technology---boutique---plus-maintenance-automated /tmp/boutique-model
```

We can optionally inspect the Variability4TOSCA model.
This model contains all possible elements having conditions assigned.
However, due to the automatic selection of technologies, no technologies must be modeled.

Next, we enrich the Variability4TOSCA template.
This will automatically generate conditional deployment technology assignments.

```shell linenums="1"
vintner templates inspect --template unfurl-technology
vintner template enrich --template /tmp/boutique-model/variable-service-template.yaml --output /tmp/boutique-model/variable-service-template.yaml
```

## Resolve the Template

## Resolve Variability

We want to deploy the Kubernetes variant of the web shop application with the optional and the premium feature enabled.
We want to deploy the Kubernetes variant with the all features enabled.
Therefore, we first create the following file.

```shell linenums="1" title="/tmp/variability-inputs.yaml"
```yaml linenums="1" title="/tmp/variability-inputs.yaml"
env: KUBERNETES
tier: LARGE
optional_feature: true
premium_feature: true
optional_payment_feature: true
premium_payment_feature: true
optional_analytical_feature: true
premium_analytical_feature: true
```
Next, we resolve the variability and generate a TOSCA model.
This will automatically select deployment technologies.
```shell linenums="1"
vintner template resolve --template /tmp/boutique-model/variable-service-template.yaml --output /tmp/boutique-model/variable-service-template.yaml --inputs /tmp/variability-inputs.yaml
```

Next, we resolve the variability.
Next, we generate the Deployment Technology-Specific Models.

```shell linenums="1"
vintner instances resolve --instance unfurl-technology --inputs /tmp/variability-inputs.yaml
vintner template implement --dir /tmp/boutique-model --orchestrator unfurl
```

You can optionally inspect the generated TOSCA-compliant model.
This template contains only the elements required for the Kubernetes variant.
Moreover, deployment technologies have been assigned.
## Import the Template

Next, we import the TOSCA template.

```shell linenums="1"
vintner instances inspect --instance unfurl-technology
vintner templates import --template boutique-model --path /tmp/boutique-model
```

Then, we initialize an application instance.

```shell linenums="1"
vintner instances init --instance boutique-instance --template boutique-model
```

## Deploy the Application

Finally, we can deploy the application.
Therefore, we need to provide deployment inputs, e.g., credentials to OpenStack.
Next, we need a Kubernetes cluster.
We can start a development one locally using minikube.

```shell linenums="1"
minikube start
```

Next, we provide deployment inputs, e.g., credentials to Kubernetes.
These inputs are specified in `topology_template.inputs` of the TOSCA-compliant model.
The following inputs must be defined.

```shell linenums="1" title="/tmp/deployment-inputs.yaml"
```yaml linenums="1" title="/tmp/deployment-inputs.yaml"
database_password: YOUR_DB_PASSWORD
database_password: YOUR_DBMS_PASSWORD
dbms_password: YOUR_DBMS_PASSWORD
k8s_host: YOUR_K8S_HOST
k8s_ca_cert_file: YOUR_K8S_CA_CERT_FILE
k8s_client_cert_file: YOUR_K8S_CLIENT_CERT_FILE
k8s_client_key_file: YOUR_K8S_CLIENT_KEY_FILE
```
In case of minikube, the following deployment inputs should be fitting.
Note, you need to resolve `$(minikube ip)` and `$HOME` first.

- `k8s_host`: `http://$(minikube ip):8443`
- `k8s_ca_cert_file`: `$HOME/.minikube/ca.crt`
- `k8s_client_cert_file`: `$HOME/.minikube/profiles/minikube/client.crt`
- `k8s_client_key_file`: `$HOME/.minikube/profiles/minikube/client.key`

Next, we start the deployment.
The deployment will take around 1-5 minutes.
The deployment will take around 1-2 minutes.

```shell linenums="1"
vintner instances deploy --instance unfurl-technology --inputs /tmp/deployment-inputs.yaml
vintner instances deploy --instance boutique-instance --inputs /tmp/deployment-inputs.yaml
```


## Test the Application

Next, we can test that the application is correctly working.
Next, we can test that the application is correctly working.
Therefore, find out the endpoint assigned by the ingress.
In case of minikube, this can be done as follows.

```shell linenums="1"
curl --fail-with-body ${ENDPOINT}
ENDPOINT=$(minikube service frontend-external --url)
```

This should return the following.
Next, we can start the load generator.

```shell linenums="1"
{
"MESSAGE": "Successfully executed query",
"QUERY": "SELECT 1 + 1;",
"DB_DIALECT": "mysql",
"DB_NAME": "shop",
"DB_ADDRESS": "mysql",
"DB_USERNAME": "root",
"DB_PASSWORD": "5e88"
}
docker run -it --rm -e FRONTEND_ADDR=${ENDPOINT} -e USERS=5 --network host ghcr.io/opentosca/opentosca-vintner-boutique-demo:loadgenerator-v10
```

We can observe the following.

- according to `MESSAGE`, the query has been successful
- according to `DB_ADDRESS`, the MySQL instance running in Kubernetes has been used
```text linenums="1"
Type Name # reqs # fails | Avg Min Max Med | req/s failures/s
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
GET / 6 0(0.00%) | 55 48 76 52 | 0.00 0.00
GET /cart 3 0(0.00%) | 23 17 30 24 | 0.10 0.00
POST /cart 9 0(0.00%) | 21 13 37 20 | 0.30 0.00
POST /cart/checkout 2 0(0.00%) | 39 18 61 18 | 0.00 0.00
GET /product/0PUK6V6EV0 3 0(0.00%) | 26 18 30 30 | 0.20 0.00
GET /product/1YMWWN1N4O 2 0(0.00%) | 18 11 25 11 | 0.00 0.00
GET /product/2ZYFJ3GM2N 3 0(0.00%) | 25 16 32 28 | 0.10 0.00
GET /product/66VCHSJNUP 2 0(0.00%) | 20 11 29 11 | 0.00 0.00
GET /product/6E92ZMYYFZ 2 0(0.00%) | 23 20 27 20 | 0.20 0.00
GET /product/9SIQT8TOJO 1 0(0.00%) | 30 30 30 30 | 0.00 0.00
GET /product/L9ECAV7KIM 3 0(0.00%) | 16 10 29 11 | 0.00 0.00
GET /product/LS4PSXUNUM 4 0(0.00%) | 22 12 31 19 | 0.20 0.00
POST /setCurrency 2 0(0.00%) | 37 23 51 23 | 0.10 0.00
--------|----------------------------------------------------------------------------|-------|-------------|-------|-------|-------|-------|--------|-----------
Aggregated 42 0(0.00%) | 28 10 76 25 | 1.20 0.00
```


Thus, we conclude that the application has been deployed as desired.

Expand All @@ -161,13 +199,13 @@ Thus, we conclude that the application has been deployed as desired.
Afterward, we can undeploy the application.

```shell linenums="1"
vintner instances undeploy --instance unfurl-technology
vintner instances undeploy --instance boutique-instance
```

We can also optionally remove the instance or cleanup the filesystem.
Note, cleaning up the filesystem removes any vintner data including, e.g., all imported templates and created instances.

```shell linenums="1"
vintner instances delete --instance unfurl-technology
vintner instances delete --instance boutique-instance
vintner setup clean --force
```
Loading

0 comments on commit 1b031f8

Please sign in to comment.