You can deploy Debug pod from the debug pod guide via GitOps.

Manual Steps

1. Create App Folder Structure

Create the app folder in your local repo, run at top of repo:

mkdir -p apps/debugpod/base

2. Place debugpod.yaml

Place debugpod.yaml from the debug pod guide in apps/debugpod/base

3. Create Production Kustomization

Create clusters/production/kustomization.yaml:

# File: clusters/production/kustomization.yaml 
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - apps
  - flux-system

4. Create Apps Kustomization

Create clusters/production/apps/kustomization.yaml:

# File: clusters/production/apps/kustomization.yaml
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ../../../apps/debugpod/base

5. Create Base Kustomization

Create apps/debugpod/base/kustomization.yaml:

# File: apps/debugpod/base/kustomization.yaml
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - debugpod.yaml

Repository Structure

After all steps are completed, your repository folder structure would look like:

├── apps
│   └── debugpod
│       └── base
│           ├── debugpod.yaml
│           └── kustomization.yaml
└── clusters
    └── production
        ├── apps
        │   └── kustomization.yaml
        ├── flux-system
        │   ├── gotk-components.yaml
        │   ├── gotk-sync.yaml
        │   ├── kustomization.yaml
        │   └── sources  
        └── kustomization.yaml 

6. Deploy and Reconcile

Deploy and reconcile (manual reconciliation is optional, but speeds things up):

git add -A
git commit -m "Add debugpod test application"
git push
flux reconcile kustomization flux-system --with-source

7. Check Pod Deployment

Check if pod was deployed:

kubectl -n kube-system get pods

8. Test the Pod

Test that it works:

kubectl exec -it debugpod -n kube-system -- /bin/sh
# install telnet and other tools from inside pod
apk update
apk add busybox-extras
apk add curl
curl icanhazip.com
exit

Scripted Steps with Safety Checks

#!/usr/bin/env bash
#
# Purpose: Automate creation of a "debugpod" application folder and references
#          for Flux-managed GitOps deployment in a production cluster.
#
# Exit immediately on errors or unset variables, and pipe failures
set -euo pipefail

##################################################
# 0. Optional: Sanity checks before we begin
##################################################
# Verify we are in a Git repo
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
  echo "[ERROR] Not inside a valid Git repository. Please run in your repo root."
  exit 1
fi

# Optionally, check if 'debugpod/base' already exists to avoid overwriting
if [ -d "apps/debugpod/base" ]; then
  echo "[WARNING] 'apps/debugpod/base' already exists. Proceeding may overwrite files."
fi

##################################################
# 1. Create the debugpod base folder and files
##################################################
echo "[INFO] Creating debugpod folder structure..."
mkdir -p apps/debugpod/base

echo "[INFO] Generating top-level production kustomization.yaml to reference 'apps' and 'flux-system'..."
cat <<EOL > clusters/production/kustomization.yaml
# File: clusters/production/kustomization.yaml
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- apps
- flux-system
EOL

# Create the debugpod Pod YAML
echo "[INFO] Creating debugpod.yaml manifest..."
cat <<EOL > apps/debugpod/base/debugpod.yaml
# File: apps/debugpod/base/debugpod.yaml
---
apiVersion: v1
kind: Pod
metadata:
  name: debugpod
  namespace: kube-system
spec:
  hostPID: true
  containers:
  - name: debugcontainer
    image: alpine:latest
    stdin: true
    tty: true
    securityContext:
      privileged: true
    volumeMounts:
    - name: dev-mount
      mountPath: /dev
  volumes:
  - name: dev-mount
    hostPath:
      path: /dev
EOL

# Create a kustomization.yaml for the debugpod base
echo "[INFO] Creating kustomization.yaml in apps/debugpod/base..."
cat <<EOL > apps/debugpod/base/kustomization.yaml
# File: apps/debugpod/base/kustomization.yaml
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- debugpod.yaml
EOL

##################################################
# 2. Reference the debugpod application in production
##################################################
echo "[INFO] Adding the debugpod reference to clusters/production/apps/kustomization.yaml..."
if [ -f clusters/production/apps/kustomization.yaml ]; then
    # Only append if not already present (optional check)
    if ! grep -q "apps/debugpod/base" clusters/production/apps/kustomization.yaml; then
      echo "- ../../../apps/debugpod/base" >> clusters/production/apps/kustomization.yaml
    else
      echo "[INFO] 'apps/debugpod/base' already referenced in clusters/production/apps/kustomization.yaml"
    fi
else
    # Create a new kustomization.yaml file in apps
    mkdir -p clusters/production/apps
    cat <<EOL > clusters/production/apps/kustomization.yaml
# File: clusters/production/apps/kustomization.yaml
---    
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../../../apps/debugpod/base
EOL
fi

##################################################
# 4. Commit and push the changes
##################################################
echo "[INFO] Committing and pushing changes to Git..."
git add -A
git commit -m "Add debugpod test application"
git push

echo "[INFO] Done! While Flux will eventually pick up changes and"
echo "[INFO] deploy the debugpod Pod in 'kube-system' namespace,"
echo "[INFO] we'll push Flux to pick up changes immediately."
flux reconcile kustomization flux-system --with-source