Skip to content

Conversation

@devin-ai-integration
Copy link

KubernetesJS CLI Implementation

This PR implements kubectl-like commands for the KubernetesJS CLI, providing a user-friendly interface for interacting with Kubernetes clusters.

Features Implemented

  • Support for --config flag to parse YAML files and execute appropriate actions
  • Interactive resource selection using inquirerer prompts when no specific resource is specified
  • Local .kubeconfig JSON file for storing namespace context
  • Implementation of the following kubectl-like commands:
    • get - List resources (pods, services, deployments, etc.)
    • describe - Show detailed information about specific resources
    • logs - Fetch logs from pods
    • apply - Apply YAML configurations to the cluster
    • delete - Delete resources with interactive selection
    • exec - Open interactive shells in pods
    • port-forward - Forward local ports to services
    • cluster-info - Display cluster endpoints
    • config - Manage namespace context

Usage Examples

# List all pods in the current namespace
k8s get pods

# Get detailed information about a specific pod
k8s describe pod my-pod

# View logs from a pod
k8s logs my-pod

# Apply a YAML configuration
k8s apply -f deployment.yaml

# Delete resources with interactive selection
k8s delete pods

# Execute a command in a pod
k8s exec my-pod -- /bin/sh

# Forward a local port to a service
k8s port-forward svc/my-service 8080:80

# Display cluster information
k8s cluster-info

# Set the current namespace
k8s config set-context --current --namespace=my-namespace

Implementation Details

  • Each command is implemented in its own file following the established pattern
  • Commands use the KubernetesClient from the kubernetesjs package
  • Interactive prompts use the inquirerer library
  • Output is formatted with chalk for better readability
  • The --config flag allows bypassing prompts by directly applying YAML configurations

Link to Devin run

https://app.devin.ai/sessions/2e1d95e2899342eab9374c45b35243d8

Requested by

Dan Lynch ([email protected])

@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation closed this May 29, 2025
@pyramation pyramation deleted the devin/1748500887-kubectl-commands branch June 8, 2025 23:56
Anmol1696 added a commit that referenced this pull request Nov 7, 2025
feature: setup client with manifest tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants