Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
49c45a5
add files
akubrachenko Jan 16, 2019
25ec19f
changes
akubrachenko Jan 16, 2019
646076a
change jenkins file
akubrachenko Jan 16, 2019
30e0313
change var in jankinsefile
akubrachenko Jan 16, 2019
36e3f48
some changes in jenkinsfile
akubrachenko Jan 16, 2019
360ee1d
jenkins 1
akubrachenko Jan 16, 2019
b66fb63
v1
akubrachenko Jan 16, 2019
adb3906
v2
akubrachenko Jan 16, 2019
da60544
v2.1
akubrachenko Jan 16, 2019
838e568
v3
akubrachenko Jan 16, 2019
d609a43
v4
akubrachenko Jan 16, 2019
3fc70cb
v4.1
akubrachenko Jan 16, 2019
41066e9
v4.2
akubrachenko Jan 16, 2019
04cd092
v4.3
akubrachenko Jan 16, 2019
1f52f02
v5
akubrachenko Jan 16, 2019
e942d13
beta jenkinsfile
akubrachenko Jan 16, 2019
dfe8a5f
change dest
akubrachenko Jan 16, 2019
9a5bcc7
change template
akubrachenko Jan 16, 2019
73abe9a
changes
akubrachenko Jan 16, 2019
bc8b5ea
change dockerfile
akubrachenko Jan 16, 2019
208af60
some changes
akubrachenko Jan 16, 2019
96c399f
test sh
akubrachenko Jan 16, 2019
b0ad929
change sh 1
akubrachenko Jan 16, 2019
b033eaa
test
akubrachenko Jan 16, 2019
2e16af8
beta version
akubrachenko Jan 17, 2019
69c0a54
change port
akubrachenko Jan 17, 2019
38fc925
change host
akubrachenko Jan 17, 2019
31c3d40
change host
akubrachenko Jan 17, 2019
ccac79f
change image
akubrachenko Jan 18, 2019
47ef6c7
change jenkins
akubrachenko Jan 18, 2019
51fd2f2
edit jenkins
akubrachenko Jan 18, 2019
6686d66
Change Jenkinsfile
Maxghost33 Jan 23, 2019
e3cf2a8
Change Jenkinsfile
Maxghost33 Jan 23, 2019
61ac3e3
Change SED replace script
Maxghost33 Jan 23, 2019
b25c477
Restore
Maxghost33 Jan 23, 2019
8c45e49
Add new e2e test
Maxghost33 Jan 24, 2019
af55b47
Add new e2e test
Maxghost33 Jan 24, 2019
1905fc0
Update Jenkinsfile
admgolovin Jan 24, 2019
b1ed8e6
Update Jenkinsfile
admgolovin Jan 24, 2019
550ad61
Jenkins works
Maxghost33 Jan 24, 2019
992d3b9
Merge branch 'test' of https://github.com/Kv-045DevOps/SRM-DB into test
Maxghost33 Jan 24, 2019
d741784
Jenkinsfile
Maxghost33 Jan 26, 2019
29dacb8
Jenkinefile
Maxghost33 Jan 27, 2019
1b8ef77
Test
Maxghost33 Jan 31, 2019
4c67ca0
Test
Maxghost33 Jan 31, 2019
da15f32
Test Pipeline
Maxghost33 Feb 3, 2019
5586e6d
Test Pipeline
Maxghost33 Feb 3, 2019
b9f8b0e
Test Pipeline
Maxghost33 Feb 3, 2019
1736ea1
Test Pipeline
Maxghost33 Feb 3, 2019
0e1f797
Test Pipeline
Maxghost33 Feb 3, 2019
d5575ec
Test Pipeline
Maxghost33 Feb 3, 2019
196cb7a
Testing E2E
Maxghost33 Feb 3, 2019
5476fe3
Stage 3
Maxghost33 Feb 3, 2019
446b2de
Stage 3
Maxghost33 Feb 3, 2019
9951fa1
Test after deploy
Maxghost33 Feb 3, 2019
ede04d5
First failed test
Maxghost33 Feb 3, 2019
d0ffcd8
Stage 3
Maxghost33 Feb 3, 2019
e908868
Sleep test
Maxghost33 Feb 3, 2019
99e4556
Last Test
Maxghost33 Feb 3, 2019
7288d0b
Test#4
Maxghost33 Feb 3, 2019
32ca4d4
Without pull
Maxghost33 Feb 6, 2019
2d17aae
Without pull
Maxghost33 Feb 6, 2019
2be5281
Without pull
Maxghost33 Feb 6, 2019
478ef47
Without pull#3
Maxghost33 Feb 7, 2019
9f27066
Without pull
Maxghost33 Feb 8, 2019
6ddc66f
Without pull 08.02.2019
Maxghost33 Feb 8, 2019
1d0db92
Without pull 08.02.2018#1
Maxghost33 Feb 8, 2019
bfc4a8f
Without pull 08.02.2018#1
Maxghost33 Feb 8, 2019
5d813fd
Without pull 08.02.2019#3
Maxghost33 Feb 8, 2019
1c9316f
Testing Jenkinfiles HELM E2E
Maxghost33 Feb 10, 2019
8e6aa44
Testing Jenkinfiles HELM E2E
Maxghost33 Feb 10, 2019
18b5888
Testing Jenkinfiles HELM E2E - init commit
Maxghost33 Feb 10, 2019
19d1253
Testing Jenkinfiles HELM E2E - init commit
Maxghost33 Feb 10, 2019
c24ee9d
Testing Jenkinfiles HELM E2E - init commit
Maxghost33 Feb 10, 2019
b48b7a6
Testing Jenkinfiles HELM E2E - init commit
Maxghost33 Feb 10, 2019
e0df4c8
Testing Jenkinfiles HELM E2E - init commit#2
Maxghost33 Feb 10, 2019
045b9cb
Testing Jenkinfiles HELM E2E - init commit#2
Maxghost33 Feb 10, 2019
942600a
Testing Jenkinfiles HELM E2E - init commit#2
Maxghost33 Feb 10, 2019
0b474d2
Testing Jenkinfiles HELM E2E - init commit#2
Maxghost33 Feb 10, 2019
8a23a6f
Testing Jenkinfiles HELM E2E - init commit#2
Maxghost33 Feb 10, 2019
540650d
Testing Jenkinfiles HELM E2E - init commit#2
Maxghost33 Feb 10, 2019
8185fe0
Testing Jenkinfiles HELM E2E - init commit#2
Maxghost33 Feb 10, 2019
042e5fa
Testing Jenkinfiles HELM E2E - init commit#2
Maxghost33 Feb 10, 2019
f1522f0
Testing Jenkinfiles HELM E2E - init commit#2
Maxghost33 Feb 10, 2019
455f0fd
for demo 4
akubrachenko Feb 11, 2019
5619927
Test ISTIO - add annotations
Maxghost33 Feb 11, 2019
eeceb73
TEST ISTIO
Maxghost33 Feb 11, 2019
84c9b3e
Troubleshooting DB
Maxghost33 Feb 11, 2019
c834fbf
Test Deploy
Maxghost33 Feb 11, 2019
63a0d1b
Test Deploy
Maxghost33 Feb 11, 2019
1ddcfef
Test Deploy
Maxghost33 Feb 11, 2019
ff50084
Result not local
Maxghost33 Feb 12, 2019
20cb80d
Test Helm charts
Maxghost33 Feb 12, 2019
c73dccf
Test Git Jenkinsfile Istio
Maxghost33 Feb 12, 2019
690a60b
Bug resolve
Maxghost33 Feb 12, 2019
f592fe4
TEST DB
Maxghost33 Feb 12, 2019
74b47b5
Versions
Maxghost33 Feb 12, 2019
f714e7e
Bug resolve
Maxghost33 Feb 12, 2019
f8ed2cf
TEST
Maxghost33 Feb 13, 2019
7097dfa
TEST DEPLOY POST
Maxghost33 Feb 13, 2019
0d78460
TEST DEPLOY POST
Maxghost33 Feb 13, 2019
13f18aa
23
Maxghost33 Feb 13, 2019
e602d5a
B/G Ver 2
Maxghost33 Feb 14, 2019
b855463
B/G v3
Maxghost33 Feb 14, 2019
b032e13
TEST B/G v6
Maxghost33 Feb 14, 2019
e6eff99
ISTIO FUCKING RELEASE
Maxghost33 Feb 14, 2019
3915351
TEST DEPLOY
Maxghost33 Feb 14, 2019
56c4e6e
TEST DEPLOY#2
Maxghost33 Feb 14, 2019
1529a06
TEST DEPLOY#2
Maxghost33 Feb 14, 2019
689ba6b
TEST B/G v45
Maxghost33 Feb 14, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.6.7-alpine
MAINTAINER Artem Kubrachenko
WORKDIR /app
COPY dbservice.py requirements.txt ./
RUN mkdir app
COPY app/* ./app/
RUN apk --no-cache add build-base
RUN apk --no-cache add postgresql-dev
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["dbservice.py"]
95 changes: 95 additions & 0 deletions E2E-Test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---

apiVersion: v1
kind: Secret
metadata:
name: db-secret
namespace: testing
data:
username: ZGJhZG1pbg==
password: UGFzc3dvcmQ=
dbname: c3Jtc3lzdGVt
type: Opaque

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: testing
labels:
app: pvc-postgres
name: postgres-pvc
spec:
#storageClassName: slow
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
namespace: testing
name: postgres
labels:
service: postgresdb
spec:
template:
metadata:
labels:
app: postgres
spec:
initContainers:
- name: volume-mount-hack
image: busybox
command: ["sh", "-c", "chown -R 999:999 /var/lib/postgresql/"]
volumeMounts:
- name: postgres-pv-claim
mountPath: /var/lib/postgresql/data
subPath: postgres
containers:
- image: postgres:9.6.2
name: postgresql
env:
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: db-secret
key: dbname
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: db-secret
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: db-secret
key: password
ports:
- containerPort: 5432
volumeMounts:
- name: postgres-pv-claim
mountPath: /var/lib/postgresql/data
subPath: postgres
volumes:
- name: postgres-pv-claim
persistentVolumeClaim:
claimName: postgres-pvc

---
kind: Service
apiVersion: v1
metadata:
namespace: testing
name: srmsystemdb
spec:
selector:
app: postgres
ports:
- protocol: TCP
port: 5432
targetPort: 5432
---
94 changes: 94 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
def label = "mypod-${UUID.randomUUID().toString()}"


podTemplate(label: label, annotations: [podAnnotation(key: "sidecar.istio.io/inject", value: "false")], containers: [
containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v3', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', command: 'cat', ttyEnabled: true)
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock')
], serviceAccount: "jenkins")
{

def dockerRegistry = "100.71.71.71:5000"
def Creds = "git_cred"
def projName = "db-service"
def imageVersion = "latest"
def imageName = "100.71.71.71:5000/db-service:${imageVersion}"
def imageN = '100.71.71.71:5000/db-service:'

properties([
parameters([
stringParam(
defaultValue: '',
description: 'TAG',
name: 'service')
])
])


node(label)
{
try{
stage("Pre-Test"){
dir('db'){
git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-DB.git', credentialsId: "${Creds}")
imageTagDB = (sh (script: "git rev-parse --short HEAD", returnStdout: true))
tmp = "1"
pathTocodedb = pwd()
}
}
stage("Test image_regisrty_check"){
container("python-alpine"){
check_new = (sh (script: "python3 /images-registry-test.py db-service ${imageTagDB}", returnStdout:true).trim())
echo "${check_new}"
}
}

stage ("Unit Tests"){
sh 'echo "Here will be unit tests"'
}
stage("Test code using PyLint and version build"){
container('python-alpine'){
pathTocode = pwd()
sh "python3 /pylint-test.py ${pathTocodedb}/app/routes.py"
}
}
stage("Build docker image"){
container('docker'){
pathdocker = pwd()
if ("${tmp}" == "${check_new}"){
container("docker"){
sh "docker images"
sh "cat /etc/docker/daemon.json"

sh "docker build ${pathTocodedb} -t ${imageN}${imageTagDB}"
sh "docker build ${pathTocodedb}/init-container/ -t ${dockerRegistry}/init-container:${imageTagDB}"
sh "docker images"

sh "docker push ${imageN}${imageTagDB}"
sh "docker push ${dockerRegistry}/init-container:${imageTagDB}"
sleep 20
}
build(job: 'GitHub/GET-SERVICES/test1', parameters: [[$class: 'StringParameterValue', name:"imageTagDB_", value: "${imageTagDB}"],
[$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"],
[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"],
[$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"],
[$class: 'StringParameterValue', name:"service", value: "db"]], wait: true)
} else {
echo "NO"
}

}
}
}
catch(err){
currentBuild.result = 'Failure'
}
}
}





96 changes: 96 additions & 0 deletions Jenkinsfile_v1
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
def label = "mypod-${UUID.randomUUID().toString()}"

podTemplate(label: label, containers: [
containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'docker', image: 'docker', command: 'cat', ttyEnabled: true),
containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true)
],
volumes: [
hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock')
], serviceAccount: "jenkins")
{
def app
def imageTag
def dockerRegistry = "100.71.71.71:5000"
def Creds = "git_cred"
def projName = "db-service"
def imageVersion = "latest"
def imageName = "100.71.71.71:5000/db-service:${imageVersion}"
def imageN = '100.71.71.71:5000/db-service:'


node(label)
{
try{
stage("Git Checkout"){
git(
branch: "test",
url: 'https://github.com/Kv-045DevOps/SRM-DB.git',
credentialsId: "${Creds}")
//sh "git rev-parse --short HEAD > .git/commit-id"
imageTag = sh (script: "git rev-parse --short HEAD", returnStdout: true)
}
stage("Info"){
sh "echo $imageTag"
}
stage ("Unit Tests"){
sh 'echo "Here will be unit tests"'
}
stage("Test code using PyLint and version build"){
container('python-alpine'){
pathTocode = pwd()
sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/db-service ${imageTag}"
sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/init-container ${imageTag}"
sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/routes.py"
sh 'cat template.yaml'
}
}
stage("Build docker images"){
container('docker'){
pathdocker = pwd()
sh "docker build ${pathdocker} -t ${imageN}${imageTag}"
sh "docker build ${pathdocker}/init-container/ -t ${dockerRegistry}/init-container:${imageTag}"
sh "docker images"
//withCredentials([usernamePassword(credentialsId: 'docker_registry_2', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) {

sh "docker push ${imageN}${imageTag}"
sh "docker push ${dockerRegistry}/init-container:${imageTag}"
//}
}
}

stage("Deploy to Kubernetes"){
withcredentials(
[usernamePassword(credentialsId: 'DbCred', usernameVariable: 'DB_USERNAME', passwordVariable: 'DB_PASSWORD')]
[stringCredentials(credentialsId: 'DbName', secretVariable: 'DB_NAME',)])
container('kubectl'){
sh "kubectl create secret generic db-secret --from-literal=username=$DB_USERNAME --from-literal=password=$DB_PASSWORD --from-literal=dbname=$DB_NAME -n production"
sh "kubectl apply -f template.yaml"
sh "kubectl get pods --namespace=production"
}
}
stage ("E2E Tests - Stage 1"){
container('python-alpine'){
sh 'echo "Here are e2e tests"'
sh "python3 sed_python_test.py template-test.yaml ${imageTag}"
sh 'cat template-test.yaml'
}
}
stage ("E2E Tests - Stage 2"){
container('kubectl'){
sh 'kubectl apply -f template-test.yaml'
sh 'kubectl get pods -n testing'
}
}
stage ("Unit Tests"){
sh 'echo "Here will be e2e tests"'
}
}
catch(err){
currentBuild.result = 'Failure'
}
}
}


sleep 30
6 changes: 0 additions & 6 deletions app/config.py

This file was deleted.

13 changes: 7 additions & 6 deletions app/dbconnect.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import psycopg2
from app import config
import os


def connect_db(dbname):
if dbname != config.DATABASE_CONFIG['dbname']:
if dbname != str(os.getenv("PGDATABASE")):
raise ValueError("Couldn't not find DB with given name")
conn = psycopg2.connect(host=config.DATABASE_CONFIG['host'],
user=config.DATABASE_CONFIG['user'],
password=config.DATABASE_CONFIG['password'],
dbname=config.DATABASE_CONFIG['dbname'])
conn = psycopg2.connect(host=str(os.getenv("POSTGRES_HOST")),
port=str(os.getenv("POSTGRES_PORT")),
user=str(os.getenv("PGUSER")),
password=str(os.getenv("PGPASSWORD")),
dbname=str(os.getenv("PGDATABASE")))
return conn
4 changes: 3 additions & 1 deletion dbservice.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from app import app
from app import app
if __name__ == "__main__":
app.run(host="0.0.0.0", port="5002")
28 changes: 28 additions & 0 deletions images-registry-test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys
import os
import requests
import json

def main():
check_image()


def check_image():
tmp = requests.get("http://100.71.71.71:5000/v2/" + sys.argv[1] + "/tags/list")
req = tmp.json()
#print(req)
if (tmp.status_code == 404):
print("1")
return 1
else:
if req["name"] == sys.argv[1] and sys.argv[2] in req["tags"]:
print("0")
return 0
else:
#raise Exception("Image with tag " + sys.argv[1] + " does not exist in Docker Registry with IP: " + sys.argv[1])
print("1")
return 1


if __name__=='__main__':
main()
4 changes: 4 additions & 0 deletions init-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM postgres:9.6.2
MAINTAINER Artem Kubrachenko
WORKDIR /tmp
COPY check_dump.sh dbdump ./
9 changes: 9 additions & 0 deletions init-container/check_dump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
until pg_isready; do echo waiting for database; sleep 2; done;
export SELECT=$(psql -t -c "select 1 from information_schema.tables where table_schema='public' and table_name='department'")
if [ $SELECT = 1 ]
then
exit 0
else
psql -f dbdump
exit 0
fi
Loading