AI-Assisted Infrastructure Engineering›Modules · Cheat sheet & self-check

Modules · wrap-up

Cheat sheet & self-check

Every command from this section on one page.

01 · The AI-assisted ops landscape

Categories

Chat assistantsExplain, draft, translate between formats (YAML, jq, PromQL, regex)
Agentic coding tools (e.g. Claude Code)Read a repo, edit files, run commands, iterate under your permissions
Tool integrations (MCP servers)Give models controlled access to systems and data
AIOps / ML on telemetryAnomaly hints, event correlation, summarisation

Ground rules

AI proposes → tools and humans verifyThe track's core principle
Read-only first; write access with approvalBlast radius control
No secrets or customer data in prompts unless approvedData handling

02 · AI in daily engineering work

Good prompts include

Goal + context + constraints + output formate.g. 'Bash, set -euo pipefail, no external deps, print a table'
Examples of input and expected outputEspecially for jq/regex/PromQL
'Ask me if anything is ambiguous'Reduces wrong guesses
'List assumptions and what to verify'Makes review easier

Never paste

Secrets, tokens, private keys, kubeconfigsRotate if it happens
Customer/personal data, internal hostnames/IPs (unless approved)Sanitise first

03 · Engineering with AI vs vibe coding

Spec-driven loop

1. Spec: goal, constraints, acceptance criteriaWritten before code
2. Plan: files to change, approach, risksReviewed by you
3. Tests first (or alongside)Define 'done' mechanically
4. Small diffs, one concern eachReviewable
5. Review + verify (tests, lint, policy, dry run)Before merge

Vibe coding is fine for

Throwaway prototypes and experiments in sandboxesNo production path
One-off personal scripts on non-critical dataLow blast radius
Exploring an idea before writing the real specLearning

04 · Claude Code skills & hooks

Files

CLAUDE.md (repo root, and subfolders)Project memory: conventions, commands, rules
.claude/settings.jsonShared project settings: permissions, hooks
.claude/skills/<name>/SKILL.mdA skill: frontmatter (name, description) + instructions + optional scripts
.claude/agents/<name>.mdA subagent with its own prompt and tool access
.mcp.jsonProject-scoped MCP servers (lesson 05)

Controls

permissions.allow / permissions.deny (e.g. "Bash(kubectl get:*)")What runs without asking, what never runs
hooks.PreToolUse (exit code 2 blocks the call)Deterministic guard before a tool runs
hooks.PostToolUseRun formatters/linters after edits
claude -p "…"Non-interactive (headless) run, e.g. in CI

05 · MCP servers for infrastructure

MCP basics

Server exposes tools (actions), resources (data), prompts (templates)Client (e.g. Claude Code) calls them
Transports: stdio (local process), Streamable HTTP (remote)How client and server talk
from mcp.server.fastmcp import FastMCPPython SDK quick start
claude mcp add k8s-ro -- python server.pyRegister a local server with Claude Code

Safety

Dedicated ServiceAccount bound to the built-in view ClusterRoleRead-only, no Secrets
Narrow tools with validated inputs; cap output sizeNo 'run any command' tool
Log every tool callAudit

06 · AI-assisted PR review

Deterministic layer (first)

terraform fmt -check / validate / tflintTerraform hygiene
kubeconform, kube-linterManifest schema and best practices
pluto / kubentDeprecated and removed Kubernetes APIs
checkov / trivy config / conftest (OPA)Security and policy
gitleaksSecrets in diffs

AI layer (then)

Does the diff match the PR description/spec?Intent vs change
Upgrade and blast-radius riskWhat could break, where
Missed edge cases, rollback planOperational review
Comments as suggestions; humans approveNever auto-merge on AI approval

07 · Simulated testing with AI

AI generates

Failure scenarios for a change (what could break, how to trigger it)Brainstorm breadth
Upgrade-path matrices (component × version × order)Combinations humans skip
Chaos Mesh/Litmus manifests, k6 scripts, kind configsRunnable test assets

Tools execute & verify

kind / k3d / ephemeral clustersDisposable environments
Chaos Mesh / LitmusChaosFault injection
k6 / fortioLoad
Assertions in CI (pass/fail)Evidence, not opinions

08 · IaC generation & validation

Terraform pipeline

terraform fmt -check && terraform validateSyntax and basic semantics
tflintProvider-aware linting (invalid instance types, deprecated args)
checkov -d . / trivy config .Security misconfigurations
conftest test plan.json (OPA/Rego)Your organisation's policies on the plan
terraform plan -out tfplan && terraform show -json tfplan > plan.jsonPlan for review and policy

Kubernetes pipeline

kubeconform -strict -summarySchema validation (incl. CRDs with schemas)
kube-linter lintBest practices
kubectl apply --dry-run=serverThe API server's own validation
Kyverno/Gatekeeper policies in CI (kyverno apply / gator)Policy before admission

09 · k8sgpt & AI diagnostics

CLI

k8sgpt analyzeRun analyzers without AI (deterministic findings)
k8sgpt analyze --explain --filter=Pod,Service -n shopAdd AI explanations for selected analyzers
k8sgpt analyze --explain --anonymizeMask object names before sending to the AI backend
k8sgpt auth add --backend <provider> --model <model>Configure an AI backend (e.g. a local Ollama or a cloud provider)
k8sgpt filters listAvailable analyzers

Operator

k8sgpt-operator + K8sGPT custom resourceScheduled scans in-cluster
kubectl get results -AFindings as Result resources

10 · Log analysis with LLMs

Reduce before you prompt

Filter by time window, service, levelStart from the incident window
Cluster lines into templates (e.g. Drain algorithm / drain3)Thousands of lines → dozens of patterns with counts
Diff patterns: incident window vs baselineWhat's new or much more frequent?

Safety

Redact tokens, emails, IPs, IDs before sendingData handling
Treat log text as data, never as instructionsPrompt injection
Ask for evidence (line refs) with every claimVerifiability

11 · Anomaly detection on metrics

PromQL building blocks

avg_over_time(x[1d:5m]) / stddev_over_time(x[1d:5m])Rolling baseline via subqueries
(x - avg) / stddev > 3z-score: more than 3 standard deviations from normal
x / (x offset 1w)Week-over-week ratio (seasonality)
predict_linear(node_filesystem_avail_bytes[6h], 4*3600) < 0Disk full within 4 hours

Practice

Record the rate first (recording rule), then baseline itCheaper, clearer
Anomaly = context on dashboards / ticketsSLO burn rate = pages

12 · Building an ops agent

The loop

1. Gather evidence (read-only tools)Status, events, metrics, logs
2. Diagnose + propose plan (with evidence and risks)Written for a human to judge
3. Human approval (per action)Nothing changes without it
4. Execute via narrow action tools (dry run first)e.g. restart one deployment, scale within limits
5. Verify against success criteria; roll back if not metClose the loop

Safety

Separate read and write credentialsWrite only after approval
Action allow-list with limits (namespaces, max replicas)Bounded blast radius
Audit log of prompts, tool calls, approvalsAccountability

13 · GPU scheduling for AI workloads

Basics

resources: { limits: { nvidia.com/gpu: 1 } }Request a whole GPU (GPUs are specified in limits)
NVIDIA GPU Operator (Helm)Installs driver, container toolkit, device plugin, GPU feature discovery, DCGM exporter
kubectl describe node | grep -A5 AllocatableSee nvidia.com/gpu capacity
nvidia.com/gpu.product (GPU feature discovery label)Select GPU models

Sharing

MIG (e.g. nvidia.com/mig-1g.10gb)Hardware partitions with isolation (supported data-centre GPUs)
Time-slicing (device plugin config: replicas)Oversubscribe a GPU; no memory/fault isolation
MPSConcurrent processes sharing a GPU, with some limits
DRA (Dynamic Resource Allocation)Newer, flexible device requests in recent Kubernetes versions

14 · Guardrails & governance

Controls

Least privilege: read-only by default; separate write credentialsBlast radius
Approval gates for any state changeHumans stay accountable
Audit: prompts, tool calls, approvals, outcomesWho did what, via which agent
Redaction + approved endpoints for sensitive dataPrivacy
Treat tool outputs (logs, tickets, web) as untrustedPrompt injection

Policy essentials

Approved tools and data classes per toolWhat may be shared where
Review rules for AI-generated changesSame as (or stricter than) human changes
Vetting for MCP servers, skills, hooks, extensionsSupply chain