-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: experimental blue-green deployment
Introduce the ability to specify different deployment-strategies. Implement blue-green deployments. Adds "experimental" meta field to joi schemas. Introduce "Experimental feature" warning message.
- Loading branch information
Showing
29 changed files
with
495 additions
and
14 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,33 @@ | ||
# Deployment strategies example | ||
|
||
A basic demo project showing different deployment strategies. | ||
|
||
It is based on the [examples/demo-project](https://github.com/garden-io/garden/tree/master/examples/demo-project) and it's meant to show how to configure the deployment strategies. | ||
|
||
> NOTE: the "Deployment Strategies feature" is still in the experimental phase. This means there might be changes to the properties names/values or to the behaviour in the future. Please be aware of this when using the feature. | ||
|
||
## Usage | ||
|
||
This project doesn't require any specific set up and can be deployed (in your local cluster) in a single step with the `deploy` command: | ||
|
||
```sh | ||
garden deploy --env=local-blue-green | ||
``` | ||
|
||
The first deploy on a fresh cluster will always be a normal `rolling-update` deploy. After making some changes to any of the module you will be able to see the Blue/Green strategy in action. | ||
|
||
### Example of configuration | ||
|
||
For more detailed configuration please check out the `garden.yml` file. | ||
|
||
```yaml | ||
kind: Project | ||
name: My Project | ||
environments: | ||
# Blue-green deployment strategy on local-kubernetes. | ||
- name: local-blue-green | ||
providers: | ||
- name: local-kubernetes | ||
deploymentStrategy: blue-green | ||
``` |
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,4 @@ | ||
node_modules | ||
Dockerfile | ||
garden.yml | ||
app.yaml |
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,27 @@ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
_testmain.go | ||
|
||
*.exe | ||
*.test | ||
*.prof | ||
|
||
.vscode/settings.json | ||
webserver/*server* |
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,14 @@ | ||
FROM golang:1.8.3-alpine | ||
MAINTAINER Aurelien PERRIER <a.perrier89@gmail.com> | ||
|
||
ENV webserver_path /go/src/github.com/perriea/webserver/ | ||
ENV PATH $PATH:$webserver_path | ||
|
||
WORKDIR $webserver_path | ||
COPY webserver/ . | ||
|
||
RUN go build . | ||
|
||
ENTRYPOINT ./webserver | ||
|
||
EXPOSE 8080 |
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,14 @@ | ||
kind: Module | ||
name: backend | ||
description: Backend service container | ||
type: container | ||
services: | ||
- name: backend | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
# Maps service:80 -> container:8080 | ||
servicePort: 80 | ||
ingresses: | ||
- path: /hello-backend | ||
port: http |
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,17 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
func handler(w http.ResponseWriter, r *http.Request) { | ||
fmt.Fprint(w, "Hello from Go!") | ||
} | ||
|
||
func main() { | ||
http.HandleFunc("/hello-backend", handler) | ||
fmt.Println("Server running...") | ||
|
||
http.ListenAndServe(":8080", nil) | ||
} |
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,4 @@ | ||
node_modules | ||
Dockerfile | ||
garden.yml | ||
app.yaml |
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,12 @@ | ||
FROM node:9-alpine | ||
|
||
ENV PORT=8080 | ||
EXPOSE ${PORT} | ||
WORKDIR /app | ||
|
||
ADD package.json /app | ||
RUN npm install | ||
|
||
ADD . /app | ||
|
||
CMD ["npm", "start"] |
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,27 @@ | ||
const express = require('express'); | ||
const request = require('request-promise') | ||
const app = express(); | ||
|
||
const backendServiceEndpoint = `http://backend/hello-backend` | ||
|
||
app.get('/hello-frontend', (req, res) => res.send('Hello from the frontend!')); | ||
|
||
app.get('/call-backend', (req, res) => { | ||
// Query the backend and return the response | ||
request.get(backendServiceEndpoint) | ||
.then(message => { | ||
message = `Backend says: '${message}'` | ||
res.json({ | ||
message, | ||
}) | ||
}) | ||
.catch(err => { | ||
res.statusCode = 500 | ||
res.json({ | ||
error: err, | ||
message: "Unable to reach service at " + backendServiceEndpoint, | ||
}) | ||
}); | ||
}); | ||
|
||
module.exports = { app } |
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,27 @@ | ||
kind: Module | ||
name: frontend | ||
description: Frontend service container | ||
type: container | ||
services: | ||
- name: frontend | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
healthCheck: | ||
httpGet: | ||
path: /hello-frontend | ||
port: http | ||
ingresses: | ||
- path: /hello-frontend | ||
port: http | ||
- path: /call-backend | ||
port: http | ||
dependencies: | ||
- backend | ||
tests: | ||
- name: unit | ||
args: [npm, test] | ||
- name: integ | ||
args: [npm, run, integ] | ||
dependencies: | ||
- frontend |
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,3 @@ | ||
const { app } = require('./app'); | ||
|
||
app.listen(process.env.PORT, '0.0.0.0', () => console.log('Frontend service started')); |
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,22 @@ | ||
{ | ||
"name": "frontend", | ||
"version": "1.0.0", | ||
"description": "Simple Node.js docker service", | ||
"main": "main.js", | ||
"scripts": { | ||
"start": "node main.js", | ||
"test": "echo OK", | ||
"integ": "node_modules/mocha/bin/mocha test/integ.js" | ||
}, | ||
"author": "garden.io <info@garden.io>", | ||
"license": "ISC", | ||
"dependencies": { | ||
"express": "^4.16.2", | ||
"request": "^2.83.0", | ||
"request-promise": "^4.2.2" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^5.1.1", | ||
"supertest": "^3.0.0" | ||
} | ||
} |
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,17 @@ | ||
const supertest = require("supertest") | ||
const { app } = require("../app") | ||
|
||
describe('GET /call-backend', () => { | ||
const agent = supertest.agent(app) | ||
|
||
it('should respond with a message from the backend service', (done) => { | ||
agent | ||
.get("/call-backend") | ||
.expect(200, { message: "Backend says: 'Hello from Go!'" }) | ||
.end((err) => { | ||
if (err) return done(err) | ||
done() | ||
}) | ||
}) | ||
}) | ||
|
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,28 @@ | ||
kind: Project | ||
name: deployment-strategies | ||
environments: | ||
# Default deployment strategy | ||
- name: local | ||
providers: | ||
- name: local-kubernetes | ||
# Default deployment strategy. | ||
# Same as above but explicit | ||
- name: local-default | ||
providers: | ||
- name: local-kubernetes | ||
deploymentStrategy: rolling | ||
# Blue-green deployment strategy. | ||
- name: local-blue-green | ||
providers: | ||
- name: local-kubernetes | ||
deploymentStrategy: blue-green | ||
# Testing environment | ||
- name: testing | ||
providers: | ||
- name: kubernetes | ||
context: gke_garden-dev-200012_europe-west1-b_garden-dev-1 | ||
namespace: deployment-strategies-testing-${local.env.CIRCLE_BUILD_NUM || local.username} | ||
defaultHostname: deployment-strategies-testing.dev-1.sys.garden | ||
buildMode: cluster-docker | ||
deploymentStrategy: blue-green | ||
|
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
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
Oops, something went wrong.