Docs update

This commit is contained in:
Denis Zheleztsov 2017-02-07 12:41:43 +03:00
parent e13b74730b
commit 53f446e219
3 changed files with 208 additions and 57 deletions

View File

@ -5,19 +5,16 @@ conf.d/myapp.json
{ {
"services": [ "services": [
{ {
"name": "myapp", "name": "kioskservice",
"group": "backend.production", "group": "production.romania",
"ports": ["proxy", "api"] "ports": ["web", "socket"]
},
{
"name": "nginx",
"group": "frontend.production"
} }
], ],
"conf_name": "myapp_backend_production", "conf_name": "kiosk",
"template": "/etc/surok/templates/myapp.jj2", "template": "/etc/surok/templates/kiosk.jj2",
"dest": "/etc/myapp/myapp.cfg", "dest": "/etc/nginx/sites-available/kioskservice.conf",
"reload_cmd": "killall -9 myapp; /usr/local/bin/myapp -config /etc/myapp/myapp.cfg" "reload_cmd": "/sbin/nginx -t && /bin/systemctl reload nginx",
"run_cmd": ["/usr/bin/node", "-c", "config.json"]
} }
``` ```
* **services**. List of hashes with required services for app. * **services**. List of hashes with required services for app.

View File

@ -1,10 +1,10 @@
# Surok main config file # Surok main config file (0.8.x)
Default location is /etc/surok/conf/surok.json Default location is **/etc/surok/conf/surok.json**
conf/surok.json
``` ```
{ {
"version": "0.8"
"marathon": { "marathon": {
"enabled": false, "enabled": false,
"restart": false, "restart": false,
@ -24,7 +24,6 @@ conf/surok.json
"wait_time": 20, "wait_time": 20,
"lock_dir": "/var/tmp", "lock_dir": "/var/tmp",
"loglevel": "info", "loglevel": "info",
"container": false,
"memcached": { "memcached": {
"enabled": false, "enabled": false,
"discovery": { "discovery": {
@ -36,10 +35,56 @@ conf/surok.json
} }
} }
``` ```
* **marathon section**. Restarting app over marathon api if config changed. Disabled by default.
* **confd**. Directory where located configs apps. ## Config file options
* **domain**. Domain served by mesos-dns. * **version** - *string. Optional. "0.7" by default.*
* **lock_dir**. Directory where surok writes temporary configs after resolving. Config files and templates version. Accept "0.7" or "0.8".
* **wait_time**. Sleep time in main loop. * "0.7" - config files <= 0.7.х version
* **container**. Not implemented. * "0.8" - >= 0.8.x config files version
* **memcached section**. Memcached support. Disabled by default.
##### 0.8 version
* **marathon**, **mesos**, **consul**, **memcached** - *dict/hash. Optional. '{"enable":false}'. by default*
Surok working with folowing systems. If system is disabled parameters will be ignored.
* **enable** - *boolean. Optional. false by default*
Enable/disable system for usage.
Specific variables:
* For Marathon API "marathon"
* **force** - *boolean. Optional. true by default*
Force restart container over API.
* **restart** - *boolean. Optional. false by default*
Enable/disable restarting container
* **host** - *string. Optional. "http://marathon.mesos:8080" by default*
Marathon address.
* For Consul "consul"
* **domain** - *string. Required.*
Consul private domain
* For mesos-dns "mesos"
* **domain** - *string. Optional. "marathon.mesos" by default*
mesos-dns private domain
* For Memcached "memcached"
* **hosts** - memcached hosts
* **discovery**
* **enabled** - boolean. Enable/disable disovery memcached service
* **service** - string. memcached app name
* **group** - string. memcached app group
* **default_discovery** - *string. Optional. "mesos_dns" by default*
Accept values:
* "mesos_dns" - mesos-dns
* "marathon_api"- Marathon API
* "consul_dns" - Consul
* **confd** - *strig. Required.*
Path to directory with app config files.
* **wait_time** - *int. Required.*
Time in seconds how much Surok waits before starting to re-do the requests for service discovery
* **lock_dir** - *string. Required.*
Path to directory where Surok write lock-files.
* **loglevel** - *string. Optional. "info" by default*
Logleve. Accept values: "debug", "info", "warning", "error"
##### < 0.8 versions
* **marathon**
* **enabled** - boolean. Enable/disable container restart. Renamed to "restart" in 0.8 version.
* **domain** - string. mesos-dns private domain. Moved to "mesos" hashtable in 0.8 version.
Discovery over mesos-dns enabled all times.

View File

@ -5,8 +5,11 @@
- [Templates](#templates) - [Templates](#templates)
- [my dictionary in templates](#my-dictionary-in-templates) - [my dictionary in templates](#my-dictionary-in-templates)
- [Real template example](#real-template-example) - [0.8 version](#08-version)
- [Checks in template](#checks-in-template) - [Real template example](#real-template-example)
- [Checks in template](#checks-in-template)
- [0.7 version](#07-version)
- [Real template example](#real-template-example)
<!-- markdown-toc end --> <!-- markdown-toc end -->
@ -15,55 +18,74 @@ Surok using Jinja2 for templates. [Jinja2 documentation](http://jinja.pocoo.org/
## my dictionary in templates ## my dictionary in templates
### 0.8 version
``` ```
{ {
"services": { "services": {
"nginx": [ "asterisk": [
{ {
"name": "nginx.testing-kl92-s0.marathon.mesos.", "name": "nginx.testing-kl92-s0.marathon.mesos.",
"port": "31200", "ip": [
"ip": ["10.10.10.1"] "10.0.0.1",
"11.0.0.1"
],
"tcp": {
"rpc":31200,
"web":31201,
"sip":32000
},
"udp": {
"sip":31201
}
}, },
{ {
"name": "nginx.testing-kl123-s1.marathon.mesos.", "name": "nginx.testing-kl123-s1.marathon.mesos.",
"port": "32230", "ip": [
"ip": ["10.10.10.2"] "10.0.0.2",
"11.0.0.2"
],
"tcp": {
"rpc":31210,
"web":31211,
"sip":32010
},
"udp": {
"sip":31211
}
} }
], ],
"emailsender": [ "email": [
{ {
"name": "emailsender.testing-kl92-s0.marathon.mesos.", "name": "nginx.testing-kl92-s0.marathon.mesos.",
"port": "31201", "ip": [
"ip": ["10.10.10.1"] "10.0.0.1"
}, ],
{ "tcp": {
"name": "emailsender.testing-kl123-s1.marathon.mesos.", "smtp":31200,
"port": "32232", "pop":31201
"ip": ["10.10.10.1"] }
} }
], ],
"service-with-defined-ports": { "anyport": [
"web": [ {
{ "name": "nginx.testing-kl92-s0.marathon.mesos.",
"name": "f.q.d.n", "ip": [
"port": 12341 "10.0.0.1"
} ],
], "tcp": [
"rpc": [ 31200,
{ 31201
"name": "f.q.d.n", ]
"port": 12342 }
} ]
]
}
},
"env": { "env": {
"HOME": "/var/lib/nginx" "HOME": "/var/lib/nginx"
} }
} }
``` ```
## Real template example #### Real template example
nginx config nginx config
``` ```
@ -104,7 +126,7 @@ server {
} }
``` ```
## Checks in template #### Checks in template
_my['env']_ is a python os.environ class. Look bellow: _my['env']_ is a python os.environ class. Look bellow:
``` ```
@ -114,3 +136,90 @@ host = '{{my['env']['DB_HOST']}}'
host = 'localhost' host = 'localhost'
{% endif %} {% endif %}
``` ```
### 0.7 version
my dictionary in template
```
{
"services": {
"nginx": [
{
"name": "nginx.testing-kl92-s0.marathon.mesos.",
"port": "31200"
},
{
"name": "nginx.testing-kl123-s1.marathon.mesos.",
"port": "32230"
}
],
"emailsender": [
{
"name": "emailsender.testing-kl92-s0.marathon.mesos.",
"port": "31201"
},
{
"name": "emailsender.testing-kl123-s1.marathon.mesos.",
"port": "32232"
}
],
"service-with-defined-ports": {
"name-of-port0": [
{
"name": "f.q.d.n",
"port": 12341
}
],
"name-of-port2": [
{
"name": "f.q.d.n",
"port": 12342
}
]
}
},
"env": {
"HOME": "/var/lib/nginx"
}
}
```
#### Real template example
```
upstream matrix-http {
hash $remote_addr;
{% for server in my['services']['matrix']['http'] %}
server {{server['name']}}:{{server['port']}} max_fails=3;
{% endfor %}
}
upstream riot-http {
hash $remote_addr;
{% for server in my['services']['riot'] %}
server {{server['name']}}:{{server['port']}} max_fails=3;
{% endfor %}
}
server {
listen 10.15.56.157:80;
server_name matrix.example.com;
client_max_body_size 10m;
location / {
proxy_pass http://riot-http;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /_matrix/ {
proxy_pass http://matrix-http;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
```