diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..2e22d1185 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +sudo: true + +language: go + +go: + - 1.4 + +install: + - sudo pip install jinja2 + - sudo pip install pyyaml + - sudo pip install jsonschema + +script: + - make test diff --git a/README.md b/README.md index e3a42954d..3216d1f3b 100644 --- a/README.md +++ b/README.md @@ -2,26 +2,28 @@ [![Go Report Card](http://goreportcard.com/badge/kubernetes/deployment-manager)](http://goreportcard.com/report/kubernetes/deployment-manager) -Deployment Manager (DM) provides parameterized templates for Kubernetes clusters. +Deployment Manager (DM) provides parameterized templates for Kubernetes resources, +such as: -You can use it deploy ready-to-use types, such as: -* [Replicated Service](types/replicatedservice/v1) -* [Redis](types/redis/v1) +* [Replicated Service](templates/replicatedservice/v1) +* [Redis](templates/redis/v1) -Types live in ordinary Github repositories. This repository is a DM type registry. +Templates live in ordinary Github repositories called template registries. This +Github repository contains a template registry, as well as the DM source code. -You can also use DM to deploy simple templates that use types, such as: +You can use DM to deploy simple configurations that use templates, such as: * [Guestbook](examples/guestbook/guestbook.yaml) * [Deployment Manager](examples/bootstrap/bootstrap.yaml) -A template is just a `YAML` file that supplies parameters. (Yes, you're reading -that second example correctly. It uses DM to deploy itself. -See [examples/bootstrap/README.md](examples/bootstrap/README.md) for more information.) +A configuration is just a `YAML` file that supplies parameters. (Yes, +you're reading that second example correctly. It uses DM to deploy itself. See +[examples/bootstrap/README.md](examples/bootstrap/README.md) for more information.) DM runs server side, in your Kubernetes cluster, so it can tell you what types -you've instantiated there, what instances you've created of a given type, and even -how the instances are organized. So, you can ask questions like: +you've instantiated there, including both primitive types and templates, what +instances you've created of a given type, and even how the instances are organized. +So, you can ask questions like: * What Redis instances are running in this cluster? * What Redis master and slave services are part of this Redis instance? @@ -30,10 +32,12 @@ how the instances are organized. So, you can ask questions like: Because DM stores its state in the cluster, not on your workstation, you can ask those questions from any client at any time. +For more information about types, including both primitive types and templates, +see the [design document](../design/design.md#types). + Please hang out with us in [the Slack chat room](https://kubernetes.slack.com/messages/sig-configuration/) -and/or -[the Google Group](https://groups.google.com/forum/#!forum/kubernetes-sig-config) +and/or [the Google Group](https://groups.google.com/forum/#!forum/kubernetes-sig-config) for the Kubernetes configuration SIG. Your feedback and contributions are welcome. ## Installing Deployment Manager @@ -43,11 +47,10 @@ Follow these 3 steps to install DM: 1. Make sure your Kubernetes cluster is up and running, and that you can run `kubectl` commands against it. 1. Clone this repository into the src folder of your GOPATH, if you haven't already. -1. Use `kubectl` to install DM into your cluster: - -``` -kubectl create -f install.yaml -``` +See the [Kubernetes developer documentation](https://github.com/kubernetes/kubernetes/blob/master/docs/devel/development.md) +for information on how to setup Go and use the repository. +1. Use `kubectl` to install DM into your cluster `kubectl create -f +install.yaml` That's it. You can now use `kubectl` to see DM running in your cluster: @@ -59,38 +62,29 @@ If you see expandybird-service, manager-service, resourcifier-service, and expandybird-rc, manager-rc and resourcifier-rc with pods that are READY, then DM is up and running! -The easiest way to interact with Deployment Manager is through `kubectl` proxy: +## Using Deployment Manager + +### Setting up the client -``` -kubectl proxy --port=8001 & -``` +The easiest way to interact with Deployment Manager is through the `dm` tool +hitting a `kubectl` proxy. To set that up: -This command starts a proxy that lets you interact with the Kubernetes api -server through port 8001 on localhost. `dm` uses +1. Build the tool by running `make` in the deployment-manager repository. +1. Run `kubectl proxy --port=8001 &` to start a proxy that lets you interact +with the Kubernetes API server through port 8001 on localhost. `dm` uses `http://localhost:8001/api/v1/proxy/namespaces/default/services/manager-service:manager` as the default service address for DM. -## Using Deployment Manager - -You can use `dm` to deploy a type from the command line. This command deploys a -redis cluster with two workers from the type definition in this repository: +### Using the client -``` -dm deploy redis/v1 -``` - -When you deploy a type, you can optionally supply values for input parameters, -like this: - -``` -dm --properties workers=3 deploy redis/v1 -``` +The DM client, `dm`, can deploy configurations from the command line. It can also +pull templates from a template registry, generate configurations from them using +parameters supplied on the command line, and deploy the resulting configurations. -When you deploy a type, `dm` generates a template from the type and input -parameters, and then deploys it. +#### Deploying a configuration -You can also deploy an existing template, or read one from `stdin`. This command -deploys the canonical Guestbook example from the examples directory: +`dm` can deploy a configuration from a file, or read one from `stdin`. This +command deploys the canonical Guestbook example from the examples directory: ``` dm deploy examples/guestbook/guestbook.yaml @@ -108,68 +102,75 @@ to see the guestbook in action. For more information about this example, see [examples/guestbook/README.md](examples/guestbook/README.md) -## Additional commands +#### Deploying a template directly -The command line tool makes it easy to configure a cluster from a set of predefined -types. Here's a list of available commands: +You can also deploy a template directly, without a configuration. This command +deploys a redis cluster with two workers from the redis template in this repository: ``` -expand Expands the supplied template(s) -deploy Deploys the supplied type or template(s) -list Lists the deployments in the cluster -get Retrieves the supplied deployment -delete Deletes the supplied deployment -update Updates a deployment using the supplied template(s) -deployed-types Lists the types deployed in the cluster -deployed-instances Lists the instances of the supplied type deployed in the cluster -types Lists the types in the current registry -describe Describes the supplied type in the current registry +dm deploy redis:v1 +``` +You can optionally supply values for template parameters on the command line, +like this: + +``` +dm --properties workers=3 deploy redis:v1 ``` -## Uninstalling Deployment Manager +When you deploy a template directly, without a configuration, `dm` generates a +configuration from the template and any supplied parameters, and then deploys the +generated configuration. + +For more information about deploying templates from a template registry or adding +types to a template registry, see [the template registry documentation](docs/templates/registry.md). -You can uninstall Deployment Manager using the same configuration file: +### Additional commands + +`dm` makes it easy to configure a cluster from a set of predefined templates. +Here's a list of available `dm` commands: ``` -kubectl delete -f install.yaml +expand Expands the supplied configuration(s) +deploy Deploys the named template or the supplied configuration(s) +list Lists the deployments in the cluster +get Retrieves the named deployment +delete Deletes the named deployment +update Updates a deployment using the supplied configuration(s) +deployed-types Lists the types deployed in the cluster +deployed-instances Lists the instances of the named type deployed in the cluster +templates Lists the templates in a given template registry +describe Describes the named template in a given template registry ``` -## Creating a type registry - -All you need to create a type registry is a Github repository with top level file -named `registry.yaml`, and a top level folder named `types` that contains type definitions. +## Uninstalling Deployment Manager -A type definition is just a folder that contains one or more versions, like `/v1`, -`/v2`, etc. +You can uninstall Deployment Manager using the same configuration: -A version is just a folder that contains a type definition. As you can see from the -examples above, a type definition is just a Python or [Jinja](http://jinja.pocoo.org/) -file plus an optional schema. +``` +kubectl delete -f install.yaml +``` -## Building the container images +## Building the Container Images This project runs Deployment Manager on Kubernetes as three replicated services. By default, install.yaml uses prebuilt images stored in Google Container Registry to install them. However, you can build your own container images and push them to your own project in the Google Container Registry: -1. Set the environment variable PROJECT to the name of a project known to gcloud. -1. Run the following command: - -``` -make push -``` +1. Set the environment variable `PROJECT` to the name of a project known to +GCloud. +1. Run `make push` ## Design of Deployment Manager There is a more detailed [design document](docs/design/design.md) available. -## Status of the project +## Status of the Project This project is still under active development, so you might run into issues. If you do, please don't be shy about letting us know, or better yet, contribute a -fix or feature. We use the same [development process](CONTRIBUTING.md) as the main +fix or feature. We use the same [development process](CONTRIBUTING.md) as the main Kubernetes repository. ## Relationship to Google Cloud Platform @@ -177,5 +178,3 @@ DM uses the same concepts and languages as [Google Cloud Deployment Manager](https://cloud.google.com/deployment-manager/overview), but creates resources in Kubernetes clusters, not in Google Cloud Platform projects. - - diff --git a/dm/dm.go b/dm/dm.go index 812a40e56..f1c417a19 100644 --- a/dm/dm.go +++ b/dm/dm.go @@ -36,29 +36,28 @@ import ( ) var ( - // TODO(jackgr): Implement reading a template from stdin - //stdin = flag.Bool("stdin", false, "Reads a template from the standard input") - properties = flag.String("properties", "", "Properties to use when deploying a type (e.g., --properties k1=v1,k2=v2)") - type_registry = flag.String("registry", "kubernetes/deployment-manager", "Github based type registry [owner/repo]") - service = flag.String("service", "http://localhost:8001/api/v1/proxy/namespaces/default/services/manager-service:manager", "URL for deployment manager") - binary = flag.String("binary", "../expandybird/expansion/expansion.py", "Path to template expansion binary") + stdin = flag.Bool("stdin", false, "Reads a configuration from the standard input") + properties = flag.String("properties", "", "Properties to use when deploying a template (e.g., --properties k1=v1,k2=v2)") + template_registry = flag.String("registry", "kubernetes/deployment-manager/templates", "Github based template registry (owner/repo[/path])") + service = flag.String("service", "http://localhost:8001/api/v1/proxy/namespaces/default/services/manager-service:manager", "URL for deployment manager") + binary = flag.String("binary", "../expandybird/expansion/expansion.py", "Path to template expansion binary") ) var commands = []string{ - "expand \t\t\t Expands the supplied template(s)", - "deploy \t\t\t Deploys the supplied type or template(s)", + "expand \t\t\t Expands the supplied configuration(s)", + "deploy \t\t\t Deploys the named template or the supplied configuration(s)", "list \t\t\t Lists the deployments in the cluster", "get \t\t\t Retrieves the supplied deployment", "delete \t\t\t Deletes the supplied deployment", - "update \t\t\t Updates a deployment using the supplied template(s)", + "update \t\t\t Updates a deployment using the supplied configuration(s)", "deployed-types \t\t Lists the types deployed in the cluster", - "deployed-instances \t Lists the instances of the supplied type deployed in the cluster", - "types \t\t\t Lists the types in the current registry", - "describe \t\t Describes the supplied type in the current registry", + "deployed-instances \t Lists the instances of the named type deployed in the cluster", + "templates \t\t Lists the templates in a given template registry", + "describe \t\t Describes the named template in a given template registry", } var usage = func() { - message := "Usage: %s [] ( | | (