Commit 66b16ba6 by Cheng-En Wu

Initial commit

parents
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="FacetManager">
<facet type="django" name="Django">
<configuration>
<option name="rootFolder" value="$MODULE_DIR$" />
<option name="settingsModule" value="auto_istio/settings.py" />
<option name="manageScript" value="$MODULE_DIR$/manage.py" />
<option name="environment" value="&lt;map/&gt;" />
<option name="doNotUseTestRunner" value="false" />
<option name="trackFilePattern" value="migrations" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Remote Python 3.6.9 (sftp://ubuntu@10.0.0.210:22/usr/bin/python3)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Django" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/../auto_istio\templates" />
</list>
</option>
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" autoUpload="Always" serverName="ubuntu@10.0.0.210:22" autoUploadExternalChanges="true">
<serverData>
<paths name="10.0.0.210">
<serverdata>
<mappings>
<mapping local="$PROJECT_DIR$" web="/" />
</mappings>
</serverdata>
</paths>
<paths name="10.0.0.232">
<serverdata>
<mappings>
<mapping deploy="/home/ubuntu/auto_istio" local="$PROJECT_DIR$" />
</mappings>
</serverdata>
</paths>
<paths name="Copy of project-level server '10.0.0.210'">
<serverdata>
<mappings>
<mapping deploy="/home/ubuntu/auto_istio" local="$PROJECT_DIR$" />
</mappings>
</serverdata>
</paths>
<paths name="ubuntu@10.0.0.210:22">
<serverdata>
<mappings>
<mapping deploy="/home/ubuntu/auto_istio" local="$PROJECT_DIR$" />
</mappings>
</serverdata>
</paths>
</serverData>
<option name="myAutoUpload" value="ALWAYS" />
</component>
</project>
\ No newline at end of file
<component name="ProjectDictionaryState">
<dictionary name="Administrator">
<words>
<w>istio</w>
</words>
</dictionary>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Remote Python 3.6.9 (sftp://ubuntu@10.0.0.210:22/usr/bin/python3)" project-jdk-type="Python SDK" />
<component name="PyPackaging">
<option name="earlyReleasesAsUpgrades" value="true" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/auto_istio.iml" filepath="$PROJECT_DIR$/.idea/auto_istio.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteMappingsManager">
<list>
<list>
<remote-mappings server-id="python@63bd365f-7ccb-473e-87f1-c1520a0bafb1" />
</list>
</list>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SshConfigs">
<configs>
<sshConfig host="10.0.0.210" id="f2d64377-7ace-4838-ac83-7f66af570ffa" keyPath="C:\Users\Administrator\.ssh\id_rsa" port="22" customName="10.0.0.210" nameFormat="CUSTOM" />
<sshConfig host="10.0.0.210" id="8e8098ea-dd0e-4eff-a2c2-8ce799e84bba" keyPath="C:\Users\Administrator\.ssh\id_rsa" port="22" customName="10.0.0.210" nameFormat="CUSTOM" />
<sshConfig host="10.0.0.210" id="b714a8dd-91af-42b8-8492-836471e31607" keyPath="C:\Users\Administrator\.ssh\id_rsa" port="22" customName="10.0.0.210" nameFormat="CUSTOM" />
<sshConfig host="10.0.0.210" id="2ac788c2-67d4-4d20-ac53-415d08ce1542" keyPath="C:\Users\Administrator\.ssh\id_rsa" port="22" customName="10.0.0.210" nameFormat="CUSTOM" />
<sshConfig host="10.0.0.210" id="9471231d-b032-4b54-b64d-bb2ad6fba4cc" keyPath="C:\Users\Administrator\.ssh\id_rsa" port="22" customName="10.0.0.210" nameFormat="CUSTOM" />
<sshConfig host="10.0.0.210" id="bef5254c-7c4b-4edb-90ac-a41f04b0c4a4" keyPath="C:\Users\Administrator\.ssh\id_rsa" port="22" customName="10.0.0.210" nameFormat="CUSTOM" />
<sshConfig host="10.0.0.210" id="f1bb479e-0d00-446b-b914-b5c9efc77162" keyPath="C:\Users\Administrator\.ssh\id_rsa" port="22" customName="10.0.0.210" nameFormat="CUSTOM" />
<sshConfig host="10.0.0.210" id="2caf8e1f-253a-460c-8f71-49200d644b85" keyPath="C:\Users\Administrator\.ssh\id_rsa" port="22" customName="10.0.0.210" nameFormat="CUSTOM" />
<sshConfig host="10.0.0.210" id="f8198786-579b-4a3b-a023-6effff7823a1" keyPath="C:\Users\Administrator\.ssh\id_rsa" port="22" customName="10.0.0.210" nameFormat="CUSTOM" />
<sshConfig host="10.0.0.210" id="3cb4b2ba-367b-46a0-84d2-1e74fa89870f" keyPath="C:\Users\Administrator\.ssh\id_rsa" port="22" customName="10.0.0.210" nameFormat="CUSTOM" />
<sshConfig host="10.0.0.210" id="9d47fb10-d0f6-42d0-8e67-d00673795a7a" keyPath="C:\Users\Administrator\.ssh\id_rsa" port="22" customName="10.0.0.210" nameFormat="CUSTOM" />
</configs>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WebServers">
<option name="servers">
<webServer id="c002f63c-1771-45e0-8b53-606c3605ea1f" name="10.0.0.210" url="http://10.0.0.210">
<fileTransfer host="10.0.0.210" port="22" privateKey="C:\Users\Administrator\.ssh\id_rsa" accessType="SFTP" keyPair="true">
<advancedOptions>
<advancedOptions dataProtectionLevel="Private" passiveMode="true" shareSSLContext="true" />
</advancedOptions>
<option name="port" value="22" />
</fileTransfer>
</webServer>
</option>
</component>
</project>
\ No newline at end of file
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class AppConfig(AppConfig):
name = 'app'
from django.db import models
# Create your models here.
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: name
spec:
host: host
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
connectionPool:
tcp:
maxConnections: 1
http:
http1MaxPendingRequests: 1
maxRequestsPerConnection: 1
outlierDetection:
consecutiveErrors: 1
interval: 1s
baseEjectionTime: 30s
maxEjectionPercent: 100
\ No newline at end of file
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: name
spec:
trafficPolicy:
tls:
mode: ISTIO_MUTUAL
host: host
subsets:
- name: v1
labels:
version: v1
- name: v2
labels:
version: v2
\ No newline at end of file
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: name
spec:
hosts:
- host
http:
- route:
- destination:
host: host
subset: v1
weight: 100
mirror:
host: host
subset: v2
mirror_percent: 100
\ No newline at end of file
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: name
spec:
hosts:
- host
http:
- route:
- destination:
host: host
retries:
attempts: 3
perTryTimeout: 2s
\ No newline at end of file
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: host
spec:
hosts:
- host
http:
- route:
- destination:
host: host
subset: v1
weight: 90
- destination:
host: host
subset: v2
weight: 10
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
eyJhbGciOiJSUzI1NiIsImtpZCI6IiJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJkZWZhdWx0Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6ImRlZmF1bHQtdG9rZW4tZG5yN2giLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoiZGVmYXVsdCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6ImE5N2MwNzI4LWJiNGYtNGE1Yy1hM2RmLThlOWZmZmI5ZGI1ZSIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpkZWZhdWx0OmRlZmF1bHQifQ.kp5xdj7cqNzGKSY-j1gBitP-Rr_90bz92B_FF91NipPGFE6f9BwQtZD9eYcMCCVnyvthDALO4egh-FJuLle9KT-EdcWsF58LFklBIzbFiSgF4gj5DgXbNhu5P9ykuhng-qJMl21h1yBD6YUHmEB7yU05gOjNgg_4MjaCI4dKo7fPEthaLJygqsXjMksH3af4ss6F2XUGTC9WmB6jdjTAzUR83lzMjoF6I8Lkc5Xzj595iRXL7KZeCLyTD8mR5EcE3weThOSayWNzZHckwgOV-_qp1_o-O6Ujl4Ga7NeNhCZI49jgMSxnkbM4qIavP_FO05nfmbMWUj1UfGy6ilkFoA
\ No newline at end of file
import base64
import datetime
import json
import operator
import os
import re
import threading
import time
import requests
import yaml
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
from kubernetes import config, client
from rest_framework.decorators import action
from rest_framework.parsers import JSONParser
from rest_framework.viewsets import ModelViewSet
host = "https://10.0.0.210:6443/"
dr_url = "apis/networking.istio.io/v1alpha3/namespaces/default/destinationrules/"
vs_url = "apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices/"
class AutoIstioApi(ModelViewSet):
@csrf_exempt
@action(detail=True, methods="POST")
def create_circuit_breaking(self, request, *args, **kwargs):
# DestinationRule
circuit_breaking_json = yaml_to_json("circuit-breaking.yaml")
request_data = JSONParser().parse(request)
url = host + dr_url
headers = {'Content-Type': 'application/json', 'Authorization': "bearer " + get_token()}
requests.urllib3.disable_warnings()
circuit_breaking_json['metadata']['name'] = request_data['name']
circuit_breaking_json['spec']['host'] = request_data['host']
circuit_breaking_json['spec']['trafficPolicy']['connectionPool']['tcp']['maxConnections'] \
= request_data['maxConnections']
circuit_breaking_json['spec']['trafficPolicy']['connectionPool']['http'][
'maxRequestsPerConnection'] = request_data['maxRequestsPerConnection']
circuit_breaking_json['spec']['trafficPolicy']['connectionPool']['http'][
'http1MaxPendingRequests'] = request_data['maxConnections'] * request_data[
'maxRequestsPerConnection']
requests.post(url, headers=headers, data=json.dumps(circuit_breaking_json), verify=False)
return JsonResponse({"status": "succeed"}, status=201)
@csrf_exempt
@action(detail=True, methods="POST")
def create_canary_release(self, request, *args, **kwargs):
request_data = JSONParser().parse(request)
config.kube_config.load_kube_config()
v1 = client.CoreV1Api()
v1beta1 = client.ExtensionsV1beta1Api()
service = v1.read_namespaced_service(name=request_data['host'], namespace='default')
pod_ret = v1.list_namespaced_pod(namespace='default',
label_selector="app=" + service.metadata.labels['app'])
pod_list = pod_ret.items
pod_info_dict = dict()
for pod in pod_list:
pod_info = PodInfo(pod.metadata.name, pod.metadata.labels['version'],
pod.metadata.creation_timestamp)
pod_info_dict[pod_info.name] = pod_info
pod_info_list = list()
sorted_version = list()
for pod in (sorted(pod_info_dict.values(), key=operator.attrgetter('version'))):
sorted_version.append(pod.version)
pod_info_list.append(pod)
replicas = sorted_version.__len__() - 1
sorted_version = list(sorted(set(sorted_version)))
# DestinationRule
mirroring_dr_json = yaml_to_json("mirroring-dr.yaml")
url = host + dr_url
headers = {'Content-Type': 'application/json', 'Authorization': "bearer " + get_token()}
requests.urllib3.disable_warnings()
mirroring_dr_json['metadata']['name'] = request_data['name']
mirroring_dr_json['spec']['host'] = request_data['host']
mirroring_dr_json['spec']['subsets'][0]['name'] = sorted_version[0]
mirroring_dr_json['spec']['subsets'][0]['labels']['version'] = \
sorted_version[0]
mirroring_dr_json['spec']['subsets'][1]['name'] = sorted_version[1]
mirroring_dr_json['spec']['subsets'][1]['labels']['version'] = \
sorted_version[1]
response = requests.post(url, headers=headers, data=json.dumps(mirroring_dr_json),
verify=False)
if response.status_code != 201:
url = url + mirroring_dr_json['metadata']['name']
headers = {'Content-Type': 'application/merge-patch+json',
'Authorization': "bearer " + get_token()}
requests.patch(url, headers=headers, data=json.dumps(mirroring_dr_json),
verify=False)
# VirtualService
url = host + vs_url + request_data['name']
headers = {'Content-Type': 'application/json', 'Authorization': "bearer " + get_token()}
mirroring_vs_json = yaml_to_json("mirroring-vs.yaml")
mirroring_vs_json['metadata']['name'] = request_data['name']
mirroring_vs_json['spec']['hosts'][0] = request_data['host']
mirroring_vs_json['spec']['http'][0]['route'][0]['destination']['host'] = \
request_data['host']
mirroring_vs_json['spec']['http'][0]['route'][0]['destination']['subset'] = \
sorted_version[0]
mirroring_vs_json['spec']['http'][0]['mirror']['host'] = request_data['host']
mirroring_vs_json['spec']['http'][0]['mirror']['subset'] = sorted_version[1]
mirroring_vs_json['spec']['http'][0]['mirror_percent'] = int(100 / replicas)
response = requests.post(url, headers=headers, data=json.dumps(mirroring_vs_json),
verify=False)
if response.status_code != 201:
headers = {'Content-Type': 'application/merge-patch+json',
'Authorization': "bearer " + get_token()}
requests.patch(url, headers=headers, data=json.dumps(mirroring_vs_json), verify=False)
plugin_thread = threading.Thread(target=canary_release_threading,
args=(request_data,
pod_info_list[pod_info_list.__len__() - 1].name,
pod_info_list[
pod_info_list.__len__() - 1].creation_time,
sorted_version))
plugin_thread.start()
return JsonResponse({"status": "succeed"}, status=202)
@csrf_exempt
@action(detail=True, methods="POST")
def create_retry_policy(self, request, *args, **kwargs):
# VirtualService
url = host + vs_url
headers = {'Content-Type': 'application/json', 'Authorization': "bearer " + get_token()}
requests.urllib3.disable_warnings()
request_data = JSONParser().parse(request)
retries_json = yaml_to_json("retries.yaml")
retries_json['metadata']['name'] = request_data['name']
retries_json['spec']['hosts'][0] = request_data['host']
retries_json['spec']['http'][0]['route'][0]['destination']['host'] = request_data['host']
retries_json['spec']['http'][0]['retries']['attempts'] = request_data['attempts']
retries_json['spec']['http'][0]['retries']['perTryTimeout'] = str(
request_data['perTryTimeout']) + 's'
requests.post(url, headers=headers, data=json.dumps(retries_json), verify=False)
return JsonResponse({"status": "succeed"}, status=201)
@csrf_exempt
@action(detail=True, methods="DELETE")
def destroy(self, request, *args, **kwargs):
pass
class PodInfo:
def __init__(self, name, version, creation_time):
self.name = name
self.version = version
self.creation_time = creation_time
def get_token():
config.load_kube_config()
v1 = client.CoreV1Api()
secret = v1.read_namespaced_secret(namespace='default', name="default-token-dnr7h")
return base64.b64decode(secret.data['token']).decode("utf-8")
def yaml_to_json(file):
input_file = os.path.join(os.path.abspath(os.path.dirname(os.path.realpath(__file__))),
"templates", file)
with open(input_file, 'r') as stream:
try:
json_object = json.dumps(yaml.safe_load(stream), sort_keys=True, indent=2)
stream.close()
except yaml.YAMLError as exc:
json_object = "{}"
print(exc)
return eval(json_object)
def create_traffic_shifting_vs(request_data, sorted_version, new_version_weight):
# VirtualService
url = host + vs_url + request_data['name']
headers = {'Content-Type': 'application/merge-patch+json',
'Authorization': "bearer " + get_token()}
traffic_shifting_vs_json = yaml_to_json("traffic-shifting-vs.yaml")
traffic_shifting_vs_json['metadata']['name'] = request_data['name']
traffic_shifting_vs_json['spec']['hosts'][0] = request_data['host']
traffic_shifting_vs_json['spec']['http'][0]['route'][0]['destination']['host'] = \
request_data['host']
traffic_shifting_vs_json['spec']['http'][0]['route'][0]['destination']['subset'] = \
sorted_version[0]
traffic_shifting_vs_json['spec']['http'][0]['route'][0]['weight'] = 100 - new_version_weight
traffic_shifting_vs_json['spec']['http'][0]['route'][1]['destination']['host'] = \
request_data['host']
traffic_shifting_vs_json['spec']['http'][0]['route'][1]['destination']['subset'] = \
sorted_version[1]
traffic_shifting_vs_json['spec']['http'][0]['route'][1]['weight'] = new_version_weight
requests.patch(url, headers=headers, data=json.dumps(traffic_shifting_vs_json), verify=False)
def canary_release_threading(request_data, new_pod_name, new_pod_timestamp, sorted_version):
v1 = client.CoreV1Api()
v1beta1 = client.ExtensionsV1beta1Api()
successes = 0
while successes < 10:
successes = 0
failed = 0
now_time = datetime.datetime.now()
since_seconds = time.mktime(now_time.timetuple()) - time.mktime(
new_pod_timestamp.timetuple())
logs = v1.read_namespaced_pod_log(namespace='default',
container='istio-proxy',
name=new_pod_name,
since_seconds=int(since_seconds))
for line in logs.splitlines(keepends=False):
http_2xx_pattern = re.compile("2[0-9][0-9]")
http_3xx_pattern = re.compile("3[0-9][0-9]")
http_4xx_pattern = re.compile("4[0-9][0-9]")
http_5xx_pattern = re.compile("5[0-9][0-9]")
start_mark = re.compile(
'^\\[([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):'
'([0-5][0-9]):([0-5][0-9]|60)(\\.[0-9]+)?(([Zz])|([+|-]([01][0-9]|2[0-3]):'
'[0-5][0-9]))\\]$')
line_list = line.split(" ")
if start_mark.match(line_list[0]):
if http_2xx_pattern.match(line_list[4]):
successes = successes + 1
elif (http_3xx_pattern.match(line_list[4]) or
http_4xx_pattern.match(line_list[4]) or
http_5xx_pattern.match(line_list[4])):
failed = failed + 1
if failed >= 5:
return
print(sorted_version)
service = v1.read_namespaced_service(name=request_data['host'], namespace='default')
deployment_label = "app=" + service.metadata.labels['app'] + ",version=" + sorted_version[0]
old_deployment_ret = v1beta1.list_namespaced_deployment(namespace='default',
label_selector=deployment_label)
old_deployment = old_deployment_ret.items[0]
deployment_label = "app=" + service.metadata.labels['app'] + ",version=" + sorted_version[1]
new_deployment_ret = v1beta1.list_namespaced_deployment(namespace='default',
label_selector=deployment_label)
new_deployment = new_deployment_ret.items[0]
new_deployment.spec.replicas = old_deployment.spec.replicas
v1beta1.patch_namespaced_deployment(new_deployment.metadata.name, "default", new_deployment)
time.sleep(10)
for i in range(101):
print(i)
create_traffic_shifting_vs(request_data, sorted_version, i)
time.sleep(1)
old_deployment.spec.replicas = 0
v1beta1.patch_namespaced_deployment(old_deployment.metadata.name, "default", old_deployment)
print('finish canary deploy')
"""
Django settings for auto_istio project.
Generated by 'django-admin startproject' using Django 2.2.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'p5y#bacdj*@#lnr5xqa5edpaqo_x17@)%6x2r)0=ff_z9uyixj'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['*']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework'
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'auto_istio.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')]
,
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'auto_istio.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
STATIC_URL = '/static/'
"""auto_istio URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
from django.urls import path, include
from app.views import AutoIstioApi
urlpatterns = [
path('admin/', admin.site.urls),
url(r'^api-auth/', include('rest_framework.urls')),
url(r'^istio/circuit_breaking',
AutoIstioApi.as_view({
'post': 'create_circuit_breaking'})),
url(r'^istio/canary_release',
AutoIstioApi.as_view({
'post': 'create_canary_release'})),
url(r'^istio/retries',
AutoIstioApi.as_view({
'post': 'create_retry_policy'}))
]
"""
WSGI config for auto_istio project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'auto_istio.settings')
application = get_wsgi_application()
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'auto_istio.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment