Metadata-Version: 2.1
Name: mkmavrykchain
Version: 6.27.6
Summary: A utility to generate k8s configs for a Mavryk blockchain
Home-page: https://github.com/mavryk-network/mavryk-k8s
Author: MavrykDynamics
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: pyyaml
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: autoflake; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: black; extra == "dev"

- [Install mkmavrykchain](#install-mkmavrykchain)
- [Generate Helm Values](#generate-helm-values)
  - [mkmavrykchain parameters](#mkmavrykchain-parameters)
- [Create Mavryk Chain](#create-mavryk-chain)

# mkmavrykchain

Helper program to generate values for the Mavryk chain Helm chart

## Prerequisites

To run `mkmavrykchain`, you must either have docker or pymavryk installed.

### Installing Docker

To be consistent with other documentation in this project, we describe
how to install docker with minikube. We need to install:

    - [docker](https://docs.docker.com/get-docker/),
    - [minikube](https://minikube.sigs.k8s.io/docs/),
    - [helm](https://helm.sh/),
    - and `python3`.

Start minikube and configure your shell environment to use minikube's
Docker daemon:

```shell
minikube start

eval $(minikube docker-env)
```

### Installing pymavryk

This is documented at:
https://pymavryk.mavryk.org/quick_start.html#requirements

## Install mkmavrykchain

```shell
mkdir mkmavrykchain && cd mkmavrykchain
python3 -m venv .venv
. .venv/bin/activate
pip install wheel && pip install mkmavrykchain
```

Set [unbuffered IO](https://docs.python.org/3.6/using/cmdline.html#envvar-PYTHONUNBUFFERED) for python:

```shell
export PYTHONUNBUFFERED=x
```

## Generate Helm Values

Set as an environment variable the name you would like to give to your chain:

```shell
export CHAIN_NAME=my-chain
```

Your chain is uniquely defined by a set of values such as bootstrap account keys, chain id, timestamp...

To generate these values run:

```shell
mkmavrykchain $CHAIN_NAME
```

This command will create a yaml file in your current working directory: `<$CHAIN_NAME>_values.yaml`

If you configure your chain to run over a Zerotier VPN, mkmavrykchain will create an additional file for invitees to join your network: `<$CHAIN_NAME>_invite_values.yaml`.

### mkmavrykchain parameters

You can explicitly specify some values by:

- passing CLI parameters to `mkmavrykchain`
- directly modifying the values yaml file generated by `mkmavrykchain`
- passing arguments to [helm install](https://helm.sh/docs/helm/helm_install/) or [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) commands using the `--set` flag, which will selectively override the current yaml values

| YAML Key                         | mkmavrykchain argument         | Description                                                    | Default                 |
| -------------------------------- | ------------------------ | -------------------------------------------------------------- | ----------------------- |
|                                  | -h                       | mkmavrykchain help message                                           |                         |
|                                  | -v                       | mkmavrykchain version                                                |                         |
|                                  | --number-of-bakers       | Number of baking nodes in the cluster                          | 1                       |
|                                  | --number-of-nodes        | Number of non-baking nodes in the cluster                      | 0                       |
| bootstrap_peers                  | --bootstrap-peers        | Peer ips to connect to                                         | []                      |
| expected_proof_of_work           | --expected-proof-of-work | Node identity generation difficulty                            | 0                       |
| images.mavkit                     | --mavkit-docker-image     | Version of the Mavkit docker image to run                       | mavrykdynamics/mavryk:v19.3 |
|                                  | --use-docker (--no...)   | Use (or don't use) docker to generate keys rather than pymavryk | autodetect              |
| zerotier_config.zerotier_network | --zerotier-network       | Zerotier network id for external chain access                  |                         |
| zerotier_config.zerotier_token   | --zerotier-token         | Zerotier token for external chain access                       |                         |

## Create Mavryk Chain

Make sure you have the Mavryk Helm chart repo:

```shell
helm repo add mavryk-network https://mavryk-network.github.io/mavryk-helm-charts
```

Then install the Mavryk Helm chart:

```shell
helm install $CHAIN_NAME mavryk-network/mavryk-chain \
--values ./${CHAIN_NAME}_values.yaml \
--namespace mavryk-network --create-namespace
```


