13 ms·
Show HN: Simplenetes – I replaced Kubernetes with 17k lines of shell script
- theamk 6y ago> simple > 17k lines of shell script those two phrases don't belong together... to think about this, "17k lines" and "shell script" should not be used together either. Also, you are a bit light on tests.. there only seems to be a single trivial one, which seems way too low for a codebase this size.
- thomasbacklund 6y agoThis is why Simplenetes is built with Space.sh [1], a tool to build shell script applications. About the tests, can't disagree with you, they will come. [1] https://github.com/space-sh/space https://github.com/space-sh/space
- pcthrowaway 6y agoFirst time I'm hearing of space also. It looks quite impressive, surprised to see no stars
- thomasbacklund 6y agoThanks! We just moved Space.sh from GitLab to GitHub (hurts in my heart, but yeah community is on GitHub). Also we are lousy at promoting our stuff, maybe April 1st is not the best day to do this either...
- pcthrowaway 6y agoIt's OK, I'm sure more stars will start appearing in Space as visibility improves :)
- robertlagrant 6y ago> community is on GitHub I'm surprised when people say this. I thought communities were only around repos.
- conradludgate 6y agoIt's easier to get contributors and responses when most people already have github accounts. When not many habe have gitlab, it adds some friction to contributing and a lot won't bother
- robertlagrant 6y agoFair enough. I'm surprised they don't have a Sign In With GitHub button :D
- Proven 6y ago> (hurts in my heart) Wut? Are you a Space.sh project member, or FSF functionary?
- debarshri 6y agoYou are hearing of space.sh for the first because it is written by the same authors who wrote this project.
- deleted 6y ago[deleted]
- scubbo 6y ago> those two phrases don't belong together I assumed it was tongue-in-cheek?
- a-dub 6y agoi dunno. autotools is hairy, but it also solved some incredibly hairy problems over an enormous breadth for a very long time in a very reliable manner. portability across all the different unices with their weird c compilers and differing libcs that actually worked out of the box every time was a gargantuan task.
- verdverm 6y agoWhat happens if a node fails?
- thomasbacklund 6y agoAs long as you have multiple replicas of the pods they keep serving traffic.
- verdverm 6y agoSo no work rescheduling? That is a significant divergence from k8s and means you cannot "replace" it with this
- kristaps 6y agoNot April fools judging by github history...
- thomasbacklund 6y agoThank you for noticing! :) Yeah, this represent a few months of full time work.
- faeyanpiraat 6y agoSo you’ve worked on it for like a 1000 hours and shared it for free? How can you afford this?
- sli 6y agoIf I had to hazard a guess, I'd say they saved up enough money to cover their living costs over that time.
- spamizbad 6y agoWas delighted to discover this!
- some_random 6y agoThis is really cool, but is there a real use case for this?
- thomasbacklund 6y agoThanks :) The real use case is super simple clusters, which could be just 1 node, no etcd, no API (SSH managed), no iptables. Simplenetes is not a living breathing thing which auto heals it self, it's a deterministic approach where you can see your cluster with all hosts in the git repo which represents the cluster. Also, it's focused on making local development easy, so you can develop in a micro services architecture straight on your laptop with very quick iterations.
- cat199 6y ago> clusters, which could be just 1 node Despite whatever the k8s crowd misuses the term to be, 1 node is not a cluster. It might be a single node managed using cluster-capable technologies, but it's still not a cluster.
- yen223 6y agoI am a fan of the two-node cluster - one node to do the work, and the other node to manage the cluster. Main upside is that I can put Kubernetes on my resume.
- deleted 6y ago[deleted]
- danpalmer 6y agoThis is ~17k lines of shell scripting and claims to be "simple". Kuberentes is probably ~1m lines of Go. I'm not entirely convinced that this is less complex (simpler) than Kubernetes. There are many factors in complexity, but a big one for me is what I have to hold in my head – global state. From any given point, what do I need to understand to know what's actually going on. For Go, this is actually comparatively little. Between a fairly straightforward language, static binaries, and the focus on ease of distribution, there's not a whole lot outside of a codebase itself to think about. However for a shell like Bash there's a relatively large amount to consider. You're very exposed to the underlying OS, to libraries and system packages, to various tools, to configurations users may have specified, to things being redefined underneath you. There's a lot of global state to consider for a Bash script. I suspect it is simpler than Kubernetes, but I don't think it's a clear cut case.
- undefined1 6y agothe 30 million line problem; https://caseymuratori.com/blog_0031 https://caseymuratori.com/blog_0031
- intricatedetail 6y agoGo has a lot of boilerplate code - simple things take many lines, so I wouldn't be too serious about 1M
- danpalmer 6y agoYeah that's kinda my point. Boilerplate isn't necessarily "complex" in that way. If you can ignore it that's great. I'm not sure you can with shell scripting because of all the global system state.
- jozvolskyef 6y agoTo be fair Kubernetes itself probably has 17k lines of bash, and it is a good thing. It is the first go-to project that I use as a reference for bash scripting best practices. edit: wc reports 47023 lines in *.sh[1], out of which 23836 are unique[2]. [1]: find . -name '*.sh' | xargs cat | wc -l [2]: find . -name '*.sh' | xargs cat | sort | uniq | wc -l
- knodi 6y agoIf you drop enough feature everything is simpler.
- mplewis 6y agoMost of these source code files are very large. Where should I start reading?
- llarsson 6y agoNo Persistent Volume support, so not great for stateful applications. Claims that type of thing is "magic", and therefore out of scope. Quite an engineering feat, though, I am sure! Is this to have fun, to learn, to actually use in production?
- thomasbacklund 6y agoThanks!! We do use it in production, it is however fresh from the keyb so giving it some time before putting sensitive stuff in there. About the state, it's perfectly doable, but requires some more Ops than k8s and isn't as flexible, naturally.
- mikece 6y ago1. Anything that offers effective competition to Kubernetes is a Good Thing. I'm not saying this is because I haven't look at it closely enough but competition brings about improvement. 2. Why do people write "Simplenetes has a 100x less code than Kubernetes" instead of saying it has 1/100th the code?
- verdverm 6y agowhy is that a perceived benefit By contrast, Kubernetes has at least 1000x more developers working on it
- oropolo 6y agoDon't you mean "1/1000th less" developers working on it?
- nullserver 6y ago1000x developers sounds like a huge red flag. It’s way too complex already.
- peytn 6y agoIt’s tens of thousands of times as many contributors. For comparison, IIRC WebKit had like 500 contributors as of five or six years ago.
- HereBeBeasties 6y agoBut you don't understand. 100x less code than k8s means that using it must reduce my own codebase by 99 million lines of code! Who wouldn't want that?
- motoboi 6y agoKubernetes might follow the sad path of spring. Perfect, complete and too complex. For big and great applications, spring if the obvious choice. It makes incredible complex and difficult things easy. But, unfortunately, makes simple and quick applications incredible complex and difficult.
- karmakaze 6y agoYou can't be talking of Spring Framework!? That's a 2000's solution (in particular Hibernate) trying to stay relevant.
- mixedCase 6y agoI don't disagree with your conclusion. But your comment communicates no argument against Spring and how the trade-offs it makes make it a poor option for new projects.
- karmakaze 6y agoAnyone with sufficient experience with JPQL and Hibernate will realize their limits and how poorly it works in the latency sensitive transactions we want now. Spring and Hibernate were designed to cache domain 'entities' and manage their dirty state client-side as an optimization. Any time you go want to go near the EntityManager you're hitting this impedance mismatch.
- johnnycerberus 6y agoWhat's the alternative?
- karmakaze 6y agoSeveral are mentioned in comments of this thread. Search results show too many old ones. As a short-list sampling, a Micronaut SQL guide[0] lists the following: JDBC Hibernate JAsync SQL jOOQ Jdbi Reactive MySQL Client Reactive Postgres Client I myself chose JDBI for more recent projects using Java/Kotlin. [0] https://micronaut-projects.github.io/micronaut-sql/latest/guide/ https://micronaut-projects.github.io/micronaut-sql/latest/gu...
- marvinblum 6y agoIf you're looking for a simple Kubernetes alternative, take a look at the HasiCorp stack. I use that in production and it's easy to set up and maintain.
- xrd 6y agoDo you have a link to an introduction?
- marvinblum 6y agoThe YouTube channel [0] has plenty of introduction videos, but I find the documentation [1] to be the best place to start. You should set up Consul (service mesh) first, followed by Nomad (orchestration), and Vault (secret management) if you need it. The only thing I initially struggled with was the systemd-resolved config on Ubuntu, to make the service discovery work. I plan to write an article about it, should I ever find the time for it :) Btw. the cluster consists out of three servers on Hetzner [2] and runs our web analytics platform Pirsch [3]. [0] https://www.youtube.com/channel/UC-AdvAxaagE9W2f0webyNUQ https://www.youtube.com/channel/UC-AdvAxaagE9W2f0webyNUQ [1] https://learn.hashicorp.com/consul https://learn.hashicorp.com/consul (for Consul, the pages for Nomad and Vault are similar) [2] https://www.hetzner.com/cloud https://www.hetzner.com/cloud [3] https://pirsch.io/ https://pirsch.io/
- skynet-9000 6y agoOr k3s (https://k3s.io https://k3s.io), which is Rancher's awesome and lightweight Kubernetes distribution.
- debarshri 6y agoor microk8s with comes pre-installed with ubuntu
- jjeaff 6y agoI use k3s in production, and it is great. But as far as daily use, it is not any simpler than kuberenetes. Initial setup and clustering is a breeze with k3s. But after that, you are mostly just working with the same k3s api as a full kuberenetes setup.
- SomaticPirate 6y agoI’m not sure if rewriting applications in bash should be considered an improvement... https://twitter.com/astarasikov/status/568825996532707330?s=21 https://twitter.com/astarasikov/status/568825996532707330?s=...
- yosito 6y agoSoftware developers should be required to have a license to use the word "simple".
- debarshri 6y agoor kubernetes or cloud-native
- wongarsu 6y agobut is it web-scale?
- ForHackernews 6y agohttp://thedjbway.b0llix.net/license_free.html http://thedjbway.b0llix.net/license_free.html
- jeffrom 6y agoReminds me of a coworker many years ago who wrote a script he called bash-reduce. Turned out not to be so simple in practice ;)
- debarshri 6y agoBuilding a platform to deploy stateless services are the easy part. This might even work nicely at a smaller scale. It is gets super complicated when you want to mount volumes, re-use those volumes. This is like a nice weekend project, contrarian in nature, but it is just not a replacement for kubernetes. This is some bash script orchestration on top of podman. Bulk of complexity in opensource distro of kubernetes comes from the fact that everything is interface driven and has to work in an generic way. For example, you don't really have to implement cri-o like thing if you are opinionated platform and only supports docker. Similarly, you don't have to build CSI, if you only support ceph or aws' storage. I love the contrarian thought, but matter of the fact is modern orchestration platforms that want to be a general purpose platform is going to be big. It is a really nice exercise however build something like this when you want to learn about networking, containers, orchestration, storage etc. and how to tied everything together.
- thomasbacklund 6y agoSimplenetes does support state, no sweat. But it can't pull a disk out of the cloud for you, there is some traditional Ops involved.
- debarshri 6y agoSo, it can reschedule container if there is a continuous error state on a particular host it is deployed?
- thomasbacklund 6y agoNo, don't build the next Netflix on Simplenetes. However, if you are just dealing with a three node cluster (Yes I know many of you are running tri-cycles with k8s stickers on it) then maybe it can be fine for many applications to not have a scheduler. Simplenetes does however support multiple replicas of pods so if one node fails it can be OK.
- debarshri 6y ago
- sleepybrett 6y agoThis seems like a huge waste of time and effort. I can only hope that it an april fools joke.
- thomasbacklund 6y agoHaha :) Well, the learning has been great I can confirm that. My script-fu is on a whole new level now, it was already quite up there after creating Space.sh [1] Waste of time... Well... Let's not think too much about that. I'm at least a very happy user of this :) [1] https://github.com/space-sh/space https://github.com/space-sh/space
- deleted 6y ago[deleted]
- ogre_codes 6y agoAt some point, April Fools jokes ceased being funny. Now I’m trying to figure out if I just got too old to appreciate them, or if the good ones have all been used up.
- jfoutz 6y ago-q Set to be quite. I doubt it's intentional, but I kinda love it.
- thomasbacklund 6y agoOh geez.. Hehe, thank you for pointing that out facepalm
- gigatexal 6y ago17k lines of shell? Hah give me the infinity lines of Go that is kubernetes — maintaining shell scripts is a nightmare. At least Go is a proper language with an ecosystem and tests and established best practices, etc., etc. Also namespaces are a killer feature of K8s imo
- deleted 6y ago[deleted]
- deleted 6y ago[deleted]
- aabhay 6y agoThe amount of vitriol in this comments section is astonishing. Can we not share fun projects without the professional Kubernetes experts thumbing their noses? At the very least, it does seem now like the complexity of K8s’s code base is a point of very thin skin for the community.
- thomasbacklund 6y agoThank you aabhay for a nice comment. Seems like my click-baity title brought out some strong feelings :) I do actually like Kubernetes. I recommend it to clients, I assess candidates who are to work with it, but I do really think it is a Beast. Because it is. Kubernetes is like C++, extremely useful but it just keeps growing and nobody really knows all of it. While Simplenetes is like... Lua, batteries not included, your boss will not approve, it doesnt't hit the buzzspot, but some people will secretely use it and be happy about it.
- runawaybottle 6y agoYou just described every other software project. ‘It keeps growing and nobody really knows it all’, story of my life.
- deleted 6y ago[deleted]
- nix23 6y agoThe peoples who criticize that project should be remained why Unix even came to life.
- Skhalar 6y agoI read vitriol as virtio and was throughly confused for a few minutes. I was thinking why are people talking about virtio so much.
- a-dub 6y ago17k lines is a lot of shell... but... it bypasses all the complexity of heavyweight scripting languages, bash is a lightweight interpreter that is always there and just works and i bet it's fast. this is a cool idea. next up, somebody will modernize daemontools for the container/cluster era...
- a-dub 6y agoi must say though, i'm not sure how i feel about a shell script "daemon"...
- bonestormii_ 6y agoWhy? This is not a completely novel concept, and a daemon is not a particularly complicated thing. You can use shell scripts to easily "daemonize" small programs. It's both fun and effective to do so.
- megous 6y agoDaemon is just something running in a loop.
- a-dub 6y agoactually no. there are a bunch of properties to properly daemonize in unix. things like special handling for stdin/stdout/stderr, reparenting, signal handling... look it up. classic rookie mistake to just call a program that doesn't exit a daemon... proper daemons can stay up for years.
- megous 6y agoInfinite loop will stay up for years too. Running "in the background", handling of stdin/out/err, logging, detaching from tty, creating a new process group/session, closing fds, and much more is handled these days mostly by systemd. No need to put all this into your program at all. I'll give you that signal handling still needs to be done in the target process, if the defaults don't satisfy you. But you really don't need anything special anymore to make any old script into a daemon.
- debarshri 6y agoThe whole setup of github project looks like it is a serious attempt.
- ay 6y agoAnyone taking up 17KLOC of shell script “as is”, regardless of how many cool domains it is on, to use in production deserves everything they get subsequently. It will be a useful learning experience. The same goes about taking up k8s with no thinking, by the way.
- corndoge 6y agoWoe to ye if hn decides your project is Not Fun
- avmich 6y agoDon't mess with HackNe's-s
- rualca 6y agoI don't understand your type of comment. If people involved with a project decide to advertise it on HN, specially following questionable clickbait methods, is it reasonable to demand that all posts must be exclusively comprised of high praises and compliments?
- skynet-9000 6y ago> specially following questionable clickbait methods The title seems both true (for the author's situation) and falsifiable. I don't think it's clickbait.
- rualca 6y agoYou should check the discussion because the submitter already admitted that the title was clickbaity.
- mlvljr 6y agoNow do this with .bat files :)
- sova 6y agoLanguages: Shell 100.0% Impressive
- nunez 6y agotbf the maintainer of Simplenetes throws an incredible amount of shade against Kubernetes
- balfirevic 6y agoWhere?
- nunez 6y ago- "Let's put the Dev and Ops back into DevOps." - "Simplenetes doesn't go there because that is when DevOps becomes MagicOps." - " You enjoy the simple things in life."
- balfirevic 6y agoThat's not an "incredible amount of shade".
- endisneigh 6y agoHaha, you can’t be serious. That’s an incredible amount of shade? Gimme a break
- deleted 6y ago[deleted]
- sli 6y agoThese read no differently than any random startup's slogan.
- fakedang 6y agoThat is so mild, I suspect somebody here is way too insecure about his expertise.
- nunez 6y agoi love your username
- 6y ago
- amerine 6y agoThis is my kind of tom foolery. Love it. You should come work with me at Heroku: https://www.heroku.com/careers/software-engineer-heroku-runtime-infrastructure-102 https://www.heroku.com/careers/software-engineer-heroku-runt...
- thomasbacklund 6y agoThanks for sharing, I'll have a peek :) Heroku is ACE
- kjjjjjjjjjjjjjj 6y agoThis is a cool idea regardless of being simple or complex. Who cares, its cool. Nice job
- thomasbacklund 6y agoThank you :)
- remram 6y agoThis has been bugging me for a while. Programmers love to reinvent the wheel. There a millions of make(1) clones, key-value stores, etc but I don't seem to see many projects (even toys) in the "declarative container runners" space. I think it's a shame. While Kubernetes is hopefully Very Good, it is complicated, and I have often wondered what other approaches would yield (e.g. more imperative ones, because writing admission controllers is not exactly easy). So I'm glad to see people playing around, though I don't know if this amount of bash is healthy or if 17,000 lines is simple.
- bfrog 6y agoThis or something like this is very much needed
- deathanatos 6y ago- No magic involved says the one with a single file 13k LoC shell script.
- thomasbacklund 6y agoYou are looking at the `./release/sns` file, which is the "compiled" release, it's like looking at the .exe (404 kb isn't that bad for an ".exe") The source files involved are smaller [1]. [1] https://github.com/simplenetes-io/simplenetes/tree/master/include https://github.com/simplenetes-io/simplenetes/tree/master/in...
- deathanatos 6y agoAh; since the title was "17k" lines, and the directory was named "includes", I presumed those were includes. So that would seem to say the title is also counting that compiled version, when in fact it is much simpler. But then also, why is the compiled version longer than the sum of the files in includes?
- thomasbacklund 6y agoI like the detailed questions :) The line count is a rough (overestimate) summoning the source of the three projects involved, simplenetes, simplenetesd and podc, and it also includes comments and blank lines. The compiled output pulls in some dependency modules which is reusable code (STRING, etc). So it's not clear where to draw the line :) Reason the compiled output gets bigger is because the compilation process `(make.sh)` includes compilations of actions, which I use when connecting over SSH agentless to manage the nodes. This tough part is handled by Space.sh [1] [1] https://github.com/space-sh https://github.com/space-sh
- p_m_c 6y agogreat job! looks like a fun project.
- john-tells-all 6y agoWait, he writes insane shell scripts, and his Twitter handle is BASH-lund? I'm in love! <3 :-D Related: Bocker, Docker rewritten in 100 lines of Bash https://github.com/p8952/bocker https://github.com/p8952/bocker
- theamk 6y agoI don’t care about Kubernetes, but someone might read this post and decide that it is a good idea to “simplify” an existing project by rewriting it in 17000 lines bash script. And some hapless person will be stuck maintaining and debugging it. It could be me, or you, your friend. You don’t want this to happen.
- arathore 6y ago> I don’t care about Kubernetes, but someone might read this post and decide that it is a good idea to “simplify” an existing project by rewriting it in 17000 lines bash script. I think the 17kloc would discourage that kind of thinking.
- exdsq 6y agoTo be honest if you’re in a position to implement a 17kloc shell script into your project, and you do, you deserve the lesson :)
- aristofun 6y agoIm personally not ever gonna use it as long as docker swarm is maintained. But thank you for bringing the world another tiny step closer to abandoning k8s and k8s (over-engineering) mentality. You’re doing so much for the world and for all the developers. Thank you!
- xvector 6y agoThis is so cool. Might be useful for self-hosting a bunch of things on my local network.
- keeganpoppen 6y agoi love this, and especially love how there are only a few things in the world that one could reasonably claim to simplify with "17k lines of shell script", and one of those is kubernetes. hilarious! (and i even see the value beyond the mere humor of the project's existence, which for me (and unlike all these salty k8s stan commenters*) would be more than enough justification on its own for creating the project in the first place). it's like both a useful project and performance art! * for the umpteenth time i daresay that hn needs to grow a sense of humor sometimes...
- voidfunc 6y agoLove it. Also love how triggered the very serious cloud native HN weenies are about this in the comments. Lighten up folks.
- coldtea 6y agoNo wireless, less space than a Nomad. Lame.
- Zenst 6y agoRewriting anything is the ultimate learning experience and to do a Kubernetes implementation in shell script, impressive.
- l0b0 6y agoUnsolicited review of sync.sh ahoy! The easy stuff: - Non-exported variables are by convention lower_case, while exported variables are UPPER_CASE. - Function names are by convention lower_case. - There's a "quite" signature string and variable; should it be "quiet"? - The lines like `local hosts=` can be simplified as `local hosts`. You can also join such lines, as with `export`, into `local foo bar baz …`. - `[[` is generally considered more reliable than `[` (there are a bunch of posts about this on Stack Overflow and Unix Stack Exchange). - Naming scripts .bash rather than .sh lets `shellcheck` inspect them without telling it which shell to verify against. You do check these files using `shellcheck`, right? - Variable names like `list` and `tuple` are unhelpful; what do they actually contain? Also, they should probably be actual arrays rather than a space-separated string to avoid relying on word splitting, and to allow entries with whitespace in them. The scary stuff: - All the string packing and unpacking also makes me nervous. That's not simpler than using JSON/YAML, it's just a different kind of complexity. - Reusing the same variable a bunch of times in the same function makes it really easy to end up with the wrong value at some point. Better to split stuff into more functions or rename the variables to make them single use. - `set -o errexit -o pipefail` would be good to have for safety. - `kill -9` anything[1] - Why are some of the variables inside functions not local? They effectively end up being globals, which makes for really difficult debugging. The good stuff: - Using local variables everywhere. - Descriptive error messages. - Returning early in case of errors. All in all, Bash is not a good language for any system of this size, no matter how diligently you program. The error handling isn't comparable to most mainstream languages, the data types are incredibly limited, and there's no native support of recursive languages like JSON. You've done a great job, but I'm afraid a system like this is doomed to failure from these facts alone. [1] https://mywiki.wooledge.org/ProcessManagement#I.27m_trying_to_kill_-9_my_job_but_blah_blah_blah...
- thomasbacklund 6y agoThanks for taking the time l0b0! A lot of good points. Coding in shell sure is a challenge, I try to avoid bashims where I can, that's why most scripts are .sh not .bash, since they run also with dash/ash (that's why preferring `[` over `[[`). The only Bash requirement we have is the `podc` (pod compiler) since it parses YAML docs, I couldn't pull that one off without the more powerful Bash. The code base as a whole absolutely needs testing and shellchecks all over the place to be labelled as mature in any sense. Our other large shell project is Space.sh [1] where go overboard on testing, each module is tested under a bunch of distributions. [2] [3] Next step would be to do the same for Simplenetes. Given that in shell that the only way to protect a variable from functions down the call stack accessing it is to redeclare/shadow it as "local" brings some murky waters. BUT, isn't it amazing what is actually possible to do with Shell?? For me Simplenetes in the long run is not about it being written in Shell, I'm perfectly happy rewriting it in Rust if we get traction on it. Simplenetes is primarily about having a simpler architecture of what a container cluster is and is not. I think many projects just get too complex because they want to fill every single use case out there, while the interesting part is saying no to things. [1] https://github.com/space-sh/space https://github.com/space-sh/space [2] https://github.com/space-sh/space/tree/master/test https://github.com/space-sh/space/tree/master/test [3] https://github.com/space-sh/space/blob/master/.github/workflows/main.yml https://github.com/space-sh/space/blob/master/.github/workfl...