Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: license controller. #4111

Merged
merged 59 commits into from Oct 20, 2023
Merged

feat: license controller. #4111

merged 59 commits into from Oct 20, 2023

Conversation

lingdie
Copy link
Collaborator

@lingdie lingdie commented Oct 18, 2023

🤖 Generated by Copilot at 214e7fe

Summary

📄🛠️🚀

This pull request adds the initial scaffolding and implementation of a license controller, which is a Kubernetes controller that manages License custom resources. The pull request uses kubebuilder, controller-gen, and kustomize tools to generate the project structure, code, and configuration files. The pull request also adds a Dockerfile, a Makefile, and a launcher program to build and run the controller image. The pull request defines the License type and its spec and status fields, and implements the main logic for the controller manager. The pull request also adds some .gitignore and .dockerignore files to ignore irrelevant files. The pull request is a work in progress and needs more documentation and testing.

license controller
scaffolded with kubebuilder
autumn of code starts

Walkthrough

  • Add a license controller project with scaffolding and basic files (link-link)
  • Create a .dockerignore and .gitignore file to exclude irrelevant files from the image and the repository (link, link)
  • Define a Dockerfile to build the image for the license controller, using a launcher as the entry point (link)
  • Define a Makefile to automate the common tasks for building, testing, generating, and deploying the license controller (link)
  • Create a PROJECT file to track the information used to scaffold the project and allow the plugins to work properly (link)
  • Create a README.md file to provide a brief overview of the project and its purpose, as well as some instructions on how to get started, contribute, and license the project (link)
  • Define the License type and its spec and status fields, as well as the LicenseList type, with some validation and defaulting annotations, and some constants for the license type and status phase (link)
  • Register the license API group and version with the scheme, and provide a SchemeBuilder and AddToScheme function for adding the types in this group-version to the given scheme (link)
  • Implement the DeepCopy, DeepCopyInto, and DeepCopyObject methods for the License and LicenseList types, which are required for the types to implement the runtime.Object interface and to be used by the controller (link)
  • Define the CustomResourceDefinition for the License type, specifying the group, version, kind, scope, schema, subresources, and validation of the License type (link)
  • List the resources and patches for the CRDs, including some commented out patches for enabling webhook and cert-manager for the CRD, and a configurations section that teaches kustomize how to substitute name and namespace references in the CRD (link)
  • Define the nameReference, namespace, and varReference for the CRD, telling kustomize how to update the service name and namespace in the webhook clientConfig, and how to add the cert-manager annotation to the CRD metadata (link)
  • Add a directive for cert-manager to inject CA into the CRD, specifying the cert-manager.io/inject-ca-from annotation with the certificate namespace and name as the value (link)
  • Enable a conversion webhook for the CRD, specifying the conversion strategy, webhook clientConfig, and conversionReviewVersions for the CRD (link)
  • List the resources and patches for the default configuration of the license controller, including the crd, rbac, manager, and optionally webhook, certmanager, and prometheus subdirectories as resources, and some patches for adding auth proxy, webhook, and cert-manager to the manager deployment, and setting the namespace and namePrefix for all resources, and some replacements for adding cert-manager annotations to the webhook service and configurations (link)
  • Inject a sidecar container that is a HTTP proxy for the controller manager, performing RBAC authorization against the Kubernetes API using SubjectAccessReviews, and protecting the /metrics endpoint by putting it behind auth (link)
  • Add a placeholder for adding additional arguments or environment variables to the manager container (link)
  • Define the main program for the license controller, setting up the logger, manager, database, and controller, and adding health and readiness checks, and parsing some flags for metrics, probes, and leader election, and using the current kubeconfig context to connect to the cluster (link)
  • Define a simple launcher program that runs the preset and manager binaries in parallel using exec.Command and sync.WaitGroup, and use it as the entry point for the Docker image (link)
  • Define a stub for the preset program that will be run by the launcher, and is intended to perform some initialization or configuration tasks before the manager starts, such as creating or updating CRDs, RBAC, or webhooks (link)

@pull-request-size
Copy link

Whoa! Easy there, Partner!

This PR is too big. Please break it up into smaller PRs.

@sealos-ci-robot
Copy link
Member

sealos-ci-robot commented Oct 18, 2023

🤖 Generated by lychee action

Summary

Status Count
🔍 Total 956
✅ Successful 373
⏳ Timeouts 0
🔀 Redirected 0
👻 Excluded 580
❓ Unknown 0
🚫 Errors 2

Errors per input

Errors in deploy/registry/README.md

Full action output

Full Github Actions output

@sweep-ai
Copy link

sweep-ai bot commented Oct 18, 2023

Apply Sweep Rules to your PR?

  • Apply: Leftover TODOs in the code should be handled.
  • Apply: All new business logic should have corresponding unit tests in the tests/ directory.
  • Apply: Any clearly inefficient or repeated code should be optimized or refactored.

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!.

@lingdie lingdie added this to the v5.0 milestone Oct 20, 2023
Signed-off-by: yy <lingdie.yy@outlook.com>
@bxy4543 bxy4543 merged commit 7aaad32 into labring:main Oct 20, 2023
56 of 57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants