To visualize multiple Kubernetes clusters and their pods using Hubble UI with Cilium Cluster Mesh, you can deploy Hubble's observability components in a centralized manner. This involves setting up Hubble Relay to aggregate observability data from both clusters and deploying Hubble UI to visualize the aggregated data.
Below is a comprehensive guide using YAML manifests to achieve this setup.
Prerequisites
- Two Kubernetes Clusters: Ensure you have two Kubernetes clusters set up and connected via Cilium Cluster Mesh.
- Cilium Installed: Both clusters should have Cilium installed with Cluster Mesh enabled.
- kubectl Configured: Ensure
kubectl is configured to interact with both clusters.
Overview of Steps
- Deploy a Central Hubble Relay: This will act as the central point to collect observability data from both clusters.
- Configure Each Cluster to Relay Data: Update Cilium configurations on both clusters to send observability data to the central Hubble Relay.
- Deploy Hubble UI: Deploy the Hubble UI to visualize the aggregated data from the Relay.
Step 1: Deploy a Central Hubble Relay
Choose one of your clusters to host the central Hubble Relay and Hubble UI. For this guide, we'll assume Cluster A is the central cluster.
1.1. Create a Namespace for Hubble Components
apiVersion: v1
kind: Namespace
metadata:
name: hubble
---
apiVersion: v1
kind: Namespace
metadata:
name: hubble-ui
Save the above as namespace.yaml and apply it:
kubectl apply -f namespace.yaml --context=cluster-a-context
1.2. Deploy Hubble Relay
Create a hubble-relay.yaml manifest:
apiVersion: v1
kind: ServiceAccount
metadata:
name: hubble-relay
namespace: hubble
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: hubble-relay
rules:
- apiGroups: [""]
resources:
- pods
- services
- endpoints
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: hubble-relay
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: hubble-relay
subjects:
- kind: ServiceAccount
name: hubble-relay
namespace: hubble
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hubble-relay
namespace: hubble
spec:
replicas: 1
selector:
matchLabels:
app: hubble-relay
template:
metadata:
labels:
app: hubble-relay
spec:
serviceAccountName: hubble-relay
containers:
- name: hubble-relay
image: cilium/hubble-relay:v1.13.3
args:
- "--kubeconfig=/var/run/secrets/kubernetes.io/serviceaccount/token"
- "--listen-addr=0.0.0.0:4244"
ports:
- containerPort: 4244
---
apiVersion: v1
kind: Service
metadata:
name: hubble-relay
namespace: hubble
spec:
type: ClusterIP
ports:
- port: 4244
targetPort: 4244
selector:
app: hubble-relay
Apply the manifest:
kubectl apply -f hubble-relay.yaml --context=cluster-a-context
1.3. Expose Hubble Relay (Optional)
If Hubble Relay needs to be accessed from Cluster B, expose it via a Service accessible to Cluster B. This could be via a LoadBalancer, NodePort, or using a VPN/tunnel between clusters.
Here’s an example using a LoadBalancer service:
apiVersion: v1
kind: Service
metadata:
name: hubble-relay-external
namespace: hubble
spec:
type: LoadBalancer
ports:
- port: 4244
targetPort: 4244
protocol: TCP
selector:
app: hubble-relay
Apply the manifest:
kubectl apply -f hubble-relay-external.yaml --context=cluster-a-context
Note: Ensure that the LoadBalancer IP is accessible from Cluster B. You might need to update firewall rules or DNS accordingly.
Step 2: Configure Each Cluster to Relay Data to Central Hubble Relay
For both Cluster A and Cluster B, configure Cilium to send observability data to the central Hubble Relay.
2.1. Obtain Hubble Relay Endpoint
After deploying hubble-relay-external, get its external IP:
kubectl get svc hubble-relay-external -n hubble --context=cluster-a-context
Assume the external IP is RELAY_IP.
2.2. Update Cilium ConfigMap
For each cluster (both Cluster A and Cluster B), update the Cilium ConfigMap to point to the central Hubble Relay.
Create a cilium-config.yaml file:
apiVersion: v1
kind: ConfigMap
metadata:
name: cilium-config
namespace: kube-system
data:
hubble-listen-address: ":4244"
hubble-enabled: "true"
hubble-ui-enabled: "true"
hubble-relay-address: "RELAY_IP:4244"
Replace RELAY_IP with the actual external IP of the Hubble Relay service.
Apply the ConfigMap to both clusters:
kubectl apply -f cilium-config.yaml --context=cluster-a-context
kubectl apply -f cilium-config.yaml --context=cluster-b-context
2.3. Restart Cilium Pods
After updating the ConfigMap, restart the Cilium pods to apply the changes:
kubectl rollout restart daemonset cilium -n kube-system --context=cluster-a-context
kubectl rollout restart daemonset cilium -n kube-system --context=cluster-b-context
kubectl rollout restart daemonset cilium -n kube-system --context=cluster-b-context
Wait for the Cilium pods to become ready.
Step 3: Deploy Hubble UI
Deploy Hubble UI in the central cluster (Cluster A) to visualize data from both clusters.
3.1. Create Hubble UI Deployment and Service
Create a hubble-ui.yaml manifest:
apiVersion: v1
kind: Namespace
metadata:
name: hubble-ui
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: hubble-ui
namespace: hubble-ui
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: hubble-ui
rules:
- apiGroups: [""]
resources: ["pods", "services", "endpoints"]
verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: hubble-ui
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: hubble-ui
subjects:
- kind: ServiceAccount
name: hubble-ui
namespace: hubble-ui
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hubble-ui
namespace: hubble-ui
spec:
replicas: 1
selector:
matchLabels:
app: hubble-ui
template:
metadata:
labels:
app: hubble-ui
spec:
serviceAccountName: hubble-ui
containers:
- name: hubble-ui
image: cilium/hubble-ui:v1.13.3
ports:
- containerPort: 80
env:
- name: HUBBLE_RELAY_ADDRESS
value: "hubble-relay.hubble.svc.cluster.local:4244"
---
apiVersion: v1
kind: Service
metadata:
name: hubble-ui
namespace: hubble-ui
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
protocol: TCP
selector:
app: hubble-ui
Explanation:
- ServiceAccount, ClusterRole, and ClusterRoleBinding: Set up RBAC for Hubble UI to access necessary resources.
- Deployment: Runs the Hubble UI container, pointing to the central Hubble Relay.
- Service: Exposes Hubble UI via a
LoadBalancer. Adjust if necessary (e.g., use NodePort or Ingress).
Apply the manifest:
kubectl apply -f hubble-ui.yaml --context=cluster-a-context
3.2. Access Hubble UI
After deploying, retrieve the external IP of the Hubble UI service:
kubectl get svc hubble-ui -n hubble-ui --context=cluster-a-context
Assume the external IP is HUBBLE_UI_IP.
Open your browser and navigate to http://HUBBLE_UI_IP to access Hubble UI. You should see observability data from both Cluster A and Cluster B.
Additional Configuration (Optional)
4.1. Secure Communication
For secure communication between Hubble Relay and clusters, consider setting up TLS. Modify the Hubble Relay and Hubble UI configurations to use TLS certificates.
4.2. Hubble Observability Enhancements
Enable additional Hubble observability features like metrics, flow logs, and UI enhancements by updating the Hubble components' configurations as needed.
Summary
By following the above steps, you:
- Deployed a central Hubble Relay on Cluster A to aggregate observability data.
- Configured both Cluster A and Cluster B to send their observability data to the central Relay.
- Deployed Hubble UI to visualize the aggregated data from both clusters.
All configurations were done using YAML manifests, ensuring a declarative and reproducible setup. This setup allows you to monitor and visualize pods across multiple Kubernetes clusters seamlessly.
References