Skip to content

VS Code for DevOps - Street Ops

Practical workflows that make VS Code a DevOps power tool.

Workflow 1: Kubernetes Debugging Setup

Split your VS Code window into three: - Left: YAML manifests you're editing - Bottom-left terminal: kubectl logs -f <pod> (live logs) - Bottom-right terminal: kubectl get pods -w (watch pod status)

Edit a ConfigMap, apply it from the terminal, watch the pod restart and check logs - all without alt-tabbing.

One-liner: Quick split: Ctrl+\ splits the editor; Ctrl+`` toggles the terminal.Ctrl+Shift+5` splits the terminal itself. Memorize these three — they replace alt-tabbing between windows.

Workflow 2: Terraform Plan Review

  1. Edit .tf files (auto-formatted on save)
  2. In terminal: terraform plan -out=plan.tfplan 2>&1 | tee /tmp/plan.txt
  3. Open /tmp/plan.txt in a new VS Code tab
  4. Use Ctrl+Shift+F to search the plan for destroy or force replacement
  5. Side-by-side: plan output on right, source on left

Gotcha: terraform plan output can contain secrets (database passwords, API keys) if they are in your state. Never pipe plan output to shared files or paste into chat. Use terraform plan -out=plan.tfplan and share the summary, not the raw output.

Workflow 3: Multi-Environment Config Diffing

Compare Helm values across environments: 1. Open values-dev.yaml 2. Ctrl+Shift+P → "File: Compare Active File With..." 3. Select values-prod.yaml 4. Side-by-side diff shows exactly what differs between environments

This catches the classic mistake of dev having features that prod doesn't.

Workflow 4: Remote Server Debugging

When something is broken on a server: 1. Remote-SSH into the box 2. Open /var/log/ in the explorer 3. Use VS Code's search (Ctrl+Shift+F) across all log files 4. Find the error, trace it back to the config 5. Edit the config file directly, restart the service from terminal

Faster than SSHing in a bare terminal for complex log analysis.

Default trap: Remote-SSH defaults to installing VS Code Server on the remote host, which downloads ~200MB. On airgapped or bandwidth-constrained servers, pre-download the server binary or use remote.SSH.localServerDownload: always to transfer it from your machine.

Gotcha: Remote-SSH sessions die silently when your laptop sleeps or the network drops. VS Code reconnects but the terminal state is lost. Use tmux or screen on the remote host so your long-running commands survive disconnections: ssh host -t 'tmux new -A -s main'.

Workflow 5: CI Workflow Development

Developing GitHub Actions workflows is painful without feedback. VS Code helps:

  1. YAML extension validates against the GitHub Actions schema
  2. Copilot suggests valid action steps and syntax
  3. Use Ctrl+Space for autocomplete on uses:, with:, etc.
  4. Terminal for act (local GitHub Actions runner) to test without pushing

Workflow 6: Docker Development Loop

  1. Edit Dockerfile (syntax highlighting catches mistakes)
  2. Run "Docker Build" task (Ctrl+Shift+P → task)
  3. Right-click the image in Docker extension → "Run"
  4. See container logs in the Docker extension panel
  5. Exec into the container from the extension for debugging
  6. Edit, rebuild, repeat

Custom Snippets for DevOps

Create snippets for boilerplate you write often. Ctrl+Shift+P → "Configure User Snippets":

// terraform.json
{
  "AWS Resource with Tags": {
    "prefix": "awsres",
    "body": [
      "resource \"aws_${1:resource_type}\" \"${2:name}\" {",
      "  ${3}",
      "",
      "  tags = merge(var.common_tags, {",
      "    Name = \"${4:resource-name}\"",
      "  })",
      "}"
    ]
  },
  "Variable with Description": {
    "prefix": "tfvar",
    "body": [
      "variable \"${1:name}\" {",
      "  description = \"${2:description}\"",
      "  type        = ${3:string}",
      "  default     = ${4:null}",
      "}"
    ]
  }
}
// yaml.json (Kubernetes)
{
  "K8s Deployment": {
    "prefix": "k8sdeploy",
    "body": [
      "apiVersion: apps/v1",
      "kind: Deployment",
      "metadata:",
      "  name: ${1:app-name}",
      "  labels:",
      "    app: ${1:app-name}",
      "spec:",
      "  replicas: ${2:2}",
      "  selector:",
      "    matchLabels:",
      "      app: ${1:app-name}",
      "  template:",
      "    metadata:",
      "      labels:",
      "        app: ${1:app-name}",
      "    spec:",
      "      containers:",
      "        - name: ${1:app-name}",
      "          image: ${3:image}:${4:tag}",
      "          ports:",
      "            - containerPort: ${5:8000}"
    ]
  }
}

Type awsres + Tab in a .tf file and get a full resource skeleton with tags.

Remember: Snippets live in ~/.config/Code/User/snippets/ on Linux or ~/Library/Application Support/Code/User/snippets/ on macOS. Back them up to your dotfiles repo — rebuilding custom snippets from memory wastes hours.

One-liner: Install your DevOps extension pack on a fresh machine: code --install-extension hashicorp.terraform --install-extension ms-kubernetes-tools.vscode-kubernetes-tools --install-extension ms-azuretools.vscode-docker --install-extension redhat.vscode-yaml — saves 15 minutes of clicking through the marketplace.

Custom Keybindings for DevOps

Add to keybindings.json:

[
  { "key": "ctrl+shift+t", "command": "workbench.action.tasks.runTask",
    "args": "Test" },
  { "key": "ctrl+shift+l", "command": "workbench.action.tasks.runTask",
    "args": "Lint" }
]

Under the hood: VS Code's YAML extension validates against JSON Schema. For Kubernetes manifests, it uses the schema from kubernetes-json-schema on GitHub. If you use CRDs, add your CRD schema to .vscode/settings.json under yaml.schemas to get autocompletion for custom resources like Istio VirtualService or ArgoCD Application.

Daily Workflow

  1. Open workspace → pull latest (GitLens shows what changed)
  2. Check PR reviews in GitHub Pull Requests extension
  3. Edit Terraform/Helm/Python with full language support
  4. Run tests with custom keybinding
  5. Use integrated terminal for kubectl, terraform, docker
  6. Commit with Source Control panel or terminal
  7. Push and create PR without leaving the editor

Debug clue: If VS Code is sluggish, open the Process Explorer (Ctrl+Shift+P -> "Developer: Open Process Explorer"). Extension host processes eating CPU usually point to a misbehaving extension — disable extensions one by one to find the culprit.