Skip to content
This repository was archived by the owner on Feb 25, 2026. It is now read-only.

Feat/add simpleapp crd - #68

Open
tsaishawn wants to merge 10 commits into
mainfrom
feat/add_simpleapp_crd
Open

Feat/add simpleapp crd#68
tsaishawn wants to merge 10 commits into
mainfrom
feat/add_simpleapp_crd

Conversation

@tsaishawn

Copy link
Copy Markdown

No description provided.

@tsaishawn
tsaishawn requested a review from iasthc as a code owner February 13, 2026 02:46
Copilot AI review requested due to automatic review settings February 13, 2026 02:46
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @tsaishawn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new SimpleApp Custom Resource Definition (CRD) and its corresponding controller. The primary goal is to simplify the deployment and management of basic applications on Kubernetes by abstracting away the complexities of individual Deployment, Service, and PersistentVolumeClaim resources. Users can now define their application's desired state using a single SimpleApp object, and the operator will ensure the necessary Kubernetes primitives are provisioned and maintained.

Highlights

  • New SimpleApp Custom Resource Definition (CRD): Introduced a new SimpleApp CRD under the apps.otterscale.io API group, allowing users to define and manage simple applications in a declarative manner. This CRD includes specifications for Kubernetes Deployments, Services, and PersistentVolumeClaims (PVCs).
  • SimpleApp Controller Implementation: Implemented a dedicated controller for the SimpleApp CRD. This controller is responsible for reconciling the desired state of a SimpleApp resource with the actual state of its underlying Kubernetes Deployment, Service, and PVC resources, ensuring they are created, updated, or deleted as specified.
  • Automated Resource Management: The SimpleApp controller now automatically manages the lifecycle of associated Deployments, Services, and PVCs. It handles creation, updates, and deletion, including proper finalizer management for cleanup and status updates to reflect the state of managed resources.
  • RBAC Roles for SimpleApp: Added specific ClusterRoles (admin, editor, viewer) for the SimpleApp CRD, providing fine-grained access control for managing SimpleApp resources within the cluster.
Changelog
  • Makefile
    • Updated the controller-gen command to include crd:generateEmbeddedObjectMeta=true for CRD generation.
  • PROJECT
    • Registered the new SimpleApp API group (apps.otterscale.io/v1alpha1) within the project configuration.
  • api/apps/v1alpha1/groupversion_info.go
    • Added a new Go file defining the apps.otterscale.io/v1alpha1 API group and its scheme builder.
  • api/apps/v1alpha1/simpleapp_types.go
    • Defined the SimpleApp CRD schema, including SimpleAppSpec (for Deployment, Service, and PVC configurations) and SimpleAppStatus (for tracking references to managed resources and conditions).
  • api/apps/v1alpha1/zz_generated.deepcopy.go
    • Generated deepcopy methods for the new SimpleApp API types to ensure proper Kubernetes object handling.
  • cmd/main.go
    • Imported the new SimpleApp API and controller packages.
    • Registered the SimpleApp API scheme with the manager.
    • Set up and started the SimpleAppReconciler within the main operator loop.
  • config/crd/kustomization.yaml
    • Added the bases/apps.otterscale.io_simpleapps.yaml entry to include the SimpleApp CRD in the Kustomize build.
  • config/rbac/apps_simpleapp_admin_role.yaml
    • Added a new ClusterRole granting full administrative permissions over SimpleApp resources.
  • config/rbac/apps_simpleapp_editor_role.yaml
    • Added a new ClusterRole granting create, update, delete, get, list, patch, update, and watch permissions for SimpleApp resources.
  • config/rbac/apps_simpleapp_viewer_role.yaml
    • Added a new ClusterRole granting read-only permissions (get, list, watch) for SimpleApp resources.
  • config/rbac/kustomization.yaml
    • Included the newly created SimpleApp RBAC roles (admin, editor, viewer) in the Kustomize configuration.
  • config/rbac/role.yaml
    • Expanded the manager's ClusterRole to include permissions for managing persistentvolumeclaims, services, deployments, and simpleapps resources, as well as their finalizers and status.
  • config/samples/apps_v1alpha1_simpleapp.yaml
    • Added a sample SimpleApp manifest demonstrating how to define a simple Nginx application with a Deployment, Service, and PVC.
  • config/samples/kustomization.yaml
    • Included the apps_v1alpha1_simpleapp sample in the Kustomize configuration for sample manifests.
  • go.mod
    • Added sigs.k8s.io/yaml as a direct dependency.
    • Removed sigs.k8s.io/yaml from the indirect dependencies section.
  • internal/controller/apps/simpleapp_controller.go
    • Implemented the SimpleAppReconciler with logic to create, update, and delete Kubernetes Deployments, Services, and PersistentVolumeClaims based on the SimpleApp's specification.
    • Added finalizer handling for proper resource cleanup during SimpleApp deletion.
    • Included status update logic to reflect the state and references of managed resources.
    • Implemented validation for DeploymentSpec to ensure selector and template labels match.
    • Defined SetupWithManager to integrate the controller with the operator runtime.
  • internal/controller/apps/simpleapp_controller_test.go
    • Added unit tests for the SimpleApp controller, covering reconciliation and resource lifecycle.
  • internal/controller/apps/suite_test.go
    • Added a test suite setup for the apps controller package, including environment bootstrapping and teardown.
Activity
  • The pull request introduces a new feature without prior activity or comments.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov

codecov Bot commented Feb 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.19048% with 45 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/controller/apps/simpleapp_controller.go 76.19% 33 Missing and 12 partials ⚠️

📢 Thoughts on this report? Let us know!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new SimpleApp CRD and its corresponding controller. While a good start, a significant security risk has been identified: the controller acts as a 'pass-through' for user-provided DeploymentSpec and ServiceSpec. This allows users with limited permissions to escalate privileges by creating resources with insecure configurations (e.g., privileged pods or traffic interception via externalIPs) using the operator's high-privilege ServiceAccount. It is recommended to implement strict validation of these specs or to only expose a safe subset of configuration options. Beyond this, critical issues include incorrect API type definitions, a bug in the service reconciliation logic that will lead to infinite reconcile loops, and an invalid sample manifest. Suggestions for improving testing, status reporting, and fixing a minor controller initialization bug are also provided.

Comment thread internal/controller/apps/simpleapp_controller.go Outdated
Comment thread api/apps/v1alpha1/simpleapp_types.go Outdated
Comment thread api/apps/v1alpha1/simpleapp_types.go Outdated
Comment thread api/apps/v1alpha1/simpleapp_types.go Outdated
Comment thread api/apps/v1alpha1/simpleapp_types.go Outdated
Comment thread config/samples/apps_v1alpha1_simpleapp.yaml Outdated
Comment thread internal/controller/apps/simpleapp_controller.go
Comment thread cmd/main.go
Comment thread internal/controller/apps/simpleapp_controller.go
Comment thread internal/controller/apps/simpleapp_controller_test.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new SimpleApp API (CRD) and controller to the otterscale-operator, wiring it into manager startup, RBAC, CRD kustomization, samples, and envtest-based controller tests.

Changes:

  • Introduce apps.otterscale.io/v1alpha1 SimpleApp API types + generated deepcopy, and register it in cmd/main.go.
  • Add SimpleAppReconciler that manages a Deployment/Service/PVC from fields in the SimpleApp spec.
  • Extend manifests (CRD kustomization, RBAC, sample manifests) and add controller-runtime envtest scaffolding/tests.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
internal/controller/apps/suite_test.go Adds envtest/Ginkgo test suite scaffolding for apps controllers.
internal/controller/apps/simpleapp_controller_test.go Adds initial reconciliation test scaffold for SimpleApp.
internal/controller/apps/simpleapp_controller.go Implements SimpleApp controller logic (finalizer, reconcile PVC/Deployment/Service, status refs).
go.mod Promotes sigs.k8s.io/yaml to a direct dependency.
config/samples/kustomization.yaml Adds SimpleApp sample to kustomize samples set.
config/samples/apps_v1alpha1_simpleapp.yaml Adds an example SimpleApp custom resource manifest.
config/rbac/role.yaml Updates manager ClusterRole rules for Deployments/Services/PVCs + SimpleApp resources.
config/rbac/kustomization.yaml Includes generated SimpleApp admin/editor/viewer roles in RBAC kustomization.
config/rbac/apps_simpleapp_viewer_role.yaml Adds read-only ClusterRole for SimpleApp.
config/rbac/apps_simpleapp_editor_role.yaml Adds edit ClusterRole for SimpleApp.
config/rbac/apps_simpleapp_admin_role.yaml Adds admin ClusterRole for SimpleApp.
config/crd/kustomization.yaml Adds SimpleApp CRD to CRD kustomization resources.
cmd/main.go Registers the apps API scheme and sets up the SimpleApp controller with the manager.
api/apps/v1alpha1/zz_generated.deepcopy.go Adds generated deepcopy implementations for new API types.
api/apps/v1alpha1/simpleapp_types.go Defines SimpleApp spec/status and kubebuilder markers/printcolumns.
api/apps/v1alpha1/groupversion_info.go Adds apps API group registration (GroupVersion/SchemeBuilder).
PROJECT Declares the new SimpleApp API/controller to kubebuilder project metadata.
Makefile Adjusts CRD generation flags for controller-gen.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/controller/apps/simpleapp_controller_test.go Outdated
Comment thread internal/controller/apps/simpleapp_controller.go Outdated
Comment thread config/samples/apps_v1alpha1_simpleapp.yaml Outdated
Comment thread config/samples/kustomization.yaml Outdated
Comment thread config/samples/apps_v1alpha1_simpleapp.yaml Outdated
Comment thread internal/controller/apps/simpleapp_controller.go
Comment thread internal/controller/apps/simpleapp_controller.go
Comment thread cmd/main.go Outdated
Comment thread api/apps/v1alpha1/simpleapp_types.go Outdated
Comment thread internal/controller/apps/suite_test.go
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants