Metadata-Version: 2.1
Name: platform-agent
Version: 0.0.63
Summary: UNKNOWN
Home-page: UNKNOWN
License: MIT
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Description-Content-Type: text/markdown
Requires-Dist: requests (==2.24.0)
Requires-Dist: urllib3 (<1.26)
Requires-Dist: pyroute2 (==0.5.12)
Requires-Dist: websocket-client (==0.57.0)
Requires-Dist: PyNaCl (==1.3.0)
Requires-Dist: docker-py (==1.10.6)
Requires-Dist: icmplibv2 (==1.0.6)
Requires-Dist: PyYAML (==5.3.1)
Requires-Dist: dnspython (==1.16.0)
Requires-Dist: iperf3 (==0.1.11)
Requires-Dist: prometheus-client (==0.8.0)
Requires-Dist: psutil (==5.7.2)
Requires-Dist: kubernetes (==11.0.0)

[TOC]

---

#### Prerequisites

* Wireguard kernel module is installed and loaded:
```bash
lsmod | grep wireguard
```

* Optional:  Docker is installed and running: 
```sh
docker system info
```
---
#### Limitations

* Docker network subnets can't overlap.
* 10.69.0.0/16 is used for internal Wireguard network

#### Steps
----
##### 1. Login to [https://platform.noia.network](https://platform.noia.network) 
---
##### 2. Create API key (Settings > API keys)

---

##### 3. Install NOIA Agent

Possible versions:

Stable:  ```noia/agent:prod```

Development:  ```noia/agent:devel``` or ```noia/agent:latest```  


###### With Docker 

```bash
docker run --network="host" --restart=on-failure:10 \ 
--cap-add=NET_ADMIN --cap-add=SYS_MODULE \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
--device /dev/net/tun:/dev/net/tun \
--name=noia-agent \
-e NOIA_API_KEY='z99CuiZnMhe2qtz4LLX43Gbho5Zu9G8oAoWRY68WdMTVB9GzuMY2HNn667A752EA' \
-e NOIA_NETWORK_API='docker' \
-d noia/agent:prod
```
Check agent logs:

```docker logs noia-agent```

More information:     [https://bitbucket.org/noianetwork-team/platform-agent/src/master/DOCKER.md](https://bitbucket.org/noianetwork-team/platform-agent/src/master/DOCKER.md)

---


###### With Docker-compose


> With Portainer agent:

```bash
curl  https://bitbucket.org/noianetwork-team/platform-agent/raw/master/docker-compose/na-pa.yml \
-o docker-compose.yaml
```

> Without portainer agent:

```bash
curl  https://bitbucket.org/noianetwork-team/platform-agent/raw/master/docker-compose/noia-agent.yaml \
-o docker-compose.yaml
```

Edit ```docker-compose.yaml``` file and edit these environment variables:

```yaml
NOIA_API_KEY= your_api_key
```

Start containers:

```bash
docker-compose up -d
```

Check agent logs:
```bash
docker logs noia-agent
```

P.S. NOIA Agent will ignore the default docker network, you will  need to create a separate network with different subnets on different hosts. Also, subnet 10.69.0.0/16 is used by our agent.

More information:

[https://bitbucket.org/noianetwork-team/platform-agent/src/master/DOCKER_COMPOSE.md](https://bitbucket.org/noianetwork-team/platform-agent/src/master/DOCKER_COMPOSE.md)

---


###### With pip 

```bash
pip3 install platform-agent
```

Download systemd service file:

```bash
curl https://bitbucket.org/noianetwork-team/platform-agent/raw/master/systemd/noia-agent.service -o /etc/systemd/system/noia-agent.service
```

Create noia-agent directory:
```bash
mkdir /etc/systemd/system/noia-agent.service.d/
chmod -R 600 /etc/systemd/system/noia-agent.service.d/
```
Download settings file:
```bash
curl https://bitbucket.org/noianetwork-team/platform-agent/raw/master/systemd/10-vars.conf -o /etc/systemd/system/noia-agent.service.d/10-vars.conf
```

Edit settings file ```/etc/systemd/system/noia-agent.service.d/10-vars.conf``` and change these settings:

```ini
[Service]
# Required parameters
Environment=NOIA_API_KEY=YOUR_API_KEY
# Optional parameters
Environment=NOIA_CONTROLLER_URL=controller-prod-platform-agents.noia.network
Environment=NOIA_ALLOWED_IPS=[{"10.0.44.0/24":"oracle_vpc"},{"192.168.111.2/32":"internal"}]
#If using docker , NOIA_NETWORK_API=docker would allow agent to access docker networks for information.
Environment=NOIA_NETWORK_API=none
Environment="NOIA_AGENT_NAME=Azure EU gateway"

# Select one of providers from the list - https://noia-network.readme.io/docs/start-noia-agent#section-variables
Environment="NOIA_PROVIDER=1"

Environment=NOIA_LAT=40.14
Environment=NOIA_LON=-74.21
Environment=NOIA_TAGS=Tag1,Tag2
Environment=NOIA_SERVICES_STATUS=false
```

```bash
systemctl  daemon-reload
```

```bash
systemctl enable --now noia-agent
```

Check if service is running:
```bash
systemctl status noia-agent
```

More information: [https://bitbucket.org/noianetwork-team/platform-agent/src/master/pip.md](https://bitbucket.org/noianetwork-team/platform-agent/src/master/pip.md)

---


###### On Portainer

1. Select image:

![alt_text](images/image.png "Select docker image")


2. Select network (Agent **MUST** run in the host network): 

![alt_text](images/network.png "Select network")

3. Add environment variables:

** Mandatory variables: **

```ini
NOIA_API_KEY= your_api_key
```

** Metadata (Optional) **
```ini
-e NOIA_NETWORK_API='docker'
-e NOIA_AGENT_NAME='Azure EU gateway '

# Select one of providers from the list - https://noia-network.readme.io/docs/start-noia-agent#section-variables
-e NOIA_PROVIDER ='1'

-e NOIA_LAT='40.14'
-e NOIA_LON='-74.21'

#You can manually add allowed ips
-e NOIA_ALLOWED_IPS='[{"127.0.24.0/24":"myvpc"},{"192.168.24.0/32":"vpc"}]'
-e NOIA_SERVICES_STATUS='false'
```


![alt_text](images/env.png "Add environment variables")


(noia agent will read docker subnets and report them to the controller). If this variable is selected, you also need to add docker.sock as a read-only volume;

![alt_text](images/volumes.png "Add docker.sock")


4. Add additional capabilities (NET_ADMIN and SYS_MODULE): 

![alt_text](images/cap.png "image_tooltip")


5. All agents will appear in NOIA Platform as endpoints:

![alt_text](images/endpoints.png "Endpoints")



6. To connect endpoints to a network, select Networks > Add new network. Input Network name, select Type (if you want connect multiple Portainer agents to Portainer, choose Gateway and select Portainer host as a gateway and select agents which you want to connect), then click Add: 

![alt_text](images/create_net.png "Create network")



