-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from ethernetdan/spread-deploy
implemented spread deploy
- Loading branch information
Showing
7 changed files
with
148 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"rsprd.com/spread/pkg/deploy" | ||
"rsprd.com/spread/pkg/entity" | ||
"rsprd.com/spread/pkg/input/dir" | ||
|
||
"github.com/codegangsta/cli" | ||
) | ||
|
||
// Deploy allows the creation of deploy.Deployments remotely | ||
func (s SpreadCli) Deploy() *cli.Command { | ||
return &cli.Command{ | ||
Name: "deploy", | ||
Usage: "spread deploy [-s] PATH [kubectl context]", | ||
Description: "Deploys a Dockerfile to a remote Kubernetes cluster.", | ||
ArgsUsage: "-s will deploy only if no other deployment found (otherwise fails)", | ||
Action: func(c *cli.Context) { | ||
srcDir := c.Args().First() | ||
if len(srcDir) == 0 { | ||
s.fatalf("A directory to deploy from must be specified") | ||
} | ||
|
||
input, err := dir.NewFileInput(srcDir) | ||
if err != nil { | ||
s.fatalf(inputError(srcDir, err)) | ||
} | ||
|
||
e, err := input.Build() | ||
if err != nil { | ||
println("build") | ||
s.fatalf(inputError(srcDir, err)) | ||
} | ||
|
||
dep, err := e.Deployment() | ||
if err == entity.ErrMissingContainer { | ||
// check if has pod; if not deploy objects | ||
pods, _ := input.Entities(entity.EntityPod) | ||
if len(pods) != 0 { | ||
s.fatalf("Failed to deploy: %v", err) | ||
} | ||
|
||
objects, err := input.Objects() | ||
if err != nil { | ||
s.fatalf(inputError(srcDir, err)) | ||
} else if len(objects) == 0 { | ||
s.fatalf("Couldn't find objects to deploy in '%s'", srcDir) | ||
} | ||
|
||
dep = new(deploy.Deployment) | ||
for _, obj := range objects { | ||
err = dep.Add(obj) | ||
if err != nil { | ||
s.fatalf(inputError(srcDir, err)) | ||
} | ||
} | ||
} else if err != nil { | ||
println("deploy") | ||
s.fatalf(inputError(srcDir, err)) | ||
} | ||
|
||
context := c.Args().Get(1) | ||
cluster, err := deploy.NewKubeClusterFromContext(context) | ||
if err != nil { | ||
s.fatalf("Failed to deploy: %v", err) | ||
} | ||
|
||
s.printf("Deploying %d objects using the %s.", dep.Len(), displayContext(context)) | ||
|
||
update := !c.Bool("s") | ||
err = cluster.Deploy(dep, update) | ||
if err != nil { | ||
//TODO: make better error messages (one to indicate a deployment already existed; another one if a deployment did not exist but some other error was thrown | ||
s.fatalf("Did not deploy.: %v", err) | ||
} | ||
|
||
s.printf("Deployment successful!") | ||
}, | ||
} | ||
} | ||
|
||
func inputError(srcDir string, err error) string { | ||
return fmt.Sprintf("Error using `%s`: %v", srcDir, err) | ||
} | ||
|
||
func displayContext(name string) string { | ||
if name == deploy.DefaultContext { | ||
return "default context" | ||
} | ||
return fmt.Sprintf("context '%s'", name) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#Our philosophy | ||
|
||
Redspread's mission is to empower people to own their own deployment process and infrastructure. We're building the tools and workflows to fulfill that mission. | ||
|
||
We value collaboration, transparency, and fairness in everything we do. | ||
|
||
We also think the following are true: | ||
|
||
* Container versioning (i.e. versioning both images and configuration) will become increasingly important over the next year as more people use containers in production, just as versioning services has become common practice. | ||
* Software development is a multi-player game played with single player tools. Better collaborative tooling needs to be built for software organizations. | ||
* Introducing proprietary software into your infrastructure introduces external market risk into your product, and this risk should be very carefully considered whenever evaluating options. [See more of our thoughts on this](https://medium.com/@ciaomack/parsegate-the-case-against-proprietary-infrastructure-d397a89cbb2b). | ||
|
||
We love to talk philosophy - shoot us a note at [[email protected]](mailto:[email protected]) if you want to chat more. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters