Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 23, 2025

This PR implements automatic fallback to kubectl's built-in kustomize functionality when a standalone kustomize binary is not available, addressing the need for better accessibility when only kubectl is installed.

Changes Made

Core Functionality

  • Automatic Fallback Detection: Added logic to detect when kustomize binary is missing and automatically fall back to kubectl kustomize for build operations
  • Direct YAML Generation: Replaced kustomize edit commands with direct YAML file generation using Go structs, eliminating the need for edit operations that aren't supported by kubectl kustomize
  • Smart Command Selection: Implemented kustomizeBuildCommand() method that chooses the appropriate command based on binary availability

Technical Improvements

  • Modern Kustomization Format: Updated to use resources field instead of deprecated bases field, eliminating deprecation warnings
  • Version-Agnostic Flag Handling: Enhanced version detection to gracefully handle missing binaries and use modern flag formats when version cannot be determined
  • Maintained Compatibility: All existing functionality with standalone kustomize binary remains unchanged

Example Usage

Before this change, users needed both helm and kustomize binaries:

# This would fail if kustomize wasn't installed
chartify myapp ./kustomization-dir

After this change, kubectl's built-in kustomize automatically serves as fallback:

# This now works with just kubectl installed
chartify myapp ./kustomization-dir  # Uses kubectl kustomize if kustomize binary missing

The implementation maintains full feature compatibility including:

  • Image tag replacement
  • Name prefix/suffix configuration
  • Namespace settings
  • Alpha plugins support
  • Load restrictor configuration

Testing

Added comprehensive tests to verify:

  • Fallback functionality works when kustomize binary is missing
  • Normal kustomize behavior is preserved when binary is available
  • Generated kustomization.yaml files use modern format
  • All existing functionality continues to work correctly

The solution provides seamless user experience - users don't need to install separate kustomize binary if they already have kubectl with built-in kustomize support.

Fixes #63.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Contributor Author

Copilot AI commented Aug 23, 2025

@yxxhero 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

@Copilot Copilot AI changed the title [WIP] Allow using kubectl built-in kustomize if separate kustomize binary is missing Allow using kubectl built-in kustomize if separate kustomize binary is missing Aug 23, 2025
Copilot finished work on behalf of yxxhero August 23, 2025 23:47
@Copilot Copilot AI requested a review from yxxhero August 23, 2025 23:47
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.

Allow using kubectl built-in kustomize if separate kustomize binary is missing
2 participants