Open-source News

Monitor Kubernetes cloud costs with open source tools

opensource.com - Mon, 03/13/2023 - 15:00
Monitor Kubernetes cloud costs with open source tools mattray Mon, 03/13/2023 - 03:00

Kubernetes is a powerful platform for managing dynamic containerized applications in the cloud, but it may be difficult to understand where costs are incurred. Managing the cost efficiency of Kubernetes resources can be a challenge. That's where OpenCost comes in. OpenCost is a cloud cost monitoring tool that integrates seamlessly with Kubernetes, allowing you to track your cloud spend in real-time so you can optimize your resources accordingly.

[ Also read How to measure the cost of running applications ]

OpenCost is an open source CNCF Sandbox project and specification for the real-time monitoring of cloud costs associated with Kubernetes deployments. The specification models current and historical Kubernetes cloud spend and resource allocation by service, deployment, namespace, labels, and much more. This data is essential for understanding and optimizing Kubernetes for both cost and performance from the applications down through the infrastructure.

Requirements and installation

Getting started with OpenCost is a relatively straightforward process. OpenCost uses Prometheus for both monitoring and metric storage. You can install it from the Prometheus Community Kubernetes Helm Chart.

Install Prometheus

Begin by installing Prometheus using the following command:

$ helm install my-prometheus --repo https://prometheus-community.github.io/helm-charts prometheus \ --namespace prometheus --create-namespace \ --set pushgateway.enabled=false --set alertmanager.enabled=false -f \ https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/prometheus/extraScrapeConfigs.yamlInstall OpenCost

Next, install OpenCost using the kubectl command:

$ kubectl apply --namespace opencost -f \ https://raw.githubusercontent.com/opencost/opencost/develop/kubernetes/opencost.yaml

This command deploys OpenCost to your cluster and starts collecting data. That is all that most installations require. You can use your own Prometheus installation or customize the deployment with the OpenCost Helm Chart.

Testing and access

OpenCost automatically detects whether it runs on AWS, Azure, or GCP, and you can configure it to provide pricing for on-premises Kubernetes deployments. Begin by forwarding ports for API and UI access:

$ kubectl port-forward --namespace opencost service/opencost 9003 9090

Within about five minutes, you can verify the UI and server are running, and you may access the OpenCost UI at http://localhost:9090.

Monitor costs

You are ready to start monitoring your cloud costs with OpenCost deployed to your Kubernetes cluster. The OpenCost dashboard provides real-time visibility into your cloud spend, allowing you to identify cost anomalies and optimize your cloud resources. You can view your cloud spend by nodes, namespaces, pods, tags, and more.

Image by:

(Matthew Ray, CC BY-SA 4.0)

The kubectl cost plugin provides easy CLI queries to Kubernetes cost allocation metrics. It allows developers, operators, and others to determine the cost and efficiency for any Kubernetes workload quickly.

$ kubectl cost --service-port 9003 \ --service-name opencost --kubecost-namespace opencost \ --allocation-path /allocation/compute pod \ --window 5m --show-efficiency=true +-------+---------+-------------+----------+---------------+ |CLUSTER|NAMESPACE|POD |MONTH RATE|COST EFFICIENCY| +-------+---------+-------------+----------+---------------+ |cl-one |kube-syst|coredns-db...| 1.486732 | 0.033660 | | | |coredns-...dm| 1.486732 | 0.032272 | | | |kube-prox...7| 1.359577 | 0.002200 | | | |kube-prox...x| 1.359577 | 0.002470 | | |opencost |opencost...5t| 0.459713 | 0.187180 | | |kube-syst|aws-node-cbwl| 0.342340 | 0.134960 | | | |aws-node-gbfh| 0.342340 | 0.133760 | | |prometheu|my-prome...pv| 0.000000 | 0.000000 | | | |my-prome...hn| 0.000000 | 0.000000 | | | |my-prome...89| 0.000000 | 0.000000 | +-------+---------+-------------+----------+---------------+ | SUMMED| | | 6.837011 | | +-------+---------+-------------+----------+---------------+

More on Kubernetes What is Kubernetes? Free online course: Containers, Kubernetes and Red Hat OpenShift technical over… Test drive OpenShift hands-on An introduction to enterprise Kubernetes How to explain Kubernetes in plain terms eBook: Running Kubernetes on your Raspberry Pi homelab Kubernetes cheat sheet eBook: A guide to Kubernetes for SREs and sysadmins Latest Kubernetes articles

You can also integrate an API to extract the data programmatically into your platform of choice.

Kubernetes optimization strategies

Now that you have a handle on your cloud costs, it's time to optimize your Kubernetes environment. Optimization is an iterative process. Start at the top of the stack (containers) and work through each layer. The efficiencies compound at each step. There are many ways to optimize Kubernetes for cost efficiency, such as:

  1. Look for abandoned workloads and unclaimed volumes: Pods and storage that are no longer in use or are disconnected continue to consume resources without providing value.
  2. Right-size your workloads: Ensure you're using the right size containers for your workloads. Investigate over- and under-allocated containers.
  3. Autoscaling: Autoscaling can help you save costs by only using resources when needed.
  4. Right-size your cluster: Too many or too-large nodes may be inefficient. Finding the right balance between capacity, availability, and performance may greatly reduce costs.
  5. Investigate cheaper node types: There's a lot of variation in CPU, RAM, networking, and storage. Switching to ARM architectures may unlock even greater savings.
  6. Invest in a FinOps team: A dedicated team within your organization can look for ways to unlock greater savings by coordinating reserved instances, spot instances, and savings plans.
Get started today

Monitoring costs in a Kubernetes environment can be challenging, but with OpenCost, it doesn't have to be. To get started with OpenCost and take control of your cloud spend, visit the OpenCost website, get the code in GitHub, check out the OpenCost documentation, and get involved in the #opencost channel in the CNCF Slack.

[ Related read How to prioritize cloud spending ]

OpenCost is a cloud cost monitoring tool that integrates seamlessly with Kubernetes, allowing you to track your cloud spend in real-time so you can optimize your resources accordingly.

Image by:

Opensource.com

Kubernetes Cloud Containers SCaLE What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

Keep the solar system in your pocket with a Raspberry Pi

opensource.com - Mon, 03/13/2023 - 15:00
Keep the solar system in your pocket with a Raspberry Pi cherrybomb Mon, 03/13/2023 - 03:00

In my previous article, I talked about Stellarium in a web browser. This stellar software allows for a 3D view of your local sky, with amazing telescopic and scripting features. In this article, I'll show you how to put those stars in your pocket using a Raspberry Pi 4, along with scripting some animations for fun. If you remember my Halloween-themed article, I covered using a Raspberry Pi to make a festive Halloween jack-o-lantern. I've repurposed this same Raspberry Pi to create a traveling galaxy box. That's what I'll be calling it today. So let's get packed for a galactic trip.

What do we need for this trip?
  • One Raspberry pi 4 (with peripherals)
  • Raspbian OS
  • A sense of Astronomic wonder
Install Stellarium on your Raspberry Pi

For starting the installation of Raspberry Pi OS, I followed the instructions for the Raspberry Pi Imager instructions. I used the SD card edition of the install in my previous article, but you can choose whichever way you want using the Raspberry Pi manager. Make sure you update your OS with the most recent software.

You can do this by running these commands:

$ sudo apt update $ sudo apt upgrade

That might take a minute to run if you, for example, left your PI alone since October.

Queue some elevator music for me. It's gonna be a moment.

Next up, to install Stellarium, just run one simple command:

$ sudo apt install stellarium

And poof! It's installing.

Countdown to launch

Once you've got Stellarium installed, go to your application menu, and under education, you'll see the Stellarium app. I grabbed a screenshot just to show you.

Image by:

(Jess Cherry, CC BY-SA 4.0)

Configuration

When you first open Stellarium, it asks you for some configuration items. This includes your location, timezone, and anything else it didn't catch automatically at startup. Since my Pi already had a location configured and the timezone was set, it opened up without issue directly to my location. However, I want to show you what those settings look like, along with the highlighted button to click on the very left to change the configuration as you need:

Image by:

(Jess Cherry, CC BY-SA 4.0)

You can also download more stars in the extras section:

Image by:

(Jess Cherry, CC BY-SA 4.0)

I downloaded all of the catalogs. Each download also tells you how many stars are in the catalog, which is an incredible feature.

Each one of these sections does have some pretty neat things to look over. I'm also covering scripting in this article, though, so I'll just briefly skim through some interesting sections I played with.

Choose from the many available extensions. In this screenshot, I was looking at having the plugin for meteor showers. It allows you to create some simulations of your own meteor showers.

Image by:

(Jess Cherry, CC BY-SA 4.0)

You also have a bunch of other interesting plugins as you go.

In the information section, you can customize what you want to be visible on your screen when you click on an object.

Image by:

(Jess Cherry, CC BY-SA 4.0)

In the Time section, you can pick the time and date formats and pick entirely different times and dates to look at different skies as they appeared in history or will appear in the future. In this set of screenshots, I chose something completely random, and it worked:

Image by:

(Jess Cherry, CC BY-SA 4.0)

Finally, before I get to the fun part, you have the tools section, where you can enable and disable how your personal planetarium works. You can change labels, add a location for screenshots, change how your mouse works, and so much more.

Image by:

(Jess Cherry, CC BY-SA 4.0)

Time to script some animations

In my previous article, I mentioned in passing that you can script your own animations. That's where the scripts tab comes in:

Image by:

(Jess Cherry, CC BY-SA 4.0)

Before I get to scripting an animation, you might notice that some animations are already available for you to watch and use. For instance, in the picture above, I have a partial lunar eclipse highlighted. This is one of the animated series you can watch before you get started with scripting on your own.

Because the animations don't stop on their own with the movement of time, you must press K on your keyboard at any time to stop the animation. While Stellarium uses the QtScript engine as its scripting tool of choice, some users choose to go with Typescript. However, it's easy enough to make some simple "hello world" scripts using the script console within Stellarium. To do this, press the F12 button on your keyboard while inside the application, and a nifty console pops up.

Next on the list is a simple test of "hello galaxy". First, use the debugger library to verify that the scripting engine prints correctly to the log window:

core.debug("Hello Galaxy");

Press the Play button in the top left of the console to run the script and:

Image by:

(Jess Cherry, CC BY-SA 4.0)

You can see the output in the next tab:

Image by:

(Jess Cherry, CC BY-SA 4.0)

More on Raspberry Pi What is Raspberry Pi? eBook: Guide to Raspberry Pi Getting started with Raspberry Pi cheat sheet eBook: Running Kubernetes on your Raspberry Pi Whitepaper: Data-intensive intelligent applications in a hybrid cloud blueprint Understanding edge computing Our latest on Raspberry Pi

Now that you know that works, you can move on to something a tad bit larger, like putting words on the screen.

In this example, you'll be using the Label Manager Class to create a "Hello Galaxy" label to display on the screen. But this time, you can pick the size and color of the font, as well as its location on the screen.

var label=LabelMgr.labelScreen("Hello Galaxy", 200, 200, true, 60, "#ff080200"); core.wait(60); LabelMgr.deleteLabel(label);

This label manager displays the text "Hello Galaxy" in all black on the screen with a font size of 60 for 60 seconds. The two 200s are your points along the horizontal and vertical axis of the screen. The true Boolean is for the label to be visible on screen.

Image by:

(Jess Cherry, CC BY-SA 4.0)

Now that you have a cool onscreen setup, you can explore the scripting functionality further. It's not for the timid. I provided some notes on the scripting engine to a friend who specializes in JavaScript to see if he had any pointers for me, and the response I received was, "Oh dear."

Final thoughts

If you want to travel and teach astronomy, having this software on a Raspberry Pi is a great way to go. Easy installation lets you have stars in your pocket quickly. If you have your location functionality enabled on your Pi, you can easily and immediately have a view of your local sky given to you in real-time while you travel. For some more interesting bits on the scripting engine, I suggest you look over the official documentation. There's a good section on Typescript integration for those who have experience in Typescript.

Explore the open source planetarium Stellarium using a Raspberry Pi 4. Then have some scripting fun with animations.

Image by:

NASA, used with permission

Raspberry Pi Science What to read next This work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License. Register or Login to post a comment.

How to Create Device Files in Linux Using mknod Command

Tecmint - Mon, 03/13/2023 - 14:57
The post How to Create Device Files in Linux Using mknod Command first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

In Linux, everything is a file, even physical devices such as disk drives, CD/DVD ROM, and floppy disks are represented using files. However, these files are not regular data files. Instead, these special files

The post How to Create Device Files in Linux Using mknod Command first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

How to Install Puppet Master and Agent in RHEL-Based Systems

Tecmint - Mon, 03/13/2023 - 12:59
The post How to Install Puppet Master and Agent in RHEL-Based Systems first appeared on Tecmint: Linux Howtos, Tutorials & Guides .

Developed by Puppet Lans, Puppet is an open-source configuration management tool used for automating and centralizing the configuration of infrastructure such as servers just like Ansible and Chef. It helps the simple execution of

The post How to Install Puppet Master and Agent in RHEL-Based Systems first appeared on Tecmint: Linux Howtos, Tutorials & Guides.

Linux 6.3-rc2 Released With Two AMD Workarounds, Drops The Useless r8188eu Driver

Phoronix - Mon, 03/13/2023 - 08:54
The Linux 6.3-rc2 kernel is out today as the second weekly kernel test release since last weekend's closure of the Linux 6.3 merge window...

Linux 6.3-rc2 Introduces Stuttering Workaround For AMD Ryzen PCs Due To fTPM RNG

Phoronix - Mon, 03/13/2023 - 08:00
Since the Linux 6.1 kernel various users have reported system stuttering issues when using modern AMD Ryzen systems. This has been similar to an "intermittent system stutter" issue AMD disclosed last year for Windows 10 and Windows 11 while now for today's Linux 6.3-rc2 a workaround is finally being merged that in turn will also be back-ported to the stable kernel series...

GNOME 44 Release Candidate Arrives With Many Last Minute Changes

Phoronix - Mon, 03/13/2023 - 02:45
The GNOME 44 release candidate was officially declared today as the last test version ahead of formally releasing the GNOME 44 desktop later this month...

Linux Landing XMM Register Rollback Workaround For AMD Zen 1 / Zen 2 CPUs

Phoronix - Mon, 03/13/2023 - 00:08
Sent in this morning via x86/urgent for integration into Linux 6.3 and also for back-porting to stable kernel series is disabling the XSAVES instruction for AMD Zen 1 and Zen 2 processors to workaround an AMD processor erratum made public last year...

Linux 5.15.101 LTS Released To Fix Broken Intel Graphics At Boot

Phoronix - Sun, 03/12/2023 - 21:09
Yesterday saw emergency hot-fix releases in the Linux 6.2 and 6.1 series for addressing an easy-to-trigger kernel oops when mounting and unmounting external storage. This weekend is proving more volatile with today bringing an emergency hot-fix release for the Linux 5.15 LTS series due to a separate issue...

Pages