Skip to content

Refactor duplicated Kubernetes resources with reusable templates and tooling#33

Draft
Copilot wants to merge 7 commits intomainfrom
copilot/refactor-duplicated-code
Draft

Refactor duplicated Kubernetes resources with reusable templates and tooling#33
Copilot wants to merge 7 commits intomainfrom
copilot/refactor-duplicated-code

Conversation

Copy link

Copilot AI commented Oct 31, 2025

The repository contained significant duplication across VirtualService definitions (13 instances), NFS volume configurations (5 instances), and Kustomize patches (6+ service patches), making maintenance error-prone and onboarding difficult.

Changes

Reusable Templates (k8s-templates/)

  • VirtualService templates (base and with URI rewriting) using clear placeholder syntax (<app-name>, <gateway>)
  • NFS PersistentVolume/PersistentVolumeClaim template with configurable paths and storage classes
  • Common Kustomize patches for service ports, deployment resources, and container ports

Example usage:

# Copy template and customize placeholders
cp k8s-templates/virtualservice-base.yaml applicationset/myapp/vs.yaml
# Replace <app-name> with actual application name

Documentation

  • CONTRIBUTING.md - Complete workflow for adding applications with pattern examples
  • k8s-templates/README.md - Template usage guide with copy-paste examples
  • .github/workflows/README.md - Explains why individual workflows exist (isolated triggers, clear build status)
  • Updated main README.md with "Adding a New Application" section

Tooling

  • scripts/find-similar-files.sh - Identifies duplication candidates by grouping files with identical names, using null delimiters for safe filename handling

Bug Fix

  • applicationset/toolchain/kustomization.yaml - Added missing vs.yaml resource reference

Impact

Templates provide starting point for new applications while existing implementations remain unchanged. The detection script enables periodic audits for new duplication patterns.

Original prompt

Find and refactor duplicated code


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

Copilot AI and others added 6 commits October 31, 2025 12:02
Co-authored-by: guyzsarun <48861591+guyzsarun@users.noreply.github.com>
Co-authored-by: guyzsarun <48861591+guyzsarun@users.noreply.github.com>
Co-authored-by: guyzsarun <48861591+guyzsarun@users.noreply.github.com>
Co-authored-by: guyzsarun <48861591+guyzsarun@users.noreply.github.com>
…cript safety

Co-authored-by: guyzsarun <48861591+guyzsarun@users.noreply.github.com>
Co-authored-by: guyzsarun <48861591+guyzsarun@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor duplicated code for improved maintainability Refactor duplicated Kubernetes resources with reusable templates and tooling Oct 31, 2025
Copilot AI requested a review from guyzsarun October 31, 2025 12:16
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