enhancement: Implement advanced auto-detection for Kubernetes environments #34

Open
opened 2026-02-22 13:11:40 +00:00 by cpfarhood · 0 comments
cpfarhood commented 2026-02-22 13:11:40 +00:00 (Migrated from github.com)

Summary

Implement intelligent auto-detection to reduce required configuration by automatically discovering Kubernetes cluster capabilities and setting appropriate defaults.

Proposed Features

1. Storage Class Auto-Detection

# Auto-detect ReadWriteMany storage classes
autoDetect:
  storageClass: true      # Find RWX storage class automatically
  
# Implementation: Query available storage classes, prefer:
# 1. Classes with RWX access mode
# 2. Common names: nfs-client, longhorn, ceph-filesystem
# 3. Default storage class as fallback

2. Ingress Controller Detection

autoDetect:
  ingressClass: true      # Detect available ingress controllers
  
# Auto-configure ingress if available ingress controllers found:
# - nginx, traefik, istio, etc.

3. Load Balancer Detection

autoDetect:
  loadBalancer: true      # Auto-configure if available
  
# Detect cloud provider load balancers:
# - AWS ALB/NLB
# - GCP Load Balancer  
# - Azure Load Balancer
# - MetalLB

4. Environment-Aware Defaults

# Auto-detect environment type from cluster context
defaults:
  development:
    resources: small
    sidecars: minimal
    features: [ssh, debug]
  
  production:  
    resources: large
    sidecars: essential
    features: [monitoring, security]
    
  testing:
    resources: medium
    sidecars: testing
    features: [playwright, lightweight]

Implementation Approach

Template Functions

{{- define "antigravity.detectStorageClass" -}}
{{/* Query and select best RWX storage class */}}
{{- end }}

{{- define "antigravity.detectEnvironment" -}}  
{{/* Detect dev/staging/prod from namespace, labels, etc. */}}
{{- end }}

{{- define "antigravity.smartResourceSizing" -}}
{{/* Auto-size based on node capacity and enabled features */}}
{{- end }}

Pre-install Hook

Optional init container or hook to probe cluster capabilities:

apiVersion: batch/v1
kind: Job
metadata:
  annotations:
    "helm.sh/hook": pre-install
spec:
  template:
    spec:
      containers:
      - name: cluster-probe
        image: bitnami/kubectl
        command: ["/bin/sh"]
        args: 
        - -c
        - |
          # Probe cluster capabilities
          kubectl get storageclass -o json > /tmp/storage-classes.json
          kubectl get ingressclass -o json > /tmp/ingress-classes.json

Benefits

  • Reduced Configuration: 80% of deployments work with minimal config
  • Environment Awareness: Automatically adapt to dev/staging/prod
  • Resource Optimization: Right-sized by default
  • Error Prevention: Avoid common misconfigurations

Implementation Plan

  • Design auto-detection template helpers
  • Implement storage class detection
  • Add environment type detection
  • Create resource sizing algorithms
  • Add ingress/load balancer detection
  • Test across different Kubernetes distributions
  • Update documentation with auto-detection features

Testing

Test on various environments:

  • Local (kind, k3s, minikube)
  • Cloud providers (EKS, GKE, AKS)
  • On-premise (RKE, kubeadm)
  • Different storage classes (Longhorn, NFS, Ceph)
## Summary Implement intelligent auto-detection to reduce required configuration by automatically discovering Kubernetes cluster capabilities and setting appropriate defaults. ## Proposed Features ### 1. Storage Class Auto-Detection ```yaml # Auto-detect ReadWriteMany storage classes autoDetect: storageClass: true # Find RWX storage class automatically # Implementation: Query available storage classes, prefer: # 1. Classes with RWX access mode # 2. Common names: nfs-client, longhorn, ceph-filesystem # 3. Default storage class as fallback ``` ### 2. Ingress Controller Detection ```yaml autoDetect: ingressClass: true # Detect available ingress controllers # Auto-configure ingress if available ingress controllers found: # - nginx, traefik, istio, etc. ``` ### 3. Load Balancer Detection ```yaml autoDetect: loadBalancer: true # Auto-configure if available # Detect cloud provider load balancers: # - AWS ALB/NLB # - GCP Load Balancer # - Azure Load Balancer # - MetalLB ``` ### 4. Environment-Aware Defaults ```yaml # Auto-detect environment type from cluster context defaults: development: resources: small sidecars: minimal features: [ssh, debug] production: resources: large sidecars: essential features: [monitoring, security] testing: resources: medium sidecars: testing features: [playwright, lightweight] ``` ## Implementation Approach ### Template Functions ```yaml {{- define "antigravity.detectStorageClass" -}} {{/* Query and select best RWX storage class */}} {{- end }} {{- define "antigravity.detectEnvironment" -}} {{/* Detect dev/staging/prod from namespace, labels, etc. */}} {{- end }} {{- define "antigravity.smartResourceSizing" -}} {{/* Auto-size based on node capacity and enabled features */}} {{- end }} ``` ### Pre-install Hook Optional init container or hook to probe cluster capabilities: ```yaml apiVersion: batch/v1 kind: Job metadata: annotations: "helm.sh/hook": pre-install spec: template: spec: containers: - name: cluster-probe image: bitnami/kubectl command: ["/bin/sh"] args: - -c - | # Probe cluster capabilities kubectl get storageclass -o json > /tmp/storage-classes.json kubectl get ingressclass -o json > /tmp/ingress-classes.json ``` ## Benefits - **Reduced Configuration**: 80% of deployments work with minimal config - **Environment Awareness**: Automatically adapt to dev/staging/prod - **Resource Optimization**: Right-sized by default - **Error Prevention**: Avoid common misconfigurations ## Implementation Plan - [ ] Design auto-detection template helpers - [ ] Implement storage class detection - [ ] Add environment type detection - [ ] Create resource sizing algorithms - [ ] Add ingress/load balancer detection - [ ] Test across different Kubernetes distributions - [ ] Update documentation with auto-detection features ## Testing Test on various environments: - [ ] Local (kind, k3s, minikube) - [ ] Cloud providers (EKS, GKE, AKS) - [ ] On-premise (RKE, kubeadm) - [ ] Different storage classes (Longhorn, NFS, Ceph)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: farhoodlabs/devcontainer#34