How to use lightwing to save cost for non production KOPS-Kubernetes cluster
This guide assumes the following KOPS cluster:
- 1 x t2.large master node
- 6 x t2.large worker nodes
- 1 x load balancer for master
- 1 x kubernetes service exposed via load balancer at
qa.example.com
Estimated cost: $600
Estimated cost with LW: $180
. $420
saved
Configuring master node
- On lightwing console, click on
Autostopping
- Click on
Add a gateway
- Choose
Loadbalanced
- Enter 60mins for idle time
- Choose
ELB
from load balancer type - Enter autoscaling group name of the master node
- Enter load balancer URL without scheme (http/https)
- Enter desired capacity as 1
- Save the gateway
We are configuring 1hr idle time for the master node because it takes more time for the master node to start up comparing to the worker nodes.
Configuring worker nodes
- On lightwing console, click on
Autostopping
- Click on
Add a gateway
- Choose
Loadbalanced
- Choose
ELB
from load balancer type - Enter autoscaling group name of the worker nodes
- Enter load balancer URL without scheme (http/https)
- Enter desired capacity as 6
- Add a dependency to master node
- Save the gateway
Finishing up
You can add a CNAME entry to the lightwing generated URL so that there is no change in the URL that users are accessing. Adding CNAME entry is different for each service provider. Refer to the documentation provided by the service provider.
Read more about setting up custom domain.
Summary
With the above setup, when someone visits qa.example.com
, lightwing intercepts the traffic and start the worker nodes and master if they are not running. If they are running, lightwing will just proxy the traffic. When lightwing detects idle time, it will shut down the servers. In this case, worker nodes will be down after 15mins of idle time. Master node will stay active for 1hr. If no traffic is received for an hour, master node will also go down.
Let us look at the cost saving:
Typically, a QA server which is used only during working days will be idle for about 70% of the time. Lightwing will provide granular data about idle time and savings in the analytics page.
In this example, considering 70% idle time, our initial cost of $600
will now become $180
! This is higher than what reserved instances gives without worrying about paying upfront or committing to a period.