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

Update Documentation #34

Merged
merged 2 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ In real-world applications, the complexity and cost can escalate quickly. `K8sBl
## Task Execution Model
- [x] **Dynamic Task Execution Model**: Implemented a dynamic task execution model that allows for registering and retrieving `TaskRunner` implementations based on task types, enhancing extensibility.

## Pod Labeling Logic Enhancement
- [x] **Optimized Pod Labeling**:
- Implemented an optimized pod labeling process that checks existing labels and updates them only if necessary, reducing the number of API calls and improving overall performance.
- Integrated retry logic specific to pod labeling to handle intermittent API errors efficiently.

## Package Extension
- [ ] **Support for Additional Kubernetes Resources**:
- Develop the capability to manage and interact with a broader range of Kubernetes resources, including services, deployments, and stateful sets.
Expand Down
18 changes: 14 additions & 4 deletions worker/docs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package worker provides a set of tools designed to facilitate the interaction with
// Kubernetes resources from within a cluster. It offers a convenient abstraction for
// managing Kubernetes operations, focusing on pod health checks and structured logging.
// managing Kubernetes operations, focusing on pod health checks, pod labeling, and structured logging.
//
// The package is intended for applications running as pods within Kubernetes clusters
// and leverages in-cluster configuration to establish a clientset for API interactions.
Expand All @@ -16,25 +16,32 @@
// implementations based on task types. This extensibility makes it possible to easily
// add new task handling logic without modifying the core package code.
//
// - Pod Labeling Logic has been optimized to check existing labels and only update
// when necessary, reducing API calls and improving performance. It also includes
// retry logic to handle intermittent API errors.
//
// # Functions
//
// - NewKubernetesClient: Creates a new Kubernetes clientset configured for in-cluster
// communication with the Kubernetes API server.
//
// - CrewWorker: Orchestrates a worker process to perform tasks such as health checks
// on pods within a specified namespace. It includes retry logic to handle transient
// and labeling of pods within a specified namespace. It includes retry logic to handle transient
// errors and respects cancellation and timeout contexts. Structured logging is used
// to provide detailed contextual information.
//
// - CrewGetPods: Retrieves all pods within a given namespace, logging the attempt
// and outcome of the operation.
//
// - CrewProcessPods: Iterates over a collection of pods, assessing their health and
// reporting the status to a results channel. It also handles context cancellation.
// - CrewProcessPods: Iterates over a collection of pods, assessing their health,
// updating labels, and reporting the status to a results channel. It also handles context cancellation.
//
// - CrewCheckingisPodHealthy: Evaluates the health of a pod based on its phase and
// container readiness statuses.
//
// - CrewLabelPods: Updates the labels on a pod, if necessary, based on the provided
// labeling rules and specifications.
//
// Usage:
//
// Initialize the Kubernetes client using NewKubernetesClient, then leverage the client
Expand Down Expand Up @@ -71,6 +78,9 @@
// - The dynamic task execution model supports adding new tasks and task runners
// without changing existing code, facilitating scalability and extensibility.
//
// - Pod Labeling Logic has been enhanced to perform more efficiently by minimizing
// unnecessary API calls, and it now includes robust error handling and retry mechanisms.
//
// # TODO
//
// - Extend the functionality of the CrewWorker function to support a wider range
Expand Down