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¶
- Edit
.tffiles (auto-formatted on save) - In terminal:
terraform plan -out=plan.tfplan 2>&1 | tee /tmp/plan.txt - Open
/tmp/plan.txtin a new VS Code tab - Use
Ctrl+Shift+Fto search the plan fordestroyorforce replacement - Side-by-side: plan output on right, source on left
Gotcha:
terraform planoutput can contain secrets (database passwords, API keys) if they are in your state. Never pipe plan output to shared files or paste into chat. Useterraform plan -out=plan.tfplanand 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: alwaysto 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
tmuxorscreenon 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:
- YAML extension validates against the GitHub Actions schema
- Copilot suggests valid action steps and syntax
- Use
Ctrl+Spacefor autocomplete onuses:,with:, etc. - Terminal for
act(local GitHub Actions runner) to test without pushing
Workflow 6: Docker Development Loop¶
- Edit Dockerfile (syntax highlighting catches mistakes)
- Run "Docker Build" task (
Ctrl+Shift+P→ task) - Right-click the image in Docker extension → "Run"
- See container logs in the Docker extension panel
- Exec into the container from the extension for debugging
- 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-schemaon GitHub. If you use CRDs, add your CRD schema to.vscode/settings.jsonunderyaml.schemasto get autocompletion for custom resources like Istio VirtualService or ArgoCD Application.
Daily Workflow¶
- Open workspace → pull latest (GitLens shows what changed)
- Check PR reviews in GitHub Pull Requests extension
- Edit Terraform/Helm/Python with full language support
- Run tests with custom keybinding
- Use integrated terminal for kubectl, terraform, docker
- Commit with Source Control panel or terminal
- 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.