Added docs readme file
This commit is contained in:
parent
374729f6eb
commit
6c665295be
164
docs/README.md
164
docs/README.md
|
@ -4,112 +4,118 @@
|
||||||
1. [PIP-only, Fast deployment setup (demo)](README.md#fast-deployment-setup)
|
1. [PIP-only, Fast deployment setup (demo)](README.md#fast-deployment-setup)
|
||||||
2. [Docker container (development)](INSTALLDEV.md)
|
2. [Docker container (development)](INSTALLDEV.md)
|
||||||
3. [Install on current system (production)](INSTALL.md)
|
3. [Install on current system (production)](INSTALL.md)
|
||||||
1. Copy orchestra SSH key to the servers to be managed (you can use <span title="`orchestra@panel:~ ssh-copy-id root@server.address`">`ssh-copy-id`</span>: ), then Add the servers to be managed by orchestra into the servers section `/admin/orchestration/servers`, then copy orchestra's SSH pubkey to them
|
|
||||||
|
|
||||||
2. Now configure service by service (domains, databases, webapps, websites...):
|
1. Copy orchestra SSH key to the servers to be managed, you can use `ssh-copy-id`:
|
||||||
1. Add the route through `/admin/orchestration/route/`
|
```bash
|
||||||
2. Check and configure related settings on `/admin/settings/setting/`
|
orchestra@panel:~ ssh-copy-id root@server.address
|
||||||
3. Configure related resources if needed `/resources/resource/`, like Account Disc limit and traffic.
|
```
|
||||||
3. Test that everything works by creating and deleting services
|
Then add the servers to orchestra using the web interface `/admin/orchestration/servers`, check that the SSH connection is working and Orchestra can report the uptime of the servers.
|
||||||
|
|
||||||
|
2. Now configure service by service (domains, databases, webapps, websites, ...):
|
||||||
|
1. Add the route via `/admin/orchestration/route/`
|
||||||
|
2. Configure related settings on `/admin/settings/setting/`
|
||||||
|
3. If required, configure related resources like Account disc limit, VPS traffic, etc `/resources/resource/`
|
||||||
|
3. Test that everything works as expected by creating and deleting service instances
|
||||||
4. Do the same for the other services
|
4. Do the same for the other services
|
||||||
3. Configure billing by adding services `/admin/services/service/add/` and plans `/admin/plans/plan/`
|
|
||||||
1. Once a service is created hit the *Update orders* button
|
3. Configure billing by adding services `/admin/services/service/add/` and plans `/admin/plans/plan/`. Once a service is created hit the *Update orders* button to create the orders for the existing service instances.
|
||||||
|
|
||||||
|
|
||||||
### Architecture
|
### Architecture
|
||||||
Orchestration
|
Orchestration
|
||||||
Orders
|
Orders
|
||||||
|
Resources
|
||||||
|
|
||||||
|
|
||||||
### Creating new services
|
### Creating new services
|
||||||
1. Think about if the service can fit into one of the existing models like: SaaS or WebApps, refere to the related documentation if that is the case.
|
1. Think about if the service can fit into one of the existing service models like: SaaS or WebApps, refere to the related documentation if that is the case.
|
||||||
2. Create a new django app using startapp management command. For ilustrational purposes we will create a crontab services that will allow orchestra to manage user-based crontabs.
|
2. Create a new django app using `startapp` management command. For ilustrational purposes we will create a crontab services that will allow orchestra to manage user-based crontabs.
|
||||||
`python3 manage.py startapp crontabs`
|
```bash
|
||||||
3. Add the new *crontabs* app to the `INSTALLED_APPS` in your project's `settings.py`
|
python3 manage.py startapp crontabs
|
||||||
3. Create a `models.py` file with the data your service needs to keep in order to be managed by orchestra
|
```
|
||||||
|
3. Add the new *crontabs* app to the `INSTALLED_APPS` in your project's `settings.py`
|
||||||
|
3. Create a `models.py` file with the data your service needs to keep in order to be managed by orchestra
|
||||||
```python
|
```python
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
class CrontabSchedule(models.Model):
|
class CrontabSchedule(models.Model):
|
||||||
account = models.ForeignKey('accounts.Account', verbose_name=_("account"))
|
account = models.ForeignKey('accounts.Account', verbose_name=_("account"))
|
||||||
minute = models.CharField(_("minute"), max_length=64, default='*')
|
minute = models.CharField(_("minute"), max_length=64, default='*')
|
||||||
hour = models.CharField(_("hour"), max_length=64, default='*')
|
hour = models.CharField(_("hour"), max_length=64, default='*')
|
||||||
day_of_week = models.CharField(_("day of week"), max_length=64, default='*')
|
day_of_week = models.CharField(_("day of week"), max_length=64, default='*')
|
||||||
day_of_month = models.CharField(_("day of month"), max_length=64, default='*')
|
day_of_month = models.CharField(_("day of month"), max_length=64, default='*')
|
||||||
month_of_year = models.CharField(_("month of year"), max_length=64, default='*')
|
month_of_year = models.CharField(_("month of year"), max_length=64, default='*')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('month_of_year', 'day_of_month', 'day_of_week', 'hour', 'minute')
|
ordering = ('month_of_year', 'day_of_month', 'day_of_week', 'hour', 'minute')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
rfield = lambda f: f and str(f).replace(' ', '') or '*'
|
rfield = lambda f: f and str(f).replace(' ', '') or '*'
|
||||||
return "{0} {1} {2} {3} {4} (m/h/d/dM/MY)".format(
|
return "{0} {1} {2} {3} {4} (m/h/d/dM/MY)".format(
|
||||||
rfield(self.minute), rfield(self.hour), rfield(self.day_of_week),
|
rfield(self.minute), rfield(self.hour), rfield(self.day_of_week),
|
||||||
rfield(self.day_of_month), rfield(self.month_of_year),
|
rfield(self.day_of_month), rfield(self.month_of_year),
|
||||||
)
|
)
|
||||||
|
|
||||||
class Crontab(models.Model):
|
class Crontab(models.Model):
|
||||||
account = models.ForeignKey('accounts.Account', verbose_name=_("account"))
|
account = models.ForeignKey('accounts.Account', verbose_name=_("account"))
|
||||||
schedule = models.ForeignKey(CrontabSchedule, verbose_name=_("schedule"))
|
schedule = models.ForeignKey(CrontabSchedule, verbose_name=_("schedule"))
|
||||||
description = models.CharField(_("description"), max_length=256, blank=True)
|
description = models.CharField(_("description"), max_length=256, blank=True)
|
||||||
command = models.TextField(_("content"))
|
command = models.TextField(_("content"))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return (self.description or self.command)[:32]
|
return (self.description or self.command)[:32]
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Create a `admin.py` to enable the admin interface
|
4. Create a `admin.py` to enable the admin interface, refere to [Django Admin documentation](https://docs.djangoproject.com/en/1.9/ref/contrib/admin/) for further customization.
|
||||||
```python
|
```python
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import CrontabSchedule, Crontab
|
from .models import CrontabSchedule, Crontab
|
||||||
|
|
||||||
class CrontabScheduleAdmin(admin.ModelAdmin):
|
class CrontabScheduleAdmin(admin.ModelAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class CrontabAdmin(admin.ModelAdmin):
|
class CrontabAdmin(admin.ModelAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
admin.site.register(CrontabSchedule, CrontabScheduleAdmin)
|
admin.site.register(CrontabSchedule, CrontabScheduleAdmin)
|
||||||
admin.site.register(Crontab, CrontabAdmin)
|
admin.site.register(Crontab, CrontabAdmin)
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Create a `api.py` to enable the REST API.
|
||||||
|
|
||||||
5. Create a `api.py` to enable the REST API.
|
6. Create a `backends.py` fiel with the needed backends for service orchestration and monitoring.
|
||||||
6. Create a `backends.py` fiel with the needed backends for service orchestration and monitoring
|
```python
|
||||||
```python
|
import os
|
||||||
import os
|
import textwrap
|
||||||
import textwrap
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from orchestra.contrib.orchestration import ServiceController, replace
|
||||||
from orchestra.contrib.orchestration import ServiceController, replace
|
from orchestra.contrib.resources import ServiceMonitor
|
||||||
from orchestra.contrib.resources import ServiceMonitor
|
|
||||||
|
|
||||||
class UNIXCronBackend(ServiceController):
|
class UNIXCronBackend(ServiceController):
|
||||||
"""
|
"""
|
||||||
Basic UNIX cron support.
|
Basic UNIX cron support.
|
||||||
"""
|
"""
|
||||||
verbose_name = _("UNIX cron")
|
verbose_name = _("UNIX cron")
|
||||||
model = 'crons.CronTab'
|
model = 'crons.CronTab'
|
||||||
|
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
super(UNIXCronBackend, self).prepare()
|
super(UNIXCronBackend, self).prepare()
|
||||||
self.accounts = set()
|
self.accounts = set()
|
||||||
|
|
||||||
def save(self, crontab):
|
def save(self, crontab):
|
||||||
self.accounts.add(crontab.account)
|
self.accounts.add(crontab.account)
|
||||||
|
|
||||||
def delete(self, crontab):
|
def delete(self, crontab):
|
||||||
self.accounts.add(crontab.account)
|
self.accounts.add(crontab.account)
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
for account in self.accounts:
|
for account in self.accounts:
|
||||||
crontab = None
|
crontab = None
|
||||||
self.append("echo '' > %(crontab_path)s" % context)
|
self.append("echo '' > %(crontab_path)s" % context)
|
||||||
chown
|
for crontab in account.crontabs.all():
|
||||||
for crontab in account.crontabs.all():
|
self.append("
|
||||||
self.append("
|
```
|
||||||
# if crontab is None:
|
7. Configure the routing
|
||||||
# self.append("rm -f %(crontab_path)s" % context)
|
|
||||||
```
|
|
||||||
7. Configure the routing
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue