11 ms·
Show HN: Kubernates in Node.js
This project was/is an attempt to recreate the core functionality of v1.29.1 Kubernetes in NodeJS, while being fully compatible with the kubectl CLI.
- speedgoose 2y agoWhy MongoDB?
- jauntywundrkind 2y agoKubernetes' API-server is a fairly small shim over etcd, another ReST data-store. MongoDB provides a similar web-ful data-store that probably greatly eases implementation, is low-impedance. Not that I would do the same, but I can understand to some degree.
- dilyevsky 2y agoIt kinda makes sense if you render objects as json (vanilla apiserver use protobufs on the wire except for crds). Im curious if mongodb supports CAS semantic properly - i heard transactions are still a pain there
- megapixel99 2y agoIt is the database I am most comfortable with, if this project were to ever blow up (which I highly doubt) I would want to add support for other databases.
- _akhe 2y agoWhy MongoDB? 1. Speed: NoSQL is way faster than SQL for most access 2. Ease: Dev time is lower as the data is kept in the way you'll use it, not in relational tables - skip the ORM, skip the db migrations, etc. 3. You need NoSQL at scale anyway: As the sole db of an app, NoSQL isn't ideal at scale because of data duplication and storage size. But when/if you need to add SQL you probably still keep the NoSQL too for the faster access, storing temp data, etc. Most companies use both SQL and NoSQL. Scenario: Imagine an API for a video game that fetches data for an Auction House type feature. If every single time your millions of players were running SQL queries, it would be an incredibly slow and expensive feature. Much better to have that data cached in a NoSQL layer so people can access it quickly/concurrently, and only periodically hit SQL to populate out NoSQL caches. Could also use an ORM with SQL, or another in-memory solution, but NoSQL is nice if there are many nodes or maybe due to your cloud setup you can't run it in memory. Really is not a "SQL vs NoSQL" you use both for different things. To me at this point it doesn't matter if someone "starts with" SQL or NoSQL, in almost all cases I would use both eventually. For hobby projects, even a slight preference toward NoSQL for ease of use and data flexibility, but getting into subjective territory. Sequelize is just as cool/easy
- sureglymop 2y ago-1: Not open source, SSPL licensed.
- _akhe 2y agoThey're also backed by the CIA lol. To your point, I should have said "NoSQL" not "MongoDB" per se. I took the question to mean "Why not SQL" but they could very well be asking "Why not another NoSQL"
- speedgoose 2y agoI am not sure about the speed actually. I wouldn't bet on a MongoDB against a PostGreSQL or even SQLite with JSONB fields and some indexes. I find NoSQL document databases harder to maintain over time, and you can always have tables with JSON columns. But moreover, my question was about MongoDB, not about SQL vs NoSQL. And it has been answered, the developer was familiar with it.
- _akhe 2y agoNoSQL is faster than SQL for access, talking like 10x faster. Which makes sense if you think about what it is. Very true with maintainability - it's ridiculous to use a NoSQL as your main db eventually because of duplicate data and the very large file storage. You'd use neither of them with certain math or AI (they use vector dbs optimized for array data) - different tools/jobs.
- speedgoose 2y agoDo you have a source about the 10x speed gain for NoSQL? It doesn’t really make sense to me and the benchmarks I found say it’s about the same, which makes sense to me.
- JohnMakin 2y agoNice… now let’s do it in bash
- thesandlord 2y agohttps://news.ycombinator.com/item?id=26661223 https://news.ycombinator.com/item?id=26661223
- megapixel99 2y agoCool!
- JohnMakin 2y agoI knew in my heart as I made the comment it had been done. Amazing
- fire_lake 2y ago[flagged]
- joncp 2y agoCheekily forging forward with Atwood's law! I love it!
- tjungblut 2y agoThis seems like a small CRUD app to replace apiserver/etcd with a nodejs app and mongodb.
- deleted 2y ago[deleted]
- megapixel99 2y agoYep!
- MrBuddyCasino 2y agoThis project evokes feelings, so it must be a good piece of art. They should have called it Kubernode.js for maximum impact.
- mdaniel 2y agodepending on what, exactly "bash commands don't work" <https://github.com/Megapixel99/nodejs-k8s/blob/master/functions.js#L69 https://github.com/Megapixel99/nodejs-k8s/blob/master/functi...> is talking about, but a thing that bites A LOT of folks when dealing with command: [] (and its args:[] friend) is that they are exec style, not "sh -c" style as one might experience with a Dockerfile RUN command. I think Dockerfile's RUN [""] syntax is also exec style, but I don't use it much because it's horrifically verbose As a concrete example, command: ["bash -c uptime"] will not work because there is no such command '/usr/bin/bash -c uptime' and the actual form is command: ["bash", "-c", "uptime"] Related, it often bites people that exec does no shell interpolation, neither resolving variables nor redirection, so command: ["doit", ">/dev/null"] will not shake out, nor will command: ["echo", "$HOSTNAME"] (although there is a nuance to that since kubernetes itself will actually resolve any env:[] references in a (regrettably horrible) syntax of command: ["echo", "$(USERNAME)"], env: [{name: USERNAME, value: megapixel99}] All in all, congratulations on your Show HN!
- thenipper 2y agoThis bites me all the time. It really shouldn't, as I'm always like: "man i'm an idiot". But inevitably I make this mistake and lose time over it.
- pavlov 2y agoReally a feature though. No quote issues, no shell interpolation, explicit variable resolution in the application’s scope — for most scripts I much prefer this as the default behavior.
- megapixel99 2y agoOff the top of my head I do not remember what the issue was (the changes to the code are from a month ago). Looking at the code now, `dockerExec` <https://github.com/Megapixel99/nodejs-k8s/blame/master/functions.js#L72 https://github.com/Megapixel99/nodejs-k8s/blame/master/funct...> uses `child_process` so that may have something to do with it... however, as I have said in other replies, I just wanted to learn more about the inner workings of k8s and I personally learn best when I create (or recreate) something, I doubt this project will take off, but if it does I will try to fix that when the time comes. Regardless, thank you for the feedback.
- hu3 2y agonit: typo in title Kubernates -> Kubernetes
- corymacd 2y ago[flagged]
- rc_mob 2y agoBut why???
- nicce 2y agoMad man. Even on plain JavaScript.
- deleted 2y ago[deleted]
- megapixel99 2y agoI wanted to learn more about the inner workings of k8s and I personally learn best when I create (or recreate) something.
- remram 2y agoI would really welcome more experimentation in the cluster process management space. Right now it's Kubernetes, Nomad, or solutions embedded into applications (e.g. cephadm). It's a shame that this is an exact copy in a different language. Kubernetes is nice but I can't wait to see what the next generation of tools will look like.
- vbezhenar 2y agoThere's also docker swarm.
- mountainriver 2y agoDiscontinued
- nicce 2y ago"Do not confuse Docker Swarm mode with Docker Classic Swarm which is no longer actively developed." https://docs.docker.com/engine/swarm/ https://docs.docker.com/engine/swarm/
- sph 2y agoDocker Swarm mode has been in maintenance mode for at least 5 years now. It's way to late to bet the house on a product that exists pretty much to support people that have bet on it, not to completely pull the rug under their feet. I introduced Docker Swarm at work in 2018 and already there were rumours that since Kubernetes had won it was just a matter of time until Docker Swarm was fully abandoned.
- robertlagrant 2y agoWhat's strange is Docker Compose is very slowly resurging. I almost feel like that with a few more primitves (e.g. nodes with tags) and you'd have a much simpler Kubernetes. Which a lot of people might like.
- mountainriver 2y ago[flagged]
- williamdclt 2y agoNo need to be so aggressive. Seems more likely than not that the goal is _not_ to compete with k8s. I’d guess learning or having fun
- ssahoo 2y agoI disagree. Someone just tried samething differently. Go isn't bad, so is nodejs.
- peddling-brink 2y agoYes but why would someone do it in a way that’s not interesting to me personally? Bad form for sure. /s
- ssahoo 2y agoAlso if this was Rust. This would be on the frontpage :)
- mountainriver 2y agoIt's been tried, a lot.. The complexity of Rust doesn't really pay off for this type of problem
- megapixel99 2y agoThis might be a fun way to learn Rust
- megapixel99 2y agoI wanted to learn more about the inner workings of k8s and I personally learn best when I create (or recreate) something. I doubt this will ever contend with k8s and I am okay if it does not.
- chrisweekly 2y agoMods: typo in title "Kubernates" -> Kubernetes
- deleted 2y ago[deleted]
- marsian23 2y ago[dead]
- majestic5762 2y ago[flagged]
- megapixel99 2y agoI do not think it was a waste, I got to learn more about k8s, I personally learn best when I create (or recreate) stuff.
- peddling-brink 2y ago[flagged]
- sgarland 2y ago[flagged]
- megapixel99 2y agoIt is definitely not production ready, at this time.
- deleted 2y ago[deleted]
- paulddraper 2y agoKubernetes in Node.js: Five comments about how stupid this is. Kubernetes in Rust: Straight to the top
- _akhe 2y agoHaha so true. I noticed there's a part of HN that hates JavaScript and NoSQL. Usually for bad reasons like a false dichotomy between SQL & NoSQL (you usually want both) or some performance comment about JS when they're using like a Rails, Django, or Laravel (some old/slow cult framework that doesn't hold a candle to Node). Feels like Rust found its place with Next.js' Turbopack (basically Webpack but in Rust), and is good for use cases like that. I think reinventing wheels in other languages makes sense when they bring obvious value like performance or some convenience - and this Show HN fits that description. Like someone else said - it might've been even cooler as not a re-write but a new approach in Node. I would love to see Node eat more of Linux personally. To me JavaScript is like the "English" of programming (C is "Latin"?), with JSON being the standard transfer format and the browser being a major (if not the major) platform. Not to mention it's by far the most performant of the dynamic web languages (compared with PHP, Ruby, Python).
- megapixel99 2y agoWhile I am not opposed to creating something that could be a competitor I wanted to learn how k8s worked. I suspect I would be hesitant to create the specs though.
- _akhe 2y agoIt's an awesome way to learn :) Well either way, cool project
- unixfox 2y agoSimilar project but in golang: https://github.com/portainer/k2d https://github.com/portainer/k2d