Skip to content

oftensmile/kubernetes-mesos

 
 

Repository files navigation

kubernetes-mesos

When Google Kubernetes meets Apache Mesos

![GoDoc] (https://godoc.org/github.com/mesosphere/kubernetes-mesos?status.png)

Kubernetes and Mesos are a match made in heaven. Kubernetes enables the Pod (group of co-located containers) abstraction, along with Pod labels for service discovery, load-balancing, and replication control. Mesos provides the fine-grained resource allocations for pods across nodes in a cluster, and can make Kubernetes play nicely with other frameworks running on the same cluster resources. Within the Kubernetes framework for Mesos, the framework scheduler first registers with Mesos and begins watching etcd's pod registry, and then Mesos offers the scheduler sets of available resources from the cluster nodes (slaves/minions). The scheduler matches Mesos' resource offers to unassigned Kubernetes pods, and then sends a launchTasks message to the Mesos master, which claims the resources and forwards the request onto the appropriate slave. The slave then fetches the kubelet/executor and starts running it. Once the scheduler knows that there are resource claimed for the kubelet to launch its pod, the scheduler writes a Binding to etcd to assign the pod to a specific host. The appropriate kubelet notices the assignment, pulls down the pod, and runs it.

Roadmap

This is still very much a work-in-progress, but stay tuned for updates as we continue development. If you have ideas or patches, feel free to contribute!

  • Launching pods (on local machine)
    1. Implement Kube-scheduler API
    2. Pick a Pod (FCFS), match it to an offer.
    3. Launch it!
    4. Kubelet as Executor+Containerizer
  • Pod Labels: for Service Discovery + Load Balancing
  • Running multi-node on GCE
  • Replication Control
  • Use resource shapes to schedule pods
  • Even smarter (Marathon-like) scheduling

Build

NOTE Kubernetes for Mesos requires Go 1.2+, protobuf 2.5.0, etcd, and Mesos 0.19+.

To install etcd, see github.com/coreos/etcd

To install Mesos, see mesosphere.io/downloads

$ sudo aptitude install golang libprotobuf-dev mercurial

$ cd $GOPATH # If you don't have one, create directory and set GOPATH accordingly.

$ go get github.com/mesos/mesos-go/mesos
$ export GOPATH=$GOPATH:$GOPATH/src/github.com/GoogleCloudPlatform/kubernetes/third_party
$ go get github.com/mesosphere/kubernetes-mesos/kubernetes-mesos # If version.go fails to build, rerun after:
$ ./src/github.com/GoogleCloudPlatform/kubernetes/hack/version-gen.sh
$ go get github.com/mesosphere/kubernetes-mesos/kubernetes-mesos
$ go get github.com/mesosphere/kubernetes-mesos/kubernetes-executor
$ go install github.com/GoogleCloudPlatform/kubernetes/cmd/proxy

Start the framework

Assuming your mesos cluster is started, and the master is running on 127.0.1.1:5050, then:

$ ./bin/kubernetes-mesos \
  -machines=$(hostname) \
  -mesos_master=127.0.1.1:5050 \
  -etcd_servers=http://$(hostname):4001 \
  -executor_path=$(pwd)/bin/kubernetes-executor \
  -proxy_path=$(pwd)/bin/proxy

###Launch a Pod

Assuming your framework is running on localhost:8080, then:

$ curl -L http://localhost:8080/api/v1beta1/pods -XPOST -d @examples/pod.json

After the pod get launched, you can check it's status via curl or your web browser:

$ curl -L http://localhost:8080/api/v1beta1/pods
{
	"kind": "PodList",
	"items": [
		{
			"id": "php",
			"labels": {
				"name": "foo"
			},
			"desiredState": {
				"manifest": {
					"version": "v1beta1",
					"id": "php",
					"volumes": null,
					"containers": [
						{
							"name": "nginx",
							"image": "dockerfile/nginx",
							"ports": [
								{
									"hostPort": 8080,
									"containerPort": 80
								}
							],
							"livenessProbe": {
								"enabled": true,
								"type": "http",
								"httpGet": {
									"path": "/index.html",
									"port": "8080"
								},
								"initialDelaySeconds": 30
							}
						}
					]
				}
			},
			"currentState": {
				"manifest": {
					"version": "",
					"id": "",
					"volumes": null,
					"containers": null
				}
			}
		}
	]
}

Or, you can run docker ps -a to verify that the example container is running:

CONTAINER ID        IMAGE                       COMMAND                CREATED             STATUS              PORTS               NAMES
3fba73ff274a        busybox:buildroot-2014.02   sh -c 'rm -f nap &&    57 minutes ago                                              k8s--net--php--9acb0442   

Test

Run test suite with:

$ go test github.com/mesosphere/kubernetes-mesos/kubernetes-mesos -v

About

A Kubernetes Framework for Apache Mesos

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published