# Deployment on Kubernetes

## Introduction

The guide here provides instructions to deploy OpenG2P on Kubernetes (K8s) cluster.&#x20;

## Pre-requisites

* K8s cluster is set up as given [here](/1.0.0/guides/deployment-guide/deployment-on-kubernetes/cluster-setup.md).

## Installation of OpenG2P

* This section assumes the OpenG2P docker is already packaged. See Packaging Instructions.
* Clone the <https://github.com/OpenG2P/openg2p-packaging>  and go to [charts/openg2p](https://github.com/OpenG2P/openg2p-packaging/tree/develop/charts/openg2p) directory
  * Run, (This installs the ref-impl dockers):

    ```
    ./install.sh \
        --set global.hostname=openg2p.sandbox.net \
        --set global.selfServiceHostname=selfservice.openg2p.sandbox.net
    ```
  * If use different docker image or tag use:

    ```
    ./install.sh \
        --set odoo.image.repository=<docker image name> \
        --set odoo.image.tag=<docker image tag> \
        --set global.hostname=openg2p.sandbox.net \
        --set global.selfServiceHostname=selfservice.openg2p.sandbox.net
    ```

## Installation of ODK

* From the [charts/odk-central](https://github.com/OpenG2P/openg2p-packaging/tree/develop/charts/odk-central) directory, run the following to install ODK helm chart.

  ```
  ./install.sh \
      --set global.hostname=openg2p.sandbox.net
  ```
* Note: The above helm chart uses the following docker images built from <https://github.com/getodk/central/tree/v2023.1.0>, since ODK Central doesn't provide pre-built docker images for these.

  ```
  openg2p/odk-central-backend:v2023.1.0
  openg2p/odk-central-frontend:v2023.1.0
  openg2p/odk-central-enketo:v2023.1.0
  ```
* Post installation:
  * Exec into the service pod, and create user (and promote if required).

    ```
    kubectl exec -it <service-pod> -- odk-cmd -u <email> user-create
    kubectl exec -it <service-pod> -- odk-cmd -u <email> user-promote
    ```
* Uninstallation:
  * To uninstall, just delete the helm installation of odk-central. Example:

    ```
    helm -n odk delete odk-central
    ```


---

# 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://docs.openg2p.org/1.0.0/guides/deployment-guide/deployment-on-kubernetes.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.
