azukiapp / azk

azk is a lightweight open source development environment orchestration tool. Instantly & safely run any environment on your local machine.
http://azk.io
Apache License 2.0
898 stars 63 forks source link

Kubernetes deployment #637

Open paralin opened 8 years ago

paralin commented 8 years ago

As far as I can tell, azk currently supports only DigitalOcean as a deployment target.

I'm interested in implementing Kubernetes as a deployment target via automation of the API. It's quite easy to generate type-safe API code via swagger-codegen (as I did for dotnet here). The scaling and deployment model in Azk should translate nicely over to how Kubernetes handles things.

Thoughts?

paralin commented 8 years ago

I'm working on this here: http://github.com/paralin/docker-deploy-kubernetes

paralin commented 8 years ago

Okay, after a long night of hacking.. It's all but done. Just need to implement image push (there will be some question of where the images should go, though).

Completed:

Sample output:

First run: http://sprunge.us/PbUa

Second run: http://sprunge.us/ODhf

fearenales commented 8 years ago

@paralin It's awesome you're working on this!

I'd like to explain you couple things about azk deployment, and this will answer the question you've posted at #641 .

There's a base image for deployment, named azukiapp/deploy. This image was designed to provide all tools for deployment (including subcommand handlers, such as azk deploy versions, azk deploy rollback etc.) and communicate to a single box via its IP.

So, if you're deploying to your own server, you can setup your credentials, the server IP and use this very image.

Also, this base image was designed to be extensible for other providers (check it here).

In order to do that, an image for a provider should:

1) Extends from the base image; 2) Communicate with the provider's API in order to create a box, and send back the box' IP to the base image so that it would know how to handle it;

All of these provider-specific actions on the top of the deployment base image should be implemented in a file named deploy-<provider-name>.sh, such as deploy-digitalocean.sh;

I'd like to hear from you if this structure fits your needs. Otherwise we still can elaborate a more flexible base image so that you can extend it in order to implement deployment using Kubernetes.

paralin commented 8 years ago

@fearenales Sorry, this doesn't work with Docker Image deployment, only with basic SSH deployment. With Kubernetes I need to generate a set of Kubernetes configuration files (replication controller definitions, service definitions) which then are submitted/applied to an existing kubernetes cluster via an API. It would not work to use ssh or literally anything inside your base image.

It makes more sense to have generic base images derive from that image but still allow any deployment image to be dropped in place for any kind of logic like this. It does not make sense to enforce a specific base image like your azukiapp/deploy image with a preset list of (pretty flawed) commands.

fearenales commented 8 years ago

@paralin Yes, I understand your point. We'll work to improve the deployment base image in order to make it possible to extend it in cases other than basic SSH deployment.

Thank you very much for your feedback!

paralin commented 8 years ago

@fearenales Thanks. I really appreciate this.

I think the key things are:

Thanks!