Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(CI): Added axon Kubernetes deployment mode and key generation mode #1655

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions devtools/chain/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Axon Deployment Repository

## Introduction

This repository serves as the storage directory for Axon deployment files. It encompasses Axon Kubernetes deployment, node deployment, and private key generation methods. The following sections provide detailed instructions for various deployment methods. It is strongly recommended to generate your own key regardless of the deployment method chosen.

## Deployment Methods

### 1. Private Key Generation

- Steps to generate a private key for securing your Axon deployment.

1. First,it is necessary to [compile](https://github.com/axonweb3/axon?tab=readme-ov-file#compile-from-source) Axon in a local or standardized Rust environment.

2. Next, generate the corresponding key using [generate-keypair](https://github.com/axonweb3/axon/tree/main/core/cli#generate-keypair)



### 2. Axon Kubernetes Deployment

- Detailed instructions and files for deploying Axon on Kubernetes.
- Navigate to the [kubernetes-deployment](https://github.com/axonweb3/axon/tree/main/devtools/chain/k8s) directory for Kubernetes-specific deployment.

### 3. Node Deployment

- Instructions for deploying Axon on individual nodes.
- Explore the [node-deployment](https://github.com/axonweb3/axon/tree/main/devtools/chain/nodes) directory for node-specific deployment details.

## Important Note

Regardless of the chosen deployment method, it is strongly advised to generate a unique private key for added security. Follow the instructions in the respective directories to create your own key.

Feel free to explore each deployment method based on your specific requirements and preferences.
105 changes: 105 additions & 0 deletions devtools/chain/k8s/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Axon Kubernetes Deployment

## Introduction
This repository contains Axon Kubernetes deployment files. The following sections provide detailed instructions for deploying Axon Chain quickly, while optimizing resource usage.

## Environmental preparation
Kubernetes enables you to deploy Axon Chain rapidly while conserving resources.

- First, you need a kubernetes system, either new or existing
- Secondly, it is necessary to plan the storageClass inside kubernetes
- The third is a machine that can have kubectl installed and can operate kubernetes

## Instructions

1. **Download the Project**

```bash
git clone https://github.com/axonweb3/axon.git
```

2. **Navigate to the Corresponding Directory**

```bash
cd devtools/chain/k8s/multple
```

3. **Create the Corresponding Namespace**

```bash
kubectl create namespace axon-alphanet
```

4. **Check Axon Version**

- Modify ```newTag: forcerelay-dev-c203acb``` to the version you want to deploy

```bash
images:
- name: ghcr.io/axonweb3/axon:0.2.0-dev
newName: ghcr.io/axonweb3/axon
newTag: forcerelay-dev-c203acb

```

5. **Check Axon's Required StorageClass and Modify**

- modifying StorageClass ```storageClassName: chain``` for your own cluster

```bash
volumeClaimTemplates:
- metadata:
name: data1
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: chain
resources:
requests:
storage: 100Gi
```

6. **Perform initialization and modify the axon1 to axon4 statefulset file to the following format**

```bash
containers:
- name: axon1
args:
- ./axon
- init
- --config=/app/devtools/chain/k8s/node_1.toml
- --chain-spec=/app/devtools/chain/chain-spec.toml
```

7. [Generate key](https://github.com/axonweb3/axon/tree/main/core/cli#generate-keypair:~:text=Generate%20Keypair,in%20config%20file.), and update the fields of the chain-spec.yaml and toml files

- [chain-spec.yaml](https://github.com/axonweb3/axon/blob/main/devtools/chain/k8s/multiple/chain-spec.toml#:~:text=interval%20%3D%203000-,%5B%5Bparams.verifier_list%5D%5D,vote_weight%20%3D%201,-axon/devtools/chain)

- [node_1.toml](https://github.com/axonweb3/axon/blob/main/devtools/chain/k8s/multiple/node_1.toml#:~:text=%5B%5Bnetwork.,p2p/QmXoSkz4zkHHiFZqmDZQ4gFYtJ72uqtp4m6FX373X4VkRq%22)

- [node_2.toml](https://github.com/axonweb3/axon/blob/main/devtools/chain/k8s/multiple/node_2.toml#:~:text=%5B%5Bnetwork.,p2p/QmXoSkz4zkHHiFZqmDZQ4gFYtJ72uqtp4m6FX373X4VkRq%22)

- [node_3.toml](https://github.com/axonweb3/axon/blob/main/devtools/chain/k8s/multiple/node_3.toml#:~:text=%5B%5Bnetwork.,p2p/QmXoSkz4zkHHiFZqmDZQ4gFYtJ72uqtp4m6FX373X4VkRq%22)

- [node_4.toml](https://github.com/axonweb3/axon/blob/main/devtools/chain/k8s/multiple/node_4.toml#:~:text=%5B%5Bnetwork.,p2p/QmXoSkz4zkHHiFZqmDZQ4gFYtJ72uqtp4m6FX373X4VkRq%22)

7. **Start Axon After the axon initialization is successful, modify the axon1 to axon4 statefulset file to the following format**

```bash
containers:
- name: axon1
args:
- ./axon
- run
- --config=/app/devtools/chain/k8s/node_1.toml
```
```
cd devtools/chain/k8s/
kubectl apply -k multiple -n axon-alphanet
```

8. **After the startup command is executed, check that the pod status is ```runing``` and the axon log is blocked normally**
```bash
kubectl get pods -n axon-alphanet
kubectl logs axon1 -n axon-alphanet -f
```

16 changes: 16 additions & 0 deletions devtools/chain/k8s/multiple/axon-chain.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: axon-chain
name: axon-chain
namespace: axon-alphanet
spec:
ports:
- name: axon-chain
port: 8000
targetPort: 8000
protocol: TCP
selector:
svc: axon-test
type: ClusterIP
16 changes: 16 additions & 0 deletions devtools/chain/k8s/multiple/axon-ws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: axon-ws
name: axon-ws
namespace: axon-alphanet
spec:
ports:
- name: axon-chain
port: 8010
targetPort: 8010
protocol: TCP
selector:
svc: axon-test
type: ClusterIP
123 changes: 123 additions & 0 deletions devtools/chain/k8s/multiple/axon1-statefulset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
apiVersion: v1
kind: Service
metadata:
labels:
app: axon1
name: axon1
namespace: axon-alphanet
spec:
ports:
- name: p2p
port: 8001
targetPort: 8001
protocol: TCP
- name: rpc
port: 8000
targetPort: 8000
protocol: TCP
- name: websocket
port: 8010
targetPort: 8010
protocol: TCP
- name: prometheus
port: 8100
targetPort: 8100
protocol: TCP
selector:
app: axon1
type: ClusterIP
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: axon1
namespace: axon-alphanet
spec:
replicas: 1
updateStrategy:
type: RollingUpdate
selector:
matchLabels:
svc: axon-test
app: axon1
logging: "true"
serviceName: "axon1"
template:
metadata:
labels:
svc: axon-test
app: axon1
logging: "true"
spec:
containers:
- name: axon1
#command: ["./axon"]
args:
#args: ["hardfork","--config=/app/devtools/chain/k8s/node_1.toml", "--hardfork-start-number", "42640", "--feature", "andromeda"]
- ./axon
- run
#- init
- --config=/app/devtools/chain/k8s/node_1.toml
#- --chain-spec=/app/devtools/chain/chain-spec.toml
image: ghcr.io/axonweb3/axon:0.2.0-dev
volumeMounts:
- name: config-node1
mountPath: /app/devtools/chain/k8s/node_1.toml
subPath: node_1.toml
- name: node1-net-key
mountPath: /app/devtools/chain/k8s/node_1_net.key
subPath: node_1_net.key
- name: node1-bls-key
mountPath: /app/devtools/chain/k8s/node_1_bls.key
subPath: node_1_bls.key
- name: config-chain-spec
mountPath: /app/devtools/chain/chain-spec.toml
subPath: chain-spec.toml
- name: config-db-options
mountPath: /app/devtools/chain/k8s/default.db-options
subPath: default.db-options
- name: data1
mountPath: /app/devtools/chain/data/node_1
subPath: node_1
ports:
- name: p2p
containerPort: 8001
- name: rpc
containerPort: 8000
- name: websocket
containerPort: 8010
- name: prometheus
containerPort: 8100
resources:
requests:
cpu: 1
memory: 1024Mi
limits:
cpu: 2
memory: 2048Mi
volumes:
- name: config-node1
configMap:
name: node1-toml
- name: config-chain-spec
configMap:
name: chain-spec
- name: config-db-options
configMap:
name: db-options
- name: node1-net-key
configMap:
name: node-1-net.key
- name: node1-bls-key
configMap:
name: node-1-bls.key
restartPolicy: Always
volumeClaimTemplates:
- metadata:
name: data1
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: chain
resources:
requests:
storage: 100Gi
Loading
Loading