Kubernetes Deployment Configuration#

DevOps-OS provides a Kubernetes configuration generator (k8s-config-generator.py) that creates YAML manifest files for deploying your applications to Kubernetes clusters.


Basic Usage#

python kubernetes/k8s-config-generator.py --name my-app --image ghcr.io/myorg/my-app:v1

Generated files are written to the ./k8s directory by default.


Options#

OptionDefaultDescription
--name NAMEappApplication name
--namespace NSdefaultKubernetes namespace
--image IMAGEdocker.io/yourorg/app:latestContainer image
--port PORT8080Port your application listens on
--replicas N1Number of pod replicas
--output DIR./k8sOutput directory for generated files
--containers NAMES(single)Comma-separated container names for multi-container pods
--ingressoffAdd an Ingress resource
--storageoffAdd a PersistentVolumeClaim
--kustomizeoffAdd Kustomize base + overlays structure
--environments ENVS(single)Comma-separated environments (e.g. dev,staging,prod)

Examples#

Single container application#

python kubernetes/k8s-config-generator.py \
  --name backend-api \
  --namespace backend \
  --image docker.io/myorg/api:v1.0 \
  --port 3000 \
  --replicas 3
# Output: k8s/deployment.yaml + k8s/service.yaml

With Ingress and persistent storage#

python kubernetes/k8s-config-generator.py \
  --name web-app \
  --ingress \
  --storage
# Output: k8s/deployment.yaml + k8s/service.yaml + k8s/ingress.yaml + k8s/pvc.yaml

Multi-environment with Kustomize#

python kubernetes/k8s-config-generator.py \
  --name my-app \
  --kustomize \
  --environments dev,staging,prod
# Output: k8s/base/ + k8s/overlays/dev/ + k8s/overlays/staging/ + k8s/overlays/prod/

Applying Configurations#

# Apply with kubectl
kubectl apply -f k8s/deployment.yaml
kubectl apply -f k8s/service.yaml

# Apply all files
kubectl apply -f k8s/

# Apply with Kustomize overlay
kubectl apply -k k8s/overlays/dev

# Deploy with ArgoCD (after generating ArgoCD configs)
python -m cli.devopsos scaffold argocd --name my-app \
       --repo https://github.com/myorg/my-app.git \
       --path k8s --namespace production
kubectl apply -f argocd/appproject.yaml
kubectl apply -f argocd/application.yaml

Integration with CI/CD Generators#

Use the Kubernetes generator alongside the CI/CD generators for a complete pipeline:

# Generate the K8s manifests
python kubernetes/k8s-config-generator.py --name my-api --replicas 3

# Generate a GitHub Actions workflow that deploys to K8s
python -m cli.devopsos scaffold gha \
  --name my-api \
  --kubernetes \
  --k8s-method kustomize

# Or generate an ArgoCD Application pointing to the k8s/ directory
python -m cli.devopsos scaffold argocd \
  --name my-api \
  --repo https://github.com/myorg/my-api.git \
  --path k8s \
  --auto-sync

GitOps Deployment#

For GitOps-based deployment, generate ArgoCD or Flux configs that watch the k8s/ directory in your repository:

# ArgoCD watches k8s/ directory
python -m cli.devopsos scaffold argocd \
  --name my-app \
  --path k8s \
  --repo https://github.com/myorg/my-app.git

# Flux CD watches k8s/ directory
python -m cli.devopsos scaffold argocd \
  --name my-app \
  --method flux \
  --path k8s \
  --repo https://github.com/myorg/my-app.git

Commit the generated k8s/ directory to your repo — ArgoCD/Flux will automatically apply changes on every push.