[HN Gopher] I rewrote in Crystal my tool to quickly create Kuber...
       ___________________________________________________________________
        
       I rewrote in Crystal my tool to quickly create Kubernetes clusters
       in Hetzner
        
       Hi all, I just released a new version of
       https://github.com/vitobotta/hetzner-k3s that is a complete rewrite
       in Crystal that is faster, better overall and allows me to offer
       simple standalone executables. The previous version was written in
       Ruby, so users had to either set up a Ruby environment, or use a
       Docker image instead. This is no longer necessary.  This is my
       first project in Crystal and I love it already! It's syntax is
       lovely - similar to Ruby's - and it's FAST!  I would appreciate any
       feedback anyone might have - if you are a Kubernetes user as well
       as a Hetzner customer, please give it a try and let me know what
       you think, if you encounter any issues etc.  During my tests I was
       able to create a cluster with highly available control plane (3
       masters behind a load balancer) and 5 nodes in multiple regions in
       just *3 minutes*. This is the total time to create the resources
       (servers, firewall, load balancer, private network), deploy
       Kubernetes to all the nodes, install some stuff required to
       provision load balancers and persistent volumes out of the box, and
       install an upgrade controller to easily upgrade the Kubernetes
       version (I use k3s as Kubernetes distro). I don't think there is a
       faster way to create a production Kubernetes cluster!  Do you have
       Kubernetes clusters in Hetzner already? If yes, which tool did you
       use to create them? Would be interested to know more about
       alternatives people are using.
        
       Author : SkyLinx
       Score  : 101 points
       Date   : 2022-12-30 14:20 UTC (8 hours ago)
        
       | mathverse wrote:
       | Love it! Have you tried to create a k8s operator in Crystal?
        
         | SkyLinx wrote:
         | Not yet, but I am definitely going to use the language more!
         | For example I want to rewrite a controller I wrote in Ruby that
         | monitors Velero backups and sends me notifications via emails,
         | Slack, or webhooks so I can know when a backup failed. I did
         | this in Ruby but want to rewrite that too.
         | 
         | In terms of operators I have an idea for an operator but it
         | would be very specific to our infrastructure and backend apps
         | at work.
        
       | xrendan wrote:
       | I have a cluster using terraform-hcloud-kube-hetzner [0] and I'm
       | quite happy with it.
       | 
       | It uses MicroOS for rolling releases and auto-upgrades for less
       | maintenance. I'm quite happy with it so far, and I like that it
       | integrates with terraform.
       | 
       | [0] https://github.com/kube-hetzner/terraform-hcloud-kube-
       | hetzne...
        
         | SkyLinx wrote:
         | I had never heard of MicroOS before, sounds interesting. Before
         | building this tool I actually used both Terraform and Pulumi.
         | My tool is a ton faster setting things up and only requires a
         | small YAML config file. Would be able to give it a try? I am
         | looking for feedback :)
        
           | stephankoelle wrote:
           | You might then be interested in Fedora CoreOS, we use it with
           | Hetzner cloud and real Hetzner root server with good success.
           | (Also with ovh)
        
             | SkyLinx wrote:
             | I can test it. What would be the advantage if I use it in
             | my tool instead of Ubuntu? At the end of the day with
             | Kubernetes I don't think it makes much difference which OS
             | you use. I picked Ubuntu because it's standard and servers
             | with this image build very quickly with Hetzner Cloud.
        
               | mdaniel wrote:
               | CoreOS (and its spiritual successor Flatcar) are
               | immutable, which gravely limits the silliness that can be
               | done to them post-launch. We use now use Bottlerocket
               | since we're on EKS, but it's even more locked down since
               | to even get an interactive shell is some major
               | hoopjumpery. I believe Talos goes even further and is
               | _completely devoid of a shell_
               | 
               | So, yes, it absolutely matters which OS you use, of
               | course depending on your threat model and tolerance for
               | "no, you don't get to ssh onto a Node and do
               | whateverthehell you want"
        
         | incompleteCode wrote:
         | How much does this cost you on a monthly basis?
        
           | SkyLinx wrote:
           | I can give you an example of one cluster than I use for
           | personal stuff:
           | 
           | - 3 masters with 3 cores and 4 GB of RAM each - load balancer
           | for the masters (for the Kubernetes API) - 3 workers with
           | faster AMD CPUs and 4 cores/8GB of RAM - around 200GB of
           | storage in persistent volumes
           | 
           | I think it costs around 60-70 euros per month total! I can't
           | remember the exact amount because I have many things with
           | Hetzner and do tests creating and deleting stuff all the time
           | so my bill is rather long lol.
           | 
           | Hetzner is very cheap, but I can voice for the performance
           | and reliability as well. It's a very good provider and I
           | highly recommend them. Now they even have 2 locations in the
           | USA!
        
             | incompleteCode wrote:
             | That's cost-effective! I've been toying with the idea of
             | running a personal distributed system that's not serverless
             | to just hack around and Hetzner seems approachable going by
             | your experience.
        
               | SkyLinx wrote:
               | Definitely. I have been using them for years and I still
               | can't understand how they can offer such a good service
               | at their prices, considering how much the competition
               | charges.
        
             | dakiol wrote:
             | Nice price. Are those dedicated servers? Or just "cloud"
             | (standard or dedicated vcpu?)?
        
               | SkyLinx wrote:
               | Cloud servers with standard shared cores. They perform
               | really well
        
       | scary-size wrote:
       | Sweet! I have no interest in Kubernetes, but this lead me to give
       | Crystal a try. Feels solid so far, nice standard lib for the
       | usual things (json, http etc.). Compiler warnings helped find
       | errors quickly. The language documentation reads very easily. And
       | best of all: standalone executables.
        
         | boredtofears wrote:
         | I used it a lot over the summer on some pet projects and really
         | enjoyed it. Being a heavy Ruby/Typescript user in recent years
         | it feels like a natural melding of the two. Macros are a really
         | interesting way to achieve many of the same metaprogramming
         | properties of Ruby (although a little awkward to reason about).
         | 
         | I used Jamis Buck's book The Ray Tracer Challenge[1] as a fun
         | kind of way to learn the language and ended up learning a good
         | chunk of the language as a result.
         | 
         | My biggest complaint is just that it's not more popular - it's
         | ecosystem is pretty web developer-centric and I'd personally
         | love to see it used for more things outside of that.
         | 
         | [1] https://pragprog.com/titles/jbtracer/the-ray-tracer-
         | challeng...
        
           | SkyLinx wrote:
           | That page doesn't mention Crystal. Is the book about Crystal
           | code?
        
             | boredtofears wrote:
             | No, it's about building a ray tracer. You can use any
             | language you want to work through the book. I find it a
             | good way to explore new languages.
        
         | SkyLinx wrote:
         | The standalone executables were the primary reason why I looked
         | to rewrite the tool in something other than Ruby. I actually
         | tried to use a sort of "compiler" for Ruby but the executables
         | were huge, took long to build and had issues.
        
       | eurg wrote:
       | Hetzner has some attractively priced dedicated servers - for some
       | heavier workloads that might be nice. Do they use a very
       | different management API? (They have a cancellation period of "30
       | days to the end of the month", which would complicate matters.)
        
         | SkyLinx wrote:
         | I don't think there is an API for the dedicated servers AFAIK,
         | only cloud.
        
           | bobek wrote:
           | They have api for dedicated servers. It may be confusing,
           | that it is called robot api, but that is how they call their
           | management interface for dedicated servers.
           | 
           | https://robot.hetzner.com/doc/webservice/en.html#preface
           | 
           | https://docs.hetzner.com/robot/dedicated-server/robot-
           | interf...
        
             | SkyLinx wrote:
             | Interesting, I had never come across it in years that I
             | have been a customer!
        
         | [deleted]
        
       | gerwim wrote:
       | Looks great! I see your tool uses Hetzner block volumes for
       | storage. How do you manage your data backups (as Hetzner does not
       | offer anything for their block storage volumes as far as I know).
       | 
       | My current setup is also on Hetzner. 1 master and 3 worker nodes.
       | Managed by Rancher and I use Longhorn (also from Rancher Labs)
       | for storage. It runs stable for two years now. But looking for a
       | simpler solution, so I looked into k3s and k0s last week -- will
       | also look into your tool ;-).
        
         | SkyLinx wrote:
         | Give it a try, looking forward to hearing what you think :)
         | 
         | For backups I just use Velero. It can back up any kind of
         | volumes with the Restic integration, and it has been rock solid
         | for years for me.
         | 
         | In the past I've used Longhorn, Rook, OpenEBS and others but
         | really, in Hetzner Cloud just use their volumes. It's much more
         | reliable than those software solutions in my experience and
         | performance is also a lot better.
        
       | hbien wrote:
       | Great job! How were you able to do a stand-alone binary for Mac?
       | I was able to for Linux via their Alpine/MUSL image, but never
       | figured out how to for Mac.
        
         | SkyLinx wrote:
         | Just using Crystal as installed with Homebrew and then running
         | `crystal build --release`. Very simple, see the Github Actions
         | workflow in the repository :)
        
       | SOLAR_FIELDS wrote:
       | Just as a point of reference, for me to spin up a 3 node cluster
       | in terraform with GKE it takes 10+ minutes.
        
         | SkyLinx wrote:
         | Yep. I tested creating a cluster with 5 nodes and it took
         | almost 20 minutes for me with GKE (just from the console, not
         | Terraform).
        
           | MuffinFlavored wrote:
           | Weird question: you use Terraform to manage the cluster nodes
           | themselves, and then you use k8s YAML (or Helm charts or
           | something else) to manage the k8s resources, right? You don't
           | manage the k8s resources from Terraform, do you?
        
             | SkyLinx wrote:
             | Correct. I can't remember the details because I haven't
             | checked this stuff recently but that's the gist of it
        
       | wg0 wrote:
       | Cannot stop myself from commenting because it has everything of
       | my interest. Kubernrtes, Hetzner and Crystal.
       | 
       | Another kubernetes installer. I think there's one Kubematic or
       | similar already for Hetzner.
       | 
       | I'm going to try this and be possibly contribute back.
       | 
       | Few questions:
       | 
       | Why k3s why not k0s? What about cluster upgrades? Are they
       | covered?
       | 
       | I'm probably going to setup a staging environment but can anyone
       | suggest me a good CI/CD for Kubernetes? How about GitHub actions?
       | 
       | Secondly, I need to run databases lots of them some in range of
       | 500 GB or so and backup/restore is important. Any suggestions
       | there?
        
       | preisschild wrote:
       | > Do you have Kubernetes clusters in Hetzner already? If yes,
       | which tool did you use to create them? Would be interested to
       | know more about alternatives people are using.
       | 
       | Yes. I use ClusterAPI[1] with the cluster-api-provider-hetzner[2]
       | & Talos[3] (and Talos' cluster-api components) for that.
       | 
       | [1]: https://cluster-api.sigs.k8s.io/user/quick-start.html
       | 
       | [2]: https://github.com/syself/cluster-api-provider-hetzner
       | 
       | [3]: https://talos.dev
        
       | sureglymop wrote:
       | If I'm allowed to ask.. what's Crystal?
        
         | SkyLinx wrote:
         | It's a programming language that looks very similar to Ruby in
         | syntax (if you are familiar with Ruby), but it's compiled, so
         | by switching from Ruby to Crystal for this tool I was able to
         | provide standalone executables which are easier to use. With
         | the Ruby version instead my users had to set up Ruby or Docker,
         | which was not optimal.
        
         | schipplock wrote:
         | https://crystal-lang.org/
        
       ___________________________________________________________________
       (page generated 2022-12-30 23:01 UTC)