|
1 | 1 | from django.core.management.base import BaseCommand |
2 | 2 | from django.shortcuts import get_object_or_404 |
3 | 3 |
|
4 | | -from api.models import Key, App, Domain, Certificate, Service |
| 4 | +from api.models import Key, App, AppSettings, Domain, Certificate, Service |
5 | 5 | from api.exceptions import DeisException, AlreadyExists |
6 | 6 |
|
7 | 7 |
|
8 | 8 | class Command(BaseCommand): |
9 | 9 | """Management command for publishing Deis platform state from the database |
10 | 10 | to k8s. |
11 | 11 | """ |
| 12 | + |
12 | 13 | def handle(self, *args, **options): |
13 | 14 | """Publishes Deis platform state from the database to kubernetes.""" |
14 | 15 | print("Publishing DB state to kubernetes...") |
@@ -40,6 +41,16 @@ def handle(self, *args, **options): |
40 | 41 | print('ERROR: There was a problem deploying {} ' |
41 | 42 | 'due to {}'.format(application, str(error))) |
42 | 43 |
|
| 44 | + # deploy autoscaling HPAs for application |
| 45 | + appsettings = AppSettings.objects.filter(app=application).order_by('-created')[0] |
| 46 | + if appsettings.autoscale: |
| 47 | + try: |
| 48 | + for proc_type in application.structure: |
| 49 | + application.autoscale(proc_type, appsettings.autoscale[proc_type]) |
| 50 | + except Exception as error: |
| 51 | + print('ERROR: There was a problem deploying HPAs for this {} proc_type ' |
| 52 | + 'of {} app due to error: {}'.format(proc_type, application, error)) |
| 53 | + |
43 | 54 | print("Done Publishing DB state to kubernetes.") |
44 | 55 |
|
45 | 56 | def save_apps(self): |
|
0 commit comments