Auto Import Configurations

kftray can automatically import port forward configurations from Kubernetes Service annotations, streamlining setup and maintaining consistency.

for a detailed guide, please refer to Auto Import

Annotation Format

Add the following annotation to your Kubernetes Services:

apiVersion: v1
kind: Service
metadata:
  name: my-service
  annotations:
    kftray.app/enabled: true
  kftray.app/configs: "test-9999-http"
spec:
  ports:
    - port: 80

Configuration Fields

The annotation JSON supports these fields:

  • enabled: Enable auto import
  • configs: Configuration alias, local port, remote port

Using Auto Import

In KFtray

  1. Click menu icon
  2. Select "Auto Import"
  3. Choose kubeconfig file
  4. Select context
  5. Click "Import"

In KFtui

  1. Press Tab for menu
  2. Select "Auto Import"
  3. Select configurations
  4. Press f to start

Example Configurations

Web Application

apiVersion: v1
kind: Service
metadata:
  name: frontend
  annotations:
    kftray.app/enabled: true
    kftray.app/configs: "frontend-9999-80"
spec:
  ports:
    - port: 80

Database

apiVersion: v1
kind: Service
metadata:
  name: database
  annotations:
    kftray.app/enabled: true
    kftray.app/configs: "database-9999-5432"
spec:
  ports:
    - port: 5432

Best Practices

  1. Naming Conventions
    • Use consistent aliases
    • Include service purpose
    • Follow team standards
  2. Port Management
    • Avoid port conflicts
    • Document port assignments
    • Use standard ports
  3. Organization
    • Group related services
    • Maintain documentation
    • Regular configuration review

Terraform Integration

Example Terraform configuration:

resource "kubernetes_service" "example" {
  metadata {
    name = "example-service"
    annotations = {
      "kftray.app/enabled" = true
      "kftray.app/configs" = "test-9999-http"
    }
  }
  spec {
    port {
      port = 80
    }
  }
}

Troubleshooting

Common issues and solutions:

  1. Import Fails
    • Verify annotation format
    • Check JSON syntax
    • Confirm service exists
  2. Port Conflicts
    • Review local ports
    • Check running services
    • Update port numbers
  3. Missing Services
    • Verify namespace access
    • Check context selection
    • Review RBAC permissions