# Get Started
This repository provides Kubernetes deployment resources for the Collaborative Organization for Resource and Trust Exchange (CORTEX), packaging manifests, configuration templates, and dependencies into reusable, configurable, version-controlled deployment artifacts.

## Repository Structure

- Helm chart files:
  - `Chart.yaml` - The Helm chart metadata and versioning information.
  - `templates/` - The Kubernetes manifest templates used by Helm to generate the final deployment manifests.
  - `values.yaml` - The default configuration values for the Helm chart.
- Documentation source: `docs/`

## Required Software

Ensure the following dependencies and cluster components are installed and configured before deployment.

| Requirement | Description |
|-------------|-------------|
| `Helm`      | Version 4.1.1 or higher for managing Kubernetes deployments |
| `kubectl`   | Configured with access to the target cluster and namespace |
| `Python`    | Version 3.12 or higher  to generate the documentation |

### Git

[Git](https://git-scm.com/) tracks changes to source code and supports distributed, non-linear workflows. Deployers require read access to the referenced repositories.

When using SSH with private repositories, configure Git's `url.<base>.insteadOf` setting to transparently map HTTPS repository URLs to SSH.

### Helm

[Helm](https://helm.sh/docs/intro/install/) is the Kubernetes package manager. Helm charts simplify the deployment, upgrade, and management of Kubernetes applications.

### Kubectl

[Kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl) is the Kubernetes command-line tool used to deploy applications, manage cluster resources, and view logs.

## Prerequisites

Before deploying the components, ensure the images are built and are accessible by your Kubernetes cluster.

- The `cortex-discovery:main` Docker image must be built using the image definition from the [cortex-discovery-docker](https://github.com/ResearchDataCom/cortex-discovery-docker) repository.

- The `cortex-ldap:main` Docker image must be built using the image definition from the [cortex-ldap-docker](https://github.com/ResearchDataCom/cortex-ldap-docker) repository.

## Building the Documentation

The project documentation is built with Sphinx.  Install the required dependencies in a virtual environment and build the HTML documentation.

```bash
make venv
make setup
```

The documentation source lives in `docs/`.
Build a single-version HTML with the output in `build/html`:

```bash
make clean html
```

Build the full documentation workflow including all versions and branches.

```bash
make docs
```

## Helm Chart Usage

### From the chart repository

Add the public chart repository, then install or upgrade.

```bash
helm repo add cortex https://cortex.rdctdev.us
helm repo update
helm install <Release.Name> cortex/cortex -n <NAMESPACE> --create-namespace
helm upgrade <Release.Name> cortex/cortex -n <NAMESPACE>
```


### From a local checkout

To render the chart only.

```bash
helm template <Release.Name> .
```

Validate the Helm chart templates with a release name `<Release.Name>`.

```bash
helm install --dry-run=client <Release.Name> .
```

Install the chart into a Kubernetes cluster.

```bash
helm install <Release.Name> . -n <NAMESPACE> --create-namespace
```

Upgrade the chart in a Kubernetes cluster.

```bash
helm upgrade <Release.Name> . -n <NAMESPACE>
```

### Verification

Verify the deployment by checking the pods, services, deployments, and configmaps in the target namespace. You can also check logs for the deployment and statefulset.

```bash
kubectl -n <NAMESPACE> get pods -o wide
kubectl -n <NAMESPACE> get services -o wide
kubectl -n <NAMESPACE> get deployments -o wide
kubectl -n <NAMESPACE> get configmaps -o wide
kubectl -n <NAMESPACE> logs deployment -o wide
kubectl -n <NAMESPACE> logs statefulset -o wide
```
