# Easy installer (Draft)

## Overview:

Easy installer is meant to install Sunbird Ed platform on Kubernetes cluster which helps the adopter to setup Sunbird Ed platform within in few hours.

## Pre-requisites:

* Server or Laptop with Ubuntu 20.04 LTS operating system
* Azure Kubernets Cluster
* Azure Storage Account
* Domain name and SSL Certificates
* Google re-captcha
* Google OAuth Credentials

To successfully complete Sunbird installation, you need to have:

* System administrator permissions to the cloud resources
* Hands-on experience in administering and debugging Linux systems
* Hands-on experience using Docker and Kubernetes to run containerized workloads

## Steps:

1. Provision Pre-requisites: Current easy installer supports azure cloud service provider. Please provision the following resources required
   * Azure Kubernetes Cluster: Please follow the steps mentioned in the below azure documentation link to provision AKS cluster using azure protal and generate the kubeconfig file for the same and save it in the server/local machine from where you will be running the installer script.

     <https://learn.microsoft.com/en-us/azure/aks/learn/quick-kubernetes-deploy-portal?tabs=azure-cli>

     * kubernetes version: 1.24.x
     * Node size: 4 Core, 16 GB RAM,
     * Node count range: 6 to 10
   * Install az cli <https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt>
   * Azure Storage account with following containers
     * `sunbird-contents-dev` public container
     * `flink-state-backend` private container
   * Google re-captcha : Follow the steps mentioned in the below link. Select Challenge(v2) -> Invisible reCAPTCHA badge. <https://www.google.com/recaptcha/admin/create>
   * Google OAuth Credentials: Follow the steps mentioned in the below link and set `Authorised redirect URIs` value to https\://{domain-name}/oauth2/callback . Save Client id and Client secret values. <https://developers.google.com/workspace/guides/create-credentials#oauth-client-id>
   * Domain name and SSL Certificates: You can create free Letsencrypt SSL certificates using <https://punchsalad.com/ssl-certificate-generator/> for the domain which is valid for 90 days. Or purchase the SSL certs from Godaddy or Namecheap like vendors
2. Update environment values
   * Clone the repository

     ```
     git clone https://github.com/project-sunbird/sunbird-devops -b oneclickinstaller
     cd sunbird-devops/oneclickinstaller
     chmod +x *sh
     ```
   * Use your favourite text editor and update variables mentioned in global-values.yaml. Follow the instructions mentioned in the `global-values.yaml` file under every variable
3. Run the Ed easy installer bash script. While the installer is running, you can view the deployments to the kubernetes cluster using any kubernetes client like kubectl or k9s. This step take 45 min to 1 hour based on the internet speed on the machine where you are running the script. Take a break and check back !

K9s download link: <https://k9scli.io/topics/install/>

```
bash ./install-ed.sh /path/to/kubeconfig.yaml -i ed-install  
```

4. Manual keycloak configurations

`NOTE: These manual configurations will be automated in the next consequent releases`

* Port forward to keycloak pod to access admin console through web browser. If you are running installer from server(not local machine).Make sure SSH tunnel is done b/w local machine to server.Make sure there is no process running on port 8080 on the system from where you are running the installer. Also, make sure context to kubectl is set to the right kubernetes cluster.

  ```
  POD_NAME=$(kubectl get pods -n dev | grep keycloak | awk '{print $1}')
  ```

  ```
  kubectl port-forward -n dev "$POD_NAME" 8080:8080 
  ```
* Go to `http://localhost:8080/auth/admin/master/console/#/realms/sunbird/clients`

  username: admin password: admin

  * Click `lms` client -> Select `service account roles` -> Click on `Client roles` drop down -> Select `realm management` -> Select `manage-users in` Available Roles -> Click on `Add Selected`
  * Click on `Credentials TAB`-> Copy the secret value -> Update `sunbird_sso_client_secret` variable value in `global-values.yaml` with the copied secret value
  * Click on `Realm Settings`-> `Keys` -> Click on `public key` button-> Copy the key. Update the variables `sunbird_sso_publickey` and `keycloak_sunbird_realm_public_key` in `global-values.yaml` with the copied public key
  * Click on `Realm Settings` -> Click on Themes -> Select `sunbird` as a login theme -> click save
* Goto `http://localhost:8080/auth/admin/master/console/#/realms/sunbird/user-federation` Click on `cassandra-storage-provider` -> Copy the `Provider ID`. Update the `sunbird_keycloak_user_federation_provider_id` variable in `global-values.yaml` with the copied Provider ID
* Goto `http://localhost:8080/auth/admin/master/console/#/realms/sunbird/keys` -> copy KID of Type RSA . Update the variable `keycloak_sunbird_realm_kid` in global-values.yaml

5. Run the Ed easy installer post install script

```
bash ./install-ed.sh /path/to/kubeconfig.yaml -i postscript  
```

6. Update the DNS record: Get the public ip printed on the console and add DNS A record for the same domain you have added to global-values.yaml. Access the Ed instance using https\://{domain-name}

## Functional Configuration:

Once above steps are completed, functional configurations need to be setup. Following postman collection helps to setup minimal functional configuration.You can leverage same postman collection to setup functional configuration for your use case.

To configure these functionalities, you will need to use the Postman tool. You can download and install the Postman tool by visiting the following link: <https://www.postman.com/downloads/>.

Please refer the below mentioned postman collection to setup minimal functional configuration for content creation workflow.

Download the postman collection of Sunbird-Ed functional configuration

<https://github.com/project-sunbird/sunbird-devops/blob/oneclickinstaller/oneclickinstaller/collection.json>

Download the postman environment variable file

<https://github.com/project-sunbird/sunbird-devops/blob/oneclickinstaller/oneclickinstaller/environment.json>

Import postman collection and environment variables to postman tool

<https://learning.postman.com/docs/getting-started/importing-and-exporting-data/#importing-postman-data>\\

Update below mentioned environmental variables in postman tool. Please refer global\_values.yaml file for varaible values.

| Environment key name | global\_values.yaml key name                      | Description             |
| -------------------- | ------------------------------------------------- | ----------------------- |
| host                 | domain                                            | <http://example.co.in/> |
| kong\_api\_key       | Bearer {{core\_vault\_sunbird\_api\_auth\_token}} | Bearer xxx.yyy.zzz      |

* Import the Postman collection and environment files. Then, go to the "Environment" section and choose the "sunbird-easeinstall" environment. Update the values of the "host" and "kong\_api\_key" variables, and remember to save the changes.
* Once you have updated the environment variables, click on the "Collections" tab located in the upper-left corner. From the dropdown menu in the upper-right corner, select the desired environment name.
* Now, you can start triggering the APIs in the collection one by one, following the specified sequence. Proceed to the next API only when the response from the current API is a successful "200" status code.

If you have any queries or facing issues please create a discussion thread at <https://github.com/orgs/Sunbird-Ed/discussions/categories/installation>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ed.sunbird.org/older-versions/use/installing-ed-platform/easy-installer-draft.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
