Kubernetes

Deploying VeilNet with Kubernetes to enable horizontal scalability and high availability.

Obtain a registration token

Please refer to the Quickstart Guide to obtain a registration token.

Deploy a new Conflux Node

To deploy a new Conflux Node, simply use the following deployment manifest:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: conflux
  namespace: default # adjust to your namespace
spec:
  replicas: 1 # adjust to your desired number of replicas
  selector:
    matchLabels:
      name: conflux
  template:
    metadata:
      labels:
        name: conflux
    spec:
      containers:
        - name: conflux
          image: veilnet/conflux:beta
          imagePullPolicy: Always
          securityContext:
            privileged: true
          env:
            - name: VEILNET_REGISTRATION_TOKEN
              value: <registration_token> # replace with your registration token
            - name: VEILNET_PORTAL
              value: "true" # Portal mode allows you to access the entire container network, host, and local network.
          resources:
            requests:
              cpu: "500m" # adjust according to your needs
              memory: "512Mi" # adjust according to your needs
            limits:
              cpu: "500m" # adjust according to your needs
              memory: "512Mi" # adjust according to your needs

Enable Horizontal Scaling

To enable horizontal scaling, simply create a horizontal pod autoscaler:

apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: conflux
  namespace: default # adjust to your namespace
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: conflux
  minReplicas: 1
  maxReplicas: 3
  metrics:
    - type: Resource
      resource:
        name: cpu
        target:
          type: Utilization
          averageUtilization: 70
    - type: Resource
      resource:
        name: memory
        target:
          type: Utilization
          averageUtilization: 70

New pods of VeilNet Conflux will be created automatically when the CPU or memory utilization is greater than 70%. You can adjust the metrics as needed, according to the offical kubernetes documentation.

Enable High Availability

When the number of replicas is greater than 1, VeilNet Conflux will automatically be in high availability mode. Each pod could be used as the connector to the container network, host, and local network. The Anchor Protocol will automatically choose the best pod to connect to the destination, and multiple pods could be used concurrently to achieve higher throughput.

There is nothing you need to do to enable high availability.

Warning: Envrionment variables VEILNET_CONFLUX_CIDR can be used to set the CIDR of the VeilNet Conflux pod, but this will disable the high availability mode because new instance will attempt to register with the same CIDR, which will cause conflicts.