652 points · by cdoxsey · 8y ago · 329 comments
Having used it, there's a sizeable amount of further work needed which the article doesn't mention (e.g. learning how to use the pretty confusing google interface, finding the right logs and using their tools). So the overhead is really huge.
Furthermore, the whole system is slow. Want to run a SQL query against your postgres? You need to use a google cloud command that changes the firewall and ssh's you in on the machine... and this takes a couple of minutes, just enough to make me desist unless I _really_ need to run that query. Abysmal.
Finally, and this is a pet peeve against many advocacy blog posts, they just show you the happy path! Sure, _in the best of cases_ you just edit a file. In a more realistic case, you'll be stuck with a remote management system which is incredibly rich but also a really steep learning curve. Your setup is not performant? Good luck. Need to tweak or fine tune? Again, best of luck.
We've tried to adopt k8s 3-4 times at work and every single time productivity dropped significantly without having significant benefits over normal provisioning of machines. {Edit: this does not mean k8s is bad, but rather that we are probably not the right use case for it!}
...which in turn is usually significantly slower than building your own home server (but that's another story!)
I know a bio scientist who spent two months working on containers and Docker and what not, for what are essentially independent shell scripts that are best run as batch jobs. I spoke with him in length, and he realized at the end of the day that what he really needed was better understanding of standard *nix processes and not containers...
- automated ssl
- centralized logging
- super easy scaling up and down (going from 1 instance to 2 instance is a headache manually)
- centralized auth (have a service which doesnt have built in auth?)
- super easy recovery (containers recreated/volumes attached automatically/apps just work unless you have db type of application which shouldn't be just restarted, which is rare)
- Smooth CI/CD (gogs/jenkins/private docker image repository)
As for the "execute query" example, why is it such a headache ? I just "kubectl ssh <container>" and I am in.
> I know a bio scientist who spent
Super obscure example. Kubernetes is definitely not for non-tech people. And I didn't pick k8s overnight. Spent a year doing playful POCs before deploying in a production environment.
If the only thing thats stopping you from using k8s is the learning curve, I suggest you to go ahead and learn it. Its a huge boon.
I question myself whether it is necessary to hide my operational needs behind a behemoth of complexity like Kubernetes. The list of conveniences you mentioned sounds like magic you get from Kubernetes. What if there is a problem with any of them?
Missing logs?
Inappropriate scaling?
Auth failures? or worse, failure of Auth system?
Easy recovery? what if there were failures to checkpoint/backup/snapshot containers?
CI/CD is good regardless of whether you use Kubernetes or not.
EDIT: The question is, if you have any of these problems, why is it better to get your head into how Kubernetes deals with those operations & tools rather than dealing with well-defined unix tools that specialise in doing these jobs. syslog instead of however Kubernetes gathers the logs, reading FreeIPA docs instead of Kubernetes auth system logs?
My point is, that to deal with all of the conveniences you mentioned, you need to know their details anyway. Why rely on Kubernetes abstraction if there is no such need? (I'm not trying to being snarky. I'm genuinely curious why you think it is a good idea. If you convince me otherwise, perhaps I would start adopting Kubernetes as well.)
I run my cluster(I'm a sysadmin) with
a couple of OpenBSD server that runs redundant DNS and DHCP.
a CentOS 7 box that runs FreeIPA as central Auth.
an OpenBSD server that acts as public facing SSH server.
about 20 nodes, all provisioned using kickstart files, and then configured using Ansible. They run databases, web servers, batch jobs, Git, etc.
A single server that runs ELK stack for log analysis.
A single server that runs Prometheus for quick aggregated monitoring.
Do you think I should switch over to Kubernetes for any benefits?
It's slow as hell.
> I had an excellent time working with kubernetes
I'm happy for you, seriously, and I'm not claiming general validity of my experience. What I am disputing is the blog post (which does claim general validity).
Source: I am also using Kubernetes in production, migrating off it soon.
> Spent a year
> go ahead and learn it. Its a huge boon.
for green field deployment with a 1 year R&D budget for devops, sure K8s is great choice perhaps, but for the rest of us (even in tech)?
I mean, sure, kubernetes _is_ complex. But it's complex in the way that using Rails is more complex than pure Ruby. It's fine when you're playing, or you have a weird subset of problems where you don't care if someone runs or not, but as soon as you deal with the problems of HA, DR, live deployments, secret management, sharing servers, working in a team, etc then if you're solving these issues with ansible and terraform, you're probably just inventing something as complex, and worse, bespoke to your problem.
At the end of the day, once you've learned to use kube, it's probably no worse than any other configuration as code based system, and the question is which of us should be learning it and when, and which of us should just be using higher levels of abstractions like gitlabs autodevops.
Now, indeed, if you're just hacking and you have no need for a CI and CD pipeline, or reproducibility, etc, then sure, it's probably not the time to learn a hosting framework, but once you do know it, you're free to make an informed opinion on your problem.
Personally, I sell kube a lot, but I tend to work for orgs that have several development teams and several apps, and bringing them to a platform seems like a good idea. The question is, should I also put a startup on GKE, or should I do something bespoke where they can't hire another contractor to take over as easily? Personally, I'd go GKE.
GKE takes a lot of the load off by making it Google's problem. The possible downside (which may or may not matter depending on use case) is that you're tied to what Google's control plane provides.
So if you want a shiney admission controller, you're out of luck unless they support it.
But for basic workloads, it's likely to work well and their management solves a lot of vanilla k8s pain points.
One of it's main functionalities is to eliminate the complexities of getting going with automated software delivery by automatically setting up the pipeline and necessary integrations, freeing up yourself to focus on the culture part. That means everyone can skip the manual work of configuration, and focus on the creative and human aspects of software creation.
Here's the doc with more info about it https://docs.gitlab.com/ee/topics/autodevops/
https://adamdrake.com/command-line-tools-can-be-235x-faster-...
Over the years you easily end up with a pile of these projects, which want to keep running mostly for fun and therefore want to minimize the associated fixed costs. Using containers may help in keeping the herd manageable so that you can, for example, move everything to some other hosting provider.
Interestingly, while the author compares k8s to an SQL database, they actually do not deploy a DB. It's all fun an giggles until you deploy a DB.
Or, as worst, the shortcut to understanding the underlying tech. But, isn't that the point of abstraction?
and the people who, when they show up at their Google interview, nail the part about scaling. Not that Google ever asked me how to scale a project, but it doesn't hurt learning things just for the sake of learning.
> They're Google wannabies that thinks in Google's scale but forget that it is utterly unnecessary in their case.
Meaning they _unnecessarily_ think in Google's scale when there is no need for it.
Having interviewed many tenths of engineers at Amazon - no, not really.
So, what happened almost every time is that the business unknowingly pivoted into innovating on PaaS, because Docker/Kubernetes was only the first step. After that, you had to figure out the best approach to CI, how to set up your deploy pipelines across multiple environments, how to replicate what you were used to seeing with Heroku, etc.
And of course the cost balloons at that stage because your cheap 3 node setup ends up exposing half a dozen load balancers that each cost money, so you start to think about hosting Traefik or nginx-ingress-controller so you can manage load balancing yourself and save some money, and because it's so easy to add more services once you know how, you start wanting to self-host all the things.
Meanwhile your startup hasn't even launched to the public yet and the sunk cost fallacy has fully embedded itself in the team mentality: they've just put months of time and effort into setting up the perfect K8S/Docker architecture and workflow, that now requires actual devops experience to maintain, and you can't push back on it because it's all about scaling when things go live, and self-hosting, and how convenient it all is.
Except, you know, that's 3-6 months of runway down the drain because leadership didn't shift the focus back to an MVP and let the fantasy continue. And it would be hard to justify anything like Kubernetes for pushing an MVP out of the door; that's what Heroku and cheap Digital Ocean boxes are for.
Exactly. I was following along with the article until he mentioned that startups are doing this. Using k8s at a startup (especially a startup building an MVP) is just like using microservices. It is a disservice to the business by technologists.
Building the monolith on heroku will get you to market faster.
Yagni. (Until you do, and thrn by all means pay off that technical debt.)
https://github.com/githubsaturn/captainduckduck
It made it so much easier to deploy new changes (just `captainduckduck deploy` and done). We also use minio.io (open-source S3) and are extremely productive with those tools.
It's perfect for web agencies. It's not sophisticated enough for k8s' use case, but it's extremely easy to use (you can just add nodes and it will restart containers automatically [1]).
[1]: https://captainduckduck.com/docs/app-scaling-and-cluster.htm...
D) Disable Firewall Some server providers have strict firewall settings. To disable firewall on Ubuntu: ufw disable
WTF?
Getting Started section is aimed for beginners. You surely don't have to disable firewalls entirely. There's a section in the docs outlining the ports that are being used by Captain.
I ended up just running a single Digital Ocean droplet with Traefik as a loadbalancer/entry point, and then running each of my projects with docker-compose. (And building each project with Docker)
With Traefik I can set up reverse proxying for each project just by adding a few labels to its docker containers, and Traefik manages LetsEncrypt for me.
Dokku has no support for clustering, but it's amazingly simple to set up and start deploying apps. (Digital Ocean has a pre-built and up-to-date image ready to go.) I like it for the heroku-style buildpack deployment, although it also has dockerfile-based deployment. Great little system for low-risk projects.
We need to go back and understand the problem we’re trying to solve, and for 99% of smallish companies and projects this is not container orchestration or hardware resource abstraction.
And most often all those app or two are doing is converting JSON to SQL and SQL to JSON actually. And PostgREST would be pretty much enough for that.
Admittedly, operation via Rancher comes with its own complexities: setting up security groups and IAM roles. These are documented of course, but as you say: minimum effort remains non-trivial.
I'll grant that there can be headaches that I don't really see anymore because I was deeply immersed in it for a while. But running a linux server by itself was hard till I learned that too.
Performance is a subtler point, not sure I follow what you're trying to say there. Container overhead? At least in my experience gke seemed responsive, and deployments settled pretty quick.
Tweaking is usually a strong point of k8s. Just reapply... so I'm probably misunderstanding what you were getting at here.
Kubernetes needs to improve their accessibility to newcomers but the happy path isn't unheard, for simple stateless apps it mostly just works. And when it doesn't I can usually kubectl log and kubectl delete pod my way to a solution and there are docs and stack overflow to help.
Not perfect but I was surprised it worked as well as it did.
Best solution is Cloud SQL Proxy: https://cloud.google.com/sql/docs/postgres/sql-proxy
We thought about k8s a couple of times but it always looked too over complicated and no gain compared to our use of DCOS
That said, once you learn all of these k8s concepts and mechanisms, and probably script nearly all of them, they all become like breathing and don't really take much time.
I frankly now am at the point where it is faster to spin up a small project on k8s than it would be to do so with the cloud providers PaaS platform.
Properly hosting custom apps on the web in a resilient way isn't easy. This being the case, it seems an error to interpret the thoroughness of the article as a signal that the proposed solution or situation is unreasonably complex.
I'll take detailed and exhaustive over sparse and hand-wavy any day!
Kubernetes certainly has a learning curve, just like most worthwhile things in life.
That being said, there are certainly existing solutions for doing that, for cheap or even free tiers with less effort - Heroku, Google App Engine, etc.
It can be rough to manage Kubernetes when you just want to focus on your app. I was having that same problem when building side projects and focused on building a platform to deploy dockerfiles on a managed Kubernetes instance.
> Edit: this does not mean k8s is bad, but rather that we are probably not the right use case for it!
Or it could mean you're not the right people for it?
Do you have a dedicated individual or team that represents infrastructure engineering? Are you a team of developers trying to play the Ops game? More often than not people/companies that struggle to get K8s going or use it are a team of developers who's expertise is code and not infrastructure/automation.
K8s is hard when done from scratch (there's a book and a video course about that by THE K8s guy.) It's not hard when you use Kops, Tectonic (discontinued, I believe), EKS, or one of the other managed services. Implementing a YAML file and launching it isn't hard. Also, you don't have to understand it inside out; you only have to understand how-to use it. Can you tell me how every component in your microwave works or do you just get on with cooking your food?
And to say you're not the use case for it - that's highly unlikely. I mean, it's possible, but it's unlikely. Your work loads and software solutions would have to be highly unique and or specialised because hey, it's not like Google's setup is simple, right?
Great idea! We could call that team 'Operations' and they would do all that stuff so developers don't have to!
I'm skipping job postings which require k8s. It just tells me they're not competent, falling for the hype. For AWS, ECS is way simpler and is a fully featured orchestration tool. I had an interview today, where I tried to educate why simple is better, and why they don't need k8s. No luck :)
If you're doing individual development, however, it's quite likely that you're also doing development of the database, and need to do ad-hoc data analysis before you include those queries in that app.
"Then don't do it. It only shows you're an idiot anyway."
Not a good answer.
1. Something that makes it easy to run the application(s) you're working on locally... 2. ...but have it interact with services in a local kubernetes cluster easily. 3. Something that makes your entire development environment effectively immutable, read-from-files the same way as the immutable infrastructure we're talking so much about. 4. Something that gives you a good start to running in production, so the first day of bringing your service up isn't a mess of trying to find/remember what environment variables/config options to set. 5. Something that's one tool, instead of a mixture of `minikube`, `kubectl`, `docker`, `draft`, and `telepresence`. 6. Something that's opinionated, and follows "convention over configuration", with conventions that make for the best future designs.
Basically, we need something with a Rails-like impact but in the Kubernetes ecosystem.
Swarm is such a pleasant and easy alternative that comes out of the box with Docker, does 90% of what Kubernetes does, and does 100% of what anyone with less than 50 servers needs. The learning curve is also an order of magnitude easier.
https://forums.docker.com/t/is-there-a-built-in-kubernetes-i...
https://blog.docker.com/2018/07/kubernetes-is-now-available-...
I just installed Docker via package manager so I guess I never really learned about the organization's offerings in total and didn't know which product I had (CE for Linux). Is there a more up-to-date/better practice for using Docker CE with k8s than this guide dated March[0] using Minikube[1]?
[0]: https://blog.sourcerer.io/a-kubernetes-quick-start-for-peopl... [1]: https://github.com/kubernetes/minikube
As for an app deployment tool I've had good success with Helm. It allows you to define all the services, app, variables, etc. that your app needs. Though the templates do seem to be a bit convoluted and hard to read at times if you aren't careful.
What I want is a Maven for Kubernetes. With transitive dependencies, strong conventions, injection of parameters etc.
The templating stuff feels very...unstructured to me. Every Chart is slightly different.
2. Haven't tried this, but I'm aware of it - does this address your point here ? https://www.telepresence.io/
3. Something like this? https://github.com/rycus86/docker-pycharm I agree that this could be very cool if further developed.
I agree that we'll start to see deeper integration across the development environment though, as more dev-hours are spent on building up the toolchain.
# Local development / testing
I use "minikube" for developing and testing each service locally. I use a micro service architecture in which each service can be tested in isolation. If all tests pass, I create a Helm Chart with a new version for the service and push it to a private Helm Repo. This allows for fast dev/test cycles.
These are the tasks that I run from a "build" script:
* install: Install the service in your minikube cluster
* delete: Delete the service from your minikube cluster
* build: Build all artifacts, docker images, helm charts, etc.
* test: Restart pods in minikube cluster and run tests.
* deploy: Push Helm Chart / Docker images to private registry.
This fits in a 200 LOC Python script. The script relies on a library though, which contains most of the code that does the heavy lifting. I use that lib for for all micro-services which I deploy to k8s.
# Testing in a dev cluster
If local testing succeeds, I proceed testing the service in a dev cluster. The dev cluster is a (temporary) clone of the production cluster, running services with a domain-prefix (e.g. dev123.foo.com, dev-peter.foo.com). You can clone data from the production cluster via volume snapshots if you need. If you have multiple people in your org, each person could spawn their own dev clusters e.g. dev-peter.foo.com, dev-sarah.foo.com.
I install the new version of the micro-service in the dev-cluster via `helm install` and start testing.
These are the steps that need automation for cloning the prod cluster:
* Register nodes and spawn clean k8s cluster.
* Create prefixed subdomains and link them to the k8s master.
* Create new storage volumes or clone those from the production cluster or somewhere else.
* Update the domains and the volume IDs and run all cluster configs.
I haven't automated all of these steps, since I don't need to spawn new dev clusters too often. It takes about 20 minutes to clone an entire cluster, including 10 minutes of waiting for the nodes to come up. I'm going to automate most of this soon.
# Deploy in prod cluster
If the above tests pass I run `helm upgrade` for the service in the production cluster.
This works really well.
No worries :) I use digitalocean for the nodes, storage volumes, etc. and namecheap to register the domains.
At namecheap I simply use the "Custom DNS" option for each domain to apply the digitalocean nameservers. I only have to do this once for every domain.
After that is done, I can use the digitalocean API, the "doctl" tool or the web-interface to handle domain records, subdomains, etc.
In order to connect a domain/subdomain to a k8s cluster, I point the domain/subdomain to the master node of a cluster. In each k8s cluster I use an "ingress" (nginx) [0] to handle the incoming traffic (directing each request to the right service/pod. You can think of it as a loadbalancer that runs within your cluster).
This strategy would work on other cloud providers (Azure, gcloud, etc) as well, I guess.
I was really hyped about Azure Dev Spaces (https://docs.microsoft.com/en-us/azure/dev-spaces/), but it's Azure only, even though it sounds like something that should work on any k8 cluster..
One vagrant VM allows you to make assumptions about what software is installed on a dev desktop which is especially useful if you're writing documentation. Getting into the Vagrant VM from various OSes is the main problem but once you're in... Then you can install container software and teach others how to work in docker given one assumed OS.
Since Vagrant and containers encourage some form of infrastructure/documentation as code, then more experienced developers can read through what goes into the Vagrant set up and replicate on their native OS if they prefer. As someone writing documentation, I can forget about those more experienced devs and just write to one OS.
Once you have documentation that you can guarantee works when using container software, much of the headache can be swept under the rug for more junior engineers which I think is the krux of the issue for others when using k8.
I'd very much like a Ruby/Python/Rust of cloud infrastructure to come along and clean up this mess.
Those "always free" f1 micros have 600mb of RAM, do not have SSDs and according to some tests[0] you only get 20% of 1 vCPU. There's also some pretty severe write limitations.
That's a really big difference vs DO's 1gb of RAM, SSD and 100% of 1 vCPU. The performance difference alone with SSD vs no-SSD is massive, especially on a database and while most web apps aren't CPU bound, 20% of 1 vCPU is bound to run into problems beyond a simple hello world that you set up in your example.
Also what happens if your app doesn't even fit in that 600mb? On DO you could get a 600mb app + 100mb OS + 150mb DB + whatever else running on that $5/month server since it has 1gb of ram.
In a real world application I wouldn't be surprised if that cluster performs way worse than a single DO server in the $5/month range. In some cases your app wouldn't even be able to run.
[0]: https://www.opsdash.com/blog/google-cloud-f1-micro.html
Of course, that's mostly for running Jobs; a single node + preemptible with a production app is not a great idea.
I‘m running a full-featured three node cluster for less than $10/month on Hetzner Cloud. This kind of setup requires a little more effort, but it can be fully automated and you learn a couple of things about Kubernetes on the way. I published and maintain this guide[1], including provisioning using Terraform and a bunch of example manifests to get you started.
Any attacker who was able to get on to the pod network (e.g. if there's a vulnerability in one of the apps running on the cluster) could hit the etcd endpoint and dump the contents of the database, which generally includes sensitive information like k8s secrets.
Edit: I think this was you.
It was curiosity that turned my non-existent infrastructure into having a cheap, small-scale Kubernetes cluster ready for my shenanigans.
My tiny cluster gives me great freedom. Setup is fully automated. When a new k8s release comes around, I simply tear down my old cluster and ramp up a new one in mere minutes. If I want to deploy a service or application, all I need to do is to write a couple of manifests and roll all the moving parts out. Hassle-free - no SSH, no additional costs, no accounts, no 3rd-party services, persistent storage and TLS certificates out of the box.
Currently, a Unifi controller is the only long-term resident on my cluster; other services and projects come and go. Besides that, the following agents are deployed as Kubernetes pods: Datadog (free tier) for basic monitoring & alerting and Papertrail ($5-10/month) which acts as a centralized log sink for all my hosts, NAS and networking gear.
That's a quote from the article. The thought that someone with that mindset is responsible for anything more than a network-connected waffle iron is terrifying. This article advocates for willful ignorance of Unix/Linux, because you don't need any of those things if you know k8s.
That said, k8s is nice for some things. I admin a large deployment at work, and it's relatively painless for developers to be productive with. One of the reasons for that stability isn't k8s itself though - it's the legion of seasoned Unix/Linux pros working alongside me. The reason "it just works" is because under the covers, there are a whole lot of us doing all the boring stuff to hundreds of physical hosts.
If one of my devs wants to deploy a rails app I don't expect them to suddenly be a sysadmin or network engineer or infosec expert. I expect their application to be well written but the rest of the stack is up to ops.
Although I guess for personal projects it could actually work as long as the load is low enough and when there is no data involved that needs to be protected. ;)
All the arguments stem from the assumption that personal projects have the same uptime, scaling, and deployment requirements as some large commercial site. Some personal projects might but I'd argue most of those are really commercial in the sense that you're developing them for a portfolio or the like. They're not personal.
It makes sense to use business tools like kubernetes when you're making a demo business site. It doesn't make it a good platform for personal projects.
The best platform for those is hosting from home on a single computer, for free, with total control. ie, personal.
If you include running my own blog/mail/XMPP/matrix servers in "personal projects", then I would love to have perfect uptime.
Additionally, being able to reuse high quality helm charts here just makes things simple instead of having one set of instructions for "personal" use and one set of instructions for everyone else.
I've been running my personal website from home for almost 2 decades on Comcast and I've never had a problem. I can always access my sites when I'm not home. And additionally I can access all my other media. Even when I only had a megabit or so of upload it was more than enough. Downtimes have been very rare and usually only for a couple hours once per year in the middle of local night.
That said, of course you can't run a mailserver from home. For that, because of residential IP blacklists, I run from a rented VPS. In fact I run webservers on them too, but only for hosting large files. It's easier to just cp whatever ~/www than always have to upload things.
What I can get commercially? yes. the best available to me is 14/1 ADSL. And I'm in a dense upscale urban area. As far as I understand it, this is relatively common situation worldwide.
> If it is I think you have bigger problems you should address before working on personal projects.
What I have done is set up my own wireless link using Ubiquiti dishes to a nearby location with a 100mbps net connection. But this is hugely unusual: both to have building access to add a dish to my apartment building roof, and to have a Line-of-sight location to connect to, that also lets me set up a dish on their roof, and connect it to their network.
> I can always access my sites when I'm not home.
I used to try and do that (subject to internet quality), but then I realised I was spending $50 a month on power bills for leaving my desktop powered on 24/7. The cost of a $5 dollar VPS is far less.
What about work life balance? (yes, it's a personal project, but still)
Sometimes the personal project is a website: it has progress tracking that I want to check on.
Sometimes the personal project is for home automation, I want to check the status of it or tell my heater to turn on remotely.
Or just get a cheap DO box. You can run quite a lot one, and have it always accessible, on the internet, etc...
Kubernetes is a complicated, complex beast. Even on managed K8s on a cloud provider, you still need to learn a lot of stuff that has absolutely nothing to do with what you intend to accomplish (unless your personal project is learning to use K8s.
Most of my personal projects get deployed on Google's App Engine. It's easy, simple and unbelievably cheap.
There was a fantastic presentation at the last IO about riding as much as you can on free tiers:
Kubernetes was never intended as a system for hobbyists, but for bringing more users onto google cloud. At that it is incredibly successful. But in exchange a lot of other stuff it does really badly.
It is much better to start with a single-node system in mind that expects getting more nodes at some point and develop from there. This will bring in a lot of hobbyists and really carves out how to solve the developer story. Then this will grow automatically with the size of popular projects building on it.
That said, of course it's nice if people invest energy into finding other usecases for k8s as well. But it shouldn't be the community's main effort.
If you further use spot instances (the equivalent here to "preemptible") you can save a ton more.
The real savings (or $7 per month) is that on GCE you won't need to run your control server. GCE does that for you for free.
Edit: now another issue here is (and I have no idea if this is true for GCE like it is AWS). t2 instances will throttle you if you use too much CPU which can be an issue when running a lot of containers.
Google Cloud refused to refund or provide any guide as to how to entirely disable / purge StackDriver, so I'm back on AWS and won't be recommending anyone move to GKE any time soon (it's extremely extremely easy to suddenly more than 100x your bill...)
With my hand-built Kube on AWS I have 15gb assigned for my ELK logging cluster, and it costs me nothing because it falls under the free tier. Looking forward to trying out Digital Ocean's product next!
kube-system is taking about 730 mCPU of the node's 2000 mCPU.
The issue is that the kube-system is deployed on each node of the pool so (tell me if I misunderstood/misconfigured something). If you have a pool of 3 nodes which have 1 vCPU each, with kube-system taking approximately 700 mCPU on each you have only 300 * 3 = 900 mCPU allocatable.
If you have any tips on how I could reduce the costs of my personal projects I'm listening !
https://github.com/kubernetes/kubernetes/pull/67504
Still not sure if these are the configuration files that GKE uses behind the scenes, but the author is a Google employee.
For logging, you could use FluentBit which is more lightweight: https://docs.fluentbit.io/manual/output/stackdriver
Most of the CPU usage is kube-dns, which I think requires much less CPU if you make few internal network connections.
Not the right choice for all apps, obviously, but something to compare this setup to.
I'd like to use containers, partially because it gives an easily reproducible environment for running locally.
For such a small setup, what's the recommended way of handling this, such that I get automatic failover and can easily do zero-downtime updates?
I did look a bit into k8s, but quickly came to the conclusion that it's far too complex for this.
Oh, I'm also constrained to using the Azure cloud, if it matters.
Kubernetes is great, but Convox is way easier to set up. It's much closer to having Heroku in your own AWS account. It also leverages a lot of AWS services (ECS, RDS, etc.) instead of re-inventing the wheel. The only downside is that it only supports AWS.
I'd recommend Convox for personal projects, but it can be a bit expensive because you have to run a minimum of 3 EC2 instances.
I really like being able to push a completely new container whenever I push to master - this is done with CircleCI, which builds the image, pushes to Docker Hub, and just does the kubectl apply. I couldn't think of any other way to do it that wouldn't result in some downtime if I had to change or upgrade packages.
I wrote about it here a bit: https://hackernoon.com/lessons-learned-from-moving-my-side-p...
https://github.com/helm/helm ?
You push the new version of your app as a helm chart to your helm repo and then run:
helm upgrade my-appIn general I really don't think k8s is the monster people make it out to be. I did all this on the side over the course of a few weeks, a few hours here and there. I know I'm only scratching the surface of what is possible, but everything just works fine, and my .yaml files are pretty self-explanatory.
So, fellow hn'ians. My requirements ATM are quite simple: Submit code via git, run automated test, if all good, put the files into the live system. Pull-requests are must and everything must be self-hosted because cloud is just another persons computer. Code is written in python. What would you recommend? Edit: grammar.
GitLab CI/CD documentation can be found at the link that I shared, and it can build and deploy truly all kinds of software, and does not require k8s.
Our documentation on getting started with CI/CD is here: https://docs.gitlab.com/ee/ci/
AutoDevOps has a good example of GitLab licensing that frustrates me. It's the "Support for multiple Kubernetes clusters" feature. Running development and production in separate environments seems like a best practice. A mistake that brings down a cluster is really the type of thing you'd want to catch in development or testing, right? However, IMO, if you're a small developer using Core or Starter, GitLab is forcing you to do something subpar by using the same cluster for development and production.
I think "Environment-specific variables" is the same situation where Core and Starter users are lead into bad practices. For example, ASP.NET Core uses ASPNETCORE_ENVIRONMENT which (unfortunately) defaults to "production". The lack of environment specific varaibles means people will put that in the job config of .gitlab-ci.yml.
deploy_dev:
variables:
ASPNETCORE_ENVIRONMENT: "Development"
It also means protected pipelines will be given all the variables needed for deploying to all environments. Ex: DEVELOPMENT_DB,PRODUCTION_DB. I'm sure you can see where this is going, but, if you're using something like EF Core migrations, all it takes is for someone to mess up the (ex:) "deploy_dev" job's ASPNETCORE_ENVIRONMENT variable on protected branch and the CI build is going to end up in "production" mode with access to all the variables needed to break a production DB.GitLab Flow has a diagram showing master, which is a protected branch, deploying to staging with another branch used for production. I like that workflow, but it means all deployable branches end up being protected branches (I think that's the intent ?) which means production credentials end up exposed everywhere but feature branches.
I don't know how protected variables interact with environment specific variables, but, ideally, I'd want to have ASPNETCORE_ENVIRONMENT be an environment specific variable and PRODUCTION_DB be both environment specific AND protected. The more safeguards the better and navigating into the "production" environment variables page is a good way for me to get into "be super careful" mode.
I think small developers will tend to be the ones where people merge their own changes, so they're especially vulnerable to the type of mistake I just described.
For your particular use case, you could use the same cluster for multiple environments if you have separate namespaces and use separate service accounts for each. Using RBAC will further ensure you don't have any collisions, this way if there's an error in development, the production namespace will remain untouched.
When deciding which features are paid vs free we ask ourselves if the particular feature may be more relevant to larger organizations; that doesn't necessarily mean there won't be a use case at smaller companies, but just wanted to let you know our reasoning. You can read more about it here: https://about.gitlab.com/stewardship#what-features-are-paid-....
If you're looking for something more legit: Ansible
> Other workloads, Kubernetes just doesn’t support well and likely will not support well in the near future because it’s really hard to do. It’s not magic, as some of the hype surrounding it would have you believe.
https://gravitational.com/blog/running-postgresql-on-kuberne...
- Heroku is cheap for personal projects. - A single Digital Ocean droplet where you manage everything yourself, is cheap for personal projects. - If you're working in node, Glitch.com is literally free node hosting
I don't feel like any of them have to do with personal hosting/blogs.
If you really want to go simple/cheap for that, why not eschewing compute entirely and go serverless/static?
Also out of the box docker offers a lot of functionality for single machine and development environments that might be good enough. I've seen kubernetes make more sense when you need to grow to multiple machines and are trying to optimize resource utilization.
I guess my main question is would anybody actually use preemptive for k8s knowing that if a worker node gets reaped k8s will magically route only to healthy nodes while the preempted instance replacement is standing up?
First of all, GK3 would create new nodes when one of them gets killed.
Second, builidng “cloud-native” applications means to build stateless applications, e.g. using 12-factor. So it does not really matter if your application gets killed, restarted or horizontally scaled.
For databases, i always recommend to use a PaaS offering to have an easy and worry-free life
Just make sure your app has proper probes, and make sure the probes returns 500 when the process receives a sigterm, and it should be invisible to you.
Server-less will be remembered as the most embarrassing thing humans have ever invented.
I've tried to replace my Docker setup with Kubernetes multiple, but it was always too much of a hassle. Things that were easy with a "bare" Docker setup became hard, and single-node clusters always felt like a second-class citizen.
But how do you manage deployments of new versions without downtime?
I use Docker Compose, but I had to complete it with some scripts to manage the deployment (start the new containers, wait for new containers to be ready, switch traffic to new containers, shutdown old containers), and it's a bit messy and non-standard. I'm thinking of using using Docker in swarm mode which offers the concept of services with automated deployments.
I don't try to have 100% uptime. For most projects I will usually have a few seconds to a minute of downtime when deploying (as long as it takes the docker container to start). When I try to minimize the downtime below that, I spin up a second container in parallel, change the HAProxy address to that and reload HAProxy, which gives zero-downtime (with small caveats).
For most scenarios (including business) I've found that to be a reasonable approach. Most businesses can live with that kind of downtime, and trying to achieve less downtime becomes unproportionally more expensive.
Amazon EKS launched last month in the EU west region, which I was excited about. But each cluster is $150 per month (20c per hour) before you even add any servers. To have a dev, qa and production cluster we're looking at $450 per month before the cost of EC2 instances to actually run the application. Our EC2 costs for backend services are about $800 per month, so it instantly negates the selling point that we can use reduce costs by using resources more efficiently.
Our current deployment setup is groups of Docker services deployed to a set of EC2 instances via Docker Compose with a load balancer in front of each server group. Having isolated server groups means that outages are isolated to particular areas. I don't know how long we'd be down if there was an issue with the Kubernetes cluster. If we introduced Kubernetes it would be left in the hands of a couple of developers to manage, which is the opposite of the DevOps culture we strive for.
We stay cloud-agnostic so it's easy for a developer to spin up a stack of dependent services with Docker Compose (Nginx, Redis, RabbitMQ etc.) when working on changes to a service. For a developer to run services locally with Kubernetes, they need to set up MiniKube. Many corporate environments have tight integration with Windows and our developers run Linux in a VM. I experimented with getting MiniKube to run in a VM but found it hard to get going with the vm-driver=none option, and it's something I definitely didn't want to add to our onboarding process.
Kubernetes has a serious hype train at the moment reminiscent of the MongoDB days. My inner conspiracy theorist says that this is because Google has a vested interest in preventing vendor lock-in on cloud providers. It solves a Google-sized problem and introduces some complexity with the promise of removing more complexity than it adds. For small to mid sized companies, however, it adds far more complexity than it removes.
Although the article starts with kind of a strawman (Kubernetes is robust section): you could do most of those with Docker (and compose) or with a non-containerized setup altogether?
After using it for a while, I found it far more cumbersome to work with, and the architecture to be confusing.
I'm quite comfortable with complicated environments, typically all I really want is a small cluster running my long-running infrastructure, and expansion to spot instance worker nodes to meet burst capability. Just setting that up in k8s, keeping it up to date, and monitoring the various components that fail because you configured just-not-enough-RAM for them became tiresome.
I recently went through the infrastructure that runs my personal projects (Django, PostgreSQL, Redis, a few static sites...). I decided to go with plain Docker + Ansible.
These tools give me enough automation to easily scale up or change hosting provider if I need, without introducing too much magic and complexity.
https://penguindreams.org/blog/installing-mesosphere-dcos-on...
I ended up doing what you did, having Ruby provision my machines, configure them with Ansible and deploy my docker containers (calling the Docker API from Ruby). The whole thing can be found here:
https://github.com/sumdog/bee2
It was a lot of work setting all that up. I should have probably just used Terraform + Ansible + docker-compose. Still, I'm glad I wrote it. I learned a lot about the complexities of running a docker infrastructure.
How do you deploy new versions of your apps without downtime (start the new containers, wait for them to be ready, switch traffic to new containers, shutdown old containers)? I'm using custom Ansible scripts coupled to docker-compose but it's a bit messy and non-standard.
- docker_container:
image: foo/bar:latest
state: started
restart_policy: always
pull: yes
This pulls the new version and restarts the container. The downtime is probably a second maximum. It's small enough that it is not worth the trouble of a rolling release or whatnot. It's a personal project after all, no one will complain for getting a 502 once a month :)I do not use docker-compose as I never felt the need to and I read on multiple occasions that it's meant for development only.
I have some projects that run on a single machine, but serve multiple requests per second, and it happens we deploy multiple times per day, so we can't afford a 1 second downtime (users would notice).
My current solution is to just run docker on some raspberry pi's and have scripts to replace the container when I do an update, with volumes regularly backed up to S3.
Works fine, although you don't get the clustering capability (I might try docker swarm one day but for now it's fine)
https://kubernetes.io/docs/tasks/access-application-cluster/...
Kubernetes seems like a lot of unnecessary complexity for small workloads. Kind of plinking tin cans with a nuclear bazooka. What is the break-even point where all of this stuff starts to really be worth bothering with?
Series B
But Azure Kubernetes in my last project was easy too, it comes with a sophisticated monitoring solution, it integrates nicely with cheap Azure Load Balancer, but still too much overhead than Azure Web App.
more interested in how he manage to do that transition. been struggling with that part myself when competing with other candidates who have years of linux experience.
Its a bit silly, but sadly that's often how software goes, at least in my experience.
(also strictly speaking I couldn't do a static site cause there are some other things I run on here that are more than just html)
I fixed the copyright date :)
https://cloud.google.com/kubernetes-engine/docs/concepts/clu...
Is it what you observe?
1) Google Cloud - hello privacy and support issues.
2) Traditional enterprise-style overcomplexed configs and architecture - the shitty trick "we want your losted time as justify to stay here"
3) Forget about quick deployment and scaling.
What am I required to do in order to receive new operating system and software versions?
I'm pretty sure docker-compose + swarm can satisfy 99% percent of your needs.
No.
At least for small applications, Unix already has functional, established, and documented mechanisms for the vast majority of how they need to be managed. (Windows does too.) At the end of the day, I think people would be far better off learning and using those, until there is a specific documented need for some feature unique to some more powerful platform. Otherwise, you're continually paying a complexity cost for features you might never use.
Going back to the author's original list of 7 questions, I run a few personal apps in AWS, and here's how I answered:
> How do you deploy your application? Just rsync it to the server?
I scp a JAR file to a staging directory and run an install script. The install script is pretty much standard across the handful of apps I run.
> What about dependencies? If you use python or ruby you're going to have to install them on the server. Do you intend to just run the commands manually?
The JAR file is an uberjar, so the dependencies are included.
> How are you going to run the application? Will you simply start the binary in the background and nohup it? That's probably not great, so if you go the service route, do you need to learn systemd?
I learned systemd. It gives me easy service management and a standardized way to ensure the process comes up at server startup. The service script is pretty much standard across the handful of apps I run.
> How will you handle running multiple applications with different domain names or http paths? (you'll probably need to setup haproxy or nginx)
I installed nginx. Took about 30 minutes.
> Suppose you update your application. How do you rollout the change? Stop the service, deploy the code, restart the service?
Pretty much.
> How do you avoid downtime?
I don't. Many small apps can tolerate small downtime windows, including the ones I run, so I don't need to worry about continual operation. If I did have to worry about that, I'd have additional things to worry about in my application design.
> What if you screw up the deployment? Any way to rollback? (Symlink a folder...? this simple script isn't sounding so simple anymore)
Select the previous jar file, which I will have retained. Schema migrations complicate rollback, so I keep them to a minimum, test a bunch locally, and make sure I have backups of the database taken immediately before a deployment. (So that I can roll back if absolutely necessary.)
> Does your application use other services like redis? How do you configure those services?
Persistence handled through an embedded SQL database, and a library I've written to managed schema migrations. For nginx and git, I have source code snapshots of the configuration, but that's only needed if I rebuild the server. (Once in over five years.) Generally, for small apps, I try to keep the dependency footprint as small as possible. (Which is pretty much the entire gist of this comment, now that I think about it.)
How do you deploy your application? Just rsync it to the server?
Define an overlay for your application. For a typical application, this is just a few lines of code with stdenv.
What about dependencies? If you use python or ruby you're going to have to install them on the server. Do you intend to just run the commands manually?
If you have an overlay for your applications, you can specify dependencies in the derivation of your application. Even though these are not web apps (I primarily work on local applications), I have derivations for some of my applications, so that I can install them on every machine with little effort. Two examples:
https://github.com/danieldk/nix-home/blob/master/overlays/30...
https://github.com/danieldk/nix-home/blob/master/overlays/20...
If I want to develop one of the applications, say alpinocorpus, I can just drop in a shell with all the dependencies (cmake, boost, Berkeley DB XML, etc.) available:
nix-shell '<nixpkgs>' -A alpinocorpus
When you exit the shell, you are again in your usual environment. Another option is to create a default.nix file in a project directory and use direnv to automatically load the environment when you switch to a directory.
How are you going to run the application? Will you simply start the binary in the background and nohup it?
You can define (systemd) services in a NixOS configuration.
How will you handle running multiple applications with different domain names or http paths? (you'll probably need to setup haproxy or nginx)
NixOS has support for defining nginx virtual hosts. You can also enable Let's Encrypt and Nix will set up systemd timers to automatically renew the certificates. E.g. here is a configuration of one of my machines with a bunch of virtual hosts with Let's Encrypt:
https://github.com/danieldk/nixos-config/blob/master/machine...
Suppose you update your application. How do you rollout the change? Stop the service, deploy the code, restart the service? How do you avoid downtime?
nixos-rebuild switch --upgrade
Or with nixops you can deploy and update machines remotely.
What if you screw up the deployment? Any way to rollback? (Symlink a folder...? this simple script isn't sounding so simple anymore)
Yes, every change creates a new generation. You can always switch into or boot into an older generation as long as it isn't garbage collected. And this works for the whole system, including kernel updates, etc.
Does your application use other services like redis? How do you configure those services?
Declaratively ;). Adding services.redis.enable = true; to your NixOS configuration does the trick.
As a bonus, with nixops you can deploy a machine configurations on real-hardware, VPS, Virtual Box, KVM, etc.
FTFY
It's a simple API with an amazing CLI that immediately solves dozens of issues you would have sooner or later.
Take for example a very simple rails application. I'll keep it simple with 3 routes: manual, automated and with k8s (assuming you're not building the cluster itself).
Manually setting up would require you to:
- Create a VPS
- SSH into the VPS
- Install at least Ruby, NGINX (or some webserver), the DB and all Rails dependencies
- If you want easy deployments you'd probably use something like Capistrano and have to set it up
- If you want the system to be resilient you will have to add some sort of process monitoring and automatic startup
This is very easy to get wrong. One missing step and you're having to manually SSH into the machine and trying to figure out what went wrong.
An automated setup would essentially do everything you did on the manual setup, but you'd have to write that into something reproducible like Ansible, Chef, Puppet or similar. Every single one of these tools has a gotcha and a learning curve and that's on top of all the base knowledge of setting it all up by hand.
Finally with k8s (assuming we're using Google's GKE offering):
- Dockerize the app (which is extremely simple with tons of tutorials)
- Download the gcloud CLI (alternatively it can all be done through the website if that's your thing)
- Create the cluster
- Either create some manual yaml files or just use kubectl to create a deployment for: rails, nginx and the database (again, there are millions of examples of this even on the official docs).
- Create an ingress and point my DNS to the ingress' IP
All of these methods have learning curves and are in many ways complex. However I don't think Kubernetes is a lot different than the others. It's just a different way of doing the same.
* Instead of manually finding out how to setup load balancing and reverse proxying on NGINX, you learn how to use the k8s services.
* Instead of setting up Capistrano (or any other deployment tool) you learn how a k8s Deployment and rollouts work
* Instead of figuring out how to setup L7 load balancing you learn to use k8s Ingress
On top of all that with GKE (or any other managed k8s solution, I presume) you'd automatically have: logging, metrics, scaling, rolling updates and much, much more.
People are resistant to change and it's definitely not an "one size fits all" situation, but as soon as you need anything beyond an amateur website, k8s provides the best ROI. I've had to do this on all of these scenarios and I can confidently say Kubernetes changed the game.
I got a 10 year old Rails application with tons of dependencies from an old dedicated server setup to Kubernetes on a few days (on Kubernetes 1.1 at the time, which was a lot harder) and I'm not some kind of genius. If I can do it, any developer can.
People should check out openshift. It's built by redhat and is an abstraction layer above k8's. I love it.