Treemap

Kubernetes Cluster Resource Allocation

Dark-themed treemap showing Kubernetes cluster resource allocation across namespaces and workloads.

Output
Kubernetes Cluster Resource Allocation
Python
import matplotlib.pyplot as plt
import squarify
import numpy as np

# K8s resources (CPU millicores)
labels = ['prod-api', 'prod-web', 'prod-workers', 'staging',
          'monitoring', 'logging', 'ingress', 'databases', 
          'ml-inference', 'system']
sizes = [8000, 4500, 12000, 3000, 2500, 2000, 1500, 6000, 5500, 1800]
total = sum(sizes)

# CLAUDE.md colors
colors = ['#27D3F5', '#F5276C', '#6CF527', '#F5B027', '#5314E6',
          '#276CF5', '#F54927', '#27F5B0', '#C82909', '#F527B0']

fig, ax = plt.subplots(figsize=(12, 8), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

pct = [s/total*100 for s in sizes]
squarify.plot(sizes=sizes, 
              label=[f'{l}\n{s/1000:.1f} cores ({p:.1f}%)' for l, s, p in zip(labels, sizes, pct)],
              color=colors, alpha=0.85, ax=ax,
              text_kwargs={'fontsize': 9, 'color': 'white', 'fontweight': 'bold'})

ax.axis('off')
ax.set_title(f'K8s Cluster Resources - {total/1000:.0f} CPU Cores', 
             fontsize=18, color='#f8fafc', fontweight='bold', pad=20)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Part-to-Whole

Did this help you?

Support PyLucid to keep it free & growing

Support