Kubernetes for a Development Environment

11/29/2016

Good day

We have a development environment that consists of 6 virtual machines. Currently we are using Vagrant and Ansible with VirtualBox. As you can imagine, hosting this environment is a maintenance nightmare particularly as versions of software/OS change. Not too mention resource load for developer machines.

We have started migrating some virtual machines to docker. But this itself poses problems around orchestration, correct configurations, communication etc. This led me to Kubernetes.

Would someone be so kind as to provide some reasoning as to whether Kubernetes would or wouldn't be the right tool for the job? That is managing and orchestrating 'development' docker containers.

Thanks

-- Dane Balia
development-environment
docker
kubernetes

2 Answers

11/30/2016

As wsl mentioned before, it is a quite complex topic. But i'm doing this as well at the moment. So let me summaries some things for you:

With Kubernetes (k8s) you're going to orchestrate your SaaS Application. In best case, it is a Cloud-native Application. The properties/requirements for a Cloud-native Application are formulated by the Cloud Native Computing Foundation (CNCF), which basically were formed around k8s, after Google donates it to the Linux Foundation. So the properties/requirements for a Cloud-native Application are: Container packaged, Dynamically managed and Micro-services oriented (cncf.io/about/charter). You will benefit mostly from k8s, if your applications are micro-service based and every service has a separate container.

With micro-service based applications, every service can be developed independently. The developer only needs to follow the 12Factor Method (12factor.net) for example (use env var instead of hard coded IP addresses, etc).

In the next step the developer build the container for a service and pushes it the a container registry. For a local develop environment, you may need to run a container registry inside the cluster as well, so the developer can push and test his code locally.

Then you're able to define your k8s replication-controllers, services, PetSets, etc. with Ports, Port-mapping, env vars, Container Images... and create and run it inside the cluster.

The k8s-documentation recommend Minikube for running k8s locally (kubernetes.io/docs/getting-started-guides/minikube/). With Minikube you got features like DNS, NodePorts, ConfigMaps and Secrets Dashboards. But I choose the multi node CoreOS Kubernetes with Vagrant Cluster for my Development Environment as Puja Abbassi mentioned in the Blog "Finding The Right Local Kubernetes Development Environment" (https://deis.com/blog/2016/local-kubernetes-development-environment/), it is closer to the my production environment (12Factor: 10 - Dev/prod parity). With the Vagrant Environment you got features like:

  • Networking with flannel
  • Service Discovery with etcd
  • DNS names for a set of containers with SkyDNS
  • internal load balancing

If you want to know, how everything works look inside this Github repo github.com/coreos/coreos-kubernetes/tree/master/multi-node (vagrant and generic folder).

So you have to ask yourself, if you or your developers really need to run a complete "cloud environment" locally. In many cases a developer can develop a service (based on micro-services and containers) independently.

But sometimes it is necessary to have multiple or all services run on your local machine as a dev-environment.

-- Stefan
Source: StackOverflow

11/29/2016

This is quite complex topic and many things have to be considered if it's worth to use k8s as local dev environment. Especially I used it when I wanted to have my local developer environment very close to production one which was running on Kubernetes. This helped to avoid many configuration bugs.

In my opinion Kubernetes(k8s) will provide you all you need for a development environment.

It gives you much flexibility and does much configuration itself. Few examples:

  • An easy way to deploy new version into local kubernetes stack

You prepare k8s replication controller files for each of your application module (keep in mind that they need to be stateless modules) In replication controller you specify the docker image and that's it. Using this approach you can push new docker images to local docker_registry and then using kubectl control the lifecycle of your application.

  • Easy way to scale your application modules

For example:

kubectl scale rc your_application_service --replicas=3

This way k8s will check how many pods you have running for your service and if it recognises that the number is smaller then the replicas value it will create new to satisfy the replicas number.

It's endless topic and many other things come to my mind, but I would suggest you to try it out.

There is a https://github.com/kubernetes/kubernetes/blob/master/docs/devel/developer-guides/vagrant.md project for running the k8s cluster in vagrant.

Of course you have to remember that if you have many services all of them have to be pushed to local repository and run by k8s. This will require some time but if you automate local deploy with some custom scripts you won't regret.

-- wsl
Source: StackOverflow