In today’s fast-paced world, optimizing costs is crucial for businesses. When it comes to cloud infrastructure, managing expenses can be challenging, especially in Kubernetes environments. However, with the introduction of Knightly, a powerful tool I created, my company has achieved significant cost savings without compromising development efficiency. In this blog post, I will walk you through the features and benefits of Knightly and how it helped my company save over $20,000 every month.

Knightly Overview

Knightly is a specialized tool designed to scale down Kubernetes deployments in development environments, resulting in substantial cloud cost reductions. By leveraging Knightly, my company was able to reduce costs by 90% during weekends and approximately 80% during workday nights. This translates to massive savings and demonstrates the efficiency of this innovative solution.

The Three Knightly Services

  • Knightly Commander: This component listens to Slack slash commands and serves as the interface for interacting with Knightly. It provides a simple and intuitive way to control the scaling behavior of Kubernetes deployments.

  • Knightly Zero-Scaler: Operating as a Kubernetes cron job, the Zero-Scaler is responsible for scaling down all deployments and applying the necessary annotations for optimal cost management. It identifies namespaces marked for scaling and adjusts KEDA ScaledObjects accordingly.

  • Knightly Annotator: Another Kubernetes cron job, the Annotator performs essential annotation management tasks. It tracks the number of days to keep each namespace active and applies appropriate annotations.

By automating these processes, Knightly ensures efficient resource utilization and cost reduction.

Knightly Commander

Knightly Commander accepts the /knightly slash command, providing users with various actions to control namespaces and deployments. Let’s explore the available commands:

  1. Start Namespace: /knightly start namespace <NAME>
    • This command applies the Knightly label and annotation to the specified namespace, enabling it for scaling.
    • Additionally, it removes the paused-replicas annotation set for KEDA, ensuring the namespace’s deployments are actively running.
    • Finally, it scales all deployments in the namespace to 1, guaranteeing sufficient resources for development activities.

  2. Stop Namespace: /knightly stop namespace <NAME>
    • Executing this command applies the Knightly label and annotation to the specified namespace, marking it for scaling down.
    • It then applies the paused-replicas annotation, as described in KEDA’s scaling deployments documentation, effectively pausing autoscaling.
    • Lastly, it scales all deployments in the namespace down to 0, conserving resources and reducing costs.

  3. Keep Namespace: /knightly keep namespace <NAME> <NUM OF DAYS>
    • The “Keep Namespace” command allows users to specify a desired number of days to keep a namespace active, preventing it from being scaled down by Knightly.
    • By setting the keepmeup annotation with the desired number of days and changing the knightly.example.com/enabled label to false, the namespace remains operational for the specified duration.

Knightly Zero-Scaler

The Zero-Scaler executes as a Kubernetes cron job every night. Its primary objective is to identify namespaces enabled for scaling and perform the necessary actions to reduce costs effectively.

  1. Identifying Targeted Namespaces: The Zero-Scaler looks for namespaces labeled with knightly.example.com/enabled: true.

  2. Pausing KEDA ScaledObjects: It adds the pause-replicas annotation to KEDA ScaledObjects, to pause autoscaling for the identified workloads.

  3. Scaling Down Deployments: Finally, the Zero-Scaler scales down all deployments within the targeted namespaces to 0, ensuring minimal resource usage during non-working hours.

Knightly Annotator

The Knightly Annotator complements the Zero-Scaler by managing annotations for namespaces, ensuring efficient resource utilization and cost reduction. This Kubernetes cron job executes every morning and performs the following tasks:

  1. Identifying Targeted Namespaces: The Annotator excludes system namespaces labeled with knightly.example.com/enabled: excluded.

  2. Tracking Days to Keep: It checks the keepmeup annotation for each namespace and adjusts the value based on the number of remaining days. For example, if the annotation value is 4, it decrements it to 3.

  3. Enabling Knightly: Once the annotation reaches 1, the Annotator sets the knightly.example.com/enabled label to true, marking the namespace for scaling down during the following night.

  4. Adding Missing Annotations: If the label or annotation is not set for a namespace, the Annotator adds them to enable Knightly’s cost-saving mechanisms.

Real Cost Savings Achieved with Knightly

Implementing Knightly in our development environments has yielded remarkable cost savings for my company. Over weekends (Friday to Sunday), Knightly reduced Kubernetes costs from $1,000 to $90 per day. Additionally, by configuring Knightly to operate during workday nights (from 9 PM to 9 AM), we saved an additional estimated $600 per day. Moreover, Knightly has proven to be a valuable tool for efficiently managing Kubernetes deployments in development environments and reducing the number of inactive environments. These substantial savings add up to impressive monthly reductions in the company’s cloud expenses.

With its comprehensive set of features and seamless integration with Slack, Knightly empowers businesses to achieve significant cost savings without compromising productivity. By automating scaling operations and optimizing resource usage, Knightly exemplifies the power of innovative solutions in reducing cloud costs.

Implementing Knightly has transformed our development practices, resulted in substantial monthly savings for my employer, and helped streamline our environment utilization, making it an invaluable addition to our cost optimization strategy. By leveraging Knightly, you too can revolutionize your Kubernetes cost management, drive significant savings, and improve environment efficiency for your organization.

Start using Knightly today and embark on a journey towards cost-effective and efficient development practices.

Feel free to give Knightly project a star, watch, and fork on Github. Don’t forget to follow me as well for more open-source projects!