Skip to content

Kubernetes with K3s

HyperCloud orchestration

Code used in this process can be found in HyperCloud deployment examples.

This repository contains various working examples of how to deploy different types of infrastructure on HyperCloud. The K3S and RKE2 examples will deploy a basic K3s and RKE2 Kubernetes cluster onto HyperCloud respectively, along with a few application examples running on top. These examples also integrate with persistent storage from HyperCloud and configure the services with SSL certificates. To run the deployment, you will need recent versions of infrastructure provisioning and management tools. We recommend OpenTofu and Ansible.

HyperCloud information

Info

Keep a record of the IDs assigned, as they will be used as part of the configuration.
We used the Ubuntu - 22.04 image for the exercise, so the commands described in this article are specifically for Ubuntu; however, you can use your preferred Linux distribution, but there might be slight differences in the commands needed.

For the remainder of the document, the following HyperCloud aspects will be configured:

  • Group - Orchestration
  • Group Administrator - orchadmin
  • VNET - Infrastructure Management Network The configured VNET will be the Public and Private IPv4 Addresses for the services created within the Tenancy
  • Image - Ubuntu - 22.04 App from SoftIron Amplifier
  • VM Template - Ubuntu 22.04 App from SoftIron Amplifier

Images

For the exercise, Ubuntu - 22.04 images have been used. To set up images see * Creating images * Accessing the SoftIron marketplaces

Tenancy configuration

As part of the HyperCloud setup, a Group and VNET tenancy has been configured. For further information on tenancy management, see HyperCloud tenancy management

Group

Create a Group with Group Administrator. For further details see Create Public_VDC Group, Group Admin, and Group User.

VNET

With a production implementation, the deployment of a public and private set of IPv4 addresses is advised. And as such it is recommended that two VNETS be configured. One for public access and the other for internal communications.

For further details see Virtual networks.

Master orchestrator server configuration

Instantiate/deploy a VM within the tenancy that will act as the master orchestrator that will deploy and configure subsequent servers. The VM will run the Ansible and OpenTofu code to deploy other VMs within the tenancy. For further details see Virtual machines.

Hosts file

Edit the /etc/hosts file to include the hostname / IPv4 address of master orchestrator

<IPv4 Address> master-orchestrator

Ansible

To install Ansible, execute the following commands

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible

For alternative Linux variants see Installing Ansible on specific operating systems.

OpenTofu

To install OpenTofu, execute the following command:

snap install --classic opentofu

For alternative Linux variants see Install OpenTofu.

SSH

To be able to access the master-orchestrator VM. Within your local machine, execute the process defined in HyperCloud: SSH Keys.

Once the process has been completed you can connect into the server, via the command

ssh -I <path and filename to ppk> root@< master-orchestrator IPv4>

The Master Orchestrator (master-orchestrator) will need to access the OpenTofu created VMs. From the Master Orchestrator generate a key pair by executing:

ssh-keygen -t rsa -b 4096

Now add the public key to the Authentication settings for the HyperCloud user account. Multiple keys can be placed in the authentication settings, with a newline between keys.

Clone HyperCloud examples

Download the examples to the orchestrator VM:

git clone https://github.com/SoftIron/hypercloud-examples.git

K3S code is in the hypercloud-examples/k3s directory.

OpenTofu – Create Virtual Machines

Note

You must execute the OpenTofu commands from the hypercloud-examples/k3s/terraform/ folder.

terraform.tfvars

Some variables used by the configuration need to be modified to work on other environments as there are a few values hardcoded. You can find them in hypercloud-examples/k3s/terraform/terraform.tfvars.

  • hypercloud_image_id - ID of the image to use on the VMs, Debian or Ubuntu.
  • hypercloud_group - Name of the group used to deploy the VMs.
  • internal_net_id - ID of the network used by the VMs. Needs to be reachable from the VM running the deployment.
  • public_net_id - ID of a network that can get public IPv4 addresses.
  • public_net_ip - The public IPv4 to use. Empty by default, this will use an available IPv4 address from the network specified.

Edit the file hypercloud-examples/k3s/terraform/terraform.tfvars and update the entries

hypercloud_group  = "Orchestration"
hypercloud_image_id = < Image  ID>
internal_net_id = <VNET ID>
public_net_id = <VNET ID>

For the sake of simplicity the internal_net_id and public_net_id can be assigned the same VNET.

provider.tf

Note

For “Invalid SSL Cert”. Either have the HyperCloud certificate signed or you can have OpenTofu ignore the invalid certificate. To disable SSL verification, update the provider "example_orchestrator" entry with the attribute

insecure = true

Edit the file hypercloud-examples/k3s/terraform/provider.tf and update the entries.

endpoint = "https://<HyperCloud Address>:2634/RPC2"
flow_endpoint = "https:// <HyperCloud Address>:2475/RPC2"

Username and password

Execute the following commands:

export TF_VAR_one_username="orchadmin"
export TF_VAR_one_password="<password>"

Build VM

Note

If you get a “no such host” error. The VM’s DNS setup has not been configured correctly.

To correct the issue either:

  • Correct the misconfiguration
  • Include the HyperCloud Address in the /etc/hosts file
  • Update the HyperCloud Address within the provider.tf with the IP Address of the cluster

Once the configuration files have be updated, execute the following commands

terraform init
terraform apply

The process will create the following VMs - K3s Agent Services - k3s-agent-1 - k3s-agent-2 - K3s Load Balancer - k3s-loadbalancer-1 - K3s Server - k3s-server-1

Along with an Ansible inventory file located on hypercloud-examples/k3s/ansible/inventory/hosts

Install RKE2

With the VMs deployed, you can run the following Ansible playbook from the hypercloud-examples/k3s/ansible/ folder.

ansible-playbook --private-key=<private key file> -i inventory/hosts rke2_cluster.yaml 

Kubernetes examples

Once Kubernetes is running, you can start installing things on top. You can find on the hypercloud-examples/k3s/kubernetes/ folder the examples we are going to be deploying now.

These examples include: