Skip to content
Snippets Groups Projects
Commit acbe9903 authored by Benguria Elguezabal, Gorka's avatar Benguria Elguezabal, Gorka
Browse files

changes kustomize guides after component refactor

parent 9ae9cce7
No related branches found
No related tags found
No related merge requests found
.media/image02.png

14.5 KiB | W: | H:

.media/image02.png

23.6 KiB | W: | H:

.media/image02.png
.media/image02.png
.media/image02.png
.media/image02.png
  • 2-up
  • Swipe
  • Onion skin
.media/image09.png

40.7 KiB

.media/image10.png

66.8 KiB

.media/image11.png

85.9 KiB

.media/image12.png

79.7 KiB

.media/image13.png

44.2 KiB

...@@ -78,12 +78,12 @@ git checkout feature/component_integration ...@@ -78,12 +78,12 @@ git checkout feature/component_integration
``` ```
## Create the component folder ## Create the component folder
The first step to integrate a new component into the Caas Framework is to create a folder in the repository to hold the component manifests files. The folder should be created in the root of the repository and should have the name of the component. The folder will contain the manifests files of the component. The first step to integrate a new component into the Caas Framework is to create a folder in the repository to hold the component manifests files. The folder should be created inside the components folder of the repository and should have the name of the component. The folder will contain the manifests files of the component.
i.e. for the amoe component, the folder should be named `amoe` and should contain the manifests files of the component. i.e. for the amoe component, the folder should be named `amoe` and should contain the manifests files of the component.
```bash ```bash
mkdir amoe mkdir components/amoe
``` ```
The type of the manifests files can be different depending on the component. The most common types are: The type of the manifests files can be different depending on the component. The most common types are:
...@@ -98,19 +98,25 @@ The next step is to add the component manifests files to the folder created in t ...@@ -98,19 +98,25 @@ The next step is to add the component manifests files to the folder created in t
### ConfigMaps ### ConfigMaps
It is recommended to create Configmaps using the `kustomize` tool. The contents of the ConfigMaps for the component should be stored in a folder `configmaps` in the component folder. It is recommended to create Configmaps using the `kustomize` tool. The contents of the ConfigMaps for the component should be stored in a folder `configmaps` in the component folder (i.e. `components/amoe/configmaps`).
### Secrets ### Secrets
The Secrets will be created using the `kustomize` tool. The files to be used for the secrets generation should be **NOT** be stored in the repository. The secrets should be added in the component folder in a folder named `.secrets`. The secrets will be excluded from the repository because `.gitignore` file contains the `.secrets/` folder. The Secrets will be created using the `kustomize` tool. The files to be used for the secrets generation should be **NOT** be stored in the repository. The secrets should be added in the component folder in a folder named `.secrets`. The secrets will be excluded from the repository because `.gitignore` file contains the `.secrets/` folder.
![alt text](.media/image02.png) ![alt text](.media/image02.png)
## Create the Kustomization file for the component
## Extend the Kustomization file The next step is to create the Kustomization file for the component. The Kustomization file is a YAML file that contains the list of the manifests files that should be included in the deployment. The Kustomization file should be located in the root of the component folder and should be named `kustomization.yaml`.
The next step is to extend the Kustomization file to include the manifests files of the component. The Kustomization file is located in the root of the repository and is named `kustomization.yaml`. The Kustomization file is a YAML file that contains the list of the manifests files that should be included in the deployment. To create the Kustomization file you can use the `kustomize` tool. The `kustomize` tool is a CLI tool that allows you to manage the Kustomization file. To install the `kustomize` tool you can follow the instructions in the [official documentation](https://kubectl.docs.kubernetes.io/installation/kustomize/).
To extend the Kustomization file it is recommended to use the `kustomize` tool. The `kustomize` tool is a CLI tool that allows you to manage the Kustomization file. To install the `kustomize` tool you can follow the instructions in the [official documentation](https://kubectl.docs.kubernetes.io/installation/kustomize/). To use it over the component folder, you should be placed in the component folder in order to focus the `kustomize` tool in your component.
```bash
cd components/amoe
kustomize create --resources .
```
The relevant sections in the Kustomization file are: The relevant sections in the Kustomization file are:
- `resources`: This section contains the list of the manifests files that should be included in the deployment. The manifests files should be relative to the root of the repository. - `resources`: This section contains the list of the manifests files that should be included in the deployment. The manifests files should be relative to the root of the repository.
...@@ -140,11 +146,12 @@ In summary the steps to add a secret are: ...@@ -140,11 +146,12 @@ In summary the steps to add a secret are:
example of the secret file creation and kustomize configuration: example of the secret file creation and kustomize configuration:
```bash ```bash
cat <<EOF > amoe_redis_secrets cd components/amoe
cat <<EOF > .secrets/amoe_redis
REDIS_PASSWORD=redis_password REDIS_PASSWORD=redis_password
REDIS_SERVICE=redis_service REDIS_SERVICE=redis_service
EOF EOF
echo "add amoe_redis_secrets configuration in the kustomization.yaml file" echo "add amoe_redis secrets configuration in the kustomization.yaml file"
echo <<EOF echo <<EOF
- name: amoe-redis - name: amoe-redis
options: options:
...@@ -153,18 +160,40 @@ echo <<EOF ...@@ -153,18 +160,40 @@ echo <<EOF
- .secrets/amoe_redis - .secrets/amoe_redis
EOF EOF
vi kustomization.yaml vi kustomization.yaml
kustomize build . cd ../..
echo 'copy_from_cicd_variables "amoe_redis_secrets" "amoe/.secrets/amoe_redis"' >> k8s-pre-apply.sh echo 'copy_from_cicd_variables "amoe_redis_secrets" "components/amoe/.secrets/amoe_redis"' >> k8s-pre-apply.sh
``` ```
Once the secret is in the Gitlab CI/CD variables, the k8s-pre-apply.sh script will add the secret to the root of the repository. Once the secret is in the Gitlab CI/CD variables, the k8s-pre-apply.sh script will add the secret to the root of the repository.
## Add Keycloak configuration
Follow the [Keycloak integration](keycloak_integration.md) guidelines to add the Keycloak configuration to the component.
## Add the component to the base
The next step is to add the component to the base. The base is the base folder of the repository and contains the Kustomization file that includes all the components.
![base](.media/image09.png)
## Kustomize check configuration ## Kustomize check configuration
The Kustomize tool allows you to check the configuration of the Kustomization file. The `kustomize` tool has a command to check the configuration of the Kustomization file. The command is: The Kustomize tool allows you to check the configuration of the Kustomization file. The `kustomize` tool has a command to check the configuration of the Kustomization file. The command is:
```bash ```bash
kustomize build . kustomize build `path`
```
We can apply different paths depending what we want to check. For example, to check the configuration of the component folder we can use the following command:
```bash
kustomize build components/amoe
```
To check the whole integration we can use the following command:
```bash
kustomize build integration
``` ```
## Testing the kustomize ## Testing the kustomize
......
...@@ -58,6 +58,12 @@ kubectl -n keycloak cp keycloak-0:/tmp/export/. . ...@@ -58,6 +58,12 @@ kubectl -n keycloak cp keycloak-0:/tmp/export/. .
This will bring us the same two files: `emerald-dev-realm.json` and `emerald-dev-users-0.json`. From them the administrator will provide you the relevant sections for the concrete component. This will bring us the same two files: `emerald-dev-realm.json` and `emerald-dev-users-0.json`. From them the administrator will provide you the relevant sections for the concrete component.
## Add Keycloak configuration to the component
Due to some issues with the component used to load the component keycloak configuration, and the request to be able to check the configuration separately, the keycloak configuration should be added to the component folder as a two subcomponents. One to contain the keycloak configuration and the other to contain loader for the keycloak configuration.
![keycloak configuration](.media/image10.png)
## Kustomization ## Kustomization
The `adorsys/keycloak-config-cli:6.1.0-25.0.1` supports variable substitution in the configuration files. The variables should be defined in the configuration file using the `${VARIABLE_NAME}` format. The `adorsys/keycloak-config-cli:6.1.0-25.0.1` supports variable substitution in the configuration files. The variables should be defined in the configuration file using the `${VARIABLE_NAME}` format.
...@@ -114,3 +120,24 @@ spec: ...@@ -114,3 +120,24 @@ spec:
``` ```
and possibly to define the `AMOE_PASSWORD` in the ci/cd variables of the Gitlab project. and possibly to define the `AMOE_PASSWORD` in the ci/cd variables of the Gitlab project.
## Keycloak testing
Besides in order to be able to test the keycloak configuration separately, the keycloak configuration should be added to keycloak overlay in the integration folder. We have two options to add the keycloak configuration to the keycloak overlay: Merged and splitted.
### Splitted
The splitted test it only requires to add the keycloak components to the keycloak testing overlay. I.e. for rcm component we should add the following files:
- ./../../../components/rcm/keycloak/data
- ./../../../components/rcm/keycloak/loader
![Splitted](.media/image12.png)
### Merged
The merged test it requires to manually patch the keycloak config loader job. I.e. for rcm component we should add the following files:
- ./../../../components/rcm/patches/keycloak-loader
![RCM Keycloak Patch](.media/image13.png)
![Merged](.media/image11.png)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment