Skip to content

# How to Deploy Using Helm

In this section we will explain how to use Helm Charts to deploy OpenCAPIF using Helm Scripts present at repository.

## Overview

Complete deployment of OpenCAPIF involves below services:

- Hasicorp Vault.
- Montoring stack (Prometheus, Grafana, ...)
- OpenCAPIF.

All needed files, like helm deployments and scripts are under Helm Main directory at OpenCAPIF repository.

## Helm Directory

In order to simplify the way to deploy, OCF SDG created different helms definitions to allow the deployment of all related services, like Vault, Montoring Stack and OpenCAPIF.

Those helms are fully functional, you will need to configure each one and also load security information to vault, and also you will need the knowledge to launch helm deployment on your environment. This is out of the scope of this Documentation.

But we also created some scripts to simplify this proccess.

## Helm Scripts

OCF SDG created a set of scripts to deploy/undeploy OpenCAPIF at k8s environment, and also perform some other tasks like create users, run tests suites, ...

All scripts are stored at Helm Scripts.

Just we need to keep in mind, all scripts use configurations defined under variables.sh and environments if them are defined.

There are different types of scripts:

### Deployment Management

- install_vault.sh: Deploy Vault component from k8s cluster, only needed if vault is not previously deployed. If it’s deployed you can setup vault token on variables.sh.
- install_monitoring.sh: Deploy monitoring on k8s cluster.
- install_capif.sh: Deploy OpenCAPIF on k8s cluster. It will be deployed on configured namespace with domain and hostnames configured under variables.sh.
- uninstall_vault.sh: Rollback Vault component from k8s cluster.
- uninstall_monitoring.sh: Rollback monitoring components from k8s cluster.
- uninstall_capif.sh: Rollback OpenCAPIF from k8s cluster.

### Manage remote users

- create_remote_users.sh: This script create users setup by parameters on deployed OpenCAPIF. Those users are created by administrator.
- remove_remote_users.sh: This script removes user from deployed OpenCAPIF.
- remove_remote_users_by_prefix.sh:: This script removes users by prefix.

### Obtain DNS resolution

- get_ingress.sh: This create a configuration for dns fixed resolution for ingress configured in namespace passed by parameters.
- set_ingress.sh: This scripts adds to /etc/hosts the fixed DNS resolution for ingress setup for namespace passed by parameters.

### Run Robot Tests Suites

- run_remote_capif_tests.sh: This scripts launch Robot Test docker image on current machine to reach deployed OpenCAPIF. Is useful to launch with “--include smoke” in order to ensure all is deployed properly.

### Create Testing Dummy Info

- populate_create_remote_dummy_users.sh: : Create Dummy providers and invokers, publish service APIs and creates security context for invokers.
- populate_remove_remote_dummy_users.sh: Remove dummy information created.

### How to Run Scripts

#### Configure environment parameters

variables.sh contains all configuration that will be used on remote operation.

Currently also environment files are supported. Those environment files contains the override of variables present on variables.sh.

If you want to use environment files, just place a file under /helm/scripts/envs with name of your environment and extension ".env". You can see the example environment here

After add this environment file, you just need to indicate when you run any of the scripts at /helm/scripts directory, in this way:

    ./<script_to_run>.sh [environment] [command_options]

#### Example

Create a file under /helm/scripts/envs called production.env with below information:

    # Setup kubeconfig to be used
    export CUSTOM_KUBECONFIG="production.kubeconfig"

    # Setup Vault parameters to deploy on this environment
    export VAULT_HOSTNAME=vault.company.production
    export DOMAIN1=*.company.production
    export DOMAIN2=*.company.staging
    export DOMAIN3=*.company.dev

    # Setup Monitoring parameters
    export PROMETHEUS_HOSTNAME=prometheus.company.production

    # Setup OpenCAPIF parameters
    export CAPIF_HOSTNAME="capif.company.production"
    export REGISTER_HOSTNAME="register.company.production"
    export CAPIF_NAMESPACE=ocf-capif
    export CAPIF_CI_ENV_ENDPOINT=latest
    export CAPIF_DOMAIN=company.production
    export CAPIF_IMAGE_TAG="v3.0.0-release"

This is our environment file, with specific information of our environment. Now we can run for example the deployment scripts, just adding as first parameter the name of environment (name of file without extension):

    ./install_vault.sh production
    ./install_monitoring.sh production
    ./install_capif.sh production

After deploy OpenCAPIF we can run tests for example:

    ./run_remote_capif_tests.sh production --include capif_api_invoker_management-1

Or run any other task related, for example, creation of users at new environment:

    ./create_remote_users.sh production -u user -p pass

> NOTE: You can check also information of how to use the scripts by including "-h" flag (not present on Deployment Management scripts)