6 ms·
Let's talk about complexity for a moment, for one aspect of a simple service: ingress. Kubernetes: apiVersion: extensions/v1beta1 kind: Ingress me
by falcolas 8y ago
Let's talk about complexity for a moment, for one aspect of a simple service: ingress.
Kubernetes:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: test-ingress
spec:
rules:
- http:
paths:
- path: /testpath
backend:
serviceName: test
servicePort: 80
Nginx:
location /testpath {
proxy_path http://127.0.0.1:8080
}
Which is less complex? Which is beta, and thus could be changed over time (it happens a lot). Which one requires major (and breaking) infrastructure updates every 3 months?
> I'd argue you have less YAMLs with k8s than with Ansible for a small project.
Since you typically need one yaml document per K8s resource, and can describe multiple independent and idempotant actions in one Ansible document, I think this is easily demonstrable as false for small projects (and likely big projects as well).
- justinsaccount 8y agoThe first one is a complete configuration you could kubectl apply into a cluster that sends traffic to a backend service that may be running across multiple instances on multiple machines. The second is a configuration fragment that is useless by itself that would send all traffic to a single instance running on localhost.
- falcolas 8y agoYou can just drop it in a conf.d folder created by the package install and it would work just fine. Also we're talking simple projects, and simple projects are typically not distributed; typically don't need to be distributed. That said, supporting multiple backends with different load balancing algorithms is also pretty simple to write as well.
- justinsaccount 8y agoOk, great... I have a bunch of simple projects like that, one web instance running on a single host. How do I safely upgrade it without downtime? Ensuring that the new version starts up properly and can receive traffic before sending it requests and stopping the old one? With k8s: kubectl set image deployment/my-deployment mycontainer=myimage:1.9.1 (or just use kubectl apply -f) With your nginx config: ????
- falcolas 8y agoThat moves the goalposts a bit. We've gone from a simple service to a fleet of highly available services on multiple hosts with zero downtime requirements. At which point, sure, use Kubernetes.
- justinsaccount 8y agoNo.. I didn't move the goalposts at all. Still A single service on a single machine, how do I safely upgrade it? A rolling deployment in k8s does work the same way on a single host with minikube as it does on a 1000 node cluster, but I'm still just asking about the single host case.
- wgjordan 8y ago> Still A single service on a single machine, how do I safely upgrade it? Depending on your OS-package's provided init script (here Ubuntu), it's as simple as `service nginx reload`, (`service nginx upgrade` if upgrading nginx itself). Or skip the init script entirely with `/usr/sbin/nginx -s reload`.
- justinsaccount 8y agoI am asking how one would safely upgrade the service that nginx is proxying to, not how to restart nginx.
- icedchai 8y agoYou could do "blue-green" deployments with port numbers... service rev A is on port 1001, service rev B is on port 1002... deploy new rev... change nginx config to point to 1002... roll back, you repoint to 1001...
- justinsaccount 8y agoSo I need to write some code to keep track of which of A or B is running, then something else to template out a nginx configuration to switch between the two. Then I need to figure out how to upgrade the inactive one, test it, flip the port over in nginx, and flip it back if it breaks. Or kubectl apply -f app.yaml Which is less complex?
- Draiken 8y agoI think this is proving my point. They're basically the same, but one is completely dynamic and the other will have to be changed as soon as anything changes. We've been using Kubernetes in production for almost two years now and I have yet to face a big API change that breaks everything. The core APIs are stable. There's a lot of new stuff added, but nothing that breaks backwards compatibility. As you just said, if it's a simple project, you can upgrade the infrastructure by clicking "upgrade" on GKE. We've only ever hit problems when upgrading when using the bleeding edge stuff and the occasional bug (once since Kubernetes 1.1 to 1.10 for a large Rails app). Regarding the yaml document per resource, I mean... that's spaghetti Ansible. If you want to have a proper Ansible setup you will have separate tasks and roles. If we're going down the route of just have "less files" you can have all the Kubernetes resources in a single YAML file. I would definitely not recommend that tho. While Kubernetes is a lot more verbose, it is light years better than the Ansible jinja2 weird syntax. Even someone that never heard of Kubernetes can read that Ingress resource and guess what it does. If we're being really picky actually, the proxy_path should be pointing to some "test" thing that would have to be an upstream that would already make the NGINX config more obscure. I feel like people just hate Kubernetes to avoid change. These arguments are never about Kubernetes' strengths or faults but about why "I think my way is better". You can always do things in millions of ways and they all have tradeoffs. The fact is: ROI on Kubernetes is a lot bigger than any other kind of manual setup. I'll repeat what I said on another comment: the only reason to do anything by hand today is if it's a play thing
- dsnuh 8y agoI think the key element here is that you are using GKE. Managed cloud Kubernetes, and self-hosted on-prem Kubernetes are two different beasts. Yes, it's easy when you don't actually have to run the cluster yourself. Ansible has its warts, but it is great for managing and configuring individual servers.
- Draiken 8y agoYes I agree. But in the context of this article, we're talking about small projects. So I wouldn't expect the need for an on-prem setup. In fact I've used Kubespray[1] to setup a cluster with Ansible before with mild success. Nothing production ready, but it's actually a good tool for that job. At the end of the day you can't run Kubernetes on Kubernetes :D [1]: https://github.com/kubernetes-incubator/kubespray https://github.com/kubernetes-incubator/kubespray