News for hackers. Stuff that matters.
Re:Kubernetes by Example by rocgf on Wednesday May 31, 2017 @12:15PM (#14453641)
I'm not a very versed DevOps guy, but I have used Ansible, Terraform and Kubernetes.

It should go a bit like this:

- Use Terraform to provision VMs, networking resources and storage from DigitalOcean. Basically, write the scripts that make your whole infrastructure available with a single command.

- Then use Ansible for anything you might want installed on those machines - Kubernetes, security packages, SSH keys for your team.

- Use Kubernetes to then deploy your application on top of your secure and replicable infrastructure.

Each of the steps above should be roughly one shell command. If you are disciplined enough to always provision machines, install packages and deploy your app via config files, this should be very much achievable.

Re:Kubernetes by Example by dominotw on Wednesday May 31, 2017 @01:11PM (#14454140)
>- Use Terraform to provision VMs, networking resources and storage from DigitalOcean. Basically, write the scripts that make your whole infrastructure available with a single command.

How does autoscaling work if terraform/ansible are involved before kubernetes can take over?

Re:Kubernetes by Example by joseph on Wednesday May 31, 2017 @05:19PM (#14456011)
IMO it's better for autoscaling to bake VM images and use cloud-init or similar to add per-instance config tweaks if necessary. Using Ansible to do runtime configuration is slow and doesn't play well with autoscaling. I do like Ansible, however, and use it for building EC2 AMIs. I even wrote a tool for this purpose at https://github.com/cloudboss/bossimage.
Re:Kubernetes by Example by dalailambda on Wednesday May 31, 2017 @06:29PM (#14456442)
There are generally two levels of autoscaling involved with kubernetes.

Firstly, kubernetes is able to create multiple instances of your app as load increases and scale them out over all the nodes.

Secondly, the nodes your kubernetes cluster is running on can also autoscale. With terraform you can set up an AWS autoscaling group for example to automatically increase the size of your cluster as load increases.

Re:Kubernetes by Example by ransom1538 on Wednesday May 31, 2017 @12:57PM (#14454024)
Hey just curious:

With a dockerfile is there any point to using Ansible/Puppet/Chef any more? I have used those tools to keep 'how machines are installed' in code in the past, but with dockerfiles these days I don't get the point anymore. Seems like the future will be having a few dockerfiles (staging, prod, dev, db, etc) then just finding a place to run them (digital ocean, docker swarm, aws container service - or your macbook).

Re:Kubernetes by Example by bdcravens on Wednesday May 31, 2017 @01:18PM (#14454206)
You still have to bootstrap the instances/droplets/etc with Docker, Kubernetes, etc before Dockerfiles can be used. Unless you're starting with images where those are already baked in, Ansible/Chef/Puppet are good ways to accomplish this on a clean OS.
Re:Kubernetes by Example by zimbatm on Wednesday May 31, 2017 @03:09PM (#14455087)
It's debatable. Ansible/Chef/Puppet themselves need to be bootstrapped as well.

Bash is perfectly fine if the machine can be installed with less than 100 lines of code and immutable infrastructure is being used (so no need for idempotent operations). Just make sure to add ShellCheck to the CI pipeline.

Re:Kubernetes by Example by icebraining on Wednesday May 31, 2017 @06:08PM (#14456320)
Ansible/Chef/Puppet themselves need to be bootstrapped as well.

Nope, Ansible just needs SSH access.

Re:Kubernetes by Example by Whitestrake on Wednesday May 31, 2017 @11:56PM (#14457898)
Remote hosts need Python, but you can use the raw command functionality to figure out what the remote package manager is and install Python as required.
Re:Kubernetes by Example by zimbatm on Thursday June 01, 2017 @09:49AM (#14460175)
Not when using AutoScaling Groups. Then the machine will be provisioned on boot and therefor ansible would have to be installed on the machine.
Re:Kubernetes by Example by icebraining on Thursday June 01, 2017 @01:46PM (#14462598)
No, you'd use Ansible to prepare the new image once, then you'd use that image to scale. Bootstrapping everything each time a VM is created doesn't make much sense.
Re:Kubernetes by Example by tdurden on Wednesday May 31, 2017 @10:43PM (#14457601)
> Bash is perfectly fine if the machine can be installed with less than 100 lines of code

It is always tough to predict the future; something < 100 lines can easily grow over time. It is nice to start with a tool like Chef/Ansible/Puppet which can more easily grow as the project grows vs Bash.

Re:Kubernetes by Example by zimbatm on Thursday June 01, 2017 @09:51AM (#14460187)
I agree that it's hard to predict the future, that's why I'm not trying to add unnecessary dependencies. 100 lines of code are not hard to rewrite in anything else if necessary.
Re:Kubernetes by Example by zimbatm on Wednesday May 31, 2017 @03:00PM (#14455023)
I'm doing just that (for a SaaS).

1. Build an AMI with Packer that contains Ubuntu + Docker + aws-cli.

2. Build and publish docker images for all the services that will run on the instances. (one image per service, not per environment like you suggested)

3. Configure the EC2 instance or AutoScaling Groups with userdata. The userdata usually just contains a `docker run ...` instruction.

I used to have Chef, run test kitchen, bake AMIs, cycle all the machines. Now I have a single AMI and do most of the testing on the docker side and then some on staging. In both cases I am using terraform to manage the overall infrastructure (and userdata scripts).

The only issue is how to manage secrets as userdata are readable with the DescribeInstance ACL. The best solution that I found is to upload the secrets on S3+KMS and use IAM Role on the machine to retrieve them. Or use Hashicorp Vault.

Re:Kubernetes by Example by btmiller on Wednesday May 31, 2017 @01:34PM (#14454366)
For single-provider solutions, I'd say that's debatable. You might be fine with <insert cloud provider here>'s PaaS spin-up services for Kubernetes. The instant you want to span multiple cloud providers, you'll rub up against all the minor differences between each of their implementations, and I think that's where the value in SaltStack/Ansible/Chef/Puppet is in modern times. Manually orchestrate your infrastructure once, then deploy it to any cloud provider.
Re:Kubernetes by Example by riquito on Wednesday May 31, 2017 @11:47PM (#14457865)
I moved away from dockerfiles to Packer to build images for multiple environments. Even if you don't need that, ansible from dockerfile is a good choice to avoid writing hard to manage/reuse scripts in yml
Re:Kubernetes by Example by dullgiulio on Wednesday May 31, 2017 @01:17PM (#14454191)
I don't think it's a good idea to have different dockerfiles for your staging, dev and prod environments.

The point of using Docker containers is that you get to deploy to production your dev environment as is.

Re:Kubernetes by Example by manigandham on Wednesday May 31, 2017 @02:36PM (#14454847)
No, you don't need those tools anymore.

Cook a base VM image that has the docker engine and anything else you need. Do this once and spin up VMs you need after that. This is what images are for, and they're far easier, faster, more reliable and more secure than dealing with all this other junk.

Re:Kubernetes by Example by icebraining on Wednesday May 31, 2017 @06:12PM (#14456342)
How do you do the cooking of the base VM image?
Re:Kubernetes by Example by manigandham on Thursday June 01, 2017 @01:03AM (#14458111)
All the major clouds already have API commands to convert a VM into a reusable image - so a simple startup script + this API command is all you need. Even better since you can script all this too.

If anything changes, update the startup script, then run this "make new base image" script and you're all set. Update VMs as needed. Really doesn't get much more complicated than that and using tools like ansible just to setup your VMs so you can run docker containers later is unnecessary.

Re:Kubernetes by Example by icebraining on Thursday June 01, 2017 @01:54PM (#14462676)
You make Ansible sound like an ICBM launching system. In practice, you do a simple "apt install ansible" once (on your machine) and then you write a simple startup script in it. There's nothing extra to be "unnecessary", it's a 1:1 replacement.
Re:Kubernetes by Example by manigandham on Friday June 02, 2017 @03:14AM (#14468074)
Why do you need that then when you can just use the startup script directly with the VM?

Unnecessary = not needed to function. Replacing functionality is just preference, which is fine, but specifically not necessary.

Re:Kubernetes by Example by icebraining on Friday June 02, 2017 @02:03PM (#14472045)
Why do you need that then when you can just use the startup script directly with the VM?

My point is that's a loaded question. You could just as easily ask why do you need bash in every VM when you can just have Ansible in a single machine.

Re:Kubernetes by Example by sevagh on Wednesday May 31, 2017 @06:56PM (#14456584)
Check out Packer (https://www.packer.io/intro/)
Re:Kubernetes by Example by jdc on Wednesday May 31, 2017 @12:33PM (#14453806)
Could you point to any articles that go into a bit more depth on this provisioning-configuration-deployment flow?
Re:Kubernetes by Example by smw on Wednesday May 31, 2017 @01:12PM (#14454150)
You can use Ansible for step one, too. And I think I'd recommend it highly over Terraform for production provisioning.
Re:Kubernetes by Example by purvis on Wednesday May 31, 2017 @01:28PM (#14454311)
> I think I'd recommend it highly over Terraform for production provisioning.

I'm curious why you recommend this? I'd argue the opposite. With the declarative nature of Terraform, you can know exactly which part of your infrastructure is going to change before you actually apply it. With Ansible, this information is a bit more opaque. You basically just run the playbook and pray it goes as planned and things haven't drifted too much.

Re:Kubernetes by Example by icebraining on Wednesday May 31, 2017 @06:13PM (#14456352)
You can run Ansible in check mode and see what steps will make changes.