Metadata-Version: 2.1
Name: mkchain
Version: 3.0.1
Summary: A utility to generate k8s configs for a Tezos blockchain
Home-page: https://github.com/tqtezos/tezos-k8s
Author: TQ Tezos
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
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 mkchain](#install-mkchain)
- [Generate Helm Values](#generate-helm-values)
  - [mkchain parameters](#mkchain-parameters)
- [Create Tezos Chain](#create-tezos-chain)

# mkchain

Helper program to generate values for the Tezos chain Helm chart

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

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

```shell
minikube start

eval $(minikube docker-env)
```

## Install mkchain

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

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
mkchain $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, mkchain will create an additional file for invitees to join your network: `<$CHAIN_NAME>_invite_values.yaml`.

### mkchain parameters

You can explicitly specify some values by:

- passing CLI parameters to `mkchain`
- directly modifying the values yaml file generated by `mkchain`
- 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                         | mkchain argument         | Description                                                                 | Default                |
| -------------------------------- | ------------------------ | --------------------------------------------------------------------------- | ---------------------- |
|                                  | -h                       | mkchain help message                                                        |                        |
|                                  | -v                       | mkchain 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.tezos                     | --tezos-docker-image     | Version of the Tezos docker image to run                                    | tezos/tezos:v8-release |
| rpc_auth                         | --rpc-auth               | Whether or not an [RPC auth](../rpc-auth/README.md) backend will be spun up | False                  |
| 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 Tezos Chain

Make sure you have the Tezos Helm chart repo:

```shell
helm repo add tqtezos https://tqtezos.github.io/tezos-helm-charts
```

Then install the Tezos Helm chart:

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


