tutorial

How to Monitor kubectl-neat with Vigilmon

kubectl-neat is a kubectl plugin that strips non-informative clutter from Kubernetes manifests — removing system-managed fields like `managedFields`, `creati...

kubectl-neat is a kubectl plugin that strips non-informative clutter from Kubernetes manifests — removing system-managed fields like managedFields, creationTimestamp, status, and default values that Kubernetes adds automatically when resources are applied. The result is clean, human-readable YAML that engineers can use in code reviews, audit reports, and GitOps pipelines without drowning in irrelevant noise. In many organizations, kubectl-neat is used as part of automated manifest export pipelines and compliance reporting workflows.

When kubectl-neat's underlying dependencies fail — the Kubernetes API server, the kubectl binary, or the RBAC permissions the plugin needs to read resources — those pipelines silently produce incomplete or empty output without raising an error visible to any monitoring system. In this tutorial you'll set up uptime monitoring for the Kubernetes API access layer kubectl-neat depends on using Vigilmon — free tier, no credit card required.


Why kubectl-neat's dependencies need external monitoring

kubectl-neat is a thin transformation layer over kubectl get. Its failure modes all belong to the infrastructure it wraps:

  • Kubernetes API server unavailability — kubectl-neat cannot retrieve manifests when the API server is down; automated pipelines that call it return empty manifests or non-zero exit codes that are silently swallowed in CI
  • RBAC permission drift — when the get permission is removed from a resource type in a namespace, kubectl-neat returns an access denied error that manifest export jobs may not surface clearly
  • kubectl version skew — kubectl-neat is sensitive to kubectl binary version; a kubectl upgrade that introduces an incompatible API response format causes quiet manifest truncation
  • Admission webhook timeouts — webhook timeouts during manifest retrieval cause kubectl commands to hang, blocking export pipelines indefinitely
  • Kubeconfig credential expiry — short-lived OIDC tokens or rotated certificates cause all kubectl-neat calls to fail after the token expires, breaking scheduled manifest archival jobs

External monitoring from Vigilmon watches the Kubernetes API health endpoints kubectl-neat depends on and alerts you before manifest export pipelines start failing.


What you'll need

  • A Kubernetes cluster with kubectl-neat installed (kubectl krew install neat)
  • An exposed Kubernetes API health endpoint or a custom connectivity probe (see Step 1)
  • A free Vigilmon account

Step 1: Deploy a kubectl-neat connectivity probe

kubectl-neat itself does not expose HTTP endpoints. Create a Deployment that periodically tests the kubectl API access layer kubectl-neat relies on and exposes the result via a health server:

# kubectl-neat-health.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: kubectl-neat-health
  namespace: observability
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: kubectl-neat-health-reader
rules:
  - apiGroups: [""]
    resources: ["pods", "services", "configmaps", "namespaces"]
    verbs: ["get", "list"]
  - apiGroups: ["apps"]
    resources: ["deployments", "daemonsets", "statefulsets"]
    verbs: ["get", "list"]
  - apiGroups: ["networking.k8s.io"]
    resources: ["ingresses"]
    verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kubectl-neat-health-binding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: kubectl-neat-health-reader
subjects:
  - kind: ServiceAccount
    name: kubectl-neat-health
    namespace: observability
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kubectl-neat-health
  namespace: observability
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kubectl-neat-health
  template:
    metadata:
      labels:
        app: kubectl-neat-health
    spec:
      serviceAccountName: kubectl-neat-health
      containers:
        - name: checker
          image: bitnami/kubectl:latest
          command:
            - /bin/sh
            - -c
            - |
              while true; do
                # Simulate kubectl-neat's core operation: get a manifest
                MANIFEST=$(kubectl get deployment kubectl-neat-health \
                  -n observability -o yaml 2>&1)
                EXIT=$?
                if [ $EXIT -eq 0 ] && echo "$MANIFEST" | grep -q "apiVersion"; then
                  # Check that we can retrieve from multiple resource types
                  SVC_COUNT=$(kubectl get services --all-namespaces -o name 2>/dev/null | wc -l)
                  echo "healthy manifest_retrieval=ok service_count=$SVC_COUNT" > /tmp/status
                else
                  echo "unhealthy exit_code=$EXIT error=$(echo "$MANIFEST" | head -1)" > /tmp/status
                fi
                sleep 30
              done
        - name: health-server
          image: busybox:latest
          command:
            - /bin/sh
            - -c
            - |
              while true; do
                STATUS=$(cat /tmp/status 2>/dev/null || echo "starting")
                if echo "$STATUS" | grep -q "^healthy"; then
                  printf "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: ${#STATUS}\r\n\r\n$STATUS" | nc -l -p 8080 -q 1
                else
                  printf "HTTP/1.1 503 Service Unavailable\r\nContent-Type: text/plain\r\nContent-Length: ${#STATUS}\r\n\r\n$STATUS" | nc -l -p 8080 -q 1
                fi
              done
          ports:
            - containerPort: 8080
              name: health
          volumeMounts:
            - name: status
              mountPath: /tmp
      volumes:
        - name: status
          emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: kubectl-neat-health
  namespace: observability
spec:
  type: NodePort
  selector:
    app: kubectl-neat-health
  ports:
    - name: health
      port: 8080
      targetPort: 8080
      nodePort: 30083
kubectl apply -f kubectl-neat-health.yaml

# Verify the health endpoint
NODE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
curl http://$NODE_IP:30083/
# healthy manifest_retrieval=ok service_count=28

Step 2: Validate kubectl-neat manifest output quality

Before monitoring, verify that kubectl-neat is correctly stripping system-managed fields from your manifests. This establishes a baseline you can compare against if you suspect version skew or parser issues later:

#!/bin/bash
# validate-kubectl-neat.sh

# Install kubectl-neat if not already present
kubectl krew install neat 2>/dev/null || true

# Test on a real deployment
DEPLOY=$(kubectl get deployments --all-namespaces -o jsonpath='{.items[0].metadata.name}')
DEPLOY_NS=$(kubectl get deployments --all-namespaces -o jsonpath='{.items[0].metadata.namespace}')

echo "=== Raw kubectl output (noisy fields) ==="
kubectl get deployment "$DEPLOY" -n "$DEPLOY_NS" -o yaml | grep -E "managedFields|creationTimestamp|resourceVersion|uid:" | head -5

echo ""
echo "=== kubectl-neat output (cleaned) ==="
kubectl neat get deployment "$DEPLOY" -n "$DEPLOY_NS" | grep -E "managedFields|creationTimestamp|resourceVersion|uid:" | head -5

echo ""
echo "=== Field removal count ==="
RAW_LINES=$(kubectl get deployment "$DEPLOY" -n "$DEPLOY_NS" -o yaml | wc -l)
NEAT_LINES=$(kubectl neat get deployment "$DEPLOY" -n "$DEPLOY_NS" | wc -l)
echo "Raw: $RAW_LINES lines → Neat: $NEAT_LINES lines (removed $((RAW_LINES - NEAT_LINES)) lines)"
chmod +x validate-kubectl-neat.sh
./validate-kubectl-neat.sh

If managedFields or creationTimestamp still appear in the neat output, check that the kubectl-neat plugin is up to date with kubectl krew upgrade neat.


Step 3: Set up HTTP monitoring in Vigilmon

With the health endpoint running, add it to Vigilmon:

  1. Log in to vigilmon.online and go to Monitors → New Monitor
  2. Choose HTTP / HTTPS
  3. Add monitors for your endpoints:

| Monitor name | URL | Expected status | |---|---|---| | kubectl-neat API health | http://your-node-ip:30083/ | 200 | | Kubernetes API server livez | https://your-api-server:6443/livez | 200 |

  1. Set the check interval to 1 minute
  2. Under Expected response, set status code 200 and optionally match healthy in the response body
  3. For the Kubernetes API endpoint, configure the CA certificate under TLS settings if you use a private CA
  4. Save each monitor

Step 4: Monitor the kubectl-neat health TCP port

Add a TCP monitor to detect networking issues independently from the HTTP check:

  1. Go to Monitors → New Monitor
  2. Choose TCP Port
  3. Enter your node IP or Ingress hostname and port 30083
  4. Save the monitor

A TCP failure here while the pod is Running indicates a firewall rule or network policy change that blocks external access to the health endpoint.


Step 5: Configure alert channels

When kubectl-neat's API access fails, automated manifest export pipelines and compliance reports start producing empty or stale output. Alert immediately so the pipeline can be paused before it archives incorrect data.

Email alerts

  1. Go to Alert Channels → Add Channel → Email
  2. Enter your platform engineering team address
  3. Assign the channel to all kubectl-neat monitors

Webhook alerts for incident routing

  1. Go to Alert Channels → Add Channel → Webhook
  2. Enter your incident management webhook URL (PagerDuty, Opsgenie, Slack)
  3. The payload Vigilmon sends:
{
  "monitor_name": "kubectl-neat API health",
  "status": "down",
  "url": "http://your-node-ip:30083/",
  "started_at": "2024-01-15T10:23:00Z",
  "duration_seconds": 120
}

Wire this alert into a runbook that checks API server reachability and validates that the RBAC permissions for manifest retrieval are still in place.


Step 6: Correlate Vigilmon alerts with kubectl-neat diagnostics

When you receive a kubectl-neat health downtime alert, run these checks:

# 1. Verify the Kubernetes API is reachable
kubectl cluster-info
kubectl version --client

# 2. Test manifest retrieval directly (what kubectl-neat calls)
kubectl get deployment kubectl-neat-health -n observability -o yaml | head -10

# 3. Check RBAC permissions for the service account
kubectl auth can-i get deployments --as=system:serviceaccount:observability:kubectl-neat-health -A
kubectl auth can-i list services --as=system:serviceaccount:observability:kubectl-neat-health -A

# 4. Test kubectl-neat directly if installed on the workstation
kubectl neat get deployment kubectl-neat-health -n observability | head -20

# 5. Check the health checker pod logs for error details
kubectl logs -n observability -l app=kubectl-neat-health -c checker --tail=20

# 6. Check for admission webhook timeouts
kubectl get events --all-namespaces --field-selector reason=FailedCreate | grep -i webhook

# 7. Verify the checker deployment is running
kubectl get deployment kubectl-neat-health -n observability
kubectl describe deployment kubectl-neat-health -n observability | grep -A5 "Conditions:"

# 8. Check for kubectl version issues
kubectl version
kubectl krew list | grep neat
kubectl krew upgrade neat

If the health endpoint returns 503 and manifest retrieval works from your workstation, the most likely cause is an RBAC binding that was removed from the service account, or a network policy applied to the observability namespace that blocks outbound API server connections.


Step 7: Create a status page for manifest export infrastructure

If your team uses kubectl-neat in automated pipelines, make its health visible:

  1. Go to Status Pages → New Status Page
  2. Name it: "Manifest Export Infrastructure"
  3. Add your monitors: kubectl-neat API health, Kubernetes API server livez
  4. Share the URL with the platform engineering and security compliance teams

This lets teams confirm manifest export is working before triggering compliance report generation or GitOps sync operations.


Summary

| What you set up | What it catches | |---|---| | HTTP monitor on health endpoint | API server unreachability, RBAC permission drift, kubectl failures | | HTTP monitor on Kubernetes livez | API server degradation before manifest retrieval fails | | TCP monitor on health port | Networking issues blocking API connectivity | | Email + webhook alert channels | Immediate notification when manifest export infrastructure degrades | | Status page | Team visibility into Kubernetes manifest access health |

kubectl-neat is a productivity multiplier for engineers working with Kubernetes manifests every day. External monitoring is the only way to know when the API access layer it depends on has silently broken your automated export pipelines.

Get started at vigilmon.online — free tier, no credit card required.

Monitor your app with Vigilmon

Free plan — 5 monitors, no credit card required. Up and running in 60 seconds.

Start free →