AKS - Cost Visualization and Management
Cost management is familiar; we do it back and forth day on day off. Well, at least that's what I do most of the time when I'm not thi
Today, the first of June, is International Children's Day in Romania, so that is a better way to celebrate than playing around with different things. When I do training or talk with the people I mentor, I tell them that Kubernetes is so powerful and flexible that you can do anything you want, and the limit is your imagination.
Looking around Github for things that might make my life easier, I found this gem of a repo: it instantiates retro games inside a Kubernetes cluster.
As a gamer, I had to try and see it for myself. It took me 5 minutes to have Mario running in my Kubernetes cluster. It's so stupid, I love it!
Here's the yaml for MARIO :)
apiVersion: retro.sparkfabrik.com/v1
kind: Game
metadata:
name: mario
namespace: games
spec:
name: "Mario"
zipUrl: "https://archive.org/download/marioDOS/MARIO.zip"
dir: "."
exe: "MARIO.EXE"
But beyond the nostalgic charm, this project served as a reminder of Kubernetes' immense potential. With the proper knowledge and a willingness to experiment, the possibilities are truly endless. This wasn't just about reliving childhood memories but about pushing boundaries and uncovering innovative solutions. Imagine the possibilities – deploying complex AI models within a Kubernetes environment, orchestrating microservices for a high-traffic website, or creating a distributed rendering pipeline for a groundbreaking animation project. The applications are as diverse as our collective imagination.
Now, let's transition from the whimsical to the practical. While retro games may be an amusing diversion, Kubernetes is a powerhouse for real-world automation. I extensively utilize PowerShell scripts and functions within my Kubernetes environment, and they integrate seamlessly; after playing around with them, I cannot imagine doing things differently. In the past, I had VMs with Task Schedulers; I moved on to Azure Automation Accounts and then Azure Functions. The main differentiator? I made the time to figure the system out, and from there, I was hooked.
PowerShell scripts can seamlessly integrate into Kubernetes pods, automating each process stage. These scripts can be triggered by events within the cluster, ensuring a smooth and efficient flow. Similarly, routine system administration tasks can be automated through PowerShell scripts within Kubernetes, freeing valuable time and resources for more strategic endeavours.
You know what's the fun part? I always need help finding articles on getting this machine started. In Kubernetes, cronjobs are easy, and running Powershell jobs is not a problem.
Here's an example of a CronJob in Kubernetes that schedules a PowerShell script to run every hour:
apiVersion: batch/v1
kind: CronJob
metadata:
name: hourly-powershell-script
spec:
schedule: "0 * * * *" # Runs every hour
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
containers:
- name: powershell-script
image: mcr.microsoft.com/powershell:latest
command: ["pwsh"]
args: ["-ExecutionPolicy", "Bypass", "-File", "/path/to/script.ps1"]
restartPolicy: OnFailure
Explanation:
"0 * * * *"
runs every hour (minute 0 of every hour).This example demonstrates scheduling a basic PowerShell script execution in Kubernetes using a CronJob. You can adapt this approach to various automation tasks that can run anywhere.
So, we started with a bit of fun. We played Mario, and we learned something. At least I did :)
That being said, have a good one!