Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit e8fb03a

Browse files
author
Sven Speckmaier
committed
Added readmes listing all options
1 parent b3d7423 commit e8fb03a

File tree

6 files changed

+131
-10
lines changed

6 files changed

+131
-10
lines changed

app/Blueprint/Healthcheck/HealthcheckConfigurationToService/HealthcheckConfigurationToService.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,30 @@ public function parseToService( Service $service, Configuration $configuration )
4646
$url = $healthcheckConfig->get('url', '');
4747
$healthcheckInformation->setUrl( $url );
4848

49+
$port = $healthcheckConfig->get('port', 80);
50+
$healthcheckInformation->setPort( $port );
51+
52+
$strategy = $healthcheckConfig->get( 'strategy', HealthcheckExtraInformation::STRATEGY_NONE );
53+
$healthcheckInformation->setStrategy( $strategy );
54+
55+
$interval = $healthcheckConfig->get( 'interval', 2000 );
56+
$healthcheckInformation->setInterval( $interval );
57+
58+
$responseTimeout = $healthcheckConfig->get( 'response-timeout', 2000 );
59+
$healthcheckInformation->setResponseTimeout( $responseTimeout );
60+
61+
$initializingTimeout = $healthcheckConfig->get( 'init-timeout', 60000 );
62+
$healthcheckInformation->setInitializingTimeout( $initializingTimeout );
63+
64+
$reinitializingTimeout = $healthcheckConfig->get( 'reinit-timeout', 60000 );
65+
$healthcheckInformation->setReinitializingTimeout( $reinitializingTimeout );
66+
67+
$healthyThreshold = $healthcheckConfig->get( 'healthy-threshold', 2 );
68+
$healthcheckInformation->setHealthyThreshold( $healthyThreshold );
69+
70+
$unhealthyThreshold = $healthcheckConfig->get( 'unhealthy-threshold', 3 );
71+
$healthcheckInformation->setUnhealthyThreshold( $unhealthyThreshold );
72+
4973
$service->addExtraInformation($healthcheckInformation);
5074

5175
}

app/Blueprint/Healthcheck/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Healthcheck
2+
Set up a rancher healthcheck that periodically opens connections to the container to check whether the service running
3+
in it is actually still doing its intended job.
4+
5+
## Options
6+
All options lie in the `healthcheck` json object.
7+
- `enable` can be set to `false` to disable the healthcheck without removing its data. Intended for debugging. defaults
8+
to `true`
9+
- `port` the port to query for a successful connection. Defaults to `80`
10+
- `url` http url to check. This will enable http 1.0 checking instead of tcp 'conection opens' checking
11+
- `interval`: Interval between healthchecks in ms. Defaults to `2000`
12+
- `response-timeout`: Time in ms before a stalled request is counted as having failed. Defaults to `2000`
13+
- `init-timeout`: Time before the first healthcheck is attempted in ms. Defaults to `60000`
14+
- `reinit-timeout`: Time after a restart before the first healthcheck is attempted in ms. Defaults to `60000`
15+
- `healthy-threshold`: Number of successful requests before the service counts as being healthy. Defaults to `2`
16+
- `unhealthy-threshold`: Number of failed requests before the service counts as being unhealthy. Defaults to `3`
17+
18+
## Example
19+
```json
20+
{
21+
"default": {
22+
"healthcheck":{
23+
"url":"\/"
24+
}
25+
}
26+
}
27+
```

app/Blueprint/PublishUrls/README.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,46 @@ The rancher traefik loadbalancer publishes service ports based on a list of labe
1313
- traefik.domain
1414
- traefik.alias
1515
- traefik.path
16-
- traefik.path.prefix
17-
- traefik.priority
16+
- traefik.path.prefix - traefik.priority
1817

19-
Setting
18+
## Example
2019
```json
2120
{
22-
"publish-urls": {
23-
"enable": true,
24-
"urls":[
25-
"https://www.example.com/sitemap.xml",
26-
"https://www.example.com/sitemaps/"
27-
]
21+
"default":{
22+
"healthcheck":{
23+
"enable":true
24+
},
25+
"publish":{
26+
"enable": true,
27+
"url": "https:\/\/www.example.com"
28+
}
29+
},
30+
"environments":{
31+
"test": {
32+
"publish": {
33+
"pathes": [
34+
"\/sitemaps\/",
35+
"\/sitemap.xml"
36+
]
37+
}
38+
}
2839
}
2940
}
3041
```
3142
Will set the traefik labels to balance the pathes `sitemap.xml,/sitemaps/` on `www.example.com` to the service.
3243
The protocol is currently ignored.
3344
Since no port is given port 80 is assumed
45+
46+
## All options
47+
All options are inside the `publish` json object
48+
- `type`: The type of loadbalancer / service discovery to create info for. Currently only `traefik` is available and is used
49+
as default.
50+
- `port`: The port inside the container that should be published through the load balancer. Defaults to `80`
51+
- `pathes`: If this is non-empty then only http urls with pathes starting with the given path are forwarded to this container. Defaults to `[]`
52+
- `priority`: High priority services beat lower priority services.
53+
54+
### Traefik implementation notes
55+
- The default priority is 5. Setting `pathes` will change the default priority to `10`.
56+
- Rancher traefik only accepts containers in the `healthy` state - this state only appears when a healthcheck is set. This mean
57+
setting a [healthcheck](../Healthcheck/README.md) is NECESSARY for the published urls to work.
58+
TODO: Add check for Loadbalancer to the valdation.

app/Blueprint/Scheduler/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Scheduler
2+
Sets scheduling rules for the container.
3+
4+
## Use case
5+
Rancher uses Tag based scheduling which is set via container labels.
6+
7+
## Options
8+
All options life inside the `scheduler` json object.
9+
10+
- `enable`: Can be set to `false` to disable creating the scheduling rules without removing them. Defaults to `true`
11+
- `scheduler`: Scheduler to use. Currently the default and only implementation available is `rancher`
12+
- `same-host`: Setting this to `true` will allow multiple containers to be scheduled on the same host. Defaults to `false`
13+
- `tags`: Object or array of tags. A host must have these tags set for a container to be scheduled there. Defaults to []
14+
- Arrays or numerical object variables will be created as `$VALUE=true` tag rule
15+
- non-numerical object variables will be created as `$NAME=$VALUE` tag rule
16+
- `forbid-tags`: Object or array of forbidden tags. see `tags` except the host must NOT have these tags. Defaults to []
17+
18+
19+
## Example
20+
```json
21+
{
22+
"defaults":{
23+
"scheduler":{
24+
"tags":[
25+
"apps",
26+
],
27+
"should-not-have-tags":[
28+
"fallback"
29+
]
30+
}
31+
}
32+
}
33+
```

app/Blueprint/Scheduler/SchedulerParser/SchedulerParser.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ public function parse( Service $service, Configuration $configuration ) {
3535
$forbiddenTags = [];
3636
$schedulerInformation->setForbidTags($forbiddenTags);
3737

38+
$shouldHaveTags = $schedulerConfig->get('should-have-tags', []);
39+
if( !is_array($shouldHaveTags) )
40+
$shouldHaveTags = [];
41+
$schedulerInformation->setShouldHaveTags($shouldHaveTags);
42+
43+
$shouldNotTags = $schedulerConfig->get('should-not-tags', []);
44+
if( !is_array($shouldNotTags) )
45+
$shouldNotTags = [];
46+
$schedulerInformation->setShouldNotTags($shouldNotTags);
47+
3848
$allowSameHost = $schedulerConfig->get('same-host', false);
3949
$schedulerInformation->setAllowSameHost($allowSameHost);
4050

app/Blueprint/Webserver/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ This blueprint creates infrastructures to support apps using php7.
1010

1111

1212
### Recognized Configuration Values
13-
13+
- [Healthcheck Options](../Healthcheck/README.md)
14+
- [Scheduler Options](../Scheduler/README.md)
15+
- [Publish Urls Options](../PublishUrls/README.md)
1416

1517
#### Docker options
1618
| Option | Defaults to | Explanation |

0 commit comments

Comments
 (0)