Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #67 from remyLemeunier/add_helmdeploy
Browse files Browse the repository at this point in the history
Add deploy in k8s
  • Loading branch information
obiesmans authored Oct 10, 2017
2 parents 1afadbc + 8690826 commit 0a6ad83
Show file tree
Hide file tree
Showing 17 changed files with 584 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go

go:
- 1.8
- 1.9

install:
- sudo apt-get install -y --force-yes upx
Expand All @@ -12,7 +12,7 @@ script:
- mkdir /home/travis/.contactkey
- cp examples/config.sample.yml /home/travis/.contactkey/config.yml
- mkdir /tmp/manifests
- cp examples/manifest.sample.yml /tmp/manifests/manifest.yml
- cp examples/ggn-manifest.sample.yml /tmp/manifests/ggn-manifest.yml
- ./hack/verify-gofmt.sh
- go test --cover $(go list ./... | grep -v /vendor/)
- go build -o /tmp/cck
Expand Down
237 changes: 232 additions & 5 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,15 @@
[[constraint]]
branch = "master"
name = "github.com/spf13/cobra"

[[override]]
name = "github.com/ugorji/go"
revision = "8c0409fcbb70099c748d71f714529204975f6c3f"

[[override]]
name = "google.golang.org/grpc"
version = "=1.2.1"

[[constraint]]
branch = "master"
name = "github.com/remyLemeunier/k8s-deploy"
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,19 @@ globalEnvironments: # Define the cck environment. It can be anything.
- prod # the command line.

deployers: # Define the various deployers used in service manifest.
ggn: # Currently we have only ggn supported .
ggn: # This will enable the ggn deployment feature
vcsRegexp: -v(.+) # Extract the vcs sha1 from pod version. (Not mandatory)
workPath: /tmp
environments: # Link between ggn environment and cck environment created above.
preprod: staging
prod: production
k8s: # This will enable deployment on k8s using helm
workPath: /tmp
environments: # Link between cck environments and k8s clusters
local:
cluster: ops
preprod:
cluster: preprod

sources: # Define various version control system used in service manifest.
stash: # Currently we have only Stash supported.
Expand Down Expand Up @@ -88,6 +95,7 @@ lockSystem: # Define a lock system in order to avoid multiple com

```
## Configuration by service (manifest)

One file per service. They must be located in the workPath defined above.
The file name will be service name in the cck command.
```yaml
Expand Down Expand Up @@ -117,3 +125,6 @@ hooks: # Hooks we are going to call before and after.
- { command: "cd /tmp"}
stopOnError: true # If an error occurs stop the deployment process (not mandatory default false)
```
There are multiple `deployers`, the above example uses `ggn`, but you can deploy to kubernetes as well.
Here is an example : [k8s-manifest.sample.yaml](./examples/k8s-manifest.sample.yml).
5 changes: 4 additions & 1 deletion commands/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ func (d *Deploy) execute() {

}
}()
d.Context.Deployer.Deploy(d.Env, podVersion, stateStream)
err = d.Context.Deployer.Deploy(d.Env, podVersion, stateStream)
if err != nil {
log.Debugf("Deployment failed: %q", err)
}

for _, hook := range d.Context.Hooks {
err = hook.PostDeployment(userName, d.Env, d.Service, podVersion)
Expand Down
8 changes: 8 additions & 0 deletions context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ func NewContext(cfg *utils.Config, manifest *utils.Manifest) (*Context, error) {
if err != nil {
return nil, err
}
} else if manifest.DeployerManifest.DeployerK8sManifest != (utils.DeployerK8sManifest{}) {
log.Debug("Creating a new DeployerK8s instance")
ctx.Deployer, err = deployers.NewDeployerK8s(
cfg.DeployerConfig.DeployerK8sConfig,
manifest.DeployerManifest.DeployerK8sManifest)
if err != nil {
return nil, err
}
} else {
return nil, fmt.Errorf(
"Deployer unknown : %q",
Expand Down
Loading

0 comments on commit 0a6ad83

Please sign in to comment.