Skip to content

Commit

Permalink
Update Documentation (#34)
Browse files Browse the repository at this point in the history
* Go Docs [Worker] update documentation

- [+] chore(docs.go): update package description to include pod labeling functionality
- [+] chore(docs.go): update function descriptions to include pod labeling logic
- [+] chore(docs.go): update usage instructions to include pod labeling
- [+] chore(docs.go): update TODO section to include pod labeling enhancements

* Feat [README] [Docs] [Todo List]

- [+] feat(README.md): add optimized pod labeling logic enhancement
  • Loading branch information
H0llyW00dzZ authored Dec 24, 2023
1 parent 39b312e commit 448daf4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
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

0 comments on commit 448daf4

Please sign in to comment.