Metadata-Version: 2.4
Name: janus-dtnaas
Version: 1.1
Summary: Janus DTNaaS Controller
Author-email: Ezra Kissel <kissel@es.net>
License: BSD 3-Clause License
Project-URL: Homepage, https://github.com/esnet/janus
Keywords: Janus,Controller
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography
Requires-Dist: Flask>=3.0.2
Requires-Dist: flask-openapi3[scalar,swagger]>=4.3.1
Requires-Dist: Flask-httpauth>=4.8.0
Requires-Dist: flask-sock>=0.7.0
Requires-Dist: PyJWT>=2.10.1
Requires-Dist: Flask-JWT-Extended>=4.7.1
Requires-Dist: portainer-api
Requires-Dist: psutil
Requires-Dist: py-cpuinfo
Requires-Dist: pyyaml
Requires-Dist: requests
Requires-Dist: six
Requires-Dist: tinydb
Requires-Dist: virtfs
Requires-Dist: tcconfig
Requires-Dist: Werkzeug>=3.0.1
Requires-Dist: pydantic>=2.12.0
Requires-Dist: ansible-tower-cli==3.3.8
Requires-Dist: pytest-xprocess
Requires-Dist: kubernetes>=29.0.0
Requires-Dist: openapi-slurm-0.0.38-client
Requires-Dist: sense-o-api==1.37
Requires-Dist: pytest-cov
Requires-Dist: coverage
Dynamic: license-file

# Janus Controller

Lightweight, profile-based container orchestration with various backends, including Kubernetes and Portainer support. Janus also supports DTN-as-a-Service deployments with Agent host tuning.

## Build Instructions
```
python -m build
```
Upload to PyPi using
```
twine upload dist/*
```

## Install Instructions
```
git clone https://github.com/esnet/janus.git
cd janus
pip3 install -e .
```

## Project Setup
This guide provides step-by-step instructions for setting up the Janus Controller environment.

### Prerequisites
- Docker
- Docker Compose

### Setup Instructions
- Copy Configuration Files:
    ```
    sudo mkdir -p /etc/janus
    sudo cp janus/config/* /etc/janus/
    cp janus.conf.example janus.conf   <-- edit as needed
    cd ../scripts
    docker compose -f local-dev-compose.yml up -d
   ``` 
   - Set the Portainer user and password in the janus.conf file.


- Create the db.json File and Set Permissions:
    ```
    sudo touch /etc/janus/db.json
    sudo chown 1000:1000 /etc/janus/db.json
   ```
   
- Create a Docker Volume:
    ```
    docker volume create portainer_data
   ```
   
- Update and Run Docker Compose:
    - Navigate to the /scripts directory in the cloned repository:
    ```
   cd /path/to/janus/scripts
   ```
    - Edit the local-dev-compose.yml file to update the controller’s volume path to the location of the code on your local machine.
   ```
    volumes:
      - /path/to/local/janus:/opt/janus
   ```
    - Edits to the source code will invoke a controller reload. Additional
configuration files can be placed in the config/ subdirectory as
needed, for example a kubecfg.

  
- Run the Docker Compose file:
  ```
   docker-compose -f local-dev-compose.yml up -d
   ```
  - This will start the Janus controller in a development context along
with supporting container images.  The janus/config directory along
with the relative source tree will be mounted inside the container. 

   
- Access Portainer:
   - Open a web browser and navigate to https://localhost:<port#> (replace <port#> with the actual port number specified in the janus.conf file).
   - Log in using the credentials you set earlier.


### Adding Kubernetes config

   - Bind mount your K8s `config` file into the $HOME of the Janus controller container.
For example:

     ```
      volumes:
        - ./../janus/config/nrp.config:/home/janus/.kube/config
     ```

   - Then, when you access the Janus Web interface Endpoints view, the controller should
list the resources queried from all the contexts in your K8s config.


### Configuring container registry authentication

  - The Janus controller supports authentication to private container
registries using tokens passed via the X-Registry-Auth HTTP
header. The tokens are in the form of a base64 encoded dictionary
containing the following attributes:

    ```
    { "username": "",
      "password": "",
      "serveraddress": ""
    }
    ```

  - As an example, Harbor registries allow for the creation of robot
accounts with secret keys. Using one of these robot accounts, a valid
token for Janus/Portainer can be created as follows:

    ```
    echo '{"username": "robot+dtnaas+deployer", "password": "SECRET_KEY", "serveraddress": "wharf.es.net"}' | base64 -w 0
    ```

  - For a single authenticated registry, this token can be passed as an
environment variable when launching the controller process. In a Janus
controller Docker compose file, include the following:

    ```
    environment:
      - REGISTRY_AUTH=<TOKEN>
    ```


  - Within the Janus `settings.py` file is where the registry auth
dictionary is maintained to map registry servers to authentication
tokens. Additional registries with their associated auth tokens may be
defined as needed.
