Cluster kind + monitoring
Docker Desktop
Sezione intitolata “Docker Desktop”Settings → Resources: almeno 4 CPU e 6 GB di RAM. L’LLM gira fuori dalla VM Docker, quindi non va conteggiato qui.
docker desktop statusdocker info --format '{{.NCPU}} CPU, {{.MemTotal}} bytes'Cluster
Sezione intitolata “Cluster”mkdir -p ~/Downloads/K8S-AI/lab && cd ~/Downloads/K8S-AI/labcat > kind-ai-mon.yaml <<'EOF2'kind: ClusterapiVersion: kind.x-k8s.io/v1alpha4name: ai-monnodes: - role: control-plane extraPortMappings: - containerPort: 30090 hostPort: 9090 - containerPort: 30093 hostPort: 9093EOF2kind create cluster --config kind-ai-mon.yamlkubectl cluster-info --context kind-ai-monkubectl get nodes -o widekube-prometheus-stack
Sezione intitolata “kube-prometheus-stack”helm repo add prometheus-community https://prometheus-community.github.io/helm-chartshelm repo updateValues per un lab leggero, con Prometheus e Alertmanager esposti su NodePort (mappati su localhost:9090 e localhost:9093 dal config kind):
cat > kps-values.yaml <<'EOF2'grafana: enabled: falsekubeEtcd: enabled: falsekubeControllerManager: enabled: falsekubeScheduler: enabled: falsekubeProxy: enabled: falseprometheus: service: type: NodePort nodePort: 30090 prometheusSpec: retention: 12h scrapeInterval: 30s resources: requests: { cpu: 200m, memory: 512Mi } limits: { memory: 1Gi } serviceMonitorSelectorNilUsesHelmValues: false podMonitorSelectorNilUsesHelmValues: false ruleSelectorNilUsesHelmValues: falsealertmanager: service: type: NodePort nodePort: 30093 alertmanagerSpec: resources: requests: { cpu: 20m, memory: 64Mi }EOF2helm upgrade --install kps prometheus-community/kube-prometheus-stack -n monitoring --create-namespace -f kps-values.yamlkubectl -n monitoring rollout status sts/prometheus-kps-kube-prometheus-stack-prometheus --timeout=5mkubectl -n monitoring get podsVerifica dal Mac:
curl -s localhost:9090/-/readycurl -s localhost:9093/-/readycurl -s 'localhost:9090/api/v1/query?query=up' | jq '.data.result | length'Se le NodePort non rispondono, usa i port-forward (terminali separati):
kubectl -n monitoring port-forward svc/kps-kube-prometheus-stack-prometheus 9090kubectl -n monitoring port-forward svc/kps-kube-prometheus-stack-alertmanager 9093Grafana (opzionale)
Sezione intitolata “Grafana (opzionale)”helm upgrade kps prometheus-community/kube-prometheus-stack -n monitoring -f kps-values.yaml --set grafana.enabled=true --set grafana.adminPassword=adminkubectl -n monitoring port-forward svc/kps-grafana 3000:80Connettività pod → Ollama sull’host
Sezione intitolata “Connettività pod → Ollama sull’host”kubectl run curl --rm -it --restart=Never --image=curlimages/curl -- curl -s http://host.docker.internal:11434/api/versionSe fallisce, vedi Esporre Ollama ai pod di kind.
Stop / start / delete
Sezione intitolata “Stop / start / delete”docker stop ai-mon-control-planedocker start ai-mon-control-planekind delete cluster --name ai-mon