add example
This commit is contained in:
57
example/docker-compose.yml
Executable file
57
example/docker-compose.yml
Executable file
@@ -0,0 +1,57 @@
|
|||||||
|
version: '3.5'
|
||||||
|
|
||||||
|
services:
|
||||||
|
ldapi:
|
||||||
|
build: .
|
||||||
|
image: dtr.aws.e1.nwie.net/reese/ldapi:1.0.5
|
||||||
|
labels:
|
||||||
|
- "traefik.http.routers.ldapi.rule=Host(`ldapi.localhost`)"
|
||||||
|
- "traefik.http.services.ldapi-service.loadbalancer.server.port=8080"
|
||||||
|
volumes:
|
||||||
|
- ./manage.py:/app/manage.py
|
||||||
|
- ./config:/app/config
|
||||||
|
- ./ldapi:/app/ldapi
|
||||||
|
environment:
|
||||||
|
- DEBUG=True
|
||||||
|
- SECRET_KEY=secret
|
||||||
|
- FERNET_KEY=egj316Q7UsjVuBjnXxvcNFBIU8FNTdgk-bVnBJ-uz68=
|
||||||
|
- HOSTS=ldapi.localhost
|
||||||
|
- DJANGO_SUPERUSER_PASSWORD=django
|
||||||
|
depends_on:
|
||||||
|
- traefik
|
||||||
|
|
||||||
|
postgres:
|
||||||
|
image: postgres:12
|
||||||
|
volumes:
|
||||||
|
- data:/var/lib/postgresql/data
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: postgres
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
|
||||||
|
pgadmin:
|
||||||
|
image: dpage/pgadmin4:4
|
||||||
|
labels:
|
||||||
|
- "traefik.http.routers.pgadmin.rule=Host(`pgadmin.localhost`)"
|
||||||
|
- "traefik.http.services.pgadmin-service.loadbalancer.server.port=80"
|
||||||
|
volumes:
|
||||||
|
- pgadmin:/var/lib/pgadmin
|
||||||
|
environment:
|
||||||
|
PGADMIN_DEFAULT_EMAIL: postgres
|
||||||
|
PGADMIN_DEFAULT_PASSWORD: postgres
|
||||||
|
depends_on:
|
||||||
|
- traefik
|
||||||
|
|
||||||
|
traefik:
|
||||||
|
image: traefik:v2.2
|
||||||
|
labels:
|
||||||
|
- "traefik.http.routers.traefik.rule=Host(`traefik.localhost`)"
|
||||||
|
- "traefik.http.services.traefik-service.loadbalancer.server.port=8080"
|
||||||
|
command: --api.insecure=true --providers.docker --log.level=ERROR --accesslog=true
|
||||||
|
ports:
|
||||||
|
- "80:80"
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
data:
|
||||||
|
pgadmin:
|
||||||
9
example/templates/configmap.yaml
Normal file
9
example/templates/configmap.yaml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
labels:
|
||||||
|
app: {{ .Release.Name }}
|
||||||
|
data:
|
||||||
|
HOSTS: {{ .Values.host }}
|
||||||
|
DEBUG: "False"
|
||||||
33
example/templates/deploy.yaml
Normal file
33
example/templates/deploy.yaml
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: {{ .Release.Name }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- image: {{ required "A valid .Values.image entry required!" .Values.image }}:{{ required "A valid .Values.tag entry required!" .Values.tag }}
|
||||||
|
name: {{ .Release.Name }}-web
|
||||||
|
ports:
|
||||||
|
- containerPort: 8080
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
- secretRef:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
- secretRef:
|
||||||
|
name: postgres
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: "500Mi"
|
||||||
|
cpu: "250m"
|
||||||
|
requests:
|
||||||
|
memory: "1Mi"
|
||||||
|
cpu: "100m"
|
||||||
18
example/templates/hpa.yaml
Normal file
18
example/templates/hpa.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
apiVersion: autoscaling/v2beta2
|
||||||
|
kind: HorizontalPodAutoscaler
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
scaleTargetRef:
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
minReplicas: 1
|
||||||
|
maxReplicas: 12
|
||||||
|
metrics:
|
||||||
|
- type: Resource
|
||||||
|
resource:
|
||||||
|
name: cpu
|
||||||
|
target:
|
||||||
|
type: Utilization
|
||||||
|
averageUtilization: 50
|
||||||
17
example/templates/ingress.yaml
Executable file
17
example/templates/ingress.yaml
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
apiVersion: extensions/v1beta1
|
||||||
|
kind: Ingress
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
annotations:
|
||||||
|
kubernetes.io/ingress.class: default
|
||||||
|
spec:
|
||||||
|
tls:
|
||||||
|
- hosts:
|
||||||
|
- {{ required "A valid .Values.host entry required!" .Values.host }}
|
||||||
|
rules:
|
||||||
|
- host: {{ required "A valid .Values.host entry required!" .Values.host }}
|
||||||
|
http:
|
||||||
|
paths:
|
||||||
|
- backend:
|
||||||
|
serviceName: {{ .Release.Name }}
|
||||||
|
servicePort: 8080
|
||||||
11
example/templates/secret.yaml
Normal file
11
example/templates/secret.yaml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{{ if .Values.secrets }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
type: generic
|
||||||
|
data:
|
||||||
|
SECRET_KEY: {{ randAlphaNum 64 | b64enc | quote }}
|
||||||
|
DJANGO_SUPERUSER_PASSWORD: {{ randAlphaNum 64 | b64enc | quote }}
|
||||||
|
FERNET_KEY: {{ randAlphaNum 32 | b64enc | b64enc | quote }}
|
||||||
|
{{ end }}
|
||||||
19
example/templates/service.yaml
Normal file
19
example/templates/service.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: {{ .Release.Name }}
|
||||||
|
name: {{ .Release.Name }}
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- port: 8080
|
||||||
|
protocol: TCP
|
||||||
|
name: {{ .Release.Name }}-web
|
||||||
|
targetPort: 8080
|
||||||
|
- port: 5432
|
||||||
|
protocol: TCP
|
||||||
|
name: {{ .Release.Name }}-pg
|
||||||
|
targetPort: 5432
|
||||||
|
selector:
|
||||||
|
app: {{ .Release.Name }} # This selects the pod(s) that match the selector
|
||||||
|
type: ClusterIP
|
||||||
16
example/test.py
Normal file
16
example/test.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import getpass
|
||||||
|
import threading
|
||||||
|
import requests
|
||||||
|
import time
|
||||||
|
from requests.auth import HTTPBasicAuth
|
||||||
|
|
||||||
|
def timer(func, *args, **kwargs):
|
||||||
|
then = time.time()
|
||||||
|
func(*args, **kwargs)
|
||||||
|
print(time.time() - then)
|
||||||
|
|
||||||
|
user = getpass.getuser()
|
||||||
|
password = getpass.getpass()
|
||||||
|
me = lambda num: print(num) or print(requests.get('https://ldapi.apps-test.aws.e1.nwie.net/me/', verify="/etc/ssl/ca-bundle.pem", auth=HTTPBasicAuth(user, password)))
|
||||||
|
threadme = lambda num: threading.Thread(target=timer, args=(me, num)).start()
|
||||||
|
[threadme(y) for y in range(0,1000)]
|
||||||
Reference in New Issue
Block a user