1. Answers
  2. Setting Up High Availability Clusters With Proxmox VE CTs

Setting Up High Availability Clusters With Proxmox VE CTs

Introduction

In this guide, we will set up high availability (HA) clusters using Proxmox VE containers (CTs). Proxmox VE is an open-source server virtualization environment that allows you to manage virtual machines, containers, and storage with a web-based interface. By setting up HA clusters, you can ensure that your services remain available even if one of the nodes in the cluster fails.

Step-by-Step Explanation

Prerequisites

  1. Proxmox VE Installation: Ensure that Proxmox VE is installed on all nodes that will be part of the HA cluster.
  2. Network Configuration: All nodes should be connected to the same network and have static IP addresses assigned.
  3. Shared Storage: Set up shared storage that all nodes in the cluster can access. This can be done using NFS, iSCSI, or other shared storage solutions.

Steps

  1. Create Proxmox VE Cluster:
    • On the first node, create a new cluster:
      pvecm create my-cluster
      
    • On the other nodes, join the cluster:
      pvecm add <IP-of-first-node>
      
  2. Configure HA:
    • Enable HA on the cluster:
      pve-ha-manager enable
      
    • Add resources to the HA manager:
      ha-manager add <resource>
      
  3. Create and Configure CTs:
    • Create containers on the Proxmox VE nodes. Ensure that the containers are configured to use the shared storage.
    • Add the containers to the HA manager:
      ha-manager add CT:<CT-ID>
      
  4. Test HA Setup:
    • Simulate a node failure by shutting down one of the nodes.
    • Verify that the containers are automatically migrated to other nodes in the cluster.

Summary and Conclusion

By following these steps, you can set up a high availability cluster using Proxmox VE containers. This setup ensures that your services remain available even in the event of a node failure. Proxmox VE’s HA manager handles the automatic migration of containers, providing a robust and reliable solution for your virtualization needs.

Full Code Example

import * as pulumi from "@pulumi/pulumi";
import * as command from "@pulumi/command";

// This Pulumi program sets up a high availability (HA) cluster using Proxmox VE containers (CTs).
// Note: This program assumes that Proxmox VE is already installed and configured on all nodes.

// Step 1: Create Proxmox VE Cluster
// On the first node, create a new cluster
const createCluster = new command.local.Command("createCluster", {
    create: "pvecm create my-cluster",
});

// On the other nodes, join the cluster
const joinCluster = new command.local.Command("joinCluster", {
    create: "pvecm add <IP-of-first-node>",
});

// Step 2: Configure HA
// Enable HA on the cluster
const enableHA = new command.local.Command("enableHA", {
    create: "pve-ha-manager enable",
});

// Add resources to the HA manager
const addResourceToHA = new command.local.Command("addResourceToHA", {
    create: "ha-manager add <resource>",
});

// Step 3: Create and Configure CTs
// Create containers on the Proxmox VE nodes and ensure they use the shared storage
const createCT = new command.local.Command("createCT", {
    create: "pct create <CT-ID> <template> -storage <shared-storage>",
});

// Add the containers to the HA manager
const addCTToHA = new command.local.Command("addCTToHA", {
    create: "ha-manager add CT:<CT-ID>",
});

// Step 4: Test HA Setup
// Simulate a node failure by shutting down one of the nodes
const simulateFailure = new command.local.Command("simulateFailure", {
    create: "shutdown -h now",
});

// Verify that the containers are automatically migrated to other nodes in the cluster
const verifyMigration = new command.local.Command("verifyMigration", {
    create: "ha-manager status",
});

// Export the cluster creation status
export const clusterCreationStatus = createCluster.stdout;
export const clusterJoinStatus = joinCluster.stdout;
export const haEnableStatus = enableHA.stdout;
export const resourceAddStatus = addResourceToHA.stdout;
export const ctCreationStatus = createCT.stdout;
export const ctAddToHAStatus = addCTToHA.stdout;
export const failureSimulationStatus = simulateFailure.stdout;
export const migrationVerificationStatus = verifyMigration.stdout;

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up