Skip to content

Install

What Will You Do

In this section,
- 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 namespace 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

We will need two addons, one for deploying mettallb and another for configuring metallb.

In this step, we will check if we are using version v0.13.7 of MetalLB and customise addon with the range of IP addresses we want the load balancer to use. The addons can then be added to a blueprint to then be applied to clusters.

  • 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"
  • Open "custom-values.yaml" file and check if we are using v0.13.7 version of MetalLB for speaker and controller images. It should look like
speaker:
  image:
    tag: v0.13.7
controller:
  image:
    tag: v0.13.7
  • Update the "metallb-cm.yaml" file with the range of IP addresses to be used by the load balancer
apiVersion: v1
kind: ConfigMap
metadata:
  namespace: metallb
  name: metallb-config
data:
  config: |
    address-pools:
    - name: default
      protocol: layer2
      addresses:
      - 192.168.86.210-192.168.86.215

Step 4: Create MetalLB Addons

In this step, you will create two addons for MetalLB that uses the files changed/verified in the previous step.

  • 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
       tag: 0.13.7
- Update the "addoncm.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
apiVersion: infra.k8smgmt.io/v3
kind: AddonVersion
metadata:
  name: v1
  project: defaultproject
spec:
  addon: metallbyaml-addon
  namespace: metallb
  template:
    type: yaml
    yamlFile: ./metallb-cm.yaml
  • 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 to add first addon

rctl create addon version -f addon.yaml
- Type the command below to add second addon

rctl create addon version -f addoncm.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" and "metallbyaml-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 with the addons

  • Type the command below to add a new version
rctl create blueprint version metallb-blueprint v1 metallb-addon/v1 metallbyaml-addon/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 -> 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.