Skip to content

Commit

Permalink
Merge branch 'develop' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurVardevanyan committed Oct 17, 2021
2 parents 7c068e2 + 1125f57 commit 204c33c
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ __pycache__
.cache*
*/node_modules/*
*/logs/*
.vscode/*
env.py
cover/*
.coverage
*/my.cnf
*.env
*.env
35 changes: 34 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# WIP, TESTING ONLY, DO NOT DEPLOY
include:
- template: Security/Secret-Detection.gitlab-ci.yml
- template: Security/SAST.gitlab-ci.yml

variables:
SCAN_KUBERNETES_MANIFESTS: "true"

stages:
- test
- build
Expand All @@ -7,7 +14,7 @@ stages:

PythonTests:
stage: test
image: python:slim
image: python:3.9-slim
services:
- name: mariadb:latest
variables:
Expand Down Expand Up @@ -88,3 +95,29 @@ PushDevelop:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH

DeployKubernetes:
stage: deploy
image: ${IMAGE}
environment: production
only:
- develop
- production
script:
- sed -i "s,<IMAGE>,${CI_REGISTRY_IMAGE},g" kubernetes/deployment.yaml
- sed -i "s/<VERSION>/${CI_COMMIT_SHA}/g" kubernetes/deployment.yaml
- kubectl apply -f kubernetes/deployment.yaml

- sed -i "s,<CLIENT_ID>,${CLIENT_ID},g" kubernetes/configmap.yaml
- sed -i "s/<CLIENT_SECRET>/${CLIENT_SECRET}/g" kubernetes/configmap.yaml
- sed -i "s,<REDIRECT_URL>,${REDIRECT_URL},g" kubernetes/configmap.yaml
- sed -i "s,<HOST>,${HOST},g" kubernetes/configmap.yaml
- sed -i "s,<DATABASE>,${DATABASE},g" kubernetes/configmap.yaml
- sed -i "s,<USER>,${USER},g" kubernetes/configmap.yaml
- sed -i "s,<PASSWORD>,${PASSWORD},g" kubernetes/configmap.yaml
- kubectl apply -f kubernetes/configmap.yaml

- kubectl apply -f kubernetes/service.yaml

- sed -i "s/<URL>/${URL}/g" kubernetes/traefik.yaml
- kubectl apply -f kubernetes/traefik.yaml
19 changes: 19 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"python.testing.nosetestArgs": [
"webBackend"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": true,
"workbench.editor.highlightModifiedTabs": true,
"editor.insertSpaces": false,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.tabSize": 4,
"editor.renderControlCharacters": true,
"editor.renderWhitespace": "all",

}
2 changes: 1 addition & 1 deletion dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# WIP, TESTING ONLY, DO NOT DEPLOY
FROM python:slim
FROM python:3.9-slim
RUN apt-get update
RUN apt-get install -y apache2 libapache2-mod-wsgi-py3 libmariadb-dev gcc
COPY . /home/root/analytics-for-spotify/
Expand Down
13 changes: 13 additions & 0 deletions kubernetes/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: env
namespace: analytics-for-spotify
data:
CLIENT_ID: "<CLIENT_ID>"
CLIENT_SECRET: "<CLIENT_SECRET>"
HOST: <HOST>
DATABASE: <DATABASE>
USER: <USER>
PASSWORD: <PASSWORD>
REDIRECT_URL: "<REDIRECT_URL>"
75 changes: 75 additions & 0 deletions kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: analytics-for-spotify
namespace: analytics-for-spotify
labels:
app: analytics-for-spotify
spec:
replicas: 1
revisionHistoryLimit: 0
strategy:
type: RollingUpdate
selector:
matchLabels:
app: analytics-for-spotify
template:
metadata:
labels:
app: analytics-for-spotify
annotations:
enable.version-checker.io/analytics-for-spotify: "false"
spec:
containers:
- env:
- name: CLIENT_ID
valueFrom:
configMapKeyRef:
key: CLIENT_ID
name: env
- name: CLIENT_SECRET
valueFrom:
configMapKeyRef:
key: CLIENT_SECRET
name: env
- name: DATABASE
valueFrom:
configMapKeyRef:
key: DATABASE
name: env
- name: DOCKER
value: "YES"
- name: HOST
valueFrom:
configMapKeyRef:
key: HOST
name: env
- name: PASSWORD
valueFrom:
configMapKeyRef:
key: PASSWORD
name: env
- name: REDIRECT_URL
valueFrom:
configMapKeyRef:
key: REDIRECT_URL
name: env
- name: USER
valueFrom:
configMapKeyRef:
key: USER
name: env
image: <IMAGE>:<VERSION>
imagePullPolicy: IfNotPresent
name: analytics-for-spotify
ports:
- containerPort: 80
resources:
limits:
cpu: 350m
memory: 250M
requests:
cpu: 150m
memory: 175M
hostname: analytics-for-spotify
restartPolicy: Always
13 changes: 13 additions & 0 deletions kubernetes/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
namespace: analytics-for-spotify
name: analytics-for-spotify
spec:
ports:
- protocol: TCP
name: web
port: 80
targetPort: 80
selector:
app: analytics-for-spotify
14 changes: 14 additions & 0 deletions kubernetes/traefik.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: analytics-for-spotify
namespace: analytics-for-spotify
spec:
entryPoints:
- web
routes:
- match: "Host(`<URL>`)"
kind: Rule
services:
- name: analytics-for-spotify
port: 80

0 comments on commit 204c33c

Please sign in to comment.