diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..76f28a8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +draft.toml +charts/ +NOTICE +LICENSE +README.md diff --git a/.helmignore b/.helmignore new file mode 100644 index 0000000..747e6e9 --- /dev/null +++ b/.helmignore @@ -0,0 +1,27 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +*.png + +# known compile time folders +target/ +node_modules/ +vendor/ \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..9f652ee --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,78 @@ +pipeline { + agent { + label "jenkins-python" + } + environment { + ORG = 'mmontalvo' + APP_NAME = 'rest-django-payments' + CHARTMUSEUM_CREDS = credentials('jenkins-x-chartmuseum') + DOCKER_REGISTRY_ORG = 'strong-land-280923' + } + stages { + stage('CI Build and push snapshot') { + when { + branch 'PR-*' + } + environment { + PREVIEW_VERSION = "0.0.0-SNAPSHOT-$BRANCH_NAME-$BUILD_NUMBER" + PREVIEW_NAMESPACE = "$APP_NAME-$BRANCH_NAME".toLowerCase() + HELM_RELEASE = "$PREVIEW_NAMESPACE".toLowerCase() + } + steps { + container('python') { + sh "python -m unittest" + sh "export VERSION=$PREVIEW_VERSION && skaffold build -f skaffold.yaml" + sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:$PREVIEW_VERSION" + dir('./charts/preview') { + sh "make preview" + sh "jx preview --app $APP_NAME --dir ../.." + } + } + } + } + stage('Build Release') { + when { + branch 'master' + } + steps { + container('python') { + + // ensure we're not on a detached head + sh "git checkout master" + sh "git config --global credential.helper store" + sh "jx step git credentials" + + // so we can retrieve the version in later steps + sh "echo \$(jx-release-version) > VERSION" + sh "jx step tag --version \$(cat VERSION)" + sh "python -m unittest" + sh "export VERSION=`cat VERSION` && skaffold build -f skaffold.yaml" + sh "jx step post build --image $DOCKER_REGISTRY/$ORG/$APP_NAME:\$(cat VERSION)" + } + } + } + stage('Promote to Environments') { + when { + branch 'master' + } + steps { + container('python') { + dir('./charts/rest-django-payments') { + sh "jx step changelog --version v\$(cat ../../VERSION)" + + // release the helm chart + sh "jx step helm release" + + // promote through all 'Auto' promotion Environments + sh "jx promote -b --all-auto --timeout 1h --version \$(cat ../../VERSION)" + } + } + } + } + } + post { + always { + cleanWs() + } + } +} diff --git a/OWNERS b/OWNERS new file mode 100644 index 0000000..7ab9b24 --- /dev/null +++ b/OWNERS @@ -0,0 +1,4 @@ +approvers: +- mmontalvo +reviewers: +- mmontalvo diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES new file mode 100644 index 0000000..3d4ba91 --- /dev/null +++ b/OWNERS_ALIASES @@ -0,0 +1,6 @@ +aliases: +- mmontalvo +best-approvers: +- mmontalvo +best-reviewers: +- mmontalvo diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/__pycache__/__init__.cpython-38.pyc b/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..cdcfe6f Binary files /dev/null and b/__pycache__/__init__.cpython-38.pyc differ diff --git a/__pycache__/settings.cpython-38.pyc b/__pycache__/settings.cpython-38.pyc new file mode 100644 index 0000000..2f38c2e Binary files /dev/null and b/__pycache__/settings.cpython-38.pyc differ diff --git a/__pycache__/urls.cpython-38.pyc b/__pycache__/urls.cpython-38.pyc new file mode 100644 index 0000000..0f44456 Binary files /dev/null and b/__pycache__/urls.cpython-38.pyc differ diff --git a/__pycache__/wsgi.cpython-38.pyc b/__pycache__/wsgi.cpython-38.pyc new file mode 100644 index 0000000..da4f456 Binary files /dev/null and b/__pycache__/wsgi.cpython-38.pyc differ diff --git a/charts/preview/Chart.yaml b/charts/preview/Chart.yaml new file mode 100644 index 0000000..35e5bd8 --- /dev/null +++ b/charts/preview/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +icon: https://raw.githubusercontent.com/jenkins-x/jenkins-x-platform/master/images/python.png +name: preview +version: 0.1.0-SNAPSHOT diff --git a/charts/preview/Makefile b/charts/preview/Makefile new file mode 100755 index 0000000..4927a78 --- /dev/null +++ b/charts/preview/Makefile @@ -0,0 +1,18 @@ +OS := $(shell uname) + +preview: +ifeq ($(OS),Darwin) + sed -i "" -e "s/version:.*/version: $(PREVIEW_VERSION)/" Chart.yaml + sed -i "" -e "s/version:.*/version: $(PREVIEW_VERSION)/" ../*/Chart.yaml + sed -i "" -e "s/tag:.*/tag: $(PREVIEW_VERSION)/" values.yaml +else ifeq ($(OS),Linux) + sed -i -e "s/version:.*/version: $(PREVIEW_VERSION)/" Chart.yaml + sed -i -e "s/version:.*/version: $(PREVIEW_VERSION)/" ../*/Chart.yaml + sed -i -e "s|repository:.*|repository: $(DOCKER_REGISTRY)\/strong-land-280923\/rest-django-payments|" values.yaml + sed -i -e "s/tag:.*/tag: $(PREVIEW_VERSION)/" values.yaml +else + echo "platfrom $(OS) not supported to release from" + exit -1 +endif + echo " version: $(PREVIEW_VERSION)" >> requirements.yaml + jx step helm build diff --git a/charts/preview/requirements.yaml b/charts/preview/requirements.yaml new file mode 100755 index 0000000..7c8c5bc --- /dev/null +++ b/charts/preview/requirements.yaml @@ -0,0 +1,16 @@ +# !! File must end with empty line !! +dependencies: +- alias: expose + name: exposecontroller + repository: http://chartmuseum.jenkins-x.io + version: 2.3.92 +- alias: cleanup + name: exposecontroller + repository: http://chartmuseum.jenkins-x.io + version: 2.3.92 + + # !! "alias: preview" must be last entry in dependencies array !! + # !! Place custom dependencies above !! +- alias: preview + name: rest-django-payments + repository: file://../rest-django-payments diff --git a/charts/preview/values.yaml b/charts/preview/values.yaml new file mode 100755 index 0000000..b53ceaa --- /dev/null +++ b/charts/preview/values.yaml @@ -0,0 +1,22 @@ + +expose: + Annotations: + helm.sh/hook: post-install,post-upgrade + helm.sh/hook-delete-policy: hook-succeeded + config: + exposer: Ingress + http: true + tlsacme: false + +cleanup: + Args: + - --cleanup + Annotations: + helm.sh/hook: pre-delete + helm.sh/hook-delete-policy: hook-succeeded + +preview: + image: + repository: + tag: + pullPolicy: IfNotPresent \ No newline at end of file diff --git a/charts/rest-django-payments/.helmignore b/charts/rest-django-payments/.helmignore new file mode 100755 index 0000000..f0c1319 --- /dev/null +++ b/charts/rest-django-payments/.helmignore @@ -0,0 +1,21 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/charts/rest-django-payments/Chart.yaml b/charts/rest-django-payments/Chart.yaml new file mode 100644 index 0000000..d68bd12 --- /dev/null +++ b/charts/rest-django-payments/Chart.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +description: A Helm chart for Kubernetes +name: rest-django-payments +version: v0.1.0 diff --git a/charts/rest-django-payments/Makefile b/charts/rest-django-payments/Makefile new file mode 100755 index 0000000..12893e5 --- /dev/null +++ b/charts/rest-django-payments/Makefile @@ -0,0 +1,48 @@ +CHART_REPO := http://jenkins-x-chartmuseum:8080 +CURRENT=$(pwd) +NAME := rest-django-payments +OS := $(shell uname) +RELEASE_VERSION := $(shell cat ../../VERSION) + +build: clean + rm -rf requirements.lock + helm dependency build + helm lint + +install: clean build + helm install . --name ${NAME} + +upgrade: clean build + helm upgrade ${NAME} . + +delete: + helm delete --purge ${NAME} + +clean: + rm -rf charts + rm -rf ${NAME}*.tgz + +release: clean + helm dependency build + helm lint + helm init --client-only + helm package . + curl --fail -u $(CHARTMUSEUM_CREDS_USR):$(CHARTMUSEUM_CREDS_PSW) --data-binary "@$(NAME)-$(shell sed -n 's/^version: //p' Chart.yaml).tgz" $(CHART_REPO)/api/charts + rm -rf ${NAME}*.tgz% + +tag: +ifeq ($(OS),Darwin) + sed -i "" -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml + sed -i "" -e "s/tag:.*/tag: $(RELEASE_VERSION)/" values.yaml +else ifeq ($(OS),Linux) + sed -i -e "s/version:.*/version: $(RELEASE_VERSION)/" Chart.yaml + sed -i -e "s|repository:.*|repository: $(DOCKER_REGISTRY)\/strong-land-280923\/rest-django-payments|" values.yaml + sed -i -e "s/tag:.*/tag: $(RELEASE_VERSION)/" values.yaml +else + echo "platfrom $(OS) not supported to release from" + exit -1 +endif + git add --all + git commit -m "release $(RELEASE_VERSION)" --allow-empty # if first release then no verion update is performed + git tag -fa v$(RELEASE_VERSION) -m "Release version $(RELEASE_VERSION)" + git push origin v$(RELEASE_VERSION) diff --git a/charts/rest-django-payments/templates/NOTES.txt b/charts/rest-django-payments/templates/NOTES.txt new file mode 100755 index 0000000..da948fa --- /dev/null +++ b/charts/rest-django-payments/templates/NOTES.txt @@ -0,0 +1,15 @@ + +{{- if contains "NodePort" .Values.service.type }} + Get the application URL by running these commands: + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT/login +{{- else if contains "LoadBalancer" .Values.service.type }} + Get the application URL by running these commands: + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get svc -w {{ template "fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.externalPort }} +{{- else }} + http://{{ .Release.Name }}.{{ .Values.basedomain }} to access your application +{{- end }} diff --git a/charts/rest-django-payments/templates/_helpers.tpl b/charts/rest-django-payments/templates/_helpers.tpl new file mode 100755 index 0000000..f0d83d2 --- /dev/null +++ b/charts/rest-django-payments/templates/_helpers.tpl @@ -0,0 +1,16 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "fullname" -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/charts/rest-django-payments/templates/canary.yaml b/charts/rest-django-payments/templates/canary.yaml new file mode 100755 index 0000000..c65b131 --- /dev/null +++ b/charts/rest-django-payments/templates/canary.yaml @@ -0,0 +1,85 @@ +{{- if .Values.canary.enabled }} +apiVersion: flagger.app/v1beta1 +kind: Canary +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + provider: istio + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + progressDeadlineSeconds: {{ .Values.canary.progressDeadlineSeconds }} + {{- if .Values.hpa.enabled }} + autoscalerRef: + apiVersion: autoscaling/v2beta1 + kind: HorizontalPodAutoscaler + name: {{ template "fullname" . }} + {{- end }} + service: + port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + gateways: + - {{ template "fullname" . }} + hosts: + - {{ .Values.canary.host }} + analysis: + interval: {{ .Values.canary.canaryAnalysis.interval }} + threshold: {{ .Values.canary.canaryAnalysis.threshold }} + maxWeight: {{ .Values.canary.canaryAnalysis.maxWeight }} + stepWeight: {{ .Values.canary.canaryAnalysis.stepWeight }} + metrics: + - name: request-success-rate + threshold: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestSuccessRate.interval }} + - name: latency + templateRef: + name: latency + thresholdRange: + max: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.threshold }} + interval: {{ .Values.canary.canaryAnalysis.metrics.requestDuration.interval }} + +--- + +apiVersion: flagger.app/v1beta1 +kind: MetricTemplate +metadata: + name: latency +spec: + provider: + type: prometheus + address: http://prometheus.istio-system:9090 + query: | + histogram_quantile( + 0.99, + sum( + rate( + istio_request_duration_milliseconds_bucket{ + reporter="destination", + destination_workload_namespace="{{ "{{" }} namespace {{ "}}" }}", + destination_workload=~"{{ "{{" }} target {{ "}}" }}" + }[{{ "{{" }} interval {{ "}}" }}] + ) + ) by (le) + ) + +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: {{ template "fullname" . }} +spec: + selector: + istio: ingressgateway + servers: + - port: + number: {{ .Values.service.externalPort }} + name: http + protocol: HTTP + hosts: + - {{ .Values.canary.host }} +{{- end }} diff --git a/charts/rest-django-payments/templates/deployment.yaml b/charts/rest-django-payments/templates/deployment.yaml new file mode 100755 index 0000000..fb25128 --- /dev/null +++ b/charts/rest-django-payments/templates/deployment.yaml @@ -0,0 +1,43 @@ +{{- if .Values.knativeDeploy }} +{{- else }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + selector: + matchLabels: + app: {{ template "fullname" . }} +{{- if .Values.hpa.enabled }} +{{- else }} + replicas: {{ .Values.replicaCount }} +{{- end }} + template: + metadata: + labels: + draft: {{ default "draft-app" .Values.draft }} + app: {{ template "fullname" . }} +{{- if .Values.podAnnotations }} + annotations: +{{ toYaml .Values.podAnnotations | indent 8 }} +{{- end }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: +{{- range $pkey, $pval := .Values.env }} + - name: {{ $pkey }} + value: {{ quote $pval }} +{{- end }} + envFrom: +{{ toYaml .Values.envFrom | indent 10 }} + ports: + - containerPort: {{ .Values.service.internalPort }} + resources: +{{ toYaml .Values.resources | indent 12 }} +{{- end }} diff --git a/charts/rest-django-payments/templates/hpa.yaml b/charts/rest-django-payments/templates/hpa.yaml new file mode 100755 index 0000000..1c03eb4 --- /dev/null +++ b/charts/rest-django-payments/templates/hpa.yaml @@ -0,0 +1,25 @@ +{{- if .Values.hpa.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ template "fullname" . }} + labels: + draft: {{ default "draft-app" .Values.draft }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ template "fullname" . }} + minReplicas: {{ .Values.hpa.minReplicas }} + maxReplicas: {{ .Values.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.hpa.cpuTargetAverageUtilization }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.hpa.memoryTargetAverageUtilization }} +{{- end }} \ No newline at end of file diff --git a/charts/rest-django-payments/templates/ingress.yaml b/charts/rest-django-payments/templates/ingress.yaml new file mode 100755 index 0000000..3598ac6 --- /dev/null +++ b/charts/rest-django-payments/templates/ingress.yaml @@ -0,0 +1,17 @@ +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: {{ template "fullname" . }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + rules: + - host: {{ .Release.Name }}.{{ .Values.basedomain }} + http: + paths: + - path: / + backend: + serviceName: {{ template "fullname" . }} + servicePort: {{ .Values.service.externalPort }} +{{- end -}} diff --git a/charts/rest-django-payments/templates/ksvc.yaml b/charts/rest-django-payments/templates/ksvc.yaml new file mode 100755 index 0000000..d37fb3f --- /dev/null +++ b/charts/rest-django-payments/templates/ksvc.yaml @@ -0,0 +1,41 @@ +{{- if .Values.knativeDeploy }} +apiVersion: serving.knative.dev/v1alpha1 +kind: Service +metadata: +{{- if .Values.service.name }} + name: {{ .Values.service.name }} +{{- else }} + name: {{ template "fullname" . }} +{{- end }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +spec: + runLatest: + configuration: + revisionTemplate: + spec: + container: + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: +{{- range $pkey, $pval := .Values.env }} + - name: {{ $pkey }} + value: {{ quote $pval }} +{{- end }} + livenessProbe: + httpGet: + path: {{ .Values.probePath }} + initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }} + periodSeconds: {{ .Values.livenessProbe.periodSeconds }} + successThreshold: {{ .Values.livenessProbe.successThreshold }} + timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }} + readinessProbe: + failureThreshold: {{ .Values.readinessProbe.failureThreshold }} + httpGet: + path: {{ .Values.probePath }} + periodSeconds: {{ .Values.readinessProbe.periodSeconds }} + successThreshold: {{ .Values.readinessProbe.successThreshold }} + timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }} + resources: +{{ toYaml .Values.resources | indent 14 }} +{{- end }} diff --git a/charts/rest-django-payments/templates/service.yaml b/charts/rest-django-payments/templates/service.yaml new file mode 100755 index 0000000..9a2a4c7 --- /dev/null +++ b/charts/rest-django-payments/templates/service.yaml @@ -0,0 +1,26 @@ +{{- if or .Values.knativeDeploy .Values.canary.enabled }} +{{- else }} +apiVersion: v1 +kind: Service +metadata: +{{- if .Values.service.name }} + name: {{ .Values.service.name }} +{{- else }} + name: {{ template "fullname" . }} +{{- end }} + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" +{{- if .Values.service.annotations }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} +{{- end }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + protocol: TCP + name: http + selector: + app: {{ template "fullname" . }} +{{- end }} diff --git a/charts/rest-django-payments/values.yaml b/charts/rest-django-payments/values.yaml new file mode 100755 index 0000000..ce00c77 --- /dev/null +++ b/charts/rest-django-payments/values.yaml @@ -0,0 +1,73 @@ +# Default values for python. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +image: + repository: draft + tag: dev + pullPolicy: IfNotPresent + +# define environment variables here as a map of key: value +env: + +# enable this flag to use knative serve to deploy the app +knativeDeploy: false + +# HorizontalPodAutoscaler +hpa: + enabled: false + minReplicas: 2 + maxReplicas: 6 + cpuTargetAverageUtilization: 80 + memoryTargetAverageUtilization: 80 + +# Canary deployments +# If enabled, Istio v1.5+ and Flagger need to be installed in the cluster +canary: + enabled: false + progressDeadlineSeconds: 60 + canaryAnalysis: + interval: "1m" + threshold: 5 + maxWeight: 60 + stepWeight: 20 + # WARNING: Canary deployments will fail and rollback if there is no traffic that will generate the below specified metrics. + metrics: + requestSuccessRate: + threshold: 99 + interval: "1m" + requestDuration: + threshold: 1000 + interval: "1m" + # The host is using Istio Gateway and is currently not auto-generated + # Please overwrite the `canary.host` in `values.yaml` in each environment repository (e.g., staging, production) + host: acme.com + +service: + name: rest-django-payments + type: ClusterIP + externalPort: 80 + internalPort: 8080 + annotations: + fabric8.io/expose: "true" + fabric8.io/ingress.annotations: "kubernetes.io/ingress.class: nginx" +resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi +ingress: + enabled: false +probePath: / +livenessProbe: + initialDelaySeconds: 60 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 +readinessProbe: + failureThreshold: 1 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..9e6db56 --- /dev/null +++ b/settings.py @@ -0,0 +1,126 @@ +""" +Django settings for rest_django_payments project. + +Generated by 'django-admin startproject' using Django 2.2.12. + +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 = 'su9id&)ww_kn0%^vus+e)0^z!14hu)fu$r6rs=&d_t3hx=ise7' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = ["*"] + + +# Application definition + +INSTALLED_APPS = [ + 'rest_framework', + 'api.apps.ApiConfig', + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +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 = 'rest_django_payments.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + '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 = 'rest_django_payments.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.2/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'moneyfx', + 'USER': 'root', + 'PASSWORD': os.environ.get('POSTGRES_PASSWORD', 'password'), + 'HOST': os.environ.get('MONEYFX_PG_HOST', 'mysql'), + 'PORT': 3306, + } +} + + +# 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/' diff --git a/skaffold.yaml b/skaffold.yaml new file mode 100644 index 0000000..f20825e --- /dev/null +++ b/skaffold.yaml @@ -0,0 +1,28 @@ +apiVersion: skaffold/v1beta2 +kind: Config +build: + artifacts: + - image: strong-land-280923/rest-django-payments + context: . + docker: {} + tagPolicy: + envTemplate: + template: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}:{{.VERSION}}' + local: {} +deploy: + kubectl: {} +profiles: +- name: dev + build: + tagPolicy: + envTemplate: + template: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}:{{.DIGEST_HEX}}' + local: {} + deploy: + helm: + releases: + - name: rest-django-payments + chartPath: charts/rest-django-payments + setValueTemplates: + image.repository: '{{.DOCKER_REGISTRY}}/{{.IMAGE_NAME}}' + image.tag: '{{.DIGEST_HEX}}' diff --git a/urls.py b/urls.py new file mode 100644 index 0000000..32397e5 --- /dev/null +++ b/urls.py @@ -0,0 +1,22 @@ +"""rest_django_payments 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.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('', include('api.urls')) +] diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..92c103b --- /dev/null +++ b/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for rest_django_payments 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', 'rest_django_payments.settings') + +application = get_wsgi_application()