Skip to content

Install

What Will You Do

In this section,

  • You will create a MetalLB addon and use it in a custom cluster blueprint
  • You will then apply this cluster blueprint to a managed cluster

Important

This tutorial describes the steps to create and use a custom cluster blueprint using declarative specifications. The entire workflow can also be done through the UI.


Assumptions

  • You have already provisioned an upstream Kubernetes cluster (bare metal or VM based)
  • You have an allocated range of IP Addresses to be used for load-balancers.

Step 1: Create the MetalLB Helm Repository

In this step, you will create a repository in your project so that the controller can retrieve the Helm charts automatically. Additional information on downloading, packaging, and installing the the latest helm chart can be found here https://metallb.universe.tf/.

  • Open Terminal (on macOS/Linux) or Command Prompt (Windows) and navigate to the folder where you forked the Git repository
  • Navigate to the folder "/getstarted/metallb/repository"

The "repository.yaml" file contains the declarative specification for the repository. In this case, the specification is of type "Helm Repository" and the "endpoint" is pointing to the MetalLB Helm chart.

apiVersion: config.rafay.dev/v2
kind: Repository
metadata:
  name: metallb-repo
spec:
  repositoryType: HelmRepository
  endpoint:  https://metallb.github.io/metallb
  credentialType: CredentialTypeNotSet
  • Type the command below
rctl create repository -f repository.yaml

If you did not encounter any errors, you can optionally verify if everything was created correctly on the controller.

  • Navigate to the "defaultproject" project in your Org
  • Select Integrations -> Repositories

Repository


Step 2: Create Namespace

In this step, you will create a namespace for the MetalLB controller. The "metallb-namespace.yaml" file contains the declarative specification

The following items may need to be updated if you used alternate names.

  • value: metallb-cluster
kind: ManagedNamespace
apiVersion: config.rafay.dev/v2
metadata:
  name: metallb
  description: namespace for metallb controller
  labels:
  annotations:
spec:
  type: RafayWizard
  resourceQuota:
  placement:
    placementType: ClusterSpecific
    clusterLabels:
    - key: rafay.dev/clusterName
      value: metallb-cluster
  • Open Terminal (on macOS/Linux) or Command Prompt (Windows) and navigate to the folder where you forked the Git repository
  • Navigate to the folder "/getstarted/metallb/namespace"
  • Type the command below
rctl create namespace -f metallb-namespace.yaml

If you did not encounter any errors, you can optionally verify if everything was created correctly on the controller.

  • Navigate to the "defaultproject" project in your Org
  • Select Infrastructure -> Namespaces
  • You should see an namesapce called "metallb"

Namespace

Now, we need to publish the namespace to the cluster

  • Type the command below
rctl publish namespace metallb

If you did not encounter any errors, you can optionally verify if everything was created correctly on the cluster.

  • Click on the Kubectl button on the cluster to open a virtual terminal and run the following kubectl command
kubectl get ns

You should see a message like below

NAME                    STATUS   AGE
default                 Active   21h
kube-node-lease         Active   21h
kube-public             Active   21h
kube-system             Active   21h
metallb                 Active   1m
openebs                 Active   21h
rafay-infra             Active   21h
rafay-system            Active   21h

Step 3: Customize Values

In this step, you will create a custom values file for MetalLB addon. The addon can then be added to a blueprint to then be applied to clusters.

We must update the "custom-values.yaml" file for the MetalLB addon with the range of IP addresses we want the load balancer to use.

  • Open Terminal (on macOS/Linux) or Command Prompt (Windows) and navigate to the folder where you forked the Git repository
  • Navigate to the folder "/getstarted/metallb/addon"
  • Update the "custom-values.yaml" file with the range of IP addresses to be used by the load balancer
configInline:
  address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.86.210-192.168.86.215

Step 4: Create MetalLB Addon

In this step, you will create a addon for MetalLB that uses the custom values file previously updated.

  • Open Terminal (on macOS/Linux) or Command Prompt (Windows) and navigate to the folder where you forked the Git repository
  • Navigate to the folder "/getstarted/metallb/addon"
  • Update the "addon.yaml" file with the appropriate details to match your environment

The following items may need to be updated to match your environment

  • project: defaultproject
  • repository_ref: metallb-repo
kind: AddonVersion
metadata:
  name: v1
  project: defaultproject
spec:
  addon: metallb-addon
  namespace: metallb
  template:
    type: Helm3
    valuesFile: custom-values.yaml
    repository_ref: metallb-repo
    repo_artifact_meta:
      helm:
       chartName: metallb
  • Open Terminal (on macOS/Linux) or Command Prompt (Windows) and navigate to the folder where you forked the Git repository
  • Navigate to the folder "/getstarted/metallb/addon"
  • Type the command below
rctl create addon version -f addon.yaml

If you did not encounter any errors, you can optionally verify if everything was created correctly on the controller.

  • Navigate to the "defaultproject" project in your Org
  • Select Infrastructure -> Addons
  • You should see an addon called "metallb-addon"

MetalLB Addon


Step 5: Create Blueprint

In this step, you will create a custom cluster blueprint with the MetalLB addon. The "blueprint.yaml" file contains the declarative specification.

  • Open Terminal (on macOS/Linux) or Command Prompt (Windows) and navigate to the folder where you forked the Git repository
  • Navigate to the folder "/getstarted/metallb/blueprint"

The following items may need to be updated if you used alternate names.

  • project: defaultproject
kind: Blueprint
metadata:
  # blueprint name
  name: metallb-blueprint
  #project name
  project: defaultproject
  • Type the command below
rctl create blueprint -f blueprint.yaml

If you did not encounter any errors, you can optionally verify if everything was created correctly on the controller.

  • Navigate to the "defaultproject" project in your Org
  • Select Infrastructure -> Blueprint
  • You should see an blueprint called "metallb-blueprint

MetalLB Blueprint


New Version

Although we have a custom blueprint, we have not provided any details on what it comprises. In this step, you will create and add a new version to the custom blueprint. The YAML below is a declarative spec for the new version.

The following items may need to be updated if you used alternate names.

  • project: defaultproject
kind: BlueprintVersion
metadata:
  name: v1
  project: defaultproject
  description: metallb
spec:
  blueprint: metallb-blueprint
  baseSystemBlueprint: default
  baseSystemBlueprintVersion: ""
  addons:
    - name: metallb-addon
      version: v1
  # cluster-scoped or namespace-scoped
  pspScope: cluster-scoped
  rafayIngress: true
  rafayMonitoringAndAlerting: false
  kubevirt: false
  # BlockAndNotify or DetectAndNotify
  driftAction: BlockAndNotify 
  • Type the command below to add a new version
rctl create blueprint version -f blueprint-v1.yaml

If you did not encounter any errors, you can optionally verify if everything was created correctly on the controller.

  • Navigate to the "defaultproject" project in your Org
  • Select Infrastructure -> Blueprint
  • Click on the "metallb-blueprint" custom cluster blueprint

MetalLB Blueprint Version


Step 6: Apply Blueprint

In this step, you will update the cluster to use the newly created custom blueprint with the MetalLB addon.

  • Replace the cluster name, "metallb-cluster", in the command below with the name of your cluster.
  • Run the updated command
rctl update cluster metallb-cluster -b metallb-blueprint --blueprint-version v1

If you did not encounter any errors, you can optionally verify if everything was created correctly on the controller.

  • Navigate to the "defaultproject" project in your Org
  • Select Infrastructure -> Clusters
  • You should see the cluster is now using the "metallb-blueprint

Cluster Blueprint


Step 7: Verify Deployment

Users can optionally verify whether the correct resources have been created on the cluster.

  • Click on the Kubectl button on the cluster to open a virtual terminal
  • We will verify the pods in the "metallb" namespace. You should see something like the example below.
kubectl get pod -n metallb

NAME                                        READY   STATUS    RESTARTS   AGE
metallb-addon-controller-7d6c7f98b7-mhgh6   1/1     Running   0          2m
metallb-addon-speaker-v29gp                 1/1     Running   0          2m

Recap

Congratulations! You have successfully created a custom cluster blueprint with the MetalLB addon and applied it to a cluster. You can now use this blueprint on as many clusters as you require.