I’ve been experimenting with Elixir for a few years off and on and have really enjoyed it so far. I can’t use it professionally, so all I’ve been able to do is some Exercism exercises (which I highly recommend) along with some other random projects. For example, I used it a fair bit to solve many of the Advent of Code 2022 puzzles (here’s a link to my repo of solutions).
I’m not sure that I’m ready to call myself an expert and definitely wouldn’t say it has replaced Ruby as my favorite language, but it has been fun so far. More than fun, actually; I’ve learned a lot and it has influenced how I write code in other languages. It isn’t just that it is a functional language; there are several other aspects that feel worth carrying along with me. I love Elixir’s pattern matching and while Ruby has introduced it, it isn’t quite as powerful as Elixir’s. I assign fewer variables now, instead favoring small functions that I can chain together (thanks to
|> in Elixir). Tests in code comments — especially right above functions/methods, called Doctests — are amazing. I wish I could bring that with me to Ruby. Finally, I get why Elixirists refer to functions by their name and arity (like
foo/2) and how different Elixir is from Ruby.
If you’ve thought about picking up another language, I would highly recommend Elixir. You’ll probably learn something new!
Previously, in Part 1 I described Kubernetes Controllers and the Operator pattern. In Part 2, I explained why Controllers are important and how Metacontroller makes it easier to build them in your favorite language.
In this, the 3rd and final part of this series, I’ll show off Metatron, which is my Ruby-based approach to building Metacontrollers. We’ll walk through building a basic
CompositeController responsible for a custom
Blog Kubernetes resource. I’m still working on the gem, but this should be a good demonstration of its capabilities and how easy it is to get started. Much of this post is a recap from Part 2, but it seems worthwhile to present it all together.
Continue reading Kubernetes Controllers via Metatron (Part 3)
Previously in Part 1, I discussed what Kubernetes Controllers are, how they work, and gave some examples of their usage. I also gave a description of Operators and explained how they are just a specific kind of Controller. All this in the service of explaining what my new gem Metatron is and how it is helpful.
Here, in Part 2 of this series, I’ll describe Metacontroller, including what it is, how it is helpful, and how it relates to Metatron for creating new Controllers.
Continue reading Kubernetes Controllers via Metatron (Part 2)
I recently released a new Ruby gem called Metatron. This gem aims to make it very easy to create Kubernetes controllers, either to implement the Operator pattern or to respond to events related to built-in resource types. It does this by deferring to Metacontroller for the Kubernetes API interactions and handling the boilerplate work of providing the JSON API it expects. To be clear, Metacontroller does most of the heavy lifting here. It provides some fantastic examples for creating various kinds of controllers, but sadly none of them are Ruby-based. This really seems like a great place for Ruby to shine. So, I decided to roll up my sleeves and get to work on that.
I touched on a lot of advanced Kubernetes topics in that short paragraph. It might not be clear precisely what value Metatron is adding to the equation, so I’m going to dive deep into the concept of Kubernetes controllers, Metacontroller, and finally Metatron itself in a three-part miniseries. Buckle up and prepare to learn lots about Kubernetes!
Continue reading Kubernetes Controllers via Metatron (Part 1)
Sure, it might not be obvious why the world needs yet another bot framework, but I’m working on one. The idea is to make a scalable, intuitive, and feature-rich framework that runs on the latest Ruby. Long-running tasks shouldn’t be a problem and the framework should make things like caching a breeze. Permissions are a first-class concept, as are features like threaded replies, reactions, blocks (for rich-text responses), and support for more than just chat input. Enter Waylon: a bot framework built with these concepts (and more) in mind.
Continue reading Waylon: A New Bot Framework
Made it to Las Vegas for the Sin City Ruby conference. I’m stoked to be here and excited to see what cool stuff everyone is working on.
Most of the time, challenges I tackle with Ruby solve code-related problems. This includes things like web services, scripts, chatbots, etc., all of which are virtual in some way. Recently though, I decided to solve a puzzle in the real world.
My son was trying to put together a wooden puzzle. It requires having four colors (blue, green, red, and yellow) each present on all four sides of a rectangle. These colors are on wooden cubes that can be rotated. So four cubes, each with six sides to rotate around. It turns out that this means there are a lot of possible combinations of these cubes, most of which won’t work. By my math, there are six sides that can face up (a “
y” axis), multiplied by four possible rotations around that axis (
6 * 4 = 24) for each cube. Raised to the power of the four cubes (
24^4 = 331776). After about 30 minutes of hearing his frustration, I told him “I bet I can solve this puzzle with some code” but he was skeptical.
I took that as a challenge to both my coding skills and his respect for me as his dad, so I obliged. After finishing, I figured it would be worth sharing.
Continue reading Solving Physical Puzzles with Ruby
I recently solved a problem I’ve always wanted to solve: writing a library that can unscramble words. I know, this is a pretty geeky and pointless endeavor. Geeky, though, is what I do.
Originally, the library focused on exact matches. Given some string, I could find all words that can be formed with those letters. After accomplishing my goal, I decided to extend the project to finding the longest word possible. I noticed that this sounded a lot like finding solutions for the game Scrabble. While the library is still a work-in-progress, I thought it might be fun to share my progress. This is the story of how I wrote a library and simple web service for solving Scrabble with Crystal.
Continue reading Solving Scrabble with Crystal
Occasionally, Kubernetes workloads require specialized nodes. Sometimes it’s for machine learning, or to save money through burstable node types, or maybe just to lock certain Pods to a dedicated subset of nodes. Thankfully, Kubernetes offers a few useful mechanisms to inform the scheduler how we’d like our workloads distributed: node-based or pod-based affinity rules along with taints and tolerations. I’ll go over how to use these briefly, but I use these frequently at work for numerous reasons. Recently, I realized something interesting about how Persistent Volume Claims (PVCs) work with dynamically provisioned storage like EBS volumes (meaning volumes that are created automatically by Kubernetes based on a StorageClass, rather than referencing existing volumes). The default behavior of a StorageClass is to immediately create a volume as soon as the PVC is created. This can have some consequences when trying to guide how Pods are scheduled.
Continue reading Kubernetes Node Affinity and EBS Volumes
Recently, I wrote an AWS Lambda function at work in Ruby but I didn’t have a handy tool for creating a project skeleton like
bundle gem does. That means nothing bootstrapped my testing for me. While copy+pasting code into
pry proved that my simple function worked, that wasn’t quite good enough. What I really wanted was the ability to use RSpec with my Lambda code. After a cursory search of the Internet for some examples, I was left disappointed with how little I found. So, I rolled up my sleeves and figured it out.
Continue reading RSpec Testing for Ruby AWS Lambda Functions