Setting Up Equinix Metal Cloud Provider for RKE2
Introduction
Equinix Metal (formerly Packet) provides bare-metal cloud infrastructure for running Kubernetes. RKE2 supports Equinix Metal as an out-of-tree cloud provider, enabling integration with MetalLB for LoadBalancer services and CSI drivers for persistent storage.
This guide walks you through setting up the Equinix Metal Cloud Provider in RKE2.
Prerequisites
- An active Equinix Metal account
- A running RKE2 cluster deployed on Equinix Metal
- Equinix Metal API Key for authentication
- kubectl configured to interact with your cluster
- Helm installed for deploying the cloud provider
Step 1: Generate Equinix Metal API Key
- Log in to the Equinix Metal Console.
- Navigate to API Keys.
- Generate a read-write API key for Kubernetes integration.
- Store this key securely, as it will be required for configuring the cloud provider.
Step 2: Configure the Cloud Provider
The Equinix Metal Cloud Provider requires a configuration file (cloud-provider-config
) to be stored as a Kubernetes Secret.
1. Create the Equinix Metal Cloud Provider Config File
Create a file named metal-cloud-config.yaml
with the following contents:
[global]
api-key = "YOUR_EQUINIX_METAL_API_KEY"
project-id = "YOUR_PROJECT_ID"
Replace YOUR_EQUINIX_METAL_API_KEY
and YOUR_PROJECT_ID
with the appropriate values.
2. Create a Kubernetes Secret
Store the cloud provider configuration as a Kubernetes Secret:
kubectl create secret generic cloud-provider-config \
--from-file=cloud-provider-config=metal-cloud-config.yaml \
-n kube-system
Step 3: Deploy the Equinix Metal Cloud Controller Manager
The Cloud Controller Manager (CCM) allows Kubernetes to communicate with Equinix Metal’s APIs for managing node lifecycles, network routes, and load balancers.
- Add the Helm Repository:
helm repo add equinix-metal https://helm.equinix.com/
helm repo update
- Install the Cloud Controller Manager:
helm install equinix-metal-cloud-controller-manager equinix-metal/equinix-metal-cloud-controller-manager \
--namespace kube-system \
--set providerConfigSecretName=cloud-provider-config
- Verify Deployment:
kubectl get pods -n kube-system | grep cloud-controller-manager
Ensure that the equinix-metal-cloud-controller-manager
pod is running.
Step 4: Configure Load Balancers
Equinix Metal does not provide a native load balancer service, so MetalLB must be installed to support Kubernetes LoadBalancer Services.
- Install MetalLB:
helm install metallb metallb/metallb \
--namespace kube-system \
--create-namespace
- Configure IP Address Pool:
Create a file
metallb-config.yaml
:
apiVersion: metallb.io/v1beta1
kind: IPAddressPool
metadata:
name: default-pool
namespace: kube-system
spec:
addresses:
- 147.75.XX.XX/32 # Replace with an available IP
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
metadata:
name: default-advertisement
namespace: kube-system
Apply the configuration:
kubectl apply -f metallb-config.yaml
- Verify MetalLB is Running:
kubectl get pods -n kube-system | grep metallb
- Test Load Balancer Functionality: Create a sample LoadBalancer Service:
apiVersion: v1
kind: Service
metadata:
name: test-loadbalancer
spec:
selector:
app: my-app
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
Apply the service and check its external IP:
kubectl apply -f test-loadbalancer.yaml
kubectl get svc test-loadbalancer
Step 5: Configure Persistent Storage with CSI Driver
To use persistent volumes, install the Equinix Metal CSI Driver.
- Install the Helm Chart:
helm install equinix-metal-csi equinix-metal/equinix-metal-csi \
--namespace kube-system \
--set providerConfigSecretName=cloud-provider-config
- Verify Installation:
kubectl get pods -n kube-system | grep equinix-metal-csi
- Create a Storage Class:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: equinix-metal-sc
provisioner: csi.equinix.com
parameters:
csi.storage.k8s.io/fstype: ext4
Apply the storage class:
kubectl apply -f storage-class.yaml
- Create a Persistent Volume Claim:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: equinix-metal-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: equinix-metal-sc
Apply the PVC and verify the volume is provisioned:
kubectl apply -f persistent-volume-claim.yaml
kubectl get pvc equinix-metal-pvc
Conclusion
The Equinix Metal Cloud Provider enables Kubernetes clusters to integrate with Equinix Metal’s infrastructure, providing load balancers through MetalLB and persistent storage via CSI drivers. By following this guide, your RKE2 cluster is now fully equipped with cloud provider functionality on Equinix Metal.
For further customization and advanced configurations, refer to the Equinix Metal Kubernetes Documentation.
For more RKE2 training, check out other training posts.