From 54524bd63234b2ba63336fd9f1d1ed0e8aa177c0 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 12 Jan 2019 09:57:04 -0500 Subject: [PATCH 001/241] Add pylint test --- pylint-test.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 pylint-test.py diff --git a/pylint-test.py b/pylint-test.py new file mode 100644 index 0000000..3d1bf44 --- /dev/null +++ b/pylint-test.py @@ -0,0 +1,20 @@ +import os +import sys +from pylint.lint import Run + +def main(): + check_rate_code() + + +def check_rate_code(): + results = Run([sys.argv[1]], do_exit=False) + if (results.linter.stats['global_note'] <= 5): + raise Exception("Code rate smaller than standard") + return 1 + else: + print(results.linter.stats['global_note']) + return 0 + + +if __name__=='__main__': + main() From 6d92f1f70e49e51e2ec0d7b51fc481513dd3919f Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 12 Jan 2019 10:36:50 -0500 Subject: [PATCH 002/241] Test Error --- pylint-test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylint-test.py b/pylint-test.py index 3d1bf44..930fa8b 100644 --- a/pylint-test.py +++ b/pylint-test.py @@ -8,7 +8,7 @@ def main(): def check_rate_code(): results = Run([sys.argv[1]], do_exit=False) - if (results.linter.stats['global_note'] <= 5): + if (results.linter.stats['global_note'] <= 7): raise Exception("Code rate smaller than standard") return 1 else: From ace28842a234806b589bd42eb46fcc9be1197b2e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 12 Jan 2019 10:39:22 -0500 Subject: [PATCH 003/241] Successfull Testing Error --- pylint-test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylint-test.py b/pylint-test.py index 930fa8b..3d1bf44 100644 --- a/pylint-test.py +++ b/pylint-test.py @@ -8,7 +8,7 @@ def main(): def check_rate_code(): results = Run([sys.argv[1]], do_exit=False) - if (results.linter.stats['global_note'] <= 7): + if (results.linter.stats['global_note'] <= 5): raise Exception("Code rate smaller than standard") return 1 else: From 8732663c9c63886be9e6bcead7d137253043f211 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 12 Jan 2019 10:56:56 -0500 Subject: [PATCH 004/241] Add part Jenkinsfile --- Jenkinsfile | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..1e68ecb --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,29 @@ +node +{ + def app + def docketRegistry = "" + def Creds = "maxcred" + try{ + stage("Git Checkout"){ + git( + branch: "MZhovanik", + url: 'https://github.com/Kv-045DevOps/SRM-GET.git', + credentialsId: "${Creds}") + sh "git rev-parse --short HEAD > .git/commit-id" + imageTag= readFile ".git/commit-id" + } + stage("Info"){ + sh "echo ${imageTag}" + } + stage ("Unit Tests"){ + sh 'echo "Here will be unit tests"' + } + stage("Test code using PyLint"){ + pathTocode = pwd() + sh "python ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" + } + } + catch(err){ + currentBuild.result = 'Failure' + } +} From 061e4871277ade8095f936c88e8e9d0964abb64e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 12 Jan 2019 11:12:04 -0500 Subject: [PATCH 005/241] Change Jenkinsfile + install pylint --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 1e68ecb..3b8e8b6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,6 +19,7 @@ node sh 'echo "Here will be unit tests"' } stage("Test code using PyLint"){ + sh "pip install pylint" pathTocode = pwd() sh "python ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } From 1aea09b014cab7c9f28d8f5bf70ce57d1ad89820 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 12 Jan 2019 12:40:53 -0500 Subject: [PATCH 006/241] Change dockerfile --- dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dockerfile b/dockerfile index 8671c09..9c79577 100644 --- a/dockerfile +++ b/dockerfile @@ -2,7 +2,7 @@ FROM python:3.6-alpine MAINTAINER Maxim Zhovanik WORKDIR /service/GET-SERV COPY . /service/GET-SERV -RUN pip install -r /service/GET-SERV/project_get/app/requirements.txt -CMD ["python", "/service/GET-SERV/project_get/app/app.py"] +RUN pip install -r /service/GET-SERV/app/requirements.txt +CMD ["python", "/service/GET-SERV/app/app.py"] From 8ba6cfae7d5a2dc4a32ce81c3c060d83c43cc8c4 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 12 Jan 2019 16:20:23 -0500 Subject: [PATCH 007/241] Add check push image to Docker Registry --- images-registry-test.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 images-registry-test.py diff --git a/images-registry-test.py b/images-registry-test.py new file mode 100644 index 0000000..59c78a6 --- /dev/null +++ b/images-registry-test.py @@ -0,0 +1,21 @@ +import sys +import os +import requests +import json + +def main(): + check_image() + + +def check_image(): + tmp = requests.get("http://" + sys.argv[1] + "/v2/" + sys.argv[2] + "/tags/list") + req = tmp.json() + if req["name"] == sys.argv[2] and sys.argv[3] in req["tags"]: + return 0 + else: + raise Exception("Image with tag " + sys.argv[3] + " does not exist in Docker Registry with IP: " + sys.argv[1]) + return 1 + + +if __name__=='__main__': + main() From 6bc5ce8f68a6889d8ed25158c61c6956a99c790b Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 12 Jan 2019 16:39:15 -0500 Subject: [PATCH 008/241] Jenkinsfile without kubectl --- Jenkinsfile | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3b8e8b6..db78eaa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,8 +1,10 @@ -node +node('centos') //using label for remote agent(optional, will be change) { def app - def docketRegistry = "" - def Creds = "maxcred" + def dockerRegistry = "192.168.213.128:5000" //This is address of my Docker Regisrty. After install "prod" Docker Registry this URL will be change + def Creds = "###" //credential for GitHub account + def projName = "get-python" + def imageName = '192.168.213.128:5000/get-python' try{ stage("Git Checkout"){ git( @@ -21,7 +23,24 @@ node stage("Test code using PyLint"){ sh "pip install pylint" pathTocode = pwd() - sh "python ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" + sh "python3.4 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" //Python version will be change on version in Jenkins master instance + } + stage("Build docker image"){ + pathdocker = pwd() +// app = docker.build("${imageName}:${imageTag}") + sh "docker build ${pathdocker} -t ${imageName}:${imageTag}" + sh "docker images" + } + stage("Push to remote(testing) Docker Registry"){ + withCredentials([usernamePassword(credentialsId: 'docker_registry', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) { + sh "docker login -u ${env.dockerUser} -p ${env.dockerPassword} ${dockerRegistry}" + sh "docker push ${imageName}:${imageTag}" + } + } + stage("Check push image to Docker Registry"){ + sh "pip install requests" + pathTocode = pwd() + sh "python3.4 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" //Python version will be change on version in Jenkins master instance } } catch(err){ From 043f09c296a5ef18c8199154fea6a5d2a68f15f7 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 13 Jan 2019 19:04:38 -0500 Subject: [PATCH 009/241] Test kubectl apply --- dockerfile_jenkins_image | 11 ++++++ jenkins-pod.yaml | 72 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 dockerfile_jenkins_image create mode 100644 jenkins-pod.yaml diff --git a/dockerfile_jenkins_image b/dockerfile_jenkins_image new file mode 100644 index 0000000..d05da6f --- /dev/null +++ b/dockerfile_jenkins_image @@ -0,0 +1,11 @@ +from jenkinsci/jenkins:lts +USER root +#Install Docker +RUN apt-get -qq update && \ +apt-get -qq -y install curl && \ +curl -sSL https://get.docker.com/ | sh +# Install kubectl and helm +RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \ +chmod +x ./kubectl && \ +mv ./kubectl /usr/local/bin/kubectl +RUN usermod -aG docker jenkins diff --git a/jenkins-pod.yaml b/jenkins-pod.yaml new file mode 100644 index 0000000..5f1a0e2 --- /dev/null +++ b/jenkins-pod.yaml @@ -0,0 +1,72 @@ +apiVersion: v1 +kind: Pod +metadata: + name: jenkins-pod + namespace: jenkins-srv + labels: + service: jenkins-srvs +spec: + containers: + - name: jenkins-demo + image: 192.168.213.128:5000/get-python:v1 + +--- + +kind: Service +apiVersion: v1 +metadata: + name: jenkins-service + namespace: jenkins-srv +spec: + selector: + service: jenkins-srvs + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 + type: LoadBalancer + +--- +kind: Service +apiVersion: v1 +metadata: + name: ssh + namespace: jenkins-srv +spec: + selector: + service: jenkins-srvs + ports: + - protocol: TCP + port: 22 + targetPort: 22 + type: LoadBalancer + +--- +apiVersion: v1 +kind: Pod +metadata: + name: registry + labels: + app: registry + namespace: jenkins-srv +spec: + containers: + - name: registry + image: registry:2 + imagePullPolicy: Always + ports: + - containerPort: 5000 + +--- +kind: Service +apiVersion: v1 +metadata: + name: registry + namespace: jenkins-srv +spec: + selector: + service: jenkins-srvs + ports: + - port: 5000 + targetPort: 5000 + type: LoadBalancer From c80494950ffcdc204dcbc02e8b0655c4421917b6 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 13 Jan 2019 20:07:29 -0500 Subject: [PATCH 010/241] Modify Jenkinsfile - add deploy --- Jenkinsfile | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index db78eaa..f44822f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,12 @@ -node('centos') //using label for remote agent(optional, will be change) +node { def app - def dockerRegistry = "192.168.213.128:5000" //This is address of my Docker Regisrty. After install "prod" Docker Registry this URL will be change - def Creds = "###" //credential for GitHub account + def dockerRegistry = "192.168.213.128:5000" + def Creds = "" def projName = "get-python" - def imageName = '192.168.213.128:5000/get-python' + def imageVersion = "v1" + def imageName = "192.168.213.128:5000/get-python:${imageVersion}.${env.BUILD_NUMBER}" + def imageN = '192.168.213.128:5000/get-python:' try{ stage("Git Checkout"){ git( @@ -16,6 +18,7 @@ node('centos') //using label for remote agent(optional, will be change) } stage("Info"){ sh "echo ${imageTag}" + sh "echo ${env.BUILD_NUMBER}" } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' @@ -23,24 +26,32 @@ node('centos') //using label for remote agent(optional, will be change) stage("Test code using PyLint"){ sh "pip install pylint" pathTocode = pwd() - sh "python3.4 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" //Python version will be change on version in Jenkins master instance + sh "python3.6 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } stage("Build docker image"){ pathdocker = pwd() // app = docker.build("${imageName}:${imageTag}") - sh "docker build ${pathdocker} -t ${imageName}:${imageTag}" + sh "docker build ${pathdocker} -t ${imageName}" sh "docker images" } - stage("Push to remote(testing) Docker Registry"){ + stage("Push to remote(test) Docker Registry"){ withCredentials([usernamePassword(credentialsId: 'docker_registry', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) { sh "docker login -u ${env.dockerUser} -p ${env.dockerPassword} ${dockerRegistry}" - sh "docker push ${imageName}:${imageTag}" + sh "docker push ${imageName}" } } stage("Check push image to Docker Registry"){ sh "pip install requests" pathTocode = pwd() - sh "python3.4 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" //Python version will be change on version in Jenkins master instance + sh "python3.6 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" + } + stage("Deploy to Kubernetes"){ + sh("sed -i.bak 's#${imageN}${imageVersion}#${imageName}#' jenkins-pod.yaml") + sh "kubectl apply -f jenkins-pod.yaml --kubeconfig=kubeconfig" + sh "sudo kubectl get pods --namespace=jenkins-srv --kubeconfig=KUBECONFIG" + } + stage ("Unit Tests"){ + sh 'echo "Here will be e2e tests"' } } catch(err){ From efc0fe23993af2648ae15795ee7485bf21ff3ab0 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 14 Jan 2019 08:45:14 -0500 Subject: [PATCH 011/241] Use secret env --- jenkins-pod.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/jenkins-pod.yaml b/jenkins-pod.yaml index 5f1a0e2..967603d 100644 --- a/jenkins-pod.yaml +++ b/jenkins-pod.yaml @@ -1,3 +1,13 @@ +apiVersion: v1 +kind: Secret +metadata: + name: test-secret +data: + username: bWF4 + password: MTIzNA== + +--- + apiVersion: v1 kind: Pod metadata: @@ -9,6 +19,18 @@ spec: containers: - name: jenkins-demo image: 192.168.213.128:5000/get-python:v1 + env: + - name: SECRET_USERNAME + valueFrom: + secretKeyRef: + name: test-secret + key: username + - name: SECRET_PASSWORD + valueFrom: + secretKeyRef: + name: test-secret + key: password + --- From 0010721e733e4e9be529692304482d0f7fb61101 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 15 Jan 2019 12:48:25 -0500 Subject: [PATCH 012/241] Test integration --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f44822f..7a5041a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,7 @@ node sh 'echo "Here will be unit tests"' } stage("Test code using PyLint"){ - sh "pip install pylint" + sh "pip3 install pylint" pathTocode = pwd() sh "python3.6 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } From a3176d57bb932138d70d5924490075ea7dad844e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 15 Jan 2019 12:55:48 -0500 Subject: [PATCH 013/241] Test integration#2 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7a5041a..dae98bd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,7 +43,7 @@ node stage("Check push image to Docker Registry"){ sh "pip install requests" pathTocode = pwd() - sh "python3.6 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" + sh "python3.4 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" } stage("Deploy to Kubernetes"){ sh("sed -i.bak 's#${imageN}${imageVersion}#${imageName}#' jenkins-pod.yaml") From a98a5e95e5407592ada297ec6fbfd134860b0fb7 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 15 Jan 2019 12:58:04 -0500 Subject: [PATCH 014/241] Test integration#2 --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index dae98bd..9cdbc6b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,11 +23,11 @@ node stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' } - stage("Test code using PyLint"){ - sh "pip3 install pylint" - pathTocode = pwd() - sh "python3.6 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" - } +// stage("Test code using PyLint"){ +// sh "pip3 install pylint" +// pathTocode = pwd() +// sh "python3.6 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" +// } stage("Build docker image"){ pathdocker = pwd() // app = docker.build("${imageName}:${imageTag}") From 4f9f2a89fbb326ff9da84c8ebb6834b8cc83c016 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 17 Jan 2019 10:43:46 -0500 Subject: [PATCH 015/241] Update Jenkinsfile Kube plugins --- Jenkinsfile | 61 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9cdbc6b..3e9c0f2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,12 +1,24 @@ -node +def label = "mypod-${UUID.randomUUID().toString()}" + +//imagePullSecrets:['myregistrysecret'] + +podTemplate(label: label, containers: [ + containerTemplate(name: 'jenkins-slave', image: 'ghotsgoose33/jenkins-slave: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) +]) +{ +def app +//def dockerRegistry = "192.168.213.128:5000" +def Creds = "git_cred" +def projName = "get-python" +def imageVersion = "v1" +def imageName = "ghostgoose33/get-python:${imageVersion}" +def imageN = 'ghostgoose33/get-python:' + + +node(label) { - def app - def dockerRegistry = "192.168.213.128:5000" - def Creds = "" - def projName = "get-python" - def imageVersion = "v1" - def imageName = "192.168.213.128:5000/get-python:${imageVersion}.${env.BUILD_NUMBER}" - def imageN = '192.168.213.128:5000/get-python:' try{ stage("Git Checkout"){ git( @@ -18,37 +30,41 @@ node } stage("Info"){ sh "echo ${imageTag}" - sh "echo ${env.BUILD_NUMBER}" } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' } // stage("Test code using PyLint"){ -// sh "pip3 install pylint" // pathTocode = pwd() // sh "python3.6 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" // } stage("Build docker image"){ - pathdocker = pwd() + container('docker'){ + pathdocker = pwd() // app = docker.build("${imageName}:${imageTag}") - sh "docker build ${pathdocker} -t ${imageName}" - sh "docker images" + sh "docker build ${pathdocker} -t ${imageName}" + sh "docker images" + withCredentials([usernamePassword(credentialsId: 'docker_registry', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) { + sh "docker login -u ${env.dockerUser} -p ${env.dockerPassword}" + sh "docker push ${imageName}" } - stage("Push to remote(test) Docker Registry"){ - withCredentials([usernamePassword(credentialsId: 'docker_registry', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) { - sh "docker login -u ${env.dockerUser} -p ${env.dockerPassword} ${dockerRegistry}" - sh "docker push ${imageName}" + } } + stage("Push to remote(test) Docker Registry"){ + // } stage("Check push image to Docker Registry"){ - sh "pip install requests" + // sh "pip install requests" pathTocode = pwd() - sh "python3.4 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" + // sh "python3.4 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" } stage("Deploy to Kubernetes"){ - sh("sed -i.bak 's#${imageN}${imageVersion}#${imageName}#' jenkins-pod.yaml") - sh "kubectl apply -f jenkins-pod.yaml --kubeconfig=kubeconfig" - sh "sudo kubectl get pods --namespace=jenkins-srv --kubeconfig=KUBECONFIG" + container('kubectl'){ + sh("sed -i.bak 's#${imageN}${imageVersion}#ghostgoose33/get-python:${imageVersion}#' jenkins-pod.yaml") + // sh "kubectl apply -f jenkins-pod.yaml" + // sh "sudo kubectl get pods --namespace=stark-cluster" + sh "kubectl get pods --namespace=stark-cluster" + } } stage ("Unit Tests"){ sh 'echo "Here will be e2e tests"' @@ -58,3 +74,4 @@ node currentBuild.result = 'Failure' } } +} From 88e7e3aa755eb3cdac846edc7cec0b38912b5cf4 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 17 Jan 2019 16:37:18 -0500 Subject: [PATCH 016/241] Final Test --- jenkins-pod.yaml | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/jenkins-pod.yaml b/jenkins-pod.yaml index 967603d..5564beb 100644 --- a/jenkins-pod.yaml +++ b/jenkins-pod.yaml @@ -12,13 +12,13 @@ apiVersion: v1 kind: Pod metadata: name: jenkins-pod - namespace: jenkins-srv + namespace: stark-cluster labels: - service: jenkins-srvs + service: jenkins-srv spec: containers: - name: jenkins-demo - image: 192.168.213.128:5000/get-python:v1 + image: ghostgoose33/get-python:v1 env: - name: SECRET_USERNAME valueFrom: @@ -32,22 +32,6 @@ spec: key: password ---- - -kind: Service -apiVersion: v1 -metadata: - name: jenkins-service - namespace: jenkins-srv -spec: - selector: - service: jenkins-srvs - ports: - - protocol: TCP - port: 8080 - targetPort: 8080 - type: LoadBalancer - --- kind: Service apiVersion: v1 @@ -63,22 +47,6 @@ spec: targetPort: 22 type: LoadBalancer ---- -apiVersion: v1 -kind: Pod -metadata: - name: registry - labels: - app: registry - namespace: jenkins-srv -spec: - containers: - - name: registry - image: registry:2 - imagePullPolicy: Always - ports: - - containerPort: 5000 - --- kind: Service apiVersion: v1 From 4fc2d7185e949ebdfbcb2ee6b16642df68eff0aa Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 17 Jan 2019 17:01:01 -0500 Subject: [PATCH 017/241] Final Test #2 --- jenkins-pod.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jenkins-pod.yaml b/jenkins-pod.yaml index 5564beb..7479f1c 100644 --- a/jenkins-pod.yaml +++ b/jenkins-pod.yaml @@ -37,7 +37,7 @@ kind: Service apiVersion: v1 metadata: name: ssh - namespace: jenkins-srv + namespace: stark-cluster spec: selector: service: jenkins-srvs @@ -52,7 +52,7 @@ kind: Service apiVersion: v1 metadata: name: registry - namespace: jenkins-srv + namespace: stark-cluster spec: selector: service: jenkins-srvs From 8d370fec3d3ce7c1a1c4af9ac96a3a983453b3c6 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 17 Jan 2019 17:09:22 -0500 Subject: [PATCH 018/241] Final Test - FUCKKKKKKKKKKKK --- jenkins-pod.yaml | 56 ++++++++++-------------------------------------- 1 file changed, 11 insertions(+), 45 deletions(-) diff --git a/jenkins-pod.yaml b/jenkins-pod.yaml index 7479f1c..1313b9f 100644 --- a/jenkins-pod.yaml +++ b/jenkins-pod.yaml @@ -1,10 +1,15 @@ +kind: Service apiVersion: v1 -kind: Secret metadata: - name: test-secret -data: - username: bWF4 - password: MTIzNA== + name: registry + namespace: stark-cluster +spec: + selector: + service: jenkins-srvs + ports: + - port: 5000 + targetPort: 5000 + type: LoadBalancer --- @@ -14,49 +19,10 @@ metadata: name: jenkins-pod namespace: stark-cluster labels: - service: jenkins-srv + service: jenkins-srvs spec: containers: - name: jenkins-demo image: ghostgoose33/get-python:v1 - env: - - name: SECRET_USERNAME - valueFrom: - secretKeyRef: - name: test-secret - key: username - - name: SECRET_PASSWORD - valueFrom: - secretKeyRef: - name: test-secret - key: password ---- -kind: Service -apiVersion: v1 -metadata: - name: ssh - namespace: stark-cluster -spec: - selector: - service: jenkins-srvs - ports: - - protocol: TCP - port: 22 - targetPort: 22 - type: LoadBalancer - ---- -kind: Service -apiVersion: v1 -metadata: - name: registry - namespace: stark-cluster -spec: - selector: - service: jenkins-srvs - ports: - - port: 5000 - targetPort: 5000 - type: LoadBalancer From b75361d9ec701ff4faa70a041da49c4b1c0bef24 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 17 Jan 2019 17:51:15 -0500 Subject: [PATCH 019/241] GET - UPLOAD --- app/app.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/app.py b/app/app.py index 8cb159c..d46b80f 100644 --- a/app/app.py +++ b/app/app.py @@ -8,10 +8,10 @@ -URL_DEP = str(os.getenv("URL_DB")) + 'get-dep' -URL_EMPL = str(os.getenv("URL_DB")) + 'get-empl' -URL_TEAM = str(os.getenv("URL_DB")) + 'get-team' -URL_ALL = str(os.getenv("URL_DB")) + 'get-info' +URL_DEP = str(os.getenv("URL_DB")) + '/get-dep' +URL_EMPL = str(os.getenv("URL_DB")) + '/get-empl' +URL_TEAM = str(os.getenv("URL_DB")) + '/get-team' +URL_ALL = str(os.getenv("URL_DB")) + '/get-info' def print_url(): print(URL_DEP) From 102225a0183733102c9010245b1bf71d40768c1d Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 17 Jan 2019 21:11:31 -0500 Subject: [PATCH 020/241] Add final Jenkinsfile --- Jenkinsfile | 45 +++++++++++++++++++++++-------------------- jenkins-pod-test.yaml | 27 ++++++++++++++++++++++++++ sed_python.py | 13 +++++++++++++ stats.txt | 27 ++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 21 deletions(-) create mode 100644 jenkins-pod-test.yaml create mode 100644 sed_python.py create mode 100644 stats.txt diff --git a/Jenkinsfile b/Jenkinsfile index 3e9c0f2..04b84df 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,15 +1,17 @@ def label = "mypod-${UUID.randomUUID().toString()}" -//imagePullSecrets:['myregistrysecret'] - podTemplate(label: label, containers: [ - containerTemplate(name: 'jenkins-slave', image: 'ghotsgoose33/jenkins-slave:v1', command: 'cat', ttyEnabled: true), + 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') +] +) { def app -//def dockerRegistry = "192.168.213.128:5000" +def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" def projName = "get-python" def imageVersion = "v1" @@ -34,35 +36,33 @@ node(label) stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' } -// stage("Test code using PyLint"){ -// pathTocode = pwd() -// sh "python3.6 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" -// } + stage("Test code using PyLint and version build"){ + container('python-alpine'){ + pathTocode = pwd() + sh "python3 ${pathTocode}/sed-python.py" + sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" + } + } stage("Build docker image"){ container('docker'){ pathdocker = pwd() // app = docker.build("${imageName}:${imageTag}") - sh "docker build ${pathdocker} -t ${imageName}" + sh "docker build ${pathdocker} -t ${imageN}${imageTag}" sh "docker images" - withCredentials([usernamePassword(credentialsId: 'docker_registry', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) { - sh "docker login -u ${env.dockerUser} -p ${env.dockerPassword}" - sh "docker push ${imageName}" + withCredentials([usernamePassword(credentialsId: 'docker_registry_2', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) { + sh "docker login -u ${env.dockerUser} -p ${env.dockerPassword}" + sh "docker push ${imageN}${imageTag}" } } } - stage("Push to remote(test) Docker Registry"){ - // - } stage("Check push image to Docker Registry"){ - // sh "pip install requests" pathTocode = pwd() - // sh "python3.4 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" + sh "python3 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" } stage("Deploy to Kubernetes"){ container('kubectl'){ - sh("sed -i.bak 's#${imageN}${imageVersion}#ghostgoose33/get-python:${imageVersion}#' jenkins-pod.yaml") - // sh "kubectl apply -f jenkins-pod.yaml" - // sh "sudo kubectl get pods --namespace=stark-cluster" + sh ("cat jenkins-pod.yaml") + sh "kubectl apply -f jenkins-pod.yaml" sh "kubectl get pods --namespace=stark-cluster" } } @@ -75,3 +75,6 @@ node(label) } } } + + +sleep 30 diff --git a/jenkins-pod-test.yaml b/jenkins-pod-test.yaml new file mode 100644 index 0000000..5401861 --- /dev/null +++ b/jenkins-pod-test.yaml @@ -0,0 +1,27 @@ +kind: Service +apiVersion: v1 +metadata: + name: registry + namespace: stark-cluster +spec: + selector: + service: jenkins-srvs + ports: + - port: 5000 + targetPort: 5000 + type: LoadBalancer + +--- + +apiVersion: v1 +kind: Pod +metadata: + name: jenkins-pod + namespace: stark-cluster + labels: + service: jenkins-srvs +spec: + containers: + - name: jenkins-demo + image: 100.71.71.71/get-python:3rt3y3h + diff --git a/sed_python.py b/sed_python.py new file mode 100644 index 0000000..d54f0a7 --- /dev/null +++ b/sed_python.py @@ -0,0 +1,13 @@ +import os +import sys + +with open(sys.argv[1], 'r') as file: + str_tmp = "ghostgoose" + data = file.read() + tmp = sys.argv[2] + ":" + sys.argv[3] + data = data.replace("ghostgoose33/get-python:v1", tmp) + print(data) + + +with open(sys.argv[1], 'w') as file: + file.write( data ) diff --git a/stats.txt b/stats.txt new file mode 100644 index 0000000..bd0223b --- /dev/null +++ b/stats.txt @@ -0,0 +1,27 @@ +kind: Service +apiVersion: v1 +metadata: + name: registry + namespace: stark-cluster +spec: + selector: + service: jenkins-srvs + ports: + - port: 5000 + targetPort: 5000 + type: LoadBalancer + +--- + +apiVersion: v1 +kind: Pod +metadata: + name: jenkins-pod + namespace: stark-cluster + labels: + service: jenkins-srvs +spec: + containers: + - name: jenkins-demo + image: AAAAAAAAAA33/get-python:v1 + From 9c2ed4ac4c15f7a37d4b9de28184bdb670ff192e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 17 Jan 2019 21:12:29 -0500 Subject: [PATCH 021/241] Add final Jenkinsfile --- stats.txt | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 stats.txt diff --git a/stats.txt b/stats.txt deleted file mode 100644 index bd0223b..0000000 --- a/stats.txt +++ /dev/null @@ -1,27 +0,0 @@ -kind: Service -apiVersion: v1 -metadata: - name: registry - namespace: stark-cluster -spec: - selector: - service: jenkins-srvs - ports: - - port: 5000 - targetPort: 5000 - type: LoadBalancer - ---- - -apiVersion: v1 -kind: Pod -metadata: - name: jenkins-pod - namespace: stark-cluster - labels: - service: jenkins-srvs -spec: - containers: - - name: jenkins-demo - image: AAAAAAAAAA33/get-python:v1 - From 220590efc7d7834eb7e9c74c6a965339c4f337e4 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 17 Jan 2019 21:41:36 -0500 Subject: [PATCH 022/241] Add template.yml --- Jenkinsfile | 21 ++++++++++----------- template.yml | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 template.yml diff --git a/Jenkinsfile b/Jenkinsfile index 04b84df..e453f08 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,8 +15,8 @@ def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" def projName = "get-python" def imageVersion = "v1" -def imageName = "ghostgoose33/get-python:${imageVersion}" -def imageN = 'ghostgoose33/get-python:' +def imageName = "100.71.71.71:5000/get-service:${imageVersion}" +def imageN = '100.71.71.71:5000/get-service:' node(label) @@ -25,8 +25,8 @@ node(label) stage("Git Checkout"){ git( branch: "MZhovanik", - url: 'https://github.com/Kv-045DevOps/SRM-GET.git', - credentialsId: "${Creds}") + url: 'https://github.com/Kv-045DevOps/SRM-GET.git') + //credentialsId: "${Creds}") sh "git rev-parse --short HEAD > .git/commit-id" imageTag= readFile ".git/commit-id" } @@ -49,10 +49,10 @@ node(label) // app = docker.build("${imageName}:${imageTag}") sh "docker build ${pathdocker} -t ${imageN}${imageTag}" sh "docker images" - withCredentials([usernamePassword(credentialsId: 'docker_registry_2', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) { - sh "docker login -u ${env.dockerUser} -p ${env.dockerPassword}" - sh "docker push ${imageN}${imageTag}" - } + //withCredentials([usernamePassword(credentialsId: 'docker_registry_2', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) { + + sh "docker push ${imageN}${imageTag}" + //} } } stage("Check push image to Docker Registry"){ @@ -61,9 +61,8 @@ node(label) } stage("Deploy to Kubernetes"){ container('kubectl'){ - sh ("cat jenkins-pod.yaml") - sh "kubectl apply -f jenkins-pod.yaml" - sh "kubectl get pods --namespace=stark-cluster" + sh "kubectl apply -f template.yaml" + sh "kubectl get pods --namespace=production" } } stage ("Unit Tests"){ diff --git a/template.yml b/template.yml new file mode 100644 index 0000000..ce08dd7 --- /dev/null +++ b/template.yml @@ -0,0 +1,43 @@ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: production + name: get-deployment +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: 100.71.71.71:5000/get-python:v2 + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB From 01647d5da033748b7ccee5c0df857b783bb1477c Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 17 Jan 2019 21:52:38 -0500 Subject: [PATCH 023/241] Add latest file --- Jenkinsfile | 2 +- sed_python.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e453f08..e7fc878 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,7 +26,7 @@ node(label) git( branch: "MZhovanik", url: 'https://github.com/Kv-045DevOps/SRM-GET.git') - //credentialsId: "${Creds}") + credentialsId: "${Creds}") sh "git rev-parse --short HEAD > .git/commit-id" imageTag= readFile ".git/commit-id" } diff --git a/sed_python.py b/sed_python.py index d54f0a7..43f2ad6 100644 --- a/sed_python.py +++ b/sed_python.py @@ -5,7 +5,7 @@ str_tmp = "ghostgoose" data = file.read() tmp = sys.argv[2] + ":" + sys.argv[3] - data = data.replace("ghostgoose33/get-python:v1", tmp) + data = data.replace("100.71.71.71:5000/get-service:v1", tmp) print(data) From fba6325ecb6fa3a6e32c1035d53e903671ac70d8 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 18 Jan 2019 00:22:53 -0500 Subject: [PATCH 024/241] Add again latest file --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e7fc878..abddf67 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,7 +39,7 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed-python.py" + sh "python3 ${pathTocode}/sed-python.py template.yml ${dockerRegistry}/get-service ${imageTag}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } From bfc60968ffd2312dc8fa27aa61b1616495da4865 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 18 Jan 2019 02:37:10 -0500 Subject: [PATCH 025/241] Add testing scripts --- Jenkinsfile | 23 +++- Kuben (1).yml | 290 +++++++++++++++++++++++++++++++++++++++++++++++ Kuben.yml | 290 +++++++++++++++++++++++++++++++++++++++++++++++ e2e-test-prod.py | 28 +++++ e2e-test-test.py | 28 +++++ e2e-test.py | 29 +++++ 6 files changed, 685 insertions(+), 3 deletions(-) create mode 100644 Kuben (1).yml create mode 100644 Kuben.yml create mode 100644 e2e-test-prod.py create mode 100644 e2e-test-test.py create mode 100644 e2e-test.py diff --git a/Jenkinsfile b/Jenkinsfile index abddf67..0d8c3dd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -61,13 +61,30 @@ node(label) } stage("Deploy to Kubernetes"){ container('kubectl'){ - sh "kubectl apply -f template.yaml" + sh "kubectl apply -f template.yml" sh "kubectl get pods --namespace=production" } } - stage ("Unit Tests"){ - sh 'echo "Here will be e2e tests"' + stage ("E2E Tests - Stage 1"){ + container('python-alpine'){ + sh 'echo "Here are e2e tests"' + sh 'python3 e2e-test-prod.py' + } } + stage ("E2E Tests - Stage 2"){ + // container('kubectl'){ + // sh 'kubectl apply -f Kuben.yml' + // sh 'kubectl apply -f Kuben(1).yml' + // sh 'kubectl get pods -n testing' + // } + } + stage ("E2E Tests - Stage 3"){ + container('python-alpine'){ + sh 'echo "Here are e2e tests"' + sh 'python3 e2e-test-test.py' + } + } + } catch(err){ currentBuild.result = 'Failure' diff --git a/Kuben (1).yml b/Kuben (1).yml new file mode 100644 index 0000000..604e45c --- /dev/null +++ b/Kuben (1).yml @@ -0,0 +1,290 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: testing + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: testing + name: services-address +data: + POST_SERVICE_URL: post-service.production.svc + VIEW_SERVICE_URL: get-service.production.svc + DB_URL: db-service.production.svc + URL_DB: db-service.production.svc + +--- + +#Test secret +apiVersion: v1 +kind: Secret +metadata: + name: db-secret + namespace: testing +data: + username: ZGJhZG1pbg== + password: UGFzc3dvcmQ= + dbname: c3Jtc3lzdGVt +type: Opaque + +# --- +# kind: PersistentVolume +# apiVersion: v1 +# metadata: +# name: postgres-pv +# labels: +# type: local +# spec: +# storageClassName: manual +# capacity: +# storage: 100M +# accessModes: +# - ReadWriteOnce +# hostPath: +# path: "/mnt/data" + +# --- +# kind: StorageClass +# apiVersion: storage.k8s.io/v1 +# metadata: +# name: slow +# provisioner: kubernetes.io/aws-ebs +# parameters: +# type: gp2 +# zone: sa-east-1a +# fsType: ext4 +# reclaimPolicy: Retain + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: testing + labels: + app: pvc-postgres + name: postgres-pvc +spec: + #storageClassName: slow + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi + +# --- +# apiVersion: v1 +# kind: PersistentVolumeClaim +# metadata: +# labels: +# service: postgresdb +# namespace: production +# name: postgres-pvc +# spec: +# 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 +--- + +kind: Service +apiVersion: v1 +metadata: + name: post-service + namespace: testing + labels: + app: post +spec: + selector: + app: post + ports: + - protocol: TCP + port: 80 + targetPort: 5001 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: post-deployment + namespace: testing +spec: + selector: + matchLabels: + app: post + replicas: 1 + template: + metadata: + labels: + app: post + spec: + containers: + - name: post + image: 100:71:71:71:5000/post-service:2.1 + ports: + - containerPort: 5001 + env: + - name: DB_URL + valueFrom: + configMapKeyRef: + name: services-address + key: DB_URL +--- +kind: Service +apiVersion: v1 +metadata: + name: get-service + namespace: testing + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 80 + targetPort: 5003 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: get-deployment + namespace: testing +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: 100:71:71:71:5000/get-python:v2 + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB +--- +kind: Service +apiVersion: v1 +metadata: + name: ui-service + namespace: testing + labels: + app: ui +spec: + selector: + app: ui + ports: + - protocol: TCP + port: 80 + targetPort: 5000 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ui-deployment + namespace: testing +spec: + selector: + matchLabels: + app: ui + replicas: 1 + template: + metadata: + labels: + app: ui + spec: + containers: + - name: ui + image: 100:71:71:71:5000/ui-service:latest + ports: + - containerPort: 5000 + env: + - name: POST_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: POST_SERVICE_URL + - name: VIEW_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: VIEW_SERVICE_URL diff --git a/Kuben.yml b/Kuben.yml new file mode 100644 index 0000000..604e45c --- /dev/null +++ b/Kuben.yml @@ -0,0 +1,290 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: testing + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: testing + name: services-address +data: + POST_SERVICE_URL: post-service.production.svc + VIEW_SERVICE_URL: get-service.production.svc + DB_URL: db-service.production.svc + URL_DB: db-service.production.svc + +--- + +#Test secret +apiVersion: v1 +kind: Secret +metadata: + name: db-secret + namespace: testing +data: + username: ZGJhZG1pbg== + password: UGFzc3dvcmQ= + dbname: c3Jtc3lzdGVt +type: Opaque + +# --- +# kind: PersistentVolume +# apiVersion: v1 +# metadata: +# name: postgres-pv +# labels: +# type: local +# spec: +# storageClassName: manual +# capacity: +# storage: 100M +# accessModes: +# - ReadWriteOnce +# hostPath: +# path: "/mnt/data" + +# --- +# kind: StorageClass +# apiVersion: storage.k8s.io/v1 +# metadata: +# name: slow +# provisioner: kubernetes.io/aws-ebs +# parameters: +# type: gp2 +# zone: sa-east-1a +# fsType: ext4 +# reclaimPolicy: Retain + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: testing + labels: + app: pvc-postgres + name: postgres-pvc +spec: + #storageClassName: slow + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi + +# --- +# apiVersion: v1 +# kind: PersistentVolumeClaim +# metadata: +# labels: +# service: postgresdb +# namespace: production +# name: postgres-pvc +# spec: +# 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 +--- + +kind: Service +apiVersion: v1 +metadata: + name: post-service + namespace: testing + labels: + app: post +spec: + selector: + app: post + ports: + - protocol: TCP + port: 80 + targetPort: 5001 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: post-deployment + namespace: testing +spec: + selector: + matchLabels: + app: post + replicas: 1 + template: + metadata: + labels: + app: post + spec: + containers: + - name: post + image: 100:71:71:71:5000/post-service:2.1 + ports: + - containerPort: 5001 + env: + - name: DB_URL + valueFrom: + configMapKeyRef: + name: services-address + key: DB_URL +--- +kind: Service +apiVersion: v1 +metadata: + name: get-service + namespace: testing + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 80 + targetPort: 5003 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: get-deployment + namespace: testing +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: 100:71:71:71:5000/get-python:v2 + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB +--- +kind: Service +apiVersion: v1 +metadata: + name: ui-service + namespace: testing + labels: + app: ui +spec: + selector: + app: ui + ports: + - protocol: TCP + port: 80 + targetPort: 5000 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ui-deployment + namespace: testing +spec: + selector: + matchLabels: + app: ui + replicas: 1 + template: + metadata: + labels: + app: ui + spec: + containers: + - name: ui + image: 100:71:71:71:5000/ui-service:latest + ports: + - containerPort: 5000 + env: + - name: POST_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: POST_SERVICE_URL + - name: VIEW_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: VIEW_SERVICE_URL diff --git a/e2e-test-prod.py b/e2e-test-prod.py new file mode 100644 index 0000000..de2ba38 --- /dev/null +++ b/e2e-test-prod.py @@ -0,0 +1,28 @@ +import os +import requests + +def main(): + check_services() + + + +def check_services(): + URL = "ui-service.production.svc:5000" + req = request.get(URL) + if req.status_code == 200: + print("Tests successfull pass") + continue + else: + raise Exception("Fucking bitch!!!! Opssss") + return 1 + URL_GET = "ui-service.production.svc:5000/salaries" + reques = request.get(URL_GET) + if reques.status_code == 200: + print("Get req success to UI") + return 0 + else: + raise Exception("Fucking bitch again!!!! Opssss. You are unclever animal") + return -1 + +if __name__ == '__main__': + main() diff --git a/e2e-test-test.py b/e2e-test-test.py new file mode 100644 index 0000000..d65d936 --- /dev/null +++ b/e2e-test-test.py @@ -0,0 +1,28 @@ +import os +import requests + +def main(): + check_services() + + + +def check_services(): + URL = "ui-service.testing.svc:5000" + req = request.get(URL) + if req.status_code == 200: + print("Tests successfull pass") + continue + else: + raise Exception("Fucking bitch!!!! Opssss") + return 1 + URL_GET = "ui-service.testing.svc:5000/salaries" + reques = request.get(URL_GET) + if reques.status_code == 200: + print("Get req success to UI") + return 0 + else: + raise Exception("Fucking bitch again!!!! Opssss. You are unclever animal") + return -1 + +if __name__ == '__main__': + main() diff --git a/e2e-test.py b/e2e-test.py new file mode 100644 index 0000000..1e459ee --- /dev/null +++ b/e2e-test.py @@ -0,0 +1,29 @@ +import os +import requests + +def main(): + check_services() + + + +def check_services(): + URL = "ui-service.production.svc:5000" + req = request.get(URL) + if req.status_code == 200: + print("Tests successfull pass") + continue + else: + raise Exception("F... b...!!!! Opssss") + return 1 + URL_GET = "ui-service.production.svc:5000/salaries" + reques = request.get(URL_GET) + if reques.status_code == 200: + print("Get req success to UI") + return 0 + else: + raise Exception("F... b... again!!!! Opssss") + return -1 + +if __name__ == '__main__': + main() + From 56a76dbacfacea0973c5183b6a7c617ba258779a Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 18 Jan 2019 02:39:12 -0500 Subject: [PATCH 026/241] Add testing scripts to pipeline --- e2e-test.py | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 e2e-test.py diff --git a/e2e-test.py b/e2e-test.py deleted file mode 100644 index 1e459ee..0000000 --- a/e2e-test.py +++ /dev/null @@ -1,29 +0,0 @@ -import os -import requests - -def main(): - check_services() - - - -def check_services(): - URL = "ui-service.production.svc:5000" - req = request.get(URL) - if req.status_code == 200: - print("Tests successfull pass") - continue - else: - raise Exception("F... b...!!!! Opssss") - return 1 - URL_GET = "ui-service.production.svc:5000/salaries" - reques = request.get(URL_GET) - if reques.status_code == 200: - print("Get req success to UI") - return 0 - else: - raise Exception("F... b... again!!!! Opssss") - return -1 - -if __name__ == '__main__': - main() - From c09b20bff27787ac6f754d795f23071a20e575e2 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 18 Jan 2019 05:44:13 -0500 Subject: [PATCH 027/241] Add pipelines error1 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0d8c3dd..cdd4eea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,7 +25,7 @@ node(label) stage("Git Checkout"){ git( branch: "MZhovanik", - url: 'https://github.com/Kv-045DevOps/SRM-GET.git') + url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") sh "git rev-parse --short HEAD > .git/commit-id" imageTag= readFile ".git/commit-id" From 7a77cb0f0e7445cc68b632b06d5b3134d0c11c56 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 18 Jan 2019 06:03:54 -0500 Subject: [PATCH 028/241] Next change --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index cdd4eea..e3f1d99 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,7 +39,7 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed-python.py template.yml ${dockerRegistry}/get-service ${imageTag}" + sh "python3 ${pathTocode}/sed_python.py template.yml ${dockerRegistry}/get-service ${imageTag}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } From 5d7f9f54f2d58baf1ecb2cc89499da07ddf39f00 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 18 Jan 2019 06:47:18 -0500 Subject: [PATCH 029/241] Insecure registry --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e3f1d99..368bd76 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ 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: 'docker', image: 'docker', command: 'cat', ttyEnabled: true, args: '--insecure-registry http://100.71.71.71'), containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true) ], volumes: [ From 67974239bae862c062c7f49a6b6a0ca7a5a3f62d Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 18 Jan 2019 07:08:14 -0500 Subject: [PATCH 030/241] Insecure registry --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 368bd76..07c2111 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ 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, args: '--insecure-registry http://100.71.71.71'), + containerTemplate(name: 'docker', image: 'docker', command: 'echo "{"insecure-registries" : ["myregistrydomain.com:5000"]}" >> /etc/docker/daemon.json', ttyEnabled: true'), containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true) ], volumes: [ From cbec166172d767aed306802dc7bbdb76da7eaec0 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 18 Jan 2019 07:09:46 -0500 Subject: [PATCH 031/241] Insecure registry --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 07c2111..199f6b6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ 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: 'echo "{"insecure-registries" : ["myregistrydomain.com:5000"]}" >> /etc/docker/daemon.json', ttyEnabled: true'), + containerTemplate(name: 'docker', image: 'docker', command: 'echo "{"insecure-registries" : ["myregistrydomain.com:5000"]}" >> /etc/docker/daemon.json', ttyEnabled: true), containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true) ], volumes: [ From 255a8df278f22b9f7555f1cc6626a986b3e61b65 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 18 Jan 2019 07:20:28 -0500 Subject: [PATCH 032/241] Add daemon.json --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 199f6b6..268c236 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ 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: 'echo "{"insecure-registries" : ["myregistrydomain.com:5000"]}" >> /etc/docker/daemon.json', ttyEnabled: true), + containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', command: 'cat', ttyEnabled: true), containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true) ], volumes: [ From d5d46ff22fceadb554bddbff6783eba594113807 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 18 Jan 2019 07:33:48 -0500 Subject: [PATCH 033/241] Add daemon.json --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 268c236..8429757 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -49,6 +49,7 @@ node(label) // app = docker.build("${imageName}:${imageTag}") sh "docker build ${pathdocker} -t ${imageN}${imageTag}" sh "docker images" + sh "cat /etc/docker/daemon.json" //withCredentials([usernamePassword(credentialsId: 'docker_registry_2', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) { sh "docker push ${imageN}${imageTag}" From 7dcbd35d38401d45c9ff7055bc887e36050cf96e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 18 Jan 2019 12:03:36 -0500 Subject: [PATCH 034/241] Commit #1 --- Jenkinsfile | 6 +++--- Kuben.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8429757..07dd1ff 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -73,11 +73,11 @@ node(label) } } stage ("E2E Tests - Stage 2"){ - // container('kubectl'){ - // sh 'kubectl apply -f Kuben.yml' + container('kubectl'){ + sh 'kubectl apply -f Kuben.yml' // sh 'kubectl apply -f Kuben(1).yml' // sh 'kubectl get pods -n testing' - // } + } } stage ("E2E Tests - Stage 3"){ container('python-alpine'){ diff --git a/Kuben.yml b/Kuben.yml index 604e45c..662cf05 100644 --- a/Kuben.yml +++ b/Kuben.yml @@ -188,7 +188,7 @@ spec: spec: containers: - name: post - image: 100:71:71:71:5000/post-service:2.1 + image: 100.71.71.71:5000/post-service:2.1 ports: - containerPort: 5001 env: @@ -231,7 +231,7 @@ spec: spec: containers: - name: get - image: 100:71:71:71:5000/get-python:v2 + image: 100.71.71.71:5000/get-python:v2 ports: - containerPort: 5003 env: @@ -274,7 +274,7 @@ spec: spec: containers: - name: ui - image: 100:71:71:71:5000/ui-service:latest + image: 100.71.71.71:5000/ui-service:latest ports: - containerPort: 5000 env: From c8f4011ff7e10302b50ee32ccda1ba1fd2738f53 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 21 Jan 2019 14:05:24 -0500 Subject: [PATCH 035/241] Debug GET-service --- app/app.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/app.py b/app/app.py index d46b80f..d6f7473 100644 --- a/app/app.py +++ b/app/app.py @@ -8,10 +8,10 @@ -URL_DEP = str(os.getenv("URL_DB")) + '/get-dep' -URL_EMPL = str(os.getenv("URL_DB")) + '/get-empl' -URL_TEAM = str(os.getenv("URL_DB")) + '/get-team' -URL_ALL = str(os.getenv("URL_DB")) + '/get-info' +URL_DEP = str(os.getenv("URL_DB")) + ':5002/get-dep' +URL_EMPL = str(os.getenv("URL_DB")) + ':5002/get-empl' +URL_TEAM = str(os.getenv("URL_DB")) + ':5002/get-team' +URL_ALL = str(os.getenv("URL_DB")) + ':5002/get-info' def print_url(): print(URL_DEP) From ebf724e22b0073cc6a00ae1517524c17954bac35 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 21 Jan 2019 14:41:58 -0500 Subject: [PATCH 036/241] Debug Final GET --- app/app.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/app.py b/app/app.py index d6f7473..4fa5b1d 100644 --- a/app/app.py +++ b/app/app.py @@ -8,10 +8,10 @@ -URL_DEP = str(os.getenv("URL_DB")) + ':5002/get-dep' -URL_EMPL = str(os.getenv("URL_DB")) + ':5002/get-empl' -URL_TEAM = str(os.getenv("URL_DB")) + ':5002/get-team' -URL_ALL = str(os.getenv("URL_DB")) + ':5002/get-info' +URL_DEP = 'http://' + str(os.getenv("URL_DB")) + ':5002/get-dep' +URL_EMPL = 'http://' + str(os.getenv("URL_DB")) + ':5002/get-empl' +URL_TEAM = 'http://' + str(os.getenv("URL_DB")) + ':5002/get-team' +URL_ALL = 'http://' + str(os.getenv("URL_DB")) + ':5002/get-info' def print_url(): print(URL_DEP) From 534717f5ba68fa3e4f160f48b59e050e6ae50531 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 22 Jan 2019 10:41:36 -0500 Subject: [PATCH 037/241] Debug image check --- images-registry-test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images-registry-test.py b/images-registry-test.py index 59c78a6..f109700 100644 --- a/images-registry-test.py +++ b/images-registry-test.py @@ -8,7 +8,7 @@ def main(): def check_image(): - tmp = requests.get("http://" + sys.argv[1] + "/v2/" + sys.argv[2] + "/tags/list") + tmp = requests.get("http://" + sys.argv[1] + "/" + sys.argv[2] + "/" + sys.argv[3] + "/tags/list") req = tmp.json() if req["name"] == sys.argv[2] and sys.argv[3] in req["tags"]: return 0 From c7d02ead5e01bce56be7208546737240365dc948 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 22 Jan 2019 10:49:43 -0500 Subject: [PATCH 038/241] Debug image check --- images-registry-test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/images-registry-test.py b/images-registry-test.py index f109700..a1a3ea9 100644 --- a/images-registry-test.py +++ b/images-registry-test.py @@ -8,8 +8,9 @@ def main(): def check_image(): - tmp = requests.get("http://" + sys.argv[1] + "/" + sys.argv[2] + "/" + sys.argv[3] + "/tags/list") + tmp = requests.get("http://" + sys.argv[1] + "/v2/" + sys.argv[3] + "/tags/list") req = tmp.json() + print(req) if req["name"] == sys.argv[2] and sys.argv[3] in req["tags"]: return 0 else: From 0fcffd89778e1f67a9a45bf141a32bca4689285f Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 22 Jan 2019 10:57:04 -0500 Subject: [PATCH 039/241] Change Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 07dd1ff..80e9439 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -13,7 +13,7 @@ volumes: [ def app def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" -def projName = "get-python" +def projName = "get-service" def imageVersion = "v1" def imageName = "100.71.71.71:5000/get-service:${imageVersion}" def imageN = '100.71.71.71:5000/get-service:' From 8fc28c119fcaa57da98f318fa11cff7ea1023e29 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 22 Jan 2019 14:59:16 -0500 Subject: [PATCH 040/241] Change pipeline --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 80e9439..4b4ab47 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -7,8 +7,7 @@ podTemplate(label: label, containers: [ ], volumes: [ hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') -] -) +], serviceAccount: "jenkins") { def app def dockerRegistry = "100.71.71.71:5000" @@ -58,8 +57,10 @@ node(label) } stage("Check push image to Docker Registry"){ pathTocode = pwd() + container('python-alpine'){ sh "python3 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" } + } stage("Deploy to Kubernetes"){ container('kubectl'){ sh "kubectl apply -f template.yml" From ae148d39823e9ac9645c1c5fc8ca4fa6ae61c3d5 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 22 Jan 2019 15:14:09 -0500 Subject: [PATCH 041/241] Change pipeline --- sed_python.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sed_python.py b/sed_python.py index 43f2ad6..8936dea 100644 --- a/sed_python.py +++ b/sed_python.py @@ -5,7 +5,7 @@ str_tmp = "ghostgoose" data = file.read() tmp = sys.argv[2] + ":" + sys.argv[3] - data = data.replace("100.71.71.71:5000/get-service:v1", tmp) + data = data.replace("100.71.71.71:5000/get-service:v2", tmp) print(data) From 1c5311091c2f8329d87024045c0639ee09845c31 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 22 Jan 2019 15:19:23 -0500 Subject: [PATCH 042/241] Change scripts sed --- template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template.yml b/template.yml index ce08dd7..a276cf6 100644 --- a/template.yml +++ b/template.yml @@ -32,7 +32,7 @@ spec: spec: containers: - name: get - image: 100.71.71.71:5000/get-python:v2 + image: 100.71.71.71:5000/get-service:v2 ports: - containerPort: 5003 env: From 2c6f265c4e1b2b81fdfc07fae917aa018b006cc8 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 22 Jan 2019 15:24:38 -0500 Subject: [PATCH 043/241] Change test scripts --- e2e-test-prod.py | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test-prod.py b/e2e-test-prod.py index de2ba38..6b87942 100644 --- a/e2e-test-prod.py +++ b/e2e-test-prod.py @@ -11,7 +11,6 @@ def check_services(): req = request.get(URL) if req.status_code == 200: print("Tests successfull pass") - continue else: raise Exception("Fucking bitch!!!! Opssss") return 1 From 032b34b975e2d897069881e5dfe788f95330d9c6 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 22 Jan 2019 15:27:36 -0500 Subject: [PATCH 044/241] Change test scripts#2 --- e2e-test-prod.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test-prod.py b/e2e-test-prod.py index 6b87942..f6fd464 100644 --- a/e2e-test-prod.py +++ b/e2e-test-prod.py @@ -8,14 +8,14 @@ def main(): def check_services(): URL = "ui-service.production.svc:5000" - req = request.get(URL) + req = requests.get(URL) if req.status_code == 200: print("Tests successfull pass") else: raise Exception("Fucking bitch!!!! Opssss") return 1 URL_GET = "ui-service.production.svc:5000/salaries" - reques = request.get(URL_GET) + reques = requests.get(URL_GET) if reques.status_code == 200: print("Get req success to UI") return 0 From 411f6308a1c34ba7040c7382d7a063d9781dbb5a Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 22 Jan 2019 15:51:35 -0500 Subject: [PATCH 045/241] Working version --- Jenkinsfile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4b4ab47..607fb07 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -58,32 +58,33 @@ node(label) stage("Check push image to Docker Registry"){ pathTocode = pwd() container('python-alpine'){ - sh "python3 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" + //sh "python3 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" } } stage("Deploy to Kubernetes"){ container('kubectl'){ + sh "kubectl get pods --namespace=production" sh "kubectl apply -f template.yml" - sh "kubectl get pods --namespace=production" + } } stage ("E2E Tests - Stage 1"){ container('python-alpine'){ - sh 'echo "Here are e2e tests"' - sh 'python3 e2e-test-prod.py' + // sh 'echo "Here are e2e tests"' + // sh 'python3 e2e-test-prod.py' } } stage ("E2E Tests - Stage 2"){ container('kubectl'){ - sh 'kubectl apply -f Kuben.yml' + // sh 'kubectl apply -f Kuben.yml' // sh 'kubectl apply -f Kuben(1).yml' // sh 'kubectl get pods -n testing' } } stage ("E2E Tests - Stage 3"){ container('python-alpine'){ - sh 'echo "Here are e2e tests"' - sh 'python3 e2e-test-test.py' + // sh 'echo "Here are e2e tests"' + // sh 'python3 e2e-test-test.py' } } From a4d78df8f71ce4c1b83e475d4e4433e3c4c39cfe Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 22 Jan 2019 17:38:29 -0500 Subject: [PATCH 046/241] Rename dockerfile --- dockerfile => Dockerfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename dockerfile => Dockerfile (100%) diff --git a/dockerfile b/Dockerfile similarity index 100% rename from dockerfile rename to Dockerfile From 2bc556f208b48f09f952af8994c5f0dc41f99e13 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 22 Jan 2019 17:56:07 -0500 Subject: [PATCH 047/241] Last 22.01 change --- app/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.py b/app/app.py index 4fa5b1d..dd1738e 100644 --- a/app/app.py +++ b/app/app.py @@ -121,5 +121,5 @@ def get_one(): if __name__ == '__main__': - app.run(debug=True,host='0.0.0.0',port='5003') + app.run(debug=True) From 66243b7e609d2562b26450d33390208167455786 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 04:41:11 -0500 Subject: [PATCH 048/241] Change Git pull var --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 607fb07..7e2091c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,6 +10,7 @@ volumes: [ ], serviceAccount: "jenkins") { def app +def imageTag def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" def projName = "get-service" @@ -26,8 +27,8 @@ node(label) branch: "MZhovanik", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") - sh "git rev-parse --short HEAD > .git/commit-id" - imageTag= readFile ".git/commit-id" + //sh "git rev-parse --short HEAD > .git/commit-id" + imageTag = sh (script: "git rev-parse --short HEAD", returnStdout: true)` } stage("Info"){ sh "echo ${imageTag}" From 81da0f4e70deb4a737038d353ad992aabaa541f8 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 04:43:06 -0500 Subject: [PATCH 049/241] Change Git pull var#2 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7e2091c..648c452 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,7 +28,7 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - imageTag = sh (script: "git rev-parse --short HEAD", returnStdout: true)` + imageTag = sh (script: "git rev-parse --short HEAD", returnStdout: true) } stage("Info"){ sh "echo ${imageTag}" From 69b0ab952ff1a1e36cdacbba7c976ec19441d56d Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 05:45:48 -0500 Subject: [PATCH 050/241] Change app --- app/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.py b/app/app.py index dd1738e..5d0e837 100644 --- a/app/app.py +++ b/app/app.py @@ -121,5 +121,5 @@ def get_one(): if __name__ == '__main__': - app.run(debug=True) + app.run(host="0.0.0.0", port="5003") From 830584a4a7dc35297da4cbe7e85fa1d0c0476a86 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 07:37:34 -0500 Subject: [PATCH 051/241] CHange GET Codes#3 --- app/app.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/app.py b/app/app.py index 5d0e837..41027ee 100644 --- a/app/app.py +++ b/app/app.py @@ -22,6 +22,8 @@ def print_url(): def get_dep(): r = requests.get(URL_DEP) if r.status_code == 200: + print(type(r.content)) + print(r.content) return r.content else: return (r.status_code, r.headers) From fbb035e5511c6a3cafe764ab63673866b4bc0585 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 07:47:06 -0500 Subject: [PATCH 052/241] CHange GET Codes --- app/app.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/app.py b/app/app.py index 41027ee..63ee982 100644 --- a/app/app.py +++ b/app/app.py @@ -26,6 +26,7 @@ def get_dep(): print(r.content) return r.content else: + print(r.status_code) return (r.status_code, r.headers) def get_empl(): From c101db402391330c4cc61ea349132011930d2737 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 16:01:34 -0500 Subject: [PATCH 053/241] E2E test GET Request --- e2e-test-test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test-test.py b/e2e-test-test.py index d65d936..35f78c0 100644 --- a/e2e-test-test.py +++ b/e2e-test-test.py @@ -8,7 +8,7 @@ def main(): def check_services(): URL = "ui-service.testing.svc:5000" - req = request.get(URL) + req = requests.get(URL) if req.status_code == 200: print("Tests successfull pass") continue @@ -16,7 +16,7 @@ def check_services(): raise Exception("Fucking bitch!!!! Opssss") return 1 URL_GET = "ui-service.testing.svc:5000/salaries" - reques = request.get(URL_GET) + reques = requests.get(URL_GET) if reques.status_code == 200: print("Get req success to UI") return 0 From a323a1aaaad7dee644256da6f4b7941d1422507d Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 16:07:32 -0500 Subject: [PATCH 054/241] Testing --- Jenkinsfile | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 648c452..8fc8aa1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,7 @@ node(label) try{ stage("Git Checkout"){ git( - branch: "MZhovanik", + branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" @@ -46,22 +46,13 @@ node(label) stage("Build docker image"){ container('docker'){ pathdocker = pwd() -// app = docker.build("${imageName}:${imageTag}") sh "docker build ${pathdocker} -t ${imageN}${imageTag}" sh "docker images" sh "cat /etc/docker/daemon.json" - //withCredentials([usernamePassword(credentialsId: 'docker_registry_2', passwordVariable: 'dockerPassword', usernameVariable: 'dockerUser')]) { - sh "docker push ${imageN}${imageTag}" - //} } } - stage("Check push image to Docker Registry"){ - pathTocode = pwd() - container('python-alpine'){ - //sh "python3 ${pathTocode}/images-registry-test.py ${dockerRegistry} ${projName} ${imageTag}" - } - } + stage("Deploy to Kubernetes"){ container('kubectl'){ sh "kubectl get pods --namespace=production" @@ -71,21 +62,20 @@ node(label) } stage ("E2E Tests - Stage 1"){ container('python-alpine'){ - // sh 'echo "Here are e2e tests"' - // sh 'python3 e2e-test-prod.py' + sh 'echo "Here are e2e tests"' + sh 'python3 e2e-test-prod.py' } } stage ("E2E Tests - Stage 2"){ container('kubectl'){ - // sh 'kubectl apply -f Kuben.yml' - // sh 'kubectl apply -f Kuben(1).yml' + // sh 'kubectl apply -f Kuben.yml // sh 'kubectl get pods -n testing' } } stage ("E2E Tests - Stage 3"){ container('python-alpine'){ - // sh 'echo "Here are e2e tests"' - // sh 'python3 e2e-test-test.py' + //sh 'echo "Here are e2e tests"' + //sh 'python3 e2e-test-test.py' } } From a9c115448ee1341ff97c57f7e874ecd8bb5aefe9 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 16:25:50 -0500 Subject: [PATCH 055/241] Testing --- e2e-test-prod.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test-prod.py b/e2e-test-prod.py index f6fd464..a0cbaba 100644 --- a/e2e-test-prod.py +++ b/e2e-test-prod.py @@ -7,14 +7,14 @@ def main(): def check_services(): - URL = "ui-service.production.svc:5000" + URL = "http://ui-service.production.svc:5000/" req = requests.get(URL) if req.status_code == 200: print("Tests successfull pass") else: raise Exception("Fucking bitch!!!! Opssss") return 1 - URL_GET = "ui-service.production.svc:5000/salaries" + URL_GET = "http://ui-service.production.svc:5000/salaries" reques = requests.get(URL_GET) if reques.status_code == 200: print("Get req success to UI") From 3433db767dfc5b1c9e28f7a6ac9643aada97ad12 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 16:47:41 -0500 Subject: [PATCH 056/241] Indian Code --- Kuben.yml | 73 +++++++++++++++++++++++++++++++++++++++++++++- e2e-test-prod.py | 6 ++-- sed_python_test.py | 17 +++++++++++ 3 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 sed_python_test.py diff --git a/Kuben.yml b/Kuben.yml index 662cf05..f38c7c7 100644 --- a/Kuben.yml +++ b/Kuben.yml @@ -210,7 +210,7 @@ spec: app: get ports: - protocol: TCP - port: 80 + port: 5003 targetPort: 5003 --- @@ -288,3 +288,74 @@ spec: configMapKeyRef: name: services-address key: VIEW_SERVICE_URL + +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + namespace: testing + name: db-service +spec: + template: + metadata: + labels: + app: db-service + spec: + initContainers: + - image: 100.71.71.71:5000/init-container:latest + name: init-container-postgres + env: + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] + containers: + - image: 100.71.71.71:5000/db-service:latest + name: db-service + ports: + - containerPort: 5002 + env: + - name: POSTGRES_HOST + value: srmsystemdb + - name: POSTGRES_PORT + value: "5432" + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: db-service +spec: + selector: + app: db-service + ports: + - protocol: TCP + port: 5002 + targetPort: 5002 diff --git a/e2e-test-prod.py b/e2e-test-prod.py index a0cbaba..89161ab 100644 --- a/e2e-test-prod.py +++ b/e2e-test-prod.py @@ -10,17 +10,17 @@ def check_services(): URL = "http://ui-service.production.svc:5000/" req = requests.get(URL) if req.status_code == 200: - print("Tests successfull pass") + print("Tests UI successfull pass") else: raise Exception("Fucking bitch!!!! Opssss") return 1 URL_GET = "http://ui-service.production.svc:5000/salaries" reques = requests.get(URL_GET) if reques.status_code == 200: - print("Get req success to UI") + print("Test success to UI-GET/salaries") return 0 else: - raise Exception("Fucking bitch again!!!! Opssss. You are unclever animal") + raise Exception("Fucking bitch again!!!! Opssss. You are ....") return -1 if __name__ == '__main__': diff --git a/sed_python_test.py b/sed_python_test.py new file mode 100644 index 0000000..502a7a1 --- /dev/null +++ b/sed_python_test.py @@ -0,0 +1,17 @@ +import os +import sys + +with open(sys.argv[1], 'r') as file: + str_tmp = "ghostgoose" + arr_f = arr = ["100.71.71.71:5000/get-service", "100.71.71.71:5000/post-service", "100.71.71.71:5000/ui-service", "100.71.71.71:5000/db-service", "100.71.71.71:5000/init-container"] + arr = ["100.71.71.71:5000/get-service:v2", "100.71.71.71:5000/post-service:2.1", "100.71.71.71:5000/ui-service:latest", "100.71.71.71:5000/db-service:latest", "100.71.71.71:5000/init-container:latest"] + data = file.read() + for i in range(0,len(arr_f)-1): + tmp = arr_f[i] + ":" + sys.argv[2] + data = data.replace(arr[i], tmp) + + print(data) + + +with open(sys.argv[1], 'w') as file: + file.write( data ) From def0adcb5d6a457ba607d1a099955b611448a860 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 16:53:04 -0500 Subject: [PATCH 057/241] Indian Code#2 --- sed_python_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sed_python_test.py b/sed_python_test.py index 502a7a1..1733d7b 100644 --- a/sed_python_test.py +++ b/sed_python_test.py @@ -3,7 +3,7 @@ with open(sys.argv[1], 'r') as file: str_tmp = "ghostgoose" - arr_f = arr = ["100.71.71.71:5000/get-service", "100.71.71.71:5000/post-service", "100.71.71.71:5000/ui-service", "100.71.71.71:5000/db-service", "100.71.71.71:5000/init-container"] + arr_f = ["100.71.71.71:5000/get-service", "100.71.71.71:5000/post-service", "100.71.71.71:5000/ui-service", "100.71.71.71:5000/db-service", "100.71.71.71:5000/init-container"] arr = ["100.71.71.71:5000/get-service:v2", "100.71.71.71:5000/post-service:2.1", "100.71.71.71:5000/ui-service:latest", "100.71.71.71:5000/db-service:latest", "100.71.71.71:5000/init-container:latest"] data = file.read() for i in range(0,len(arr_f)-1): From b9be2b93653ff18b4404c5dbaeca94dc0dabae93 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 16:55:53 -0500 Subject: [PATCH 058/241] Indian Code#2 --- sed_python_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sed_python_test.py b/sed_python_test.py index 1733d7b..355ae62 100644 --- a/sed_python_test.py +++ b/sed_python_test.py @@ -6,7 +6,7 @@ arr_f = ["100.71.71.71:5000/get-service", "100.71.71.71:5000/post-service", "100.71.71.71:5000/ui-service", "100.71.71.71:5000/db-service", "100.71.71.71:5000/init-container"] arr = ["100.71.71.71:5000/get-service:v2", "100.71.71.71:5000/post-service:2.1", "100.71.71.71:5000/ui-service:latest", "100.71.71.71:5000/db-service:latest", "100.71.71.71:5000/init-container:latest"] data = file.read() - for i in range(0,len(arr_f)-1): + for i in range(0,len(arr_f)): tmp = arr_f[i] + ":" + sys.argv[2] data = data.replace(arr[i], tmp) From 4ec04f6c0910dfc6d931da7e1cf72ed1e0ad43f0 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 16:59:33 -0500 Subject: [PATCH 059/241] Indian Code#3 --- sed_python_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sed_python_test.py b/sed_python_test.py index 355ae62..6d6ebc7 100644 --- a/sed_python_test.py +++ b/sed_python_test.py @@ -6,7 +6,8 @@ arr_f = ["100.71.71.71:5000/get-service", "100.71.71.71:5000/post-service", "100.71.71.71:5000/ui-service", "100.71.71.71:5000/db-service", "100.71.71.71:5000/init-container"] arr = ["100.71.71.71:5000/get-service:v2", "100.71.71.71:5000/post-service:2.1", "100.71.71.71:5000/ui-service:latest", "100.71.71.71:5000/db-service:latest", "100.71.71.71:5000/init-container:latest"] data = file.read() - for i in range(0,len(arr_f)): + print(len(arr_f)) + for i in range(len(arr_f)-1): tmp = arr_f[i] + ":" + sys.argv[2] data = data.replace(arr[i], tmp) From 0c9fc65e3b78476d60c9c3eb704321c13e0fce76 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 17:03:49 -0500 Subject: [PATCH 060/241] Indian Code#3 --- sed_python_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sed_python_test.py b/sed_python_test.py index 6d6ebc7..e2381c6 100644 --- a/sed_python_test.py +++ b/sed_python_test.py @@ -7,7 +7,7 @@ arr = ["100.71.71.71:5000/get-service:v2", "100.71.71.71:5000/post-service:2.1", "100.71.71.71:5000/ui-service:latest", "100.71.71.71:5000/db-service:latest", "100.71.71.71:5000/init-container:latest"] data = file.read() print(len(arr_f)) - for i in range(len(arr_f)-1): + for i in range(len(arr_f)): tmp = arr_f[i] + ":" + sys.argv[2] data = data.replace(arr[i], tmp) From fd3120bf1564a329f1a8d6db19166ece897030ab Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 17:11:00 -0500 Subject: [PATCH 061/241] Indian Code#3 --- Kuben.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kuben.yml b/Kuben.yml index f38c7c7..ebb2890 100644 --- a/Kuben.yml +++ b/Kuben.yml @@ -231,7 +231,7 @@ spec: spec: containers: - name: get - image: 100.71.71.71:5000/get-python:v2 + image: 100.71.71.71:5000/get-service:v2 ports: - containerPort: 5003 env: From f4afa239deef87cceea09d54deb46381c8f7b185 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 23 Jan 2019 17:22:45 -0500 Subject: [PATCH 062/241] Change e2e testing namespace testing --- e2e-test-test.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/e2e-test-test.py b/e2e-test-test.py index 35f78c0..6ef086f 100644 --- a/e2e-test-test.py +++ b/e2e-test-test.py @@ -7,18 +7,18 @@ def main(): def check_services(): - URL = "ui-service.testing.svc:5000" + URL = "http://ui-service.testing.svc:5000" req = requests.get(URL) if req.status_code == 200: - print("Tests successfull pass") + print("Test UI successfull pass") continue else: raise Exception("Fucking bitch!!!! Opssss") return 1 - URL_GET = "ui-service.testing.svc:5000/salaries" + URL_GET = "http://ui-service.testing.svc:5000/salaries" reques = requests.get(URL_GET) if reques.status_code == 200: - print("Get req success to UI") + print("UI success to GET") return 0 else: raise Exception("Fucking bitch again!!!! Opssss. You are unclever animal") From 8e5f276af0ed1909a8b2520cb98c39e253a59cae Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 24 Jan 2019 02:31:11 -0500 Subject: [PATCH 063/241] Add new E2E test --- E2E-Test.yaml | 302 ++++++++++++++++++++++++++++++++++++++++++++++++++ Kuben.yml | 4 +- 2 files changed, 304 insertions(+), 2 deletions(-) create mode 100644 E2E-Test.yaml diff --git a/E2E-Test.yaml b/E2E-Test.yaml new file mode 100644 index 0000000..3c21035 --- /dev/null +++ b/E2E-Test.yaml @@ -0,0 +1,302 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: testing + labels: + app: pvc-postgres + name: postgres-pvc +spec: + #storageClassName: slow + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi + +# --- +# apiVersion: v1 +# kind: PersistentVolumeClaim +# metadata: +# labels: +# service: postgresdb +# namespace: testing +# name: postgres-pvc +# spec: +# 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 + +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + namespace: testing + name: db-service +spec: + template: + metadata: + labels: + app: db-service + spec: + initContainers: + - image: 100.71.71.71:5000/init-container:latest + name: init-container-postgres + env: + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] + containers: + - image: 100.71.71.71:5000/db-service:latest + name: db-service + ports: + - containerPort: 5002 + env: + - name: POSTGRES_HOST + value: srmsystemdb + - name: POSTGRES_PORT + value: "5432" + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: db-service +spec: + selector: + app: db-service + ports: + - protocol: TCP + port: 5002 + targetPort: 5002 + +--- +kind: Service +apiVersion: v1 +metadata: + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 80 + targetPort: 5003 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: get-deployment +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: 100.100.100.100/get-python:v2 + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB + +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: post-service + labels: + app: post +spec: + selector: + app: post + ports: + - protocol: TCP + port: 80 + targetPort: 5001 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: testing + name: post-deployment +spec: + selector: + matchLabels: + app: post + replicas: 1 + template: + metadata: + labels: + app: post + spec: + containers: + - name: post + image: 100.71.71.71:5000/post-service:2.1 + ports: + - containerPort: 5001 + env: + - name: DB_URL + valueFrom: + configMapKeyRef: + name: services-address + key: DB_URL + +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: ui-service + labels: + app: ui +spec: + selector: + app: ui + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: testing + name: ui-deployment +spec: + selector: + matchLabels: + app: ui + replicas: 1 + template: + metadata: + labels: + app: ui + spec: + containers: + - name: ui + image: 100.71.71.71:5000/ui-service:latest + ports: + - containerPort: 5000 + env: + - name: POST_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: POST_SERVICE_URL + - name: VIEW_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: VIEW_SERVICE_URL \ No newline at end of file diff --git a/Kuben.yml b/Kuben.yml index ebb2890..69a6844 100644 --- a/Kuben.yml +++ b/Kuben.yml @@ -167,7 +167,7 @@ spec: app: post ports: - protocol: TCP - port: 80 + port: 5001 targetPort: 5001 --- @@ -253,7 +253,7 @@ spec: app: ui ports: - protocol: TCP - port: 80 + port: 5000 targetPort: 5000 --- From dbc65908d3b61f6b5332bb1d5cf3478ecc95cfa3 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 24 Jan 2019 02:50:40 -0500 Subject: [PATCH 064/241] E2E Testing --- E2E-Test.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/E2E-Test.yaml b/E2E-Test.yaml index 3c21035..cc22d82 100644 --- a/E2E-Test.yaml +++ b/E2E-Test.yaml @@ -198,7 +198,7 @@ spec: spec: containers: - name: get - image: 100.100.100.100/get-python:v2 + image: 100.71.71.71:5000/get-service:v2 ports: - containerPort: 5003 env: @@ -256,7 +256,7 @@ spec: kind: Service apiVersion: v1 metadata: - namespace: testing + namespace: production name: ui-service labels: app: ui @@ -272,7 +272,7 @@ spec: apiVersion: apps/v1 kind: Deployment metadata: - namespace: testing + namespace: production name: ui-deployment spec: selector: @@ -299,4 +299,4 @@ spec: valueFrom: configMapKeyRef: name: services-address - key: VIEW_SERVICE_URL \ No newline at end of file + key: VIEW_SERVICE_URL From 7c77f8558794c4a12544c27e156c47d971c5d980 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 24 Jan 2019 02:53:27 -0500 Subject: [PATCH 065/241] E2E Testing --- E2E-Test.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/E2E-Test.yaml b/E2E-Test.yaml index cc22d82..a9dc5b4 100644 --- a/E2E-Test.yaml +++ b/E2E-Test.yaml @@ -1,4 +1,18 @@ --- + +apiVersion: v1 +kind: Secret +metadata: + name: db-secret + namespace: production +data: + username: ZGJhZG1pbg== + password: UGFzc3dvcmQ= + dbname: c3Jtc3lzdGVt +type: Opaque + +--- + apiVersion: v1 kind: PersistentVolumeClaim metadata: From 379b36f84aa4e1c77a5e04cff4e9aac3b5155ce6 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 24 Jan 2019 02:54:46 -0500 Subject: [PATCH 066/241] E2E Testing last script change --- e2e-test-test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/e2e-test-test.py b/e2e-test-test.py index 6ef086f..d90f0ca 100644 --- a/e2e-test-test.py +++ b/e2e-test-test.py @@ -11,7 +11,6 @@ def check_services(): req = requests.get(URL) if req.status_code == 200: print("Test UI successfull pass") - continue else: raise Exception("Fucking bitch!!!! Opssss") return 1 From e8fb916a6716ffbf801a836ddd9c972196901b39 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 24 Jan 2019 03:37:02 -0500 Subject: [PATCH 067/241] Add new e2e --- E2E-Test.yaml | 223 +--------------------------------------------- template-test.yml | 43 +++++++++ 2 files changed, 44 insertions(+), 222 deletions(-) create mode 100644 template-test.yml diff --git a/E2E-Test.yaml b/E2E-Test.yaml index a9dc5b4..bb28282 100644 --- a/E2E-Test.yaml +++ b/E2E-Test.yaml @@ -4,7 +4,7 @@ apiVersion: v1 kind: Secret metadata: name: db-secret - namespace: production + namespace: testing data: username: ZGJhZG1pbg== password: UGFzc3dvcmQ= @@ -12,7 +12,6 @@ data: type: Opaque --- - apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -28,21 +27,6 @@ spec: requests: storage: 2Gi -# --- -# apiVersion: v1 -# kind: PersistentVolumeClaim -# metadata: -# labels: -# service: postgresdb -# namespace: testing -# name: postgres-pvc -# spec: -# accessModes: -# - ReadWriteOnce -# resources: -# requests: -# storage: 2Gi - --- apiVersion: extensions/v1beta1 kind: Deployment @@ -108,209 +92,4 @@ spec: - protocol: TCP port: 5432 targetPort: 5432 - ---- -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - namespace: testing - name: db-service -spec: - template: - metadata: - labels: - app: db-service - spec: - initContainers: - - image: 100.71.71.71:5000/init-container:latest - name: init-container-postgres - env: - - name: PGDATABASE - valueFrom: - secretKeyRef: - name: db-secret - key: dbname - - name: PGUSER - valueFrom: - secretKeyRef: - name: db-secret - key: username - - name: PGPASSWORD - valueFrom: - secretKeyRef: - name: db-secret - key: password - command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] - containers: - - image: 100.71.71.71:5000/db-service:latest - name: db-service - ports: - - containerPort: 5002 - env: - - name: POSTGRES_HOST - value: srmsystemdb - - name: POSTGRES_PORT - value: "5432" - - name: PGDATABASE - valueFrom: - secretKeyRef: - name: db-secret - key: dbname - - name: PGUSER - valueFrom: - secretKeyRef: - name: db-secret - key: username - - name: PGPASSWORD - valueFrom: - secretKeyRef: - name: db-secret - key: password ---- -kind: Service -apiVersion: v1 -metadata: - namespace: testing - name: db-service -spec: - selector: - app: db-service - ports: - - protocol: TCP - port: 5002 - targetPort: 5002 - ---- -kind: Service -apiVersion: v1 -metadata: - name: get-service - labels: - app: get -spec: - selector: - app: get - ports: - - protocol: TCP - port: 80 - targetPort: 5003 - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: get-deployment -spec: - selector: - matchLabels: - app: get - replicas: 1 - template: - metadata: - labels: - app: get - spec: - containers: - - name: get - image: 100.71.71.71:5000/get-service:v2 - ports: - - containerPort: 5003 - env: - - name: URL_DB - valueFrom: - configMapKeyRef: - name: services-address - key: URL_DB - ---- -kind: Service -apiVersion: v1 -metadata: - namespace: testing - name: post-service - labels: - app: post -spec: - selector: - app: post - ports: - - protocol: TCP - port: 80 - targetPort: 5001 - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: testing - name: post-deployment -spec: - selector: - matchLabels: - app: post - replicas: 1 - template: - metadata: - labels: - app: post - spec: - containers: - - name: post - image: 100.71.71.71:5000/post-service:2.1 - ports: - - containerPort: 5001 - env: - - name: DB_URL - valueFrom: - configMapKeyRef: - name: services-address - key: DB_URL - --- -kind: Service -apiVersion: v1 -metadata: - namespace: production - name: ui-service - labels: - app: ui -spec: - selector: - app: ui - ports: - - protocol: TCP - port: 5000 - targetPort: 5000 - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: production - name: ui-deployment -spec: - selector: - matchLabels: - app: ui - replicas: 1 - template: - metadata: - labels: - app: ui - spec: - containers: - - name: ui - image: 100.71.71.71:5000/ui-service:latest - ports: - - containerPort: 5000 - env: - - name: POST_SERVICE_URL - valueFrom: - configMapKeyRef: - name: services-address - key: POST_SERVICE_URL - - name: VIEW_SERVICE_URL - valueFrom: - configMapKeyRef: - name: services-address - key: VIEW_SERVICE_URL diff --git a/template-test.yml b/template-test.yml new file mode 100644 index 0000000..1513a2e --- /dev/null +++ b/template-test.yml @@ -0,0 +1,43 @@ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: testing + name: get-deployment +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: 100.71.71.71:5000/get-service:v2 + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB From d14a2d0a78b59cb57aa3400dc70fecf3fd43d44e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 24 Jan 2019 17:04:54 -0500 Subject: [PATCH 068/241] Commit night --- E2E.yaml | 301 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Jenkinsfile | 14 ++- 2 files changed, 310 insertions(+), 5 deletions(-) create mode 100644 E2E.yaml diff --git a/E2E.yaml b/E2E.yaml new file mode 100644 index 0000000..2545842 --- /dev/null +++ b/E2E.yaml @@ -0,0 +1,301 @@ +--- + +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 +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + namespace: production + name: db-service +spec: + template: + metadata: + labels: + app: db-service + spec: + initContainers: + - image: 100.71.71.71:5000/init-container:latest + name: init-container-postgres + env: + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] + containers: + - image: 100.71.71.71:5000/db-service:latest + name: db-service + ports: + - containerPort: 5002 + env: + - name: POSTGRES_HOST + value: srmsystemdb + - name: POSTGRES_PORT + value: "5432" + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: db-service +spec: + selector: + app: db-service + ports: + - protocol: TCP + port: 5002 + targetPort: 5002 + +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: post-service + labels: + app: post +spec: + selector: + app: post + ports: + - protocol: TCP + port: 5001 + targetPort: 5001 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: testing + name: post-deployment +spec: + selector: + matchLabels: + app: post + replicas: 1 + template: + metadata: + labels: + app: post + spec: + containers: + - name: post + image: 100.71.71.71:5000/post-service:2.1 + ports: + - containerPort: 5001 + env: + - name: DB_URL + valueFrom: + configMapKeyRef: + name: services-address + key: DB_URL +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: ui-service + labels: + app: ui +spec: + selector: + app: ui + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: testing + name: ui-deployment +spec: + selector: + matchLabels: + app: ui + replicas: 1 + template: + metadata: + labels: + app: ui + spec: + containers: + - name: ui + image: 100.71.71.71:5000/ui-service:latest + ports: + - containerPort: 5000 + env: + - name: POST_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: POST_SERVICE_URL + - name: VIEW_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: VIEW_SERVICE_URL +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: testing + name: get-deployment +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: 100.71.71.71:5000/get-service:v2 + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB +--- + diff --git a/Jenkinsfile b/Jenkinsfile index 8fc8aa1..c74622e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,5 @@ def label = "mypod-${UUID.randomUUID().toString()}" +def label_f = "mypod-${UUID.randomUUID().toString()}" podTemplate(label: label, containers: [ containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', command: 'cat', ttyEnabled: true), @@ -7,7 +8,8 @@ podTemplate(label: label, containers: [ ], volumes: [ hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') -], serviceAccount: "jenkins") +], serviceAccount: "jenkins") + { def app def imageTag @@ -64,18 +66,20 @@ node(label) container('python-alpine'){ sh 'echo "Here are e2e tests"' sh 'python3 e2e-test-prod.py' + sh "python3 sed_python_test.py template-test.yml ${imageTag}" + sh 'cat template-test.yml' } } stage ("E2E Tests - Stage 2"){ container('kubectl'){ - // sh 'kubectl apply -f Kuben.yml - // sh 'kubectl get pods -n testing' + sh 'kubectl apply -f template-test.yml' + sh 'kubectl get pods -n testing' } } stage ("E2E Tests - Stage 3"){ container('python-alpine'){ - //sh 'echo "Here are e2e tests"' - //sh 'python3 e2e-test-test.py' + sh 'echo "Here are e2e tests"' + //sh 'python3 e2e-test-test.py' } } From 18cd738b595db5697c8d0cba38135c60e49785b5 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 26 Jan 2019 11:49:56 -0500 Subject: [PATCH 069/241] New Jenkinsfile --- Jenkinsfile | 37 +++----------------- Jenkinsfile_v1 | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 33 deletions(-) create mode 100644 Jenkinsfile_v1 diff --git a/Jenkinsfile b/Jenkinsfile index c74622e..c3042d9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,7 +30,7 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - imageTag = sh (script: "git rev-parse --short HEAD", returnStdout: true) + imageTag_Get = sh (script: "git rev-parse --short HEAD", returnStdout: true) } stage("Info"){ sh "echo ${imageTag}" @@ -41,48 +41,19 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed_python.py template.yml ${dockerRegistry}/get-service ${imageTag}" + sh "python3 ${pathTocode}/sed_python.py template.yml ${dockerRegistry}/get-service ${imageTag_Get}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } stage("Build docker image"){ container('docker'){ pathdocker = pwd() - sh "docker build ${pathdocker} -t ${imageN}${imageTag}" + sh "docker build ${pathdocker} -t ${imageN}${imageTag_Get}" sh "docker images" sh "cat /etc/docker/daemon.json" - sh "docker push ${imageN}${imageTag}" + sh "docker push ${imageN}${imageTag_Get}" } } - - stage("Deploy to Kubernetes"){ - container('kubectl'){ - sh "kubectl get pods --namespace=production" - sh "kubectl apply -f template.yml" - - } - } - stage ("E2E Tests - Stage 1"){ - container('python-alpine'){ - sh 'echo "Here are e2e tests"' - sh 'python3 e2e-test-prod.py' - sh "python3 sed_python_test.py template-test.yml ${imageTag}" - sh 'cat template-test.yml' - } - } - stage ("E2E Tests - Stage 2"){ - container('kubectl'){ - sh 'kubectl apply -f template-test.yml' - sh 'kubectl get pods -n testing' - } - } - stage ("E2E Tests - Stage 3"){ - container('python-alpine'){ - sh 'echo "Here are e2e tests"' - //sh 'python3 e2e-test-test.py' - } - } - } catch(err){ currentBuild.result = 'Failure' diff --git a/Jenkinsfile_v1 b/Jenkinsfile_v1 new file mode 100644 index 0000000..c74622e --- /dev/null +++ b/Jenkinsfile_v1 @@ -0,0 +1,94 @@ +def label = "mypod-${UUID.randomUUID().toString()}" +def label_f = "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: 'ghostgoose33/docker-in:v1', 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 = "get-service" +def imageVersion = "v1" +def imageName = "100.71.71.71:5000/get-service:${imageVersion}" +def imageN = '100.71.71.71:5000/get-service:' + + +node(label) +{ + try{ + stage("Git Checkout"){ + git( + branch: "test", + url: 'https://github.com/Kv-045DevOps/SRM-GET.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.yml ${dockerRegistry}/get-service ${imageTag}" + sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" + } + } + stage("Build docker image"){ + container('docker'){ + pathdocker = pwd() + sh "docker build ${pathdocker} -t ${imageN}${imageTag}" + sh "docker images" + sh "cat /etc/docker/daemon.json" + sh "docker push ${imageN}${imageTag}" + } + } + + stage("Deploy to Kubernetes"){ + container('kubectl'){ + sh "kubectl get pods --namespace=production" + sh "kubectl apply -f template.yml" + + } + } + stage ("E2E Tests - Stage 1"){ + container('python-alpine'){ + sh 'echo "Here are e2e tests"' + sh 'python3 e2e-test-prod.py' + sh "python3 sed_python_test.py template-test.yml ${imageTag}" + sh 'cat template-test.yml' + } + } + stage ("E2E Tests - Stage 2"){ + container('kubectl'){ + sh 'kubectl apply -f template-test.yml' + sh 'kubectl get pods -n testing' + } + } + stage ("E2E Tests - Stage 3"){ + container('python-alpine'){ + sh 'echo "Here are e2e tests"' + //sh 'python3 e2e-test-test.py' + } + } + + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} + + +sleep 30 From a8ead0fa82d33bf747bed07ee0f5fd9df08ac254 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 26 Jan 2019 14:36:52 -0500 Subject: [PATCH 070/241] Jenkinsfile --- Jenkinsfile | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c3042d9..24195be 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,7 @@ def imageTag def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" def projName = "get-service" -def imageVersion = "v1" +def imageVersion = "v2" def imageName = "100.71.71.71:5000/get-service:${imageVersion}" def imageN = '100.71.71.71:5000/get-service:' @@ -30,10 +30,7 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - imageTag_Get = sh (script: "git rev-parse --short HEAD", returnStdout: true) - } - stage("Info"){ - sh "echo ${imageTag}" + imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' @@ -41,17 +38,17 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed_python.py template.yml ${dockerRegistry}/get-service ${imageTag_Get}" + sh "python3 ${pathTocode}/sed_python.py template.yml ${dockerRegistry}/get-service ${imageTagGET}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } stage("Build docker image"){ container('docker'){ pathdocker = pwd() - sh "docker build ${pathdocker} -t ${imageN}${imageTag_Get}" + sh "docker build ${pathdocker} -t ${imageN}${imageTagGET}" sh "docker images" sh "cat /etc/docker/daemon.json" - sh "docker push ${imageN}${imageTag_Get}" + sh "docker push ${imageN}${imageTagGET}" } } } From e5a2be6b4f4a4a7c8b14730004fff1efec133e65 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 26 Jan 2019 14:42:32 -0500 Subject: [PATCH 071/241] Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 24195be..dbcb5c6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,14 +30,14 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) + def imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' } stage("Test code using PyLint and version build"){ container('python-alpine'){ - pathTocode = pwd() + def pathTocode = pwd() sh "python3 ${pathTocode}/sed_python.py template.yml ${dockerRegistry}/get-service ${imageTagGET}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } From f13b69d960c59403b162dcd9f195eb92004061fd Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 26 Jan 2019 14:45:56 -0500 Subject: [PATCH 072/241] Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index dbcb5c6..eb987b5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,7 +19,7 @@ def projName = "get-service" def imageVersion = "v2" def imageName = "100.71.71.71:5000/get-service:${imageVersion}" def imageN = '100.71.71.71:5000/get-service:' - +def pathTocode node(label) { @@ -37,7 +37,7 @@ node(label) } stage("Test code using PyLint and version build"){ container('python-alpine'){ - def pathTocode = pwd() + pathTocode = pwd() sh "python3 ${pathTocode}/sed_python.py template.yml ${dockerRegistry}/get-service ${imageTagGET}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } From 22548910fba767396ef6e3b9288a2335df8e2885 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 26 Jan 2019 14:49:07 -0500 Subject: [PATCH 073/241] Jenkinsfile --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index eb987b5..f55d7dc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,7 +19,6 @@ def projName = "get-service" def imageVersion = "v2" def imageName = "100.71.71.71:5000/get-service:${imageVersion}" def imageN = '100.71.71.71:5000/get-service:' -def pathTocode node(label) { @@ -30,7 +29,7 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - def imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) + imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' From 8c7f88f1eb122b9a960801c15369496a7b9c31f1 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 26 Jan 2019 15:09:25 -0500 Subject: [PATCH 074/241] Jenkinsfile --- sed_python_test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sed_python_test.py b/sed_python_test.py index e2381c6..fa49b35 100644 --- a/sed_python_test.py +++ b/sed_python_test.py @@ -2,13 +2,15 @@ import sys with open(sys.argv[1], 'r') as file: + arr_s = sys.argv[2].split(',') + print(arr_s) str_tmp = "ghostgoose" arr_f = ["100.71.71.71:5000/get-service", "100.71.71.71:5000/post-service", "100.71.71.71:5000/ui-service", "100.71.71.71:5000/db-service", "100.71.71.71:5000/init-container"] arr = ["100.71.71.71:5000/get-service:v2", "100.71.71.71:5000/post-service:2.1", "100.71.71.71:5000/ui-service:latest", "100.71.71.71:5000/db-service:latest", "100.71.71.71:5000/init-container:latest"] data = file.read() print(len(arr_f)) for i in range(len(arr_f)): - tmp = arr_f[i] + ":" + sys.argv[2] + tmp = arr_f[i] + ":" + arr_s[i] data = data.replace(arr[i], tmp) print(data) From 816b3102e2a75e2ebb96c2222fd82ec867e700ae Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 26 Jan 2019 15:20:50 -0500 Subject: [PATCH 075/241] Jenkinsfile --- sed_python_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sed_python_test.py b/sed_python_test.py index fa49b35..990576e 100644 --- a/sed_python_test.py +++ b/sed_python_test.py @@ -13,8 +13,9 @@ tmp = arr_f[i] + ":" + arr_s[i] data = data.replace(arr[i], tmp) - print(data) + with open(sys.argv[1], 'w') as file: file.write( data ) + print(data) From bda03eed8b75467829ad02bb5d6908adcc9e0c32 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 26 Jan 2019 16:13:46 -0500 Subject: [PATCH 076/241] Jenkinsfile --- E2E.yaml | 10 +++++----- sed_python_test.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/E2E.yaml b/E2E.yaml index 2545842..85c7889 100644 --- a/E2E.yaml +++ b/E2E.yaml @@ -105,7 +105,7 @@ spec: app: db-service spec: initContainers: - - image: 100.71.71.71:5000/init-container:latest + - image: 100.71.71.71:5000/init-container:5 name: init-container-postgres env: - name: PGDATABASE @@ -125,7 +125,7 @@ spec: key: password command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] containers: - - image: 100.71.71.71:5000/db-service:latest + - image: 100.71.71.71:5000/db-service:4 name: db-service ports: - containerPort: 5002 @@ -197,7 +197,7 @@ spec: spec: containers: - name: post - image: 100.71.71.71:5000/post-service:2.1 + image: 100.71.71.71:5000/post-service:2 ports: - containerPort: 5001 env: @@ -240,7 +240,7 @@ spec: spec: containers: - name: ui - image: 100.71.71.71:5000/ui-service:latest + image: 100.71.71.71:5000/ui-service:3 ports: - containerPort: 5000 env: @@ -288,7 +288,7 @@ spec: spec: containers: - name: get - image: 100.71.71.71:5000/get-service:v2 + image: 100.71.71.71:5000/get-service:1 ports: - containerPort: 5003 env: diff --git a/sed_python_test.py b/sed_python_test.py index 990576e..da5b56d 100644 --- a/sed_python_test.py +++ b/sed_python_test.py @@ -2,15 +2,15 @@ import sys with open(sys.argv[1], 'r') as file: - arr_s = sys.argv[2].split(',') - print(arr_s) + #arr_s = sys.argv[2].split(',') + #print(arr_s) str_tmp = "ghostgoose" arr_f = ["100.71.71.71:5000/get-service", "100.71.71.71:5000/post-service", "100.71.71.71:5000/ui-service", "100.71.71.71:5000/db-service", "100.71.71.71:5000/init-container"] arr = ["100.71.71.71:5000/get-service:v2", "100.71.71.71:5000/post-service:2.1", "100.71.71.71:5000/ui-service:latest", "100.71.71.71:5000/db-service:latest", "100.71.71.71:5000/init-container:latest"] data = file.read() print(len(arr_f)) for i in range(len(arr_f)): - tmp = arr_f[i] + ":" + arr_s[i] + tmp = arr_f[i] + ":" + sys.argv[i+2] data = data.replace(arr[i], tmp) From 65b2875960b3256e3f49005ee88b891c1ff65c70 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sat, 26 Jan 2019 18:04:57 -0500 Subject: [PATCH 077/241] Jenkinsfile --- E2E.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/E2E.yaml b/E2E.yaml index 85c7889..2545842 100644 --- a/E2E.yaml +++ b/E2E.yaml @@ -105,7 +105,7 @@ spec: app: db-service spec: initContainers: - - image: 100.71.71.71:5000/init-container:5 + - image: 100.71.71.71:5000/init-container:latest name: init-container-postgres env: - name: PGDATABASE @@ -125,7 +125,7 @@ spec: key: password command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] containers: - - image: 100.71.71.71:5000/db-service:4 + - image: 100.71.71.71:5000/db-service:latest name: db-service ports: - containerPort: 5002 @@ -197,7 +197,7 @@ spec: spec: containers: - name: post - image: 100.71.71.71:5000/post-service:2 + image: 100.71.71.71:5000/post-service:2.1 ports: - containerPort: 5001 env: @@ -240,7 +240,7 @@ spec: spec: containers: - name: ui - image: 100.71.71.71:5000/ui-service:3 + image: 100.71.71.71:5000/ui-service:latest ports: - containerPort: 5000 env: @@ -288,7 +288,7 @@ spec: spec: containers: - name: get - image: 100.71.71.71:5000/get-service:1 + image: 100.71.71.71:5000/get-service:v2 ports: - containerPort: 5003 env: From 544b14085594edad96f7536890500653d84e5055 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 27 Jan 2019 03:09:32 -0500 Subject: [PATCH 078/241] E2E.yaml --- E2E.yaml | 84 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/E2E.yaml b/E2E.yaml index 2545842..9087ce1 100644 --- a/E2E.yaml +++ b/E2E.yaml @@ -163,49 +163,49 @@ spec: port: 5002 targetPort: 5002 ---- -kind: Service -apiVersion: v1 -metadata: - namespace: testing - name: post-service - labels: - app: post -spec: - selector: - app: post - ports: - - protocol: TCP - port: 5001 - targetPort: 5001 +#--- +#kind: Service +#apiVersion: v1 +#metadata: +# namespace: testing +# name: post-service +# labels: +# app: post +#spec: +# selector: +# app: post +# ports: +# - protocol: TCP +# port: 5001 +# targetPort: 5001 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: testing - name: post-deployment -spec: - selector: - matchLabels: - app: post - replicas: 1 - template: - metadata: - labels: - app: post - spec: - containers: - - name: post - image: 100.71.71.71:5000/post-service:2.1 - ports: - - containerPort: 5001 - env: - - name: DB_URL - valueFrom: - configMapKeyRef: - name: services-address - key: DB_URL +#--- +#apiVersion: apps/v1 +#kind: Deployment +#metadata: +# namespace: testing +# name: post-deployment +#spec: +# selector: +# matchLabels: +# app: post +# replicas: 1 +# template: +# metadata: +# labels: +# app: post +# spec: +# containers: +# - name: post +# image: 100.71.71.71:5000/post-service:2.1 +# ports: +# - containerPort: 5001 +# env: +# - name: DB_URL +# valueFrom: +# configMapKeyRef: +# name: services-address +# key: DB_URL --- kind: Service apiVersion: v1 From abcc70ea33a351c29de9da7cc8d67242b2161dca Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 27 Jan 2019 03:33:54 -0500 Subject: [PATCH 079/241] E2E.yaml --- E2E.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/E2E.yaml b/E2E.yaml index 9087ce1..7c980ec 100644 --- a/E2E.yaml +++ b/E2E.yaml @@ -96,7 +96,7 @@ spec: apiVersion: extensions/v1beta1 kind: Deployment metadata: - namespace: production + namespace: testing name: db-service spec: template: @@ -153,7 +153,7 @@ spec: kind: Service apiVersion: v1 metadata: - namespace: production + namespace: testing name: db-service spec: selector: From 669f2c55f521f8d8a88024bf6f5e9163d9c6c1fd Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 27 Jan 2019 03:48:05 -0500 Subject: [PATCH 080/241] E2E.yaml --- E2E.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/E2E.yaml b/E2E.yaml index 7c980ec..e2a6d8f 100644 --- a/E2E.yaml +++ b/E2E.yaml @@ -244,11 +244,11 @@ spec: ports: - containerPort: 5000 env: - - name: POST_SERVICE_URL - valueFrom: - configMapKeyRef: - name: services-address - key: POST_SERVICE_URL +# - name: POST_SERVICE_URL +# valueFrom: +# configMapKeyRef: +# name: services-address +# key: POST_SERVICE_URL - name: VIEW_SERVICE_URL valueFrom: configMapKeyRef: From 045cb3835652f845bfa243c857b25e567a3cd3f2 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 27 Jan 2019 04:31:10 -0500 Subject: [PATCH 081/241] Last version on Sunday 27.01.2019 --- Jenkins_lst_new | 120 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 Jenkins_lst_new diff --git a/Jenkins_lst_new b/Jenkins_lst_new new file mode 100644 index 0000000..b313804 --- /dev/null +++ b/Jenkins_lst_new @@ -0,0 +1,120 @@ +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: 'ghostgoose33/docker-in:v1', 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 imageTag +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" +def projName = "get-service" +def imageVersion = "v2" +def imageName = "100.71.71.71:5000/get-service:${imageVersion}" +def imageN = '100.71.71.71:5000/get-service:' +def buildResult +def paramss = ["GitHub/SRM-GET/test", "GitHub/SRM-UI/test", "GitHub/SRM-DB/test"] +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) + pathTocodedb=pwd() + } + dir('ui'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-UI.git', credentialsId: "${Creds}") + imageTagUI = sh (script: "git rev-parse --short HEAD", returnStdout: true) + pathTocodeui=pwd() + } + dir('post'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-POST.git', credentialsId: "${Creds}") + imageTagPOST = sh (script: "git rev-parse --short HEAD", returnStdout: true) + pathTocodepost=pwd() + } + dir('ini'){ + git(branch: "master", url: 'https://github.com/Kv-045DevOps/Kubik-DB.git', credentialsId: "${Creds}") + imageTagINI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + pathTocodeini=pwd() + } + dir('get'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagGET = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + pathTocodeget = pwd() + } + + } + stage('testing') { + def jobs = [:] + for(i = 0; i < paramss.size(); i += 1) { + def param = paramss[i] + jobs["Jobs_build_${i}"] = { + build job: param, parameters: [string(name: 'Name', value: param)], waitForFinish: true + } + } + parallel jobs + } + stage("E2E-Test"){ + container('python-alpine'){ + sh "ls /home/jenkins/workspace/" + sh "python3 ${pathTocodeget}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/get-service ${imageTagGET}" + //sh "python3 ${pathTocodepost}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/post-service ${imageTagPOST}" + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/db-service ${imageTagDB}" + sh "python3 ${pathTocodeui}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/ui-service ${imageTagUI}" + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/init-container ${imageTagDB}" + } + + } + stage("Docker images"){ + container("docker"){ + sh "docker images" + } + } + stage("E2E Test - Stage 1"){ + container('kubectl'){ + sh "kubectl apply -f ${pathTocodeget}/E2E.yaml" + } + } + sleep 10 + stage ("E2E Tests - Stage 2"){ + container('python-alpine'){ + sh 'echo "Here is e2e test"' + sh "python3 ${pathTocodeget}/e2e-test-test.py" + } + } + stage("Deploy to Kubernetes"){ + container('python-alpine'){ + sh "python3 ${pathTocodeget}/sed_python.py ${pathTocodeget}/template.yml ${dockerRegistry}/get-service ${imageTagGET}" + //sh "python3 ${pathTocodepost}/sed_python.py ${pathTocodeget}/template.yaml ${dockerRegistry}/post-service ${imageTagPOST}" + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/db-service ${imageTagDB}" + sh "python3 ${pathTocodeui}/sed_python.py ${pathTocodeui}/template.yml ${dockerRegistry}/ui-service ${imageTagUI}" + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/init-container ${imageTagDB}" + } + container('kubectl'){ + sh "kubectl apply -f ${pathTocodeini}/template.yaml" + sh "kubectl apply -f ${pathTocodedb}/template.yaml" + sh "kubectl apply -f ${pathTocodeget}/template.yml" + sh "kubectl apply -f ${pathTocodeui}/template.yml" + //sh "kubectl apply -f ${pathTocodepost}/template.yml" + sh "kubectl get pods --namespace=production" + + } + } + stage ("Prod Tests - Stage 1"){ + container('python-alpine'){ + sh 'echo "Here is prod test"' + sh "python3 ${pathTocodeget}/e2e-test-prod.py" + } + } + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} +sleep 10 From 5c9632b5ffffa418039b330d8e9121d5a3bb98d0 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 27 Jan 2019 04:34:18 -0500 Subject: [PATCH 082/241] Modify E2E tests --- E2E.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/E2E.yaml b/E2E.yaml index e2a6d8f..53b1bd0 100644 --- a/E2E.yaml +++ b/E2E.yaml @@ -1,5 +1,25 @@ --- +apiVersion: v1 +kind: Namespace +metadata: + name: testing + +--- + +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: testing + name: services-address +data: + POST_SERVICE_URL: post-service.production.svc + VIEW_SERVICE_URL: get-service.production.svc + DB_URL: db-service.production.svc + URL_DB: db-service.production.svc + +--- + apiVersion: v1 kind: Secret metadata: From de0ad02b2d3d034a7f4b8b335a60f2d86a0d95d1 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 27 Jan 2019 04:38:17 -0500 Subject: [PATCH 083/241] Add copy modified myjob.yaml(Deploy environment) --- myjob_modified.yaml | 571 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 571 insertions(+) create mode 100644 myjob_modified.yaml diff --git a/myjob_modified.yaml b/myjob_modified.yaml new file mode 100644 index 0000000..610d53f --- /dev/null +++ b/myjob_modified.yaml @@ -0,0 +1,571 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: production + +--- + +apiVersion: v1 +kind: Namespace +metadata: + name: testing + +--- +apiVersion: v1 +kind: Secret +metadata: + name: db-secret + namespace: production +data: + username: ZGJhZG1pbg== + password: UGFzc3dvcmQ= + dbname: c3Jtc3lzdGVt +type: Opaque + +--- + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: jenkins + namespace: production + +--- + +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: jenkins + namespace: production +rules: +- apiGroups: [""] + resources: ["pods"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/exec"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/log"] + verbs: ["get","list","watch"] +- apiGroups: [""] + resources: ["services"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["extensions"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["persistentvolumeclaims"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["secrets"] + verbs: ["get"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: jenkins + namespace: production +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: jenkins +subjects: +- kind: ServiceAccount + name: jenkins +--- + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: jenkins + namespace: testing + +--- + +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: jenkins-test + namespace: testing +rules: +- apiGroups: [""] + resources: ["pods"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/exec"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/log"] + verbs: ["get","list","watch"] +- apiGroups: [""] + resources: ["services"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["extensions"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["persistentvolumeclaims"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["secrets"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["namespaces"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["configmaps"] + verbs: ["create","delete","get","list","patch","update","watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: jenkins-test + namespace: testing +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: jenkins-test +subjects: +- kind: ServiceAccount + name: jenkins + namespace: production +--- + + + +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: production + name: services-address +data: + POST_SERVICE_URL: post-service.production.svc + VIEW_SERVICE_URL: get-service.production.svc + DB_URL: db-service.production.svc + URL_DB: db-service.production.svc + +--- + +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: testing + name: services-address +data: + POST_SERVICE_URL: post-service.production.svc + VIEW_SERVICE_URL: get-service.production.svc + DB_URL: db-service.production.svc + URL_DB: db-service.production.svc + +--- + +apiVersion: v1 +data: + GitHub.xml: |- + + + + + GitHub + + + + + + + + + + git + + admgolovin + Slider256$ + + + github-1 + + admgolovin + $GITPWD + + + + + + + + + + + + + + + + false + + + + + + + true + 1 + 1 + + + + H/5 * * * * + 900000 + + + false + + + Kv-045DevOps + github-1 + + + Kubik-DB|SRM-GET|SRM-UI|SRM-DB + + + 1 + + + 1 + + + 1 + + + + + + + + Jenkinsfile + + + + + + + .* + true + + + + + +kind: ConfigMap +metadata: + creationTimestamp: "2019-01-18T03:22:02Z" + name: stark2 + namespace: production + resourceVersion: "96672" + selfLink: /api/v1/namespaces/default/configmaps/stark + uid: b70d8525-17fd-11e9-b845-02d08d5f4672 + +--- + +apiVersion: v1 +data: + config.xml: |- + + + + 2.150.2 + RUNNING + 2 + NORMAL + true + + false + + + true + false + + false + + ${JENKINS_HOME}/workspace/${ITEM_FULL_NAME} + ${ITEM_ROOTDIR}/builds + + + + + + kubernetes + + + https://kubernetes.default.svc + false + false + false + production + http://127.0.0.1:8080/ + kube-login + 10 + 5 + 0 + 0 + false + 32 + 600 + + + + 5 + 0 + + + + all + false + false + + + + all + 50000 + + + + + credentials.xml: |- + + + + + + + + + + GLOBAL + kube-login + + admin + $PASSWORD + + + GLOBAL + git_cred + + Maxghost33 + {AQAAABAAAAAg1cMYtdzX0b8pqPwU99XFsHEZtmsDLQy8n/RBMOnJnAj9ScoSD8i87dXfnx7TD0m+} + + + GLOBAL + docker_registry + + ghostgoose33 + {AQAAABAAAAAg8qaRTgg3fvfezKNrIlbz5LAhL3/WI0W5Nl4MLFgrPxYFSb8qACvkxcMFGvbtFQYx} + + + + + +kind: ConfigMap +metadata: + creationTimestamp: "2019-01-17T19:47:40Z" + name: jenconf + namespace: production + resourceVersion: "5227" + selfLink: /api/v1/namespaces/production/configmaps/jenconf + uid: bfec9ca6-1a90-11e9-a5b8-020fccbfb056 + +--- + +apiVersion: v1 +kind: Pod +metadata: + name: jenkins2 + namespace: production + labels: + service: jenkins2 +spec: + tolerations: + - key: "node" + operator: "Equal" + value: "boubde" + effect: "NoSchedule" + containers: + - name: stark-jenkins2 + image: admgolovin/myjenkins:v12 + volumeMounts: + - name: jenkins-config + mountPath: /var/jenkins_home/2/jobs/GitHub/ + - name: jenconf + mountPath: /var/jenkins_home/2 + lifecycle: + postStart: + exec: + command: ["/bin/sh","-c", "cp /var/jenkins_home/2/config.xml /var/jenkins_home/; cp /var/jenkins_home/2/credentials.xml /var/jenkins_home/; cp /var/jenkins_home/2/hudson.util.Secret /var/jenkins_home/secrets/; cp /var/jenkins_home/2/master.key /var/jenkins_home/secrets/; sleep 5m; java -jar /tools/jenkins-cli.jar -s http://127.0.0.1:8080 -auth admin:admin create-job GitHub < /var/jenkins_home/2/jobs/GitHub/GitHub.xml"] + serviceAccount: jenkins + serviceAccountName: jenkins + volumes: + - name: jenkins-config + configMap: + name: stark2 + - name: jenconf + configMap: + name: jenconf + restartPolicy: OnFailure + +# --- +# kind: Endpoints +# apiVersion: v1 +# metadata: +# name: my-service2 +# namespace: production +# subsets: +# - addresses: +# - ip: 10.0.0.1 +# targetRef: +# kind: Node +# name: node1 +# ports: +# - name: myjenkins +# port: 8080 +# protocol: TCP + +--- +kind: Service +apiVersion: v1 +metadata: + name: my-service + namespace: production +spec: + selector: + service: jenkins2 + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 + type: LoadBalancer + +--- + +kind: Service +apiVersion: v1 +metadata: + name: jenkins-agent + namespace: production +spec: + selector: + service: jenkins2 + ports: + - protocol: TCP + port: 50000 + targetPort: 50000 + type: LoadBalancer + +--- + +apiVersion: v1 +kind: Secret +metadata: + name: test-secret + namespace: production +data: + password: YWRtaW4= + +--- + +# apiVersion: v1 +# kind: Pod +# metadata: +# name: dind-jen +# namespace: production +# spec: +# containers: +# - name: jnlp +# image: '/myjenkins:jenslave' +# args: ['\$(JENKINS_SECRET)'] +# env: +# - name: DOCKER_HOST +# value: tcp://localhost:2375 +# - name: dind +# image: docker:stable-dind +# securityContext: +# privileged: true +# volumeMounts: +# - name: dind-storage +# mountPath: /var/lib/docker +# volumes: +# - name: dind-storage +# emptyDir: {} + +--- + +# apiVersion: v1 +# kind: Pod +# metadata: +# name: jenslave +# namespace: production +# labels: +# service: jenkins +# spec: +# containers: +# - name: jnlp +# image: /myjenkins:jenslave +# resources: +# limits: +# memory: "600Mi" +# requests: +# memory: "500Mi" + +# apiVersion: apps/v1 +# kind: Deployment +# metadata: +# name: jenkins-storage +# namespace: production +# spec: +# selector: +# matchLabels: +# service: jenkins +# template: +# metadata: +# labels: +# service: jenkins +# spec: +# containers: +# - name: stark-jenkins +# image: ghostgoose33/jenkins-alp:v2 +# volumeMounts: +# - name: jenkins-config +# mountPath: /var/lib/jenkins/job/GitHub +# volumes: +# - name: jenkins-config +# configMap: +# name: stark2 + +--- + +# apiVersion: v1 +# kind: Pod +# metadata: +# name: jenkins2 +# namespace: production +# labels: +# service: jenkins2 +# spec: +# containers: +# - name: stark-jenkins2 +# image: ghostgoose33/jenkins-alp:v2 + +# restartPolicy: OnFailure + +--- From d68dccb7a0afb8984b81085594bec522a788b641 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 27 Jan 2019 09:11:59 -0500 Subject: [PATCH 084/241] YML -> YAML --- template.yaml | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 template.yaml diff --git a/template.yaml b/template.yaml new file mode 100644 index 0000000..a276cf6 --- /dev/null +++ b/template.yaml @@ -0,0 +1,43 @@ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: production + name: get-deployment +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: 100.71.71.71:5000/get-service:v2 + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB From b546e6bd200ed55f994b2b8464a9422e4e354962 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 27 Jan 2019 09:28:11 -0500 Subject: [PATCH 085/241] Last version for Sunday 27.01.2019 --- Jenkins_lst_new => Jenkinsfile_lst_new | 43 ++++++++++++++++++-------- 1 file changed, 30 insertions(+), 13 deletions(-) rename Jenkins_lst_new => Jenkinsfile_lst_new (78%) diff --git a/Jenkins_lst_new b/Jenkinsfile_lst_new similarity index 78% rename from Jenkins_lst_new rename to Jenkinsfile_lst_new index b313804..b05edaa 100644 --- a/Jenkins_lst_new +++ b/Jenkinsfile_lst_new @@ -1,5 +1,15 @@ +@NonCPS +def mapToList(depmap) { + def dlist = [] + for (def entry2 in depmap) { + dlist.add(new java.util.AbstractMap.SimpleImmutableEntry(entry2.key, entry2.value)) + } + dlist +} + 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: 'ghostgoose33/docker-in:v1', command: 'cat', ttyEnabled: true), @@ -9,7 +19,7 @@ volumes: [ hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') ], serviceAccount: "jenkins") { -def imageTag + def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" def projName = "get-service" @@ -18,6 +28,7 @@ def imageName = "100.71.71.71:5000/get-service:${imageVersion}" def imageN = '100.71.71.71:5000/get-service:' def buildResult def paramss = ["GitHub/SRM-GET/test", "GitHub/SRM-UI/test", "GitHub/SRM-DB/test"] + node(label) { try{ @@ -49,7 +60,7 @@ node(label) } } - stage('testing') { + stage('Build and push Docker images') { def jobs = [:] for(i = 0; i < paramss.size(); i += 1) { def param = paramss[i] @@ -59,13 +70,15 @@ node(label) } parallel jobs } - stage("E2E-Test"){ + stage("E2E-Test-pre"){ container('python-alpine'){ sh "ls /home/jenkins/workspace/" - sh "python3 ${pathTocodeget}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/get-service ${imageTagGET}" - //sh "python3 ${pathTocodepost}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/post-service ${imageTagPOST}" - sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/db-service ${imageTagDB}" - sh "python3 ${pathTocodeui}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/ui-service ${imageTagUI}" + def map = [:] + map = [ + 'get':[tag: "${imageTagGET}", path: "${pathTocodeget}"], 'post':[tag: "${imageTagPOST}", path: "${pathTocodepost}"], + 'db':[tag: "${imageTagDB}", path: "${pathTocodedb}"], 'ui':[tag: "${imageTagUI}", path: "${pathTocodeui}"] + ] + map.each{ k, v -> sh "python3 ${v['path']}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/${k}-service ${v['tag']}" } sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/init-container ${imageTagDB}" } @@ -78,6 +91,7 @@ node(label) stage("E2E Test - Stage 1"){ container('kubectl'){ sh "kubectl apply -f ${pathTocodeget}/E2E.yaml" + sh "kubectl get pods --namespace=testing" } } sleep 10 @@ -89,17 +103,20 @@ node(label) } stage("Deploy to Kubernetes"){ container('python-alpine'){ - sh "python3 ${pathTocodeget}/sed_python.py ${pathTocodeget}/template.yml ${dockerRegistry}/get-service ${imageTagGET}" + sh "python3 ${pathTocodeget}/sed_python.py ${pathTocodeget}/template.yaml ${dockerRegistry}/get-service ${imageTagGET}" //sh "python3 ${pathTocodepost}/sed_python.py ${pathTocodeget}/template.yaml ${dockerRegistry}/post-service ${imageTagPOST}" sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/db-service ${imageTagDB}" - sh "python3 ${pathTocodeui}/sed_python.py ${pathTocodeui}/template.yml ${dockerRegistry}/ui-service ${imageTagUI}" + sh "python3 ${pathTocodeui}/sed_python.py ${pathTocodeui}/template.yaml ${dockerRegistry}/ui-service ${imageTagUI}" sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/init-container ${imageTagDB}" } container('kubectl'){ - sh "kubectl apply -f ${pathTocodeini}/template.yaml" - sh "kubectl apply -f ${pathTocodedb}/template.yaml" - sh "kubectl apply -f ${pathTocodeget}/template.yml" - sh "kubectl apply -f ${pathTocodeui}/template.yml" + def temp = [:] + temp = [ + 'ini':"${pathTocodeini}", 'db':"${pathTocodedb}", + 'get':"${pathTocodeget}", 'ui':"${pathTocodeui}" + //, 'post':"${pathTocodepost}" + ] + temp.each{ k, v -> sh "kubectl apply -f ${v}/template.yaml" } //sh "kubectl apply -f ${pathTocodepost}/template.yml" sh "kubectl get pods --namespace=production" From a6ef3c9b36e92ba2681220b4e18d0cd2345846be Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 27 Jan 2019 09:33:30 -0500 Subject: [PATCH 086/241] Delete temp files --- template.yml | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 template.yml diff --git a/template.yml b/template.yml deleted file mode 100644 index a276cf6..0000000 --- a/template.yml +++ /dev/null @@ -1,43 +0,0 @@ ---- -kind: Service -apiVersion: v1 -metadata: - namespace: production - name: get-service - labels: - app: get -spec: - selector: - app: get - ports: - - protocol: TCP - port: 5003 - targetPort: 5003 - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: production - name: get-deployment -spec: - selector: - matchLabels: - app: get - replicas: 1 - template: - metadata: - labels: - app: get - spec: - containers: - - name: get - image: 100.71.71.71:5000/get-service:v2 - ports: - - containerPort: 5003 - env: - - name: URL_DB - valueFrom: - configMapKeyRef: - name: services-address - key: URL_DB From 4fa1f76248ee882284aa1afece8e42e1df6af69d Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 30 Jan 2019 10:18:31 -0500 Subject: [PATCH 087/241] ENV --- Jenkinsfile | 2 +- app/unit_tests.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 app/unit_tests.py diff --git a/Jenkinsfile b/Jenkinsfile index f55d7dc..131a198 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,7 +29,7 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) + env.imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' diff --git a/app/unit_tests.py b/app/unit_tests.py new file mode 100644 index 0000000..9254d27 --- /dev/null +++ b/app/unit_tests.py @@ -0,0 +1,46 @@ +import unittest +from app import * +import json +import requests +import responses + +class parse_json_success(unittest.TestCase): + + def test_received_url(self): + self.assertEqual(self.s, parse_json(self.arg1, self.arg2, self.arg3)) + + @classmethod + def setUpClass(cls): + cls.arg1 = {'DEP': ['IT', 'Man']} + cls.arg2 = {'Manager': 'Goose1'} + cls.arg3 = {'Personal': 33} + cls.s = json.dumps({'DEP': ['IT', 'Man'], 'Manager': 'Goose1', 'Personal': 33}) + def setUp(self): + print("\nTest for func success 'parse_json()'") + def tearDown(self): + print ("Finish tests for success result func 'parse_json()'") + +class parse_json_failed(unittest.TestCase): + + def test_failed_res(self): + self.assertNotEqual(self.s, parse_json(self.arg1, self.arg2, self.arg3)) + def test_exception_res(self): + with self.assertRaises(Exception): + parse_json(self.arg4) + + @classmethod + def setUpClass(cls): + cls.arg1 = {'DEP': ['IT', 'Man']} + cls.arg2 = {'Manager': 'Goose1'} + cls.arg3 = {'Personal': 33} + cls.arg4 = [1, "String"] + cls.s = {'DEP': ['IT', 'Man'], 'Manager': 'Goose1', 'Personal': 33} + def setUp(self): + print("\nTest for func 'parse_json()'") + def tearDown(self): + print ("Finish tests for result func 'parse_json()'") + + + +if __name__ == '__main__': + unittest.main() From df0946bedb055b2d4c3eb9854eaf1e77c0cd2354 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 30 Jan 2019 10:44:54 -0500 Subject: [PATCH 088/241] ENV --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 131a198..8e50207 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,7 +37,7 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed_python.py template.yml ${dockerRegistry}/get-service ${imageTagGET}" + sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${imageTagGET}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } From 699e5b6679c0b2ac5d086fda8bf6d7d6a4f09257 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 30 Jan 2019 11:55:52 -0500 Subject: [PATCH 089/241] ENV --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8e50207..1d45772 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,7 +29,7 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - env.imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) + //env.imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' From c99927e26ffe40e00f220a70c2126c3a819215c9 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 30 Jan 2019 11:59:41 -0500 Subject: [PATCH 090/241] ENV --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1d45772..d9d8a4b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,7 +37,7 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${imageTagGET}" + sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${params.imageTagGET}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } From 577c4cbe1040a204601767b89e3173375613b0fb Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 30 Jan 2019 12:17:25 -0500 Subject: [PATCH 091/241] ENV --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d9d8a4b..66189bf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,7 +29,7 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - //env.imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) + imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' @@ -37,7 +37,7 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${params.imageTagGET}" + sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${imageTagGET}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } From abc7eeb801e575d1e89d3c99dc6a2651f24de51e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 30 Jan 2019 12:24:26 -0500 Subject: [PATCH 092/241] ENV --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 66189bf..65a889c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,7 +29,7 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) + env.imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' @@ -37,7 +37,7 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${imageTagGET}" + sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${env.imageTagGET}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } From 38c17c50ea31251a46d8daca29d86a726ac43faa Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 30 Jan 2019 12:34:37 -0500 Subject: [PATCH 093/241] ENV --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 65a889c..30adf9c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,7 @@ volumes: [ { def app -def imageTag +def imageTagGET def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" def projName = "get-service" @@ -29,7 +29,7 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - env.imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) + imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' @@ -37,7 +37,7 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${env.imageTagGET}" + sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${imageTagGET}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } From 767074d3abab9236dcd59210ef1366ac9dc9c87f Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 30 Jan 2019 15:55:16 -0500 Subject: [PATCH 094/241] Test --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 30adf9c..ff1623f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,17 +37,17 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${imageTagGET}" + sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${imageTag}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } stage("Build docker image"){ container('docker'){ pathdocker = pwd() - sh "docker build ${pathdocker} -t ${imageN}${imageTagGET}" + sh "docker build ${pathdocker} -t ${imageN}${imageTag}" sh "docker images" sh "cat /etc/docker/daemon.json" - sh "docker push ${imageN}${imageTagGET}" + sh "docker push ${imageN}${imageTag}" } } } From 63923230a1eab3fcaa0209083ea368c6d5817248 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 30 Jan 2019 16:11:31 -0500 Subject: [PATCH 095/241] Test --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ff1623f..831c2eb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -37,17 +37,17 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${imageTag}" + sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${params.imageTag}" sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } stage("Build docker image"){ container('docker'){ pathdocker = pwd() - sh "docker build ${pathdocker} -t ${imageN}${imageTag}" + sh "docker build ${pathdocker} -t ${imageN}${params.imageTag}" sh "docker images" sh "cat /etc/docker/daemon.json" - sh "docker push ${imageN}${imageTag}" + sh "docker push ${imageN}${params.imageTag}" } } } From 2a31b04c63d7955a47e765894fc56cffba8c23f0 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 02:38:58 -0500 Subject: [PATCH 096/241] Test --- Jenkinsfile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 831c2eb..b918c3f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,10 +29,16 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) + //imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) + environment{ + IMAGE_TAG = sh(returnStdout: true, script: "git tag --sort version:refname | tail -1") + } + def imageTagG = env.IMAGE_TAG + } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' + sh 'echo ${imageTagG}' } stage("Test code using PyLint and version build"){ container('python-alpine'){ From 52d8828d65ceaa22d5a510aaf2a078ee08bd0b73 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 03:28:04 -0500 Subject: [PATCH 097/241] Test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b918c3f..b064257 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -33,7 +33,7 @@ node(label) environment{ IMAGE_TAG = sh(returnStdout: true, script: "git tag --sort version:refname | tail -1") } - def imageTagG = env.IMAGE_TAG + def imageTagG = IMAGE_TAG } stage ("Unit Tests"){ From e8ffff99781d6f371ee3084698373b2e85e3f0c6 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 03:37:26 -0500 Subject: [PATCH 098/241] Test --- Jenkinsfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b064257..02334c4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,12 +30,13 @@ node(label) credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" //imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) - environment{ - IMAGE_TAG = sh(returnStdout: true, script: "git tag --sort version:refname | tail -1") - } - def imageTagG = IMAGE_TAG + def imageTagG = sh(returnStdout: true, script: "git tag --sort version:refname | tail -1") + def IMAGE_TAG } + environment{ + IMAGE_TAG = imageTagG + } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' sh 'echo ${imageTagG}' From d822ee6487a4e13928f4c39b1f96f6fbf04a1756 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 03:41:40 -0500 Subject: [PATCH 099/241] Test --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 02334c4..5d5129e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,6 +39,7 @@ node(label) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' + sh 'echo ${env.IMAGE_TAG}' sh 'echo ${imageTagG}' } stage("Test code using PyLint and version build"){ From cd2f102b9f8f60bc0729f552b99b2f8ede6e4cca Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 03:45:28 -0500 Subject: [PATCH 100/241] Test --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5d5129e..8c7c7bf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,8 +39,8 @@ node(label) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' - sh 'echo ${env.IMAGE_TAG}' - sh 'echo ${imageTagG}' + sh 'echo "${env.IMAGE_TAG}"' + sh 'echo "${imageTagG}"' } stage("Test code using PyLint and version build"){ container('python-alpine'){ From c0758ef18ad3c8d6d6c3eda13e01357ff142f09b Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 03:48:27 -0500 Subject: [PATCH 101/241] Test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8c7c7bf..15c0ad9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -39,7 +39,7 @@ node(label) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' - sh 'echo "${env.IMAGE_TAG}"' + sh 'echo "${IMAGE_TAG}"' sh 'echo "${imageTagG}"' } stage("Test code using PyLint and version build"){ From 3ef27ec464847a4faec810ad5c094d94581f80d9 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 04:11:10 -0500 Subject: [PATCH 102/241] Test --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 15c0ad9..03f39ac 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,10 +32,11 @@ node(label) //imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) def imageTagG = sh(returnStdout: true, script: "git tag --sort version:refname | tail -1") def IMAGE_TAG + env.IMAGE_TAG = "QWERTY" } environment{ - IMAGE_TAG = imageTagG + IMAGE_TAG = "QWERTY" } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' From 88aed2d9468e106f195e31b2e4c5a9ddcef3626c Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 04:24:44 -0500 Subject: [PATCH 103/241] Test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 03f39ac..5b39e8f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,7 +40,7 @@ node(label) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' - sh 'echo "${IMAGE_TAG}"' + sh 'echo "${env.IMAGE_TAG}"' sh 'echo "${imageTagG}"' } stage("Test code using PyLint and version build"){ From 7512af8ce8373b604de6726f307b90de1b925ea9 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 04:32:44 -0500 Subject: [PATCH 104/241] Test --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5b39e8f..06de2d5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,7 +32,9 @@ node(label) //imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) def imageTagG = sh(returnStdout: true, script: "git tag --sort version:refname | tail -1") def IMAGE_TAG + script{ env.IMAGE_TAG = "QWERTY" + } } environment{ @@ -40,7 +42,7 @@ node(label) } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' - sh 'echo "${env.IMAGE_TAG}"' + sh 'echo "${IMAGE_TAG}"' sh 'echo "${imageTagG}"' } stage("Test code using PyLint and version build"){ From 6541f6c6d46ff92a6ec13167d000aa421baebf3e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 07:19:59 -0500 Subject: [PATCH 105/241] Test --- E2E.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/E2E.yaml b/E2E.yaml index 53b1bd0..e9a3eba 100644 --- a/E2E.yaml +++ b/E2E.yaml @@ -13,10 +13,10 @@ metadata: namespace: testing name: services-address data: - POST_SERVICE_URL: post-service.production.svc - VIEW_SERVICE_URL: get-service.production.svc - DB_URL: db-service.production.svc - URL_DB: db-service.production.svc + POST_SERVICE_URL: post-service.testing.svc + VIEW_SERVICE_URL: get-service.testing.svc + DB_URL: db-service.testing.svc + URL_DB: db-service.testing.svc --- From 30e81d2c75f3672fd6dbed0076813655f5f8816d Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 09:09:14 -0500 Subject: [PATCH 106/241] Test --- Jenkinsfile_v3.0_minor | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Jenkinsfile_v3.0_minor diff --git a/Jenkinsfile_v3.0_minor b/Jenkinsfile_v3.0_minor new file mode 100644 index 0000000..89f0f4a --- /dev/null +++ b/Jenkinsfile_v3.0_minor @@ -0,0 +1,37 @@ +def buildResult +def paramss = ["GitHub/SRM-GET/test", "GitHub/SRM-UI/test", "GitHub/SRM-DB/test"] +properties([ + parameters([ + stringParam( + defaultValue: 'v3.0', + description: '', + name: 'imageTag'), + stringParam( + defaultValue: '***', + description: '', + name: 'namespace') + ]) +]) + + stage('Build and push Docker images') { + def jobs = [:] + for(i = 0; i < paramss.size(); i += 1) { + def param = paramss[i] + jobs["Jobs_build_${i}"] = { + build job: param, parameters: [[$class: 'StringParameterValue', name: "imageTag", + value: "${params.imageTag}"]], wait: true + } + } + parallel jobs + } + stage("Test"){ + + build (job: "test_e2e", parameters: [[$class: 'StringParameterValue', name: "imageTag", + value: "${params.imageTag}"]], wait: true) + } + + stage("Deploy"){ + + build (job: "test_deploy", parameters: [[$class: 'StringParameterValue', name: "imageTag", + value: "${params.imageTag}"]], wait: true) + } From d72723910f9c998407fc5fbd7ba38a13ed5cb573 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 31 Jan 2019 13:36:30 -0500 Subject: [PATCH 107/241] GitTag concepts --- Jenkinsfile | 24 ++++++++++++--- Jenkinsfile_deploy | 65 +++++++++++++++++++++++++++++++++++++++ Jenkinsfile_e2e_test | 70 ++++++++++++++++++++++++++++++++++++++++++ Jenkinsfile_v3.0_minor | 11 ------- 4 files changed, 154 insertions(+), 16 deletions(-) create mode 100644 Jenkinsfile_deploy create mode 100644 Jenkinsfile_e2e_test diff --git a/Jenkinsfile b/Jenkinsfile index 06de2d5..d2a6239 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,13 +3,25 @@ def label_f = "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: 'ghostgoose33/docker-in:v1', command: 'cat', ttyEnabled: true), - containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', 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") +properties([ + parameters([ + stringParam( + defaultValue: 'v3.0', + description: '', + name: 'imageTag'), + stringParam( + defaultValue: '***', + description: '', + name: 'namespace') + ]) +]) + { def app def imageTagGET @@ -61,12 +73,14 @@ node(label) sh "docker push ${imageN}${params.imageTag}" } } + stage("Test"){ + + build (job: "test_e2e", parameters: [[$class: 'StringParameterValue', name: "imageTag", + value: "${params.imageTag}"]], wait: true) + } } catch(err){ currentBuild.result = 'Failure' } } } - - -sleep 30 diff --git a/Jenkinsfile_deploy b/Jenkinsfile_deploy new file mode 100644 index 0000000..be0fdb5 --- /dev/null +++ b/Jenkinsfile_deploy @@ -0,0 +1,65 @@ +def label = "mypod-${UUID.randomUUID().toString()}" +properties([ + parameters([ + stringParam( + defaultValue: 'v3.0', + description: '', + name: 'imageTag'), + stringParam( + defaultValue: '***', + description: '', + name: 'namespace') + ]) +]) + +podTemplate(label: label, containers: [ + containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', 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 dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + +node(label) +{ + try{ + + stage("Deploy to Kubernetes"){ + container('python-alpine'){ + + sh "python3 ${pathTocodeget}/sed_python.py ${pathTocodeget}/template.yaml ${dockerRegistry}/get-service ${params.imageTag}" + //sh "python3 ${pathTocodepost}/sed_python.py ${pathTocodeget}/template.yaml ${dockerRegistry}/post-service ${imageTagPOST}" + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/db-service ${params.imageTag}" + sh "python3 ${pathTocodeui}/sed_python.py ${pathTocodeui}/template.yaml ${dockerRegistry}/ui-service ${params.imageTag}" + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/init-container ${params.imageTag}" + } + container('kubectl'){ + def temp = [:] + temp = [ + 'ini':"${pathTocodeini}", 'db':"${pathTocodedb}", + 'get':"${pathTocodeget}", 'ui':"${pathTocodeui}" + //, 'post':"${pathTocodepost}" + ] + temp.each{ k, v -> sh "kubectl apply -f ${v}/template.yaml" } + //sh "kubectl apply -f ${pathTocodepost}/template.yml" + sh "kubectl get pods --namespace=production" + + } + } + stage ("Prod Tests"){ + container('python-alpine'){ + sh 'echo "Here is prod test"' + sh "python3 ${pathTocodeget}/e2e-test-prod.py" + } + } + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} diff --git a/Jenkinsfile_e2e_test b/Jenkinsfile_e2e_test new file mode 100644 index 0000000..5e629be --- /dev/null +++ b/Jenkinsfile_e2e_test @@ -0,0 +1,70 @@ +def label = "mypod-${UUID.randomUUID().toString()}" +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" +podTemplate(label: label, containers: [ + containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', command: 'cat', ttyEnabled: true), + containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', 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") +{ + +properties([ + parameters([ + stringParam( + defaultValue: 'v3.0', + description: '', + name: 'imageTag'), + stringParam( + defaultValue: '***', + description: '', + name: 'namespace') + ]) +]) + +node(label) +{ + try{ + + stage("E2E-Test-pre"){ + container('python-alpine'){ + sh "ls /home/jenkins/workspace/" + def map = [:] + map = [ + 'get':[tag: "${params.imageTag}", path: "${pathTocodeget}"], 'post':[tag: "${params.imageTag}", path: "${pathTocodepost}"], + 'db':[tag: "${params.imageTag}", path: "${pathTocodedb}"], 'ui':[tag: "${params.imageTag}", path: "${pathTocodeui}"] + ] + map.each{ k, v -> sh "python3 ${v['path']}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/${k}-service ${v['tag']}" } + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/init-container ${params.imageTag}" + } + + } + stage("E2E Test - Stage 1"){ + container('kubectl'){ + sh "kubectl apply -f ${pathTocodeget}/E2E.yaml" + sh "kubectl get pods --namespace=testing" + } + } + sleep 20 + stage ("E2E Tests - Stage 2"){ + container('python-alpine'){ + sh 'echo "Here is e2e test"' + sh "python3 ${pathTocodeget}/e2e-test-test.py" + } + } + stage("Deploy"){ + + build (job: "test_deploy", parameters: [[$class: 'StringParameterValue', name: "imageTag", + value: "${params.imageTag}"]], wait: true) + } + + + + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} diff --git a/Jenkinsfile_v3.0_minor b/Jenkinsfile_v3.0_minor index 89f0f4a..4acdb17 100644 --- a/Jenkinsfile_v3.0_minor +++ b/Jenkinsfile_v3.0_minor @@ -24,14 +24,3 @@ properties([ } parallel jobs } - stage("Test"){ - - build (job: "test_e2e", parameters: [[$class: 'StringParameterValue', name: "imageTag", - value: "${params.imageTag}"]], wait: true) - } - - stage("Deploy"){ - - build (job: "test_deploy", parameters: [[$class: 'StringParameterValue', name: "imageTag", - value: "${params.imageTag}"]], wait: true) - } From 44d1782f9452cdac695e84310e83fa6da7c35d26 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 1 Feb 2019 07:15:36 -0500 Subject: [PATCH 108/241] Check registry tag --- images-registry-test.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/images-registry-test.py b/images-registry-test.py index a1a3ea9..5ca84ad 100644 --- a/images-registry-test.py +++ b/images-registry-test.py @@ -8,14 +8,15 @@ def main(): def check_image(): - tmp = requests.get("http://" + sys.argv[1] + "/v2/" + sys.argv[3] + "/tags/list") - req = tmp.json() - print(req) - if req["name"] == sys.argv[2] and sys.argv[3] in req["tags"]: - return 0 - else: - raise Exception("Image with tag " + sys.argv[3] + " does not exist in Docker Registry with IP: " + sys.argv[1]) - return 1 + tmp = requests.get("http://100.71.71.71:5000/v2/" + sys.argv[1] + "/tags/list") + req = tmp.json() + print(req) + if req["name"] == sys.argv[1] and sys.argv[2] in req["tags"]: + print("First test good!!!") + return 0 + else: + raise Exception("Image with tag " + sys.argv[1] + " does not exist in Docker Registry with IP: " + sys.argv[1]) + return 1 if __name__=='__main__': From 560456dfd44dc404dc199f9dda49a23e0e7013e8 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 1 Feb 2019 09:15:52 -0500 Subject: [PATCH 109/241] Check registry tag --- images-registry-test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/images-registry-test.py b/images-registry-test.py index 5ca84ad..8fa2f22 100644 --- a/images-registry-test.py +++ b/images-registry-test.py @@ -12,10 +12,9 @@ def check_image(): req = tmp.json() print(req) if req["name"] == sys.argv[1] and sys.argv[2] in req["tags"]: - print("First test good!!!") return 0 else: - raise Exception("Image with tag " + sys.argv[1] + " does not exist in Docker Registry with IP: " + sys.argv[1]) + #raise Exception("Image with tag " + sys.argv[1] + " does not exist in Docker Registry with IP: " + sys.argv[1]) return 1 From 89c83e05c85ac7a6155337f37a0c260f7c29ca85 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 1 Feb 2019 11:19:04 -0500 Subject: [PATCH 110/241] Test check tag --- images-registry-test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/images-registry-test.py b/images-registry-test.py index 8fa2f22..d3f125d 100644 --- a/images-registry-test.py +++ b/images-registry-test.py @@ -10,11 +10,13 @@ def main(): def check_image(): tmp = requests.get("http://100.71.71.71:5000/v2/" + sys.argv[1] + "/tags/list") req = tmp.json() - print(req) + #print(req) 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 From 7433416ad8658208c431a0c8b9a128a329e7982a Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 05:25:39 -0500 Subject: [PATCH 111/241] Test Jenkins --- Jenkinsfile | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d2a6239..dad11cd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,9 +12,9 @@ volumes: [ properties([ parameters([ stringParam( - defaultValue: 'v3.0', + defaultValue: "${params.imageTagGET}", description: '', - name: 'imageTag'), + name: 'imageTagGET'), stringParam( defaultValue: '***', description: '', @@ -41,41 +41,45 @@ node(label) url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") //sh "git rev-parse --short HEAD > .git/commit-id" - //imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) - def imageTagG = sh(returnStdout: true, script: "git tag --sort version:refname | tail -1") - def IMAGE_TAG - script{ - env.IMAGE_TAG = "QWERTY" - } + imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) + //def imageTagG = sh(returnStdout: true, script: "git tag --sort version:refname | tail -1") } - environment{ - IMAGE_TAG = "QWERTY" + stage("Test image_regisrty_check"){ + container("python-alpine"){ + check_new = (sh (script: "python3 ${pathTocodeget}/images-registry-test.py get-service ${imageTagGET}", returnStdout:true).trim()) + echo "${check_new}" + echo "${params.imageTagGET}" + echo "${imageTagGET}" + } + } + if ("${tmp}" == "${check_new}"){ + echo "YES" + } else { + echo "NO" } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' - sh 'echo "${IMAGE_TAG}"' - sh 'echo "${imageTagG}"' } stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${params.imageTag}" - sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" + //sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${params.imageTag}" + //sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" } } stage("Build docker image"){ container('docker'){ pathdocker = pwd() - sh "docker build ${pathdocker} -t ${imageN}${params.imageTag}" - sh "docker images" - sh "cat /etc/docker/daemon.json" - sh "docker push ${imageN}${params.imageTag}" + //sh "docker build ${pathdocker} -t ${imageN}${params.imageTag}" + //sh "docker images" + //sh "cat /etc/docker/daemon.json" + //sh "docker push ${imageN}${params.imageTag}" } } stage("Test"){ - build (job: "test_e2e", parameters: [[$class: 'StringParameterValue', name: "imageTag", + //build (job: "test_e2e", parameters: [[$class: 'StringParameterValue', name: "imageTag", value: "${params.imageTag}"]], wait: true) } } From 6bb0dd99458b7d73d4cd1dec03c2d2f4dfbb8706 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 05:26:58 -0500 Subject: [PATCH 112/241] Test Jenkins --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index dad11cd..fd0ca6e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -80,7 +80,7 @@ node(label) stage("Test"){ //build (job: "test_e2e", parameters: [[$class: 'StringParameterValue', name: "imageTag", - value: "${params.imageTag}"]], wait: true) + //value: "${params.imageTag}"]], wait: true) } } catch(err){ From 62f84be74fd0cff554f65ceda5b511e9bb26fd51 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 05:36:30 -0500 Subject: [PATCH 113/241] Test Jenkins --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fd0ca6e..b9121d0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,4 @@ def label = "mypod-${UUID.randomUUID().toString()}" -def label_f = "mypod-${UUID.randomUUID().toString()}" podTemplate(label: label, containers: [ containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', command: 'cat', ttyEnabled: true), @@ -40,7 +39,6 @@ node(label) branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") - //sh "git rev-parse --short HEAD > .git/commit-id" imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) //def imageTagG = sh(returnStdout: true, script: "git tag --sort version:refname | tail -1") @@ -78,7 +76,7 @@ node(label) } } stage("Test"){ - + sh "echo AAA" //build (job: "test_e2e", parameters: [[$class: 'StringParameterValue', name: "imageTag", //value: "${params.imageTag}"]], wait: true) } From d11f18c4e179762a17d1e50090855ee6072b101f Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 05:38:16 -0500 Subject: [PATCH 114/241] Test Jenkins --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b9121d0..53ec661 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ volumes: [ properties([ parameters([ stringParam( - defaultValue: "${params.imageTagGET}", + defaultValue: "***", description: '', name: 'imageTagGET'), stringParam( From cf7b8ac4e171af13e3be30831f64e1d862f8155a Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 05:40:58 -0500 Subject: [PATCH 115/241] Test Jenkins --- Jenkinsfile | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 53ec661..2714065 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,18 +8,7 @@ volumes: [ hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') ], serviceAccount: "jenkins") -properties([ - parameters([ - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagGET'), - stringParam( - defaultValue: '***', - description: '', - name: 'namespace') - ]) -]) + { def app From 0bfc147663a8729dcbe508deb4d901238bdd3106 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 05:44:08 -0500 Subject: [PATCH 116/241] Test Jenkins --- Jenkinsfile | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2714065..42096fb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,18 +1,16 @@ 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: 'ghostgoose33/docker-in:v1', command: 'cat', ttyEnabled: true) + containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', 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") - - - +], serviceAccount: "jenkins") { -def app -def imageTagGET + def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" def projName = "get-service" @@ -23,21 +21,19 @@ def imageN = '100.71.71.71:5000/get-service:' node(label) { try{ - stage("Git Checkout"){ - git( - branch: "test", - url: 'https://github.com/Kv-045DevOps/SRM-GET.git', - credentialsId: "${Creds}") - imageTagGET = sh (script: "git rev-parse --short HEAD", returnStdout: true) - //def imageTagG = sh(returnStdout: true, script: "git tag --sort version:refname | tail -1") - + stage("Pre-Test"){ + dir('get'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagGET = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + tmp = "1" + //imageTagGET = sh(returnStdout: true, script: "git tag -l --points-at HEAD").trim() + pathTocodeget = pwd() + } } - stage("Test image_regisrty_check"){ + stage("Test image_regisrty_check"){ container("python-alpine"){ check_new = (sh (script: "python3 ${pathTocodeget}/images-registry-test.py get-service ${imageTagGET}", returnStdout:true).trim()) echo "${check_new}" - echo "${params.imageTagGET}" - echo "${imageTagGET}" } } if ("${tmp}" == "${check_new}"){ @@ -60,15 +56,10 @@ node(label) pathdocker = pwd() //sh "docker build ${pathdocker} -t ${imageN}${params.imageTag}" //sh "docker images" - //sh "cat /etc/docker/daemon.json" + //sh "cat /etc/docker/daemon.json" //sh "docker push ${imageN}${params.imageTag}" } } - stage("Test"){ - sh "echo AAA" - //build (job: "test_e2e", parameters: [[$class: 'StringParameterValue', name: "imageTag", - //value: "${params.imageTag}"]], wait: true) - } } catch(err){ currentBuild.result = 'Failure' From f69d0ca10e87d0c2e5a7298b8c8ce466de825e48 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 05:53:27 -0500 Subject: [PATCH 117/241] Test Jenkins --- images-registry-test.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/images-registry-test.py b/images-registry-test.py index d3f125d..00f0536 100644 --- a/images-registry-test.py +++ b/images-registry-test.py @@ -11,13 +11,17 @@ def check_image(): tmp = requests.get("http://100.71.71.71:5000/v2/" + sys.argv[1] + "/tags/list") req = tmp.json() #print(req) - 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]) + if (req.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__': From bc9c0153e8cef0164bf98aff235bd9d0e6c3c4ef Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 05:55:39 -0500 Subject: [PATCH 118/241] Test Jenkins --- images-registry-test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images-registry-test.py b/images-registry-test.py index 00f0536..ec3737e 100644 --- a/images-registry-test.py +++ b/images-registry-test.py @@ -11,7 +11,7 @@ def check_image(): tmp = requests.get("http://100.71.71.71:5000/v2/" + sys.argv[1] + "/tags/list") req = tmp.json() #print(req) - if (req.status_code == "404"): + if (tmp.status_code == 404): print("1") return 1 else: From 859bbebd3d884e636de598f7b75501a28bf1e496 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 06:01:36 -0500 Subject: [PATCH 119/241] Test Jenkins --- Jenkinsfile | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 42096fb..4f85c06 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,6 +18,20 @@ def imageVersion = "v2" def imageName = "100.71.71.71:5000/get-service:${imageVersion}" def imageN = '100.71.71.71:5000/get-service:' +properties([ + parameters([ + stringParam( + defaultValue: "${params.imageTagGET}", + description: '', + name: 'imageTag'), + stringParam( + defaultValue: '***', + description: '', + name: 'namespace') + ]) +]) + + node(label) { try{ @@ -41,6 +55,12 @@ node(label) } else { echo "NO" } + if ("${params.imageTagGET}" == "${imageTagGET}"){ + echo "${params.imageTagGET}" + } else { + echo "${params.imageTagGET}" + echo "${imageTagGET}" + } stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' } From e707e7568903779263a047569761c404b53104e1 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 06:20:27 -0500 Subject: [PATCH 120/241] Test Jenkins --- Jenkinsfile | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4f85c06..9e7484d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,9 +21,9 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: "${params.imageTagGET}", + defaultValue: "***", description: '', - name: 'imageTag'), + name: 'imageTagGET'), stringParam( defaultValue: '***', description: '', @@ -50,17 +50,7 @@ node(label) echo "${check_new}" } } - if ("${tmp}" == "${check_new}"){ - echo "YES" - } else { - echo "NO" - } - if ("${params.imageTagGET}" == "${imageTagGET}"){ - echo "${params.imageTagGET}" - } else { - echo "${params.imageTagGET}" - echo "${imageTagGET}" - } + stage ("Unit Tests"){ sh 'echo "Here will be unit tests"' } @@ -74,10 +64,15 @@ node(label) stage("Build docker image"){ container('docker'){ pathdocker = pwd() - //sh "docker build ${pathdocker} -t ${imageN}${params.imageTag}" - //sh "docker images" - //sh "cat /etc/docker/daemon.json" - //sh "docker push ${imageN}${params.imageTag}" + if ("${tmp}" == "${check_new}"){ + sh "docker build ${pathdocker} -t ${imageN}${imageTagGET}" + sh "docker images" + sh "cat /etc/docker/daemon.json" + sh "docker push ${imageN}${imageTagGET}" + } else { + echo "NO" + } + } } } From 09996de0628051702744852db6c48abaff5eb941 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 06:24:13 -0500 Subject: [PATCH 121/241] Test Jenkins --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9e7484d..1f4c2ad 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -65,7 +65,7 @@ node(label) container('docker'){ pathdocker = pwd() if ("${tmp}" == "${check_new}"){ - sh "docker build ${pathdocker} -t ${imageN}${imageTagGET}" + sh "docker build ${pathTocodeget} -t ${imageN}${imageTagGET}" sh "docker images" sh "cat /etc/docker/daemon.json" sh "docker push ${imageN}${imageTagGET}" From 11945fd2909adabc485546736243defd20e093bf Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 07:30:21 -0500 Subject: [PATCH 122/241] Test Jenkins --- Jenkinsfile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1f4c2ad..2f0da9f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,6 +24,14 @@ properties([ defaultValue: "***", description: '', name: 'imageTagGET'), + stringParam( + defaultValue: "***", + description: '', + name: 'imageTagUI'), + stringParam( + defaultValue: "***", + description: '', + name: 'imageTagDB'), stringParam( defaultValue: '***', description: '', @@ -57,8 +65,8 @@ node(label) stage("Test code using PyLint and version build"){ container('python-alpine'){ pathTocode = pwd() - //sh "python3 ${pathTocode}/sed_python.py template.yaml ${dockerRegistry}/get-service ${params.imageTag}" - //sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" + //sh "python3 ${pathTocodeget}/sed_python.py template.yaml ${dockerRegistry}/get-service ${imageTag}" + sh "python3 ${pathTocodeget}/pylint-test.py ${pathTocode}/app/app.py" } } stage("Build docker image"){ @@ -69,6 +77,7 @@ node(label) sh "docker images" sh "cat /etc/docker/daemon.json" sh "docker push ${imageN}${imageTagGET}" + build(job: 'test_e2e', parameters: [[$class: 'StringParameterValue', name:"imageTagGET", value: "${imageTagGET}"]], wait: true) } else { echo "NO" } From 05cb4ee5d67fd903824eb04569117e460bbd486f Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 07:32:33 -0500 Subject: [PATCH 123/241] Test Jenkins#2 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2f0da9f..6610d74 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,7 +66,7 @@ node(label) container('python-alpine'){ pathTocode = pwd() //sh "python3 ${pathTocodeget}/sed_python.py template.yaml ${dockerRegistry}/get-service ${imageTag}" - sh "python3 ${pathTocodeget}/pylint-test.py ${pathTocode}/app/app.py" + sh "python3 ${pathTocodeget}/pylint-test.py ${pathTocodeget}/app/app.py" } } stage("Build docker image"){ From 42ff4d8d3e9e16d94004c288f0f3dcc87b0468b3 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 09:39:15 -0500 Subject: [PATCH 124/241] Test e2e again --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6610d74..f407bd2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,7 +22,7 @@ properties([ parameters([ stringParam( defaultValue: "***", - description: '', + description: 'Current', name: 'imageTagGET'), stringParam( defaultValue: "***", From 3257ad11a9bce320b296a61d64d6706f468f0bf7 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 11:03:42 -0500 Subject: [PATCH 125/241] Stage 3 --- Jenkinsfile_deploy | 103 ++++++++++++++++++++++++++++++++----------- Jenkinsfile_e2e_test | 92 +++++++++++++++++++++++++++++--------- Jenkinsfile_main | 38 ++++++++++++++++ 3 files changed, 187 insertions(+), 46 deletions(-) create mode 100644 Jenkinsfile_main diff --git a/Jenkinsfile_deploy b/Jenkinsfile_deploy index be0fdb5..abf2bf2 100644 --- a/Jenkinsfile_deploy +++ b/Jenkinsfile_deploy @@ -1,10 +1,22 @@ + def label = "mypod-${UUID.randomUUID().toString()}" +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + properties([ parameters([ stringParam( - defaultValue: 'v3.0', + defaultValue: "***", + description: '', + name: 'imageTagGET'), + stringParam( + defaultValue: "***", description: '', - name: 'imageTag'), + name: 'imageTagUI'), + stringParam( + defaultValue: "***", + description: '', + name: 'imageTagDB'), stringParam( defaultValue: '***', description: '', @@ -22,41 +34,82 @@ volumes: [ { -def dockerRegistry = "100.71.71.71:5000" -def Creds = "git_cred" - 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) + pathTocodedb=pwd() + } + dir('ui'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-UI.git', credentialsId: "${Creds}") + imageTagUI = sh (script: "git rev-parse --short HEAD", returnStdout: true) + pathTocodeui=pwd() + } + dir('post'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-POST.git', credentialsId: "${Creds}") + imageTagPOST = sh (script: "git rev-parse --short HEAD", returnStdout: true) + pathTocodepost=pwd() + } + dir('ini'){ + git(branch: "master", url: 'https://github.com/Kv-045DevOps/Kubik-DB.git', credentialsId: "${Creds}") + imageTagINI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + pathTocodeini=pwd() + } + dir('get'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagGET = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + pathTocodeget = pwd() + } + } stage("Deploy to Kubernetes"){ - container('python-alpine'){ - - sh "python3 ${pathTocodeget}/sed_python.py ${pathTocodeget}/template.yaml ${dockerRegistry}/get-service ${params.imageTag}" - //sh "python3 ${pathTocodepost}/sed_python.py ${pathTocodeget}/template.yaml ${dockerRegistry}/post-service ${imageTagPOST}" - sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/db-service ${params.imageTag}" - sh "python3 ${pathTocodeui}/sed_python.py ${pathTocodeui}/template.yaml ${dockerRegistry}/ui-service ${params.imageTag}" - sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/init-container ${params.imageTag}" - } - container('kubectl'){ - def temp = [:] - temp = [ - 'ini':"${pathTocodeini}", 'db':"${pathTocodedb}", - 'get':"${pathTocodeget}", 'ui':"${pathTocodeui}" - //, 'post':"${pathTocodepost}" - ] - temp.each{ k, v -> sh "kubectl apply -f ${v}/template.yaml" } - //sh "kubectl apply -f ${pathTocodepost}/template.yml" - sh "kubectl get pods --namespace=production" - - } + if(params.imageTagGET != "***"){ + container("python-alpine"){ + sh "python3 ${pathTocodeget}/sed_python.py ${pathTocodeget}/template.yaml ${dockerRegistry}/get-service ${params.imageTagGET}" + } + container ("kubectl"){ + sh "kubectl apply -f ${pathTocodeget}/template.yaml" + } + } + if(params.imageTagUI != "***"){ + container("python-alpine"){ + sh "python3 ${pathTocodeui}/sed_python.py ${pathTocodeui}/template.yaml ${dockerRegistry}/ui-service ${params.imageTagUI}" + } + container ("kubectl"){ + sh "kubectl apply -f ${pathTocodeui}/template.yaml" + } + } + if(params.imageTagDB != "***"){ + container("python-alpine"){ + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/db-service ${params.imageTagDB}" + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/init-container ${params.imageTagDB}" + } + container ("kubectl"){ + sh "kubectl apply -f ${pathTocodedb}/template.yaml" + } + } + if(params.imageTagPOST != "***"){ + container("python-alpine"){ + //sh "python3 ${pathTocodepost}/sed_python.py ${pathTocodepost}/template.yaml ${dockerRegistry}/post-service ${imageTagPOST}" + } + container ("kubectl"){ + //sh "kubectl apply -f ${pathTocodepost}/template.yaml" + } + } } + + sleep 20 + stage ("Prod Tests"){ container('python-alpine'){ sh 'echo "Here is prod test"' sh "python3 ${pathTocodeget}/e2e-test-prod.py" } } + } catch(err){ currentBuild.result = 'Failure' diff --git a/Jenkinsfile_e2e_test b/Jenkinsfile_e2e_test index 5e629be..14cdc91 100644 --- a/Jenkinsfile_e2e_test +++ b/Jenkinsfile_e2e_test @@ -1,22 +1,21 @@ def label = "mypod-${UUID.randomUUID().toString()}" def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" -podTemplate(label: label, containers: [ - containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', command: 'cat', ttyEnabled: true), - containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', 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") -{ properties([ parameters([ stringParam( - defaultValue: 'v3.0', + defaultValue: "***", + description: '', + name: 'imageTagGET'), + stringParam( + defaultValue: "***", description: '', - name: 'imageTag'), + name: 'imageTagUI'), + stringParam( + defaultValue: "***", + description: '', + name: 'imageTagDB'), stringParam( defaultValue: '***', description: '', @@ -24,20 +23,70 @@ properties([ ]) ]) +podTemplate(label: label, containers: [ + containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', command: 'cat', ttyEnabled: true), + containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', 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") +{ + + 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) + pathTocodedb=pwd() + } + dir('ui'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-UI.git', credentialsId: "${Creds}") + imageTagUI = sh (script: "git rev-parse --short HEAD", returnStdout: true) + pathTocodeui=pwd() + } + dir('post'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-POST.git', credentialsId: "${Creds}") + imageTagPOST = sh (script: "git rev-parse --short HEAD", returnStdout: true) + pathTocodepost=pwd() + } + dir('ini'){ + git(branch: "master", url: 'https://github.com/Kv-045DevOps/Kubik-DB.git', credentialsId: "${Creds}") + imageTagINI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + pathTocodeini=pwd() + } + dir('get'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagGET = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + pathTocodeget = pwd() + } + } stage("E2E-Test-pre"){ container('python-alpine'){ - sh "ls /home/jenkins/workspace/" def map = [:] map = [ - 'get':[tag: "${params.imageTag}", path: "${pathTocodeget}"], 'post':[tag: "${params.imageTag}", path: "${pathTocodepost}"], - 'db':[tag: "${params.imageTag}", path: "${pathTocodedb}"], 'ui':[tag: "${params.imageTag}", path: "${pathTocodeui}"] + 'get':[tag: "${imageTagGET}", path: "${pathTocodeget}"], 'post':[tag: "${imageTagPOST}", path: "${pathTocodepost}"], + 'db':[tag: "${imageTagDB}", path: "${pathTocodedb}"], 'ui':[tag: "${imageTagUI}", path: "${pathTocodeui}"] ] + if(params.imageTagGET != "***"){ + map['get']['tag'] = "${params.imageTagGET}" + } + if(params.imageTagUI != "***"){ + map['ui']['tag'] = "${params.imageTagUI}" + } + if(params.imageTagDB != "***"){ + map['db']['tag'] = "${params.imageTagDB}" + } + if(params.imageTagPOST != "***"){ + map['post']['tag'] = "${params.imageTagPOST}" + } + echo "${map}" map.each{ k, v -> sh "python3 ${v['path']}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/${k}-service ${v['tag']}" } - sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/init-container ${params.imageTag}" + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/init-container ${map['db']['tag']}" } } @@ -51,16 +100,17 @@ node(label) stage ("E2E Tests - Stage 2"){ container('python-alpine'){ sh 'echo "Here is e2e test"' - sh "python3 ${pathTocodeget}/e2e-test-test.py" + sh "python3 ${pathTocodeget}/e2e-test-test.py" } } - stage("Deploy"){ + + stage ("Deploy"){ - build (job: "test_deploy", parameters: [[$class: 'StringParameterValue', name: "imageTag", - value: "${params.imageTag}"]], wait: true) + build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET", value: "${params.imageTagGET}"], + [$class: 'StringParameterValue', name:"imageTagUI", value: "${params.imageTagUI}"], + [$class: 'StringParameterValue', name:"imageTagDB", value: "${params.imageTagDB}"], + [$class: 'StringParameterValue', name:"imageTagPOST", value: "${params.imageTagPOST}"]], wait: true) } - - } catch(err){ diff --git a/Jenkinsfile_main b/Jenkinsfile_main new file mode 100644 index 0000000..b626134 --- /dev/null +++ b/Jenkinsfile_main @@ -0,0 +1,38 @@ +def buildResult +def paramss = ["GitHub/SRM-GET/test", "GitHub/SRM-UI/test", "GitHub/SRM-DB/test"] +properties([ + parameters([ + stringParam( + defaultValue: 'v2.0', + description: 'Current version', + name: 'imageTagGET'), + stringParam( + defaultValue: 'v2.0', + description: 'Current version', + name: 'imageTagUI'), + stringParam( + defaultValue: 'v2.0', + description: 'Current version', + name: 'imageTagDB'), + stringParam( + defaultValue: 'v2.0', + description: 'Current version', + name: 'imageTagPOST'), + stringParam( + defaultValue: '***', + description: 'Current namespace', + name: 'namespace') + ]) +]) + + stage('Build and push Docker images') { + def jobs = [:] + for(i = 0; i < paramss.size(); i += 1) { + def param = paramss[i] + jobs["Jobs_build_${i}"] = { + build job: param, parameters: [[$class: 'StringParameterValue', name: "imageTagGET", + value: "${params.imageTagGET}"]], wait: true + } + } + parallel jobs + } From e51ca4f06e21a1f9e3c89b556caf79929f96d093 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 11:33:46 -0500 Subject: [PATCH 126/241] Stage 3 --- Jenkinsfile_deploy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile_deploy b/Jenkinsfile_deploy index abf2bf2..6ab677c 100644 --- a/Jenkinsfile_deploy +++ b/Jenkinsfile_deploy @@ -88,7 +88,9 @@ node(label) sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/init-container ${params.imageTagDB}" } container ("kubectl"){ + sh "kubectl apply -f ${pathTocodeini}/template.yaml" sh "kubectl apply -f ${pathTocodedb}/template.yaml" + } } if(params.imageTagPOST != "***"){ From 872dc1b1017a90df2ecc4afeedad20408ad4f5a6 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 11:47:32 -0500 Subject: [PATCH 127/241] Stage 3 1 commit --- Jenkinsfile_deploy | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile_deploy b/Jenkinsfile_deploy index 6ab677c..ee14102 100644 --- a/Jenkinsfile_deploy +++ b/Jenkinsfile_deploy @@ -66,6 +66,17 @@ node(label) } stage("Deploy to Kubernetes"){ + if(params.imageTagDB != "***"){ + container("python-alpine"){ + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/db-service ${params.imageTagDB}" + sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/init-container ${params.imageTagDB}" + } + container ("kubectl"){ + sh "kubectl apply -f ${pathTocodeini}/template.yaml" + sh "kubectl apply -f ${pathTocodedb}/template.yaml" + + } + } if(params.imageTagGET != "***"){ container("python-alpine"){ sh "python3 ${pathTocodeget}/sed_python.py ${pathTocodeget}/template.yaml ${dockerRegistry}/get-service ${params.imageTagGET}" @@ -82,17 +93,7 @@ node(label) sh "kubectl apply -f ${pathTocodeui}/template.yaml" } } - if(params.imageTagDB != "***"){ - container("python-alpine"){ - sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/db-service ${params.imageTagDB}" - sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/init-container ${params.imageTagDB}" - } - container ("kubectl"){ - sh "kubectl apply -f ${pathTocodeini}/template.yaml" - sh "kubectl apply -f ${pathTocodedb}/template.yaml" - - } - } + if(params.imageTagPOST != "***"){ container("python-alpine"){ //sh "python3 ${pathTocodepost}/sed_python.py ${pathTocodepost}/template.yaml ${dockerRegistry}/post-service ${imageTagPOST}" @@ -103,7 +104,7 @@ node(label) } } - sleep 20 + sleep 30 stage ("Prod Tests"){ container('python-alpine'){ From 51d55050111d34abf30b75fa2fb30f6c6dec7a0c Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 12:02:54 -0500 Subject: [PATCH 128/241] Stage 3 - Test after deploy --- e2e-test-test.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/e2e-test-test.py b/e2e-test-test.py index d90f0ca..14631ee 100644 --- a/e2e-test-test.py +++ b/e2e-test-test.py @@ -13,15 +13,12 @@ def check_services(): print("Test UI successfull pass") else: raise Exception("Fucking bitch!!!! Opssss") - return 1 URL_GET = "http://ui-service.testing.svc:5000/salaries" reques = requests.get(URL_GET) if reques.status_code == 200: print("UI success to GET") - return 0 else: raise Exception("Fucking bitch again!!!! Opssss. You are unclever animal") - return -1 if __name__ == '__main__': main() From f1de1ce5192bfc4abc9f848604d5a9376fce115a Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 12:19:40 -0500 Subject: [PATCH 129/241] First failed test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f407bd2..6610d74 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,7 +22,7 @@ properties([ parameters([ stringParam( defaultValue: "***", - description: 'Current', + description: '', name: 'imageTagGET'), stringParam( defaultValue: "***", From 029b2ac1887938184f40e10554d54db7acdc69dd Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 12:24:37 -0500 Subject: [PATCH 130/241] Init test --- e2e-test-prod.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/e2e-test-prod.py b/e2e-test-prod.py index 89161ab..b70459a 100644 --- a/e2e-test-prod.py +++ b/e2e-test-prod.py @@ -13,15 +13,12 @@ def check_services(): print("Tests UI successfull pass") else: raise Exception("Fucking bitch!!!! Opssss") - return 1 URL_GET = "http://ui-service.production.svc:5000/salaries" reques = requests.get(URL_GET) if reques.status_code == 200: print("Test success to UI-GET/salaries") - return 0 else: raise Exception("Fucking bitch again!!!! Opssss. You are ....") - return -1 if __name__ == '__main__': main() From f192876bae9085bc65a17579bbde6cef9f193480 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 12:38:44 -0500 Subject: [PATCH 131/241] 1 --- e2e-test-prod.py | 1 + 1 file changed, 1 insertion(+) diff --git a/e2e-test-prod.py b/e2e-test-prod.py index b70459a..d50e8c2 100644 --- a/e2e-test-prod.py +++ b/e2e-test-prod.py @@ -18,6 +18,7 @@ def check_services(): if reques.status_code == 200: print("Test success to UI-GET/salaries") else: + print(reques.status_code) raise Exception("Fucking bitch again!!!! Opssss. You are ....") if __name__ == '__main__': From 10f6ea6bc6bb80167e9fdb1d8af2f9f8418e2ce7 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 13:03:08 -0500 Subject: [PATCH 132/241] Sleep commit --- e2e-test-prod.py | 2 ++ e2e-test-test.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/e2e-test-prod.py b/e2e-test-prod.py index d50e8c2..4ee86e3 100644 --- a/e2e-test-prod.py +++ b/e2e-test-prod.py @@ -1,4 +1,5 @@ import os +import time import requests def main(): @@ -14,6 +15,7 @@ def check_services(): else: raise Exception("Fucking bitch!!!! Opssss") URL_GET = "http://ui-service.production.svc:5000/salaries" + time.sleep(5) reques = requests.get(URL_GET) if reques.status_code == 200: print("Test success to UI-GET/salaries") diff --git a/e2e-test-test.py b/e2e-test-test.py index 14631ee..6740e50 100644 --- a/e2e-test-test.py +++ b/e2e-test-test.py @@ -1,5 +1,6 @@ import os import requests +import time def main(): check_services() @@ -14,6 +15,7 @@ def check_services(): else: raise Exception("Fucking bitch!!!! Opssss") URL_GET = "http://ui-service.testing.svc:5000/salaries" + time.sleep(5) reques = requests.get(URL_GET) if reques.status_code == 200: print("UI success to GET") From d1223c81bd9f5135bf4f7c6ca768c01da53eee0b Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 13:20:35 -0500 Subject: [PATCH 133/241] Last Test --- e2e-test-prod.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/e2e-test-prod.py b/e2e-test-prod.py index 4ee86e3..eb80e3b 100644 --- a/e2e-test-prod.py +++ b/e2e-test-prod.py @@ -14,14 +14,6 @@ def check_services(): print("Tests UI successfull pass") else: raise Exception("Fucking bitch!!!! Opssss") - URL_GET = "http://ui-service.production.svc:5000/salaries" - time.sleep(5) - reques = requests.get(URL_GET) - if reques.status_code == 200: - print("Test success to UI-GET/salaries") - else: - print(reques.status_code) - raise Exception("Fucking bitch again!!!! Opssss. You are ....") if __name__ == '__main__': main() From 35c412bda7ec913a1f39642b880c90c2505a79d6 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 13:37:23 -0500 Subject: [PATCH 134/241] Test#4 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6610d74..e403149 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,7 +34,7 @@ properties([ name: 'imageTagDB'), stringParam( defaultValue: '***', - description: '', + description: 'Name', name: 'namespace') ]) ]) From 57f03646d89a7d1238920f5d930f4b6ae35296d7 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 3 Feb 2019 13:46:12 -0500 Subject: [PATCH 135/241] Version 4.0 --- Jenkinsfile_v1 | 94 -------------------------------------------------- 1 file changed, 94 deletions(-) delete mode 100644 Jenkinsfile_v1 diff --git a/Jenkinsfile_v1 b/Jenkinsfile_v1 deleted file mode 100644 index c74622e..0000000 --- a/Jenkinsfile_v1 +++ /dev/null @@ -1,94 +0,0 @@ -def label = "mypod-${UUID.randomUUID().toString()}" -def label_f = "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: 'ghostgoose33/docker-in:v1', 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 = "get-service" -def imageVersion = "v1" -def imageName = "100.71.71.71:5000/get-service:${imageVersion}" -def imageN = '100.71.71.71:5000/get-service:' - - -node(label) -{ - try{ - stage("Git Checkout"){ - git( - branch: "test", - url: 'https://github.com/Kv-045DevOps/SRM-GET.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.yml ${dockerRegistry}/get-service ${imageTag}" - sh "python3 ${pathTocode}/pylint-test.py ${pathTocode}/app/app.py" - } - } - stage("Build docker image"){ - container('docker'){ - pathdocker = pwd() - sh "docker build ${pathdocker} -t ${imageN}${imageTag}" - sh "docker images" - sh "cat /etc/docker/daemon.json" - sh "docker push ${imageN}${imageTag}" - } - } - - stage("Deploy to Kubernetes"){ - container('kubectl'){ - sh "kubectl get pods --namespace=production" - sh "kubectl apply -f template.yml" - - } - } - stage ("E2E Tests - Stage 1"){ - container('python-alpine'){ - sh 'echo "Here are e2e tests"' - sh 'python3 e2e-test-prod.py' - sh "python3 sed_python_test.py template-test.yml ${imageTag}" - sh 'cat template-test.yml' - } - } - stage ("E2E Tests - Stage 2"){ - container('kubectl'){ - sh 'kubectl apply -f template-test.yml' - sh 'kubectl get pods -n testing' - } - } - stage ("E2E Tests - Stage 3"){ - container('python-alpine'){ - sh 'echo "Here are e2e tests"' - //sh 'python3 e2e-test-test.py' - } - } - - } - catch(err){ - currentBuild.result = 'Failure' - } -} -} - - -sleep 30 From 89064c9b145291d34edfe87d79cf2c236ae0f9fb Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 5 Feb 2019 12:47:35 -0500 Subject: [PATCH 136/241] Without git pull#1 --- E2E-Test.yaml | 84 ------------- Jenkinsfile | 20 +-- Jenkinsfile_main | 321 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 327 insertions(+), 98 deletions(-) diff --git a/E2E-Test.yaml b/E2E-Test.yaml index bb28282..977ea8f 100644 --- a/E2E-Test.yaml +++ b/E2E-Test.yaml @@ -1,5 +1,3 @@ ---- - apiVersion: v1 kind: Secret metadata: @@ -11,85 +9,3 @@ data: 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 ---- diff --git a/Jenkinsfile b/Jenkinsfile index e403149..f363ccb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,9 +2,8 @@ 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: 'ghostgoose33/docker-in:v1', command: 'cat', ttyEnabled: true), - containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true) + containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v2', 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') @@ -35,7 +34,11 @@ properties([ stringParam( defaultValue: '***', description: 'Name', - name: 'namespace') + name: 'namespace'), + stringParam( + defaultValue: '***', + description: '###', + name: 'e2e_YAML') ]) ]) @@ -48,14 +51,14 @@ node(label) git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") imageTagGET = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) tmp = "1" - //imageTagGET = sh(returnStdout: true, script: "git tag -l --points-at HEAD").trim() pathTocodeget = pwd() } } stage("Test image_regisrty_check"){ container("python-alpine"){ - check_new = (sh (script: "python3 ${pathTocodeget}/images-registry-test.py get-service ${imageTagGET}", returnStdout:true).trim()) + check_new = (sh (script: "python3 /images-registry-test.py get-service ${imageTagGET}", returnStdout:true).trim()) echo "${check_new}" + echo "${params.e2e_YAML}" } } @@ -64,9 +67,8 @@ node(label) } stage("Test code using PyLint and version build"){ container('python-alpine'){ - pathTocode = pwd() //sh "python3 ${pathTocodeget}/sed_python.py template.yaml ${dockerRegistry}/get-service ${imageTag}" - sh "python3 ${pathTocodeget}/pylint-test.py ${pathTocodeget}/app/app.py" + sh "python3 /pylint-test.py ${pathTocodeget}/app/app.py" } } stage("Build docker image"){ @@ -77,7 +79,7 @@ node(label) sh "docker images" sh "cat /etc/docker/daemon.json" sh "docker push ${imageN}${imageTagGET}" - build(job: 'test_e2e', parameters: [[$class: 'StringParameterValue', name:"imageTagGET", value: "${imageTagGET}"]], wait: true) + //build(job: 'test_e2e', parameters: [[$class: 'StringParameterValue', name:"imageTagGET", value: "${imageTagGET}"]], wait: true) } else { echo "NO" } diff --git a/Jenkinsfile_main b/Jenkinsfile_main index b626134..fcda719 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -19,19 +19,330 @@ properties([ description: 'Current version', name: 'imageTagPOST'), stringParam( - defaultValue: '***', - description: 'Current namespace', - name: 'namespace') + defaultValue: '', + description: 'E2E Test', + name: 'e2e_YAML') ]) ]) +String e2e_YAML = """--- +apiVersion: v1 +kind: Namespace +metadata: + name: testing +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: testing + name: services-address +data: + POST_SERVICE_URL: post-service.testing.svc + VIEW_SERVICE_URL: get-service.testing.svc + DB_URL: db-service.testing.svc + URL_DB: db-service.testing.svc +--- +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 +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + namespace: testing + name: db-service +spec: + template: + metadata: + labels: + app: db-service + spec: + initContainers: + - image: 100.71.71.71:5000/init-container:${params.imageTagDB} + name: init-container-postgres + env: + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] + containers: + - image: 100.71.71.71:5000/db-service:${params.imageTagDB} + name: db-service + ports: + - containerPort: 5002 + env: + - name: POSTGRES_HOST + value: srmsystemdb + - name: POSTGRES_PORT + value: "5432" + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: db-service +spec: + selector: + app: db-service + ports: + - protocol: TCP + port: 5002 + targetPort: 5002 +#--- +#kind: Service +#apiVersion: v1 +#metadata: +# namespace: testing +# name: post-service +# labels: +# app: post +#spec: +# selector: +# app: post +# ports: +# - protocol: TCP +# port: 5001 +# targetPort: 5001 +#--- +#apiVersion: apps/v1 +#kind: Deployment +#metadata: +# namespace: testing +# name: post-deployment +#spec: +# selector: +# matchLabels: +# app: post +# replicas: 1 +# template: +# metadata: +# labels: +# app: post +# spec: +# containers: +# - name: post +# image: 100.71.71.71:5000/post-service:2.1 +# ports: +# - containerPort: 5001 +# env: +# - name: DB_URL +# valueFrom: +# configMapKeyRef: +# name: services-address +# key: DB_URL +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: ui-service + labels: + app: ui +spec: + selector: + app: ui + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: testing + name: ui-deployment +spec: + selector: + matchLabels: + app: ui + replicas: 1 + template: + metadata: + labels: + app: ui + spec: + containers: + - name: ui + image: 100.71.71.71:5000/ui-service:${params.imageTagUI} + ports: + - containerPort: 5000 + env: +# - name: POST_SERVICE_URL +# valueFrom: +# configMapKeyRef: +# name: services-address +# key: POST_SERVICE_URL + - name: VIEW_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: VIEW_SERVICE_URL +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: testing + name: get-deployment +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: 100.71.71.71:5000/get-service:{params.imageTagGET} + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB +--- +""" stage('Build and push Docker images') { def jobs = [:] for(i = 0; i < paramss.size(); i += 1) { def param = paramss[i] jobs["Jobs_build_${i}"] = { - build job: param, parameters: [[$class: 'StringParameterValue', name: "imageTagGET", - value: "${params.imageTagGET}"]], wait: true + build job: param, parameters: [[$class: 'StringParameterValue', name: "imageTagGET", value: "${params.imageTagGET}"], + [$class: 'StringParameterValue', name: "imageTagUI", value: "${params.imageTagUI}"], + [$class: 'StringParameterValue', name: "imageTagDB", value: "${params.imageTagDB}"], + [$class: 'StringParameterValue', name: "e2e_YAML", value: "${e2e_YAML}"]], wait: true } } parallel jobs From 8d7bbb2a46ff7f159dbf29e28dc85e568d3d4211 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 5 Feb 2019 14:07:34 -0500 Subject: [PATCH 137/241] Without git pull#2 --- Jenkinsfile | 8 +++++--- Jenkinsfile_main | 20 +++++++++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f363ccb..75c8eed 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,15 +22,15 @@ properties([ stringParam( defaultValue: "***", description: '', - name: 'imageTagGET'), + name: 'imageTagGET_'), stringParam( defaultValue: "***", description: '', - name: 'imageTagUI'), + name: 'imageTagUI_'), stringParam( defaultValue: "***", description: '', - name: 'imageTagDB'), + name: 'imageTagDB_'), stringParam( defaultValue: '***', description: 'Name', @@ -58,6 +58,8 @@ node(label) container("python-alpine"){ check_new = (sh (script: "python3 /images-registry-test.py get-service ${imageTagGET}", returnStdout:true).trim()) echo "${check_new}" + echo "${imageTagGET}" + echo "${params.imageTagGET_}" echo "${params.e2e_YAML}" } } diff --git a/Jenkinsfile_main b/Jenkinsfile_main index fcda719..6a9cb91 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -1,5 +1,5 @@ def buildResult -def paramss = ["GitHub/SRM-GET/test", "GitHub/SRM-UI/test", "GitHub/SRM-DB/test"] +def paramss = ["GitHub/SRM-GET/PR-3"] properties([ parameters([ stringParam( @@ -322,7 +322,7 @@ spec: spec: containers: - name: get - image: 100.71.71.71:5000/get-service:{params.imageTagGET} + image: 100.71.71.71:5000/get-service:${params.imageTagGET} ports: - containerPort: 5003 env: @@ -335,13 +335,23 @@ spec: """ stage('Build and push Docker images') { + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-DB.git', credentialsId: "${Creds}") + imageTagDB = sh (script: "git rev-parse --short HEAD", returnStdout: true) + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-UI.git', credentialsId: "${Creds}") + imageTagUI = sh (script: "git rev-parse --short HEAD", returnStdout: true) + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-POST.git', credentialsId: "${Creds}") + imageTagPOST = sh (script: "git rev-parse --short HEAD", returnStdout: true) + git(branch: "master", url: 'https://github.com/Kv-045DevOps/Kubik-DB.git', credentialsId: "${Creds}") + imageTagINI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagGET = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) def jobs = [:] for(i = 0; i < paramss.size(); i += 1) { def param = paramss[i] jobs["Jobs_build_${i}"] = { - build job: param, parameters: [[$class: 'StringParameterValue', name: "imageTagGET", value: "${params.imageTagGET}"], - [$class: 'StringParameterValue', name: "imageTagUI", value: "${params.imageTagUI}"], - [$class: 'StringParameterValue', name: "imageTagDB", value: "${params.imageTagDB}"], + build job: param, parameters: [[$class: 'StringParameterValue', name: "imageTagGET", value: "${imageTagGET}"], + [$class: 'StringParameterValue', name: "imageTagUI", value: "${imageTagUI}"], + [$class: 'StringParameterValue', name: "imageTagDB", value: "${imageTagDB}"], [$class: 'StringParameterValue', name: "e2e_YAML", value: "${e2e_YAML}"]], wait: true } } From a0e4be0ae07b0640c14e9c48c0df60f2ffea88ed Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 5 Feb 2019 14:37:43 -0500 Subject: [PATCH 138/241] Without git pull#2 --- Jenkinsfile | 5 +++-- Jenkinsfile_e2e_test | 37 ++++++------------------------------- 2 files changed, 9 insertions(+), 33 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 75c8eed..e54b352 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -60,7 +60,6 @@ node(label) echo "${check_new}" echo "${imageTagGET}" echo "${params.imageTagGET_}" - echo "${params.e2e_YAML}" } } @@ -81,7 +80,9 @@ node(label) sh "docker images" sh "cat /etc/docker/daemon.json" sh "docker push ${imageN}${imageTagGET}" - //build(job: 'test_e2e', parameters: [[$class: 'StringParameterValue', name:"imageTagGET", value: "${imageTagGET}"]], wait: true) + build(job: 'test_e2e', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${imageTagGET}"], + [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], + [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"]], wait: true) } else { echo "NO" } diff --git a/Jenkinsfile_e2e_test b/Jenkinsfile_e2e_test index 14cdc91..bf1087d 100644 --- a/Jenkinsfile_e2e_test +++ b/Jenkinsfile_e2e_test @@ -7,25 +7,24 @@ properties([ stringParam( defaultValue: "***", description: '', - name: 'imageTagGET'), + name: 'imageTagGET_'), stringParam( defaultValue: "***", description: '', - name: 'imageTagUI'), + name: 'imageTagUI_'), stringParam( defaultValue: "***", description: '', - name: 'imageTagDB'), + name: 'imageTagDB_'), stringParam( defaultValue: '***', description: '', - name: 'namespace') + name: 'e2e_YAML') ]) ]) podTemplate(label: label, containers: [ containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', command: 'cat', ttyEnabled: true), - containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', command: 'cat', ttyEnabled: true), containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true) ], volumes: [ @@ -38,38 +37,14 @@ 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) - pathTocodedb=pwd() - } - dir('ui'){ - git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-UI.git', credentialsId: "${Creds}") - imageTagUI = sh (script: "git rev-parse --short HEAD", returnStdout: true) - pathTocodeui=pwd() - } - dir('post'){ - git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-POST.git', credentialsId: "${Creds}") - imageTagPOST = sh (script: "git rev-parse --short HEAD", returnStdout: true) - pathTocodepost=pwd() - } - dir('ini'){ - git(branch: "master", url: 'https://github.com/Kv-045DevOps/Kubik-DB.git', credentialsId: "${Creds}") - imageTagINI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) - pathTocodeini=pwd() - } - dir('get'){ - git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") - imageTagGET = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) - pathTocodeget = pwd() - } + } stage("E2E-Test-pre"){ container('python-alpine'){ def map = [:] map = [ - 'get':[tag: "${imageTagGET}", path: "${pathTocodeget}"], 'post':[tag: "${imageTagPOST}", path: "${pathTocodepost}"], + 'get':[tag: "${params.imageTagGET_}", path: "${pathTocodeget}"], 'post':[tag: "${imageTagPOST}", path: "${pathTocodepost}"], 'db':[tag: "${imageTagDB}", path: "${pathTocodedb}"], 'ui':[tag: "${imageTagUI}", path: "${pathTocodeui}"] ] if(params.imageTagGET != "***"){ From d79eb5e66bf4a7bc7680c3ca8d5a8d94ed0cc55f Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 5 Feb 2019 14:51:36 -0500 Subject: [PATCH 139/241] Without git pull#2 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e54b352..e5f1bb5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,7 +64,7 @@ node(label) } stage ("Unit Tests"){ - sh 'echo "Here will be unit tests"' + sh 'echo "Here will be unit testss"' } stage("Test code using PyLint and version build"){ container('python-alpine'){ From 26f1cbfaaf27184f384f8518c4926c9924ed0f9f Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 6 Feb 2019 09:59:16 -0500 Subject: [PATCH 140/241] Without pull --- Jenkinsfile | 9 +- Jenkinsfile_e2e_test | 312 +++++++++++++++++++++++++++++++++++----- Jenkinsfile_main | 3 + string.txt | 334 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 620 insertions(+), 38 deletions(-) create mode 100644 string.txt diff --git a/Jenkinsfile b/Jenkinsfile index e5f1bb5..6384a90 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -38,7 +38,11 @@ properties([ stringParam( defaultValue: '***', description: '###', - name: 'e2e_YAML') + name: 'e2e_YAML'), + stringParam( + defaultValue: '', + description: 'TAG', + name: 'service') ]) ]) @@ -82,7 +86,8 @@ node(label) sh "docker push ${imageN}${imageTagGET}" build(job: 'test_e2e', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${imageTagGET}"], [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], - [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"]], wait: true) + [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], + [$class: 'StringParameterValue', name:"service", value: "get"]], wait: true) } else { echo "NO" } diff --git a/Jenkinsfile_e2e_test b/Jenkinsfile_e2e_test index bf1087d..a4bac91 100644 --- a/Jenkinsfile_e2e_test +++ b/Jenkinsfile_e2e_test @@ -2,6 +2,273 @@ def label = "mypod-${UUID.randomUUID().toString()}" def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" +String e2e_YAML = """ +--- \ +apiVersion: v1 \ +kind: Namespace \ +metadata: \ + name: testing \ +--- \ +apiVersion: v1 \ +kind: ConfigMap \ +metadata:\ + namespace: testing\ + name: services-address\ +data:\ + POST_SERVICE_URL: post-service.testing.svc\ + VIEW_SERVICE_URL: get-service.testing.svc\ + DB_URL: db-service.testing.svc\ + URL_DB: db-service.testing.svc\ +---\ +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:\ + 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\ +---\ +apiVersion: extensions/v1beta1\ +kind: Deployment\ +metadata:\ + namespace: testing\ + name: db-service\ +spec:\ + template:\ + metadata:\ + labels:\ + app: db-service\ + spec:\ + initContainers:\ + - image: 100.71.71.71:5000/init-container:${params.imageTagDB_}\ + name: init-container-postgres\ + env:\ + - name: PGDATABASE\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: dbname\ + - name: PGUSER\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: username\ + - name: PGPASSWORD\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: password\ + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh']\ + containers:\ + - image: 100.71.71.71:5000/db-service:${params.imageTagDB_}\ + name: db-service\ + ports:\ + - containerPort: 5002\ + env:\ + - name: POSTGRES_HOST\ + value: srmsystemdb\ + - name: POSTGRES_PORT\ + value: "5432"\ + - name: PGDATABASE\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: dbname\ + - name: PGUSER\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: username\ + - name: PGPASSWORD\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: password \ +---\ +kind: Service\ +apiVersion: v1\ +metadata:\ + namespace: testing\ + name: db-service\ +spec:\ + selector:\ + app: db-service\ + ports:\ + - protocol: TCP\ + port: 5002\ + targetPort: 5002\ +---\ +kind: Service\ +apiVersion: v1\ +metadata:\ + namespace: testing\ + name: ui-service\ + labels:\ + app: ui\ +spec:\ + selector:\ + app: ui\ + ports:\ + - protocol: TCP\ + port: 5000\ + targetPort: 5000\ +---\ +apiVersion: apps/v1\ +kind: Deployment\ +metadata:\ + namespace: testing\ + name: ui-deployment\ +spec:\ + selector:\ + matchLabels:\ + app: ui\ + replicas: 1\ + template:\ + metadata:\ + labels:\ + app: ui\ + spec:\ + containers:\ + - name: ui\ + image: 100.71.71.71:5000/ui-service:${params.imageTagUI_}\ + ports:\ + - containerPort: 5000\ + env:\ +# - name: POST_SERVICE_URL\ +# valueFrom:\ +# configMapKeyRef:\ +# name: services-address\ +# key: POST_SERVICE_URL\ + - name: VIEW_SERVICE_URL\ + valueFrom:\ + configMapKeyRef:\ + name: services-address\ + key: VIEW_SERVICE_URL\ +---\ +kind: Service\ +apiVersion: v1\ +metadata:\ + namespace: testing\ + name: get-service\ + labels:\ + app: get\ +spec:\ + selector:\ + app: get\ + ports:\ + - protocol: TCP\ + port: 5003\ + targetPort: 5003\ +---\ +apiVersion: apps/v1\ +kind: Deployment\ +metadata:\ + namespace: testing\ + name: get-deployment\ +spec:\ + selector:\ + matchLabels:\ + app: get\ + replicas: 1\ + template:\ + metadata:\ + labels:\ + app: get\ + spec:\ + containers:\ + - name: get\ + image: 100.71.71.71:5000/get-service:${params.imageTagGET_}\ + ports:\ + - containerPort: 5003\ + env:\ + - name: URL_DB\ + valueFrom:\ + configMapKeyRef:\ + name: services-address\ + key: URL_DB\ +--- """ + properties([ parameters([ stringParam( @@ -19,12 +286,13 @@ properties([ stringParam( defaultValue: '***', description: '', - name: 'e2e_YAML') + name: 'namespace') ]) ]) podTemplate(label: label, containers: [ containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', command: 'cat', ttyEnabled: true), + containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', command: 'cat', ttyEnabled: true), containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true) ], volumes: [ @@ -36,55 +304,27 @@ volumes: [ node(label) { try{ - stage("Pre-Test"){ - - } - stage("E2E-Test-pre"){ - container('python-alpine'){ - def map = [:] - map = [ - 'get':[tag: "${params.imageTagGET_}", path: "${pathTocodeget}"], 'post':[tag: "${imageTagPOST}", path: "${pathTocodepost}"], - 'db':[tag: "${imageTagDB}", path: "${pathTocodedb}"], 'ui':[tag: "${imageTagUI}", path: "${pathTocodeui}"] - ] - if(params.imageTagGET != "***"){ - map['get']['tag'] = "${params.imageTagGET}" - } - if(params.imageTagUI != "***"){ - map['ui']['tag'] = "${params.imageTagUI}" - } - if(params.imageTagDB != "***"){ - map['db']['tag'] = "${params.imageTagDB}" - } - if(params.imageTagPOST != "***"){ - map['post']['tag'] = "${params.imageTagPOST}" - } - echo "${map}" - map.each{ k, v -> sh "python3 ${v['path']}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/${k}-service ${v['tag']}" } - sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodeget}/E2E.yaml ${dockerRegistry}/init-container ${map['db']['tag']}" - } - - } stage("E2E Test - Stage 1"){ container('kubectl'){ - sh "kubectl apply -f ${pathTocodeget}/E2E.yaml" + sh (script: "echo ${e2e_YAML} | kubectl apply -n namespace -f -", returnStdout: true) sh "kubectl get pods --namespace=testing" } } sleep 20 stage ("E2E Tests - Stage 2"){ container('python-alpine'){ - sh 'echo "Here is e2e test"' - sh "python3 ${pathTocodeget}/e2e-test-test.py" + // sh 'echo "Here is e2e test"' + //sh "python3 ${pathTocodeget}/e2e-test-test.py" } } stage ("Deploy"){ - build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET", value: "${params.imageTagGET}"], - [$class: 'StringParameterValue', name:"imageTagUI", value: "${params.imageTagUI}"], - [$class: 'StringParameterValue', name:"imageTagDB", value: "${params.imageTagDB}"], - [$class: 'StringParameterValue', name:"imageTagPOST", value: "${params.imageTagPOST}"]], wait: true) + //build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET", value: "${params.imageTagGET}"], + //[$class: 'StringParameterValue', name:"imageTagUI", value: "${params.imageTagUI}"], + //[$class: 'StringParameterValue', name:"imageTagDB", value: "${params.imageTagDB}"], + //[$class: 'StringParameterValue', name:"imageTagPOST", value: "${params.imageTagPOST}"]], wait: true) } } diff --git a/Jenkinsfile_main b/Jenkinsfile_main index 6a9cb91..355820d 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -1,5 +1,8 @@ def buildResult def paramss = ["GitHub/SRM-GET/PR-3"] +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + properties([ parameters([ stringParam( diff --git a/string.txt b/string.txt new file mode 100644 index 0000000..78127b9 --- /dev/null +++ b/string.txt @@ -0,0 +1,334 @@ +def label = "mypod-${UUID.randomUUID().toString()}" +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + +String e2e_YAML = """--- \ +apiVersion: v1 \ +kind: Namespace \ +metadata: \ + name: testing \ +--- \ +apiVersion: v1 \ +kind: ConfigMap \ +metadata:\ + namespace: testing\ + name: services-address\ +data:\ + POST_SERVICE_URL: post-service.testing.svc\ + VIEW_SERVICE_URL: get-service.testing.svc\ + DB_URL: db-service.testing.svc\ + URL_DB: db-service.testing.svc\ +---\ +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:\ + 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\ +---\ +apiVersion: extensions/v1beta1\ +kind: Deployment\ +metadata:\ + namespace: testing\ + name: db-service\ +spec:\ + template:\ + metadata:\ + labels:\ + app: db-service\ + spec:\ + initContainers:\ + - image: 100.71.71.71:5000/init-container:${params.imageTagDB_}\ + name: init-container-postgres\ + env:\ + - name: PGDATABASE\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: dbname\ + - name: PGUSER\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: username\ + - name: PGPASSWORD\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: password\ + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh']\ + containers:\ + - image: 100.71.71.71:5000/db-service:${params.imageTagDB_}\ + name: db-service\ + ports:\ + - containerPort: 5002\ + env:\ + - name: POSTGRES_HOST\ + value: srmsystemdb\ + - name: POSTGRES_PORT\ + value: "5432"\ + - name: PGDATABASE\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: dbname\ + - name: PGUSER\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: username\ + - name: PGPASSWORD\ + valueFrom:\ + secretKeyRef:\ + name: db-secret\ + key: password \ +---\ +kind: Service\ +apiVersion: v1\ +metadata:\ + namespace: testing\ + name: db-service\ +spec:\ + selector:\ + app: db-service\ + ports:\ + - protocol: TCP\ + port: 5002\ + targetPort: 5002\ +---\ +kind: Service\ +apiVersion: v1\ +metadata:\ + namespace: testing\ + name: ui-service\ + labels:\ + app: ui\ +spec:\ + selector:\ + app: ui\ + ports:\ + - protocol: TCP\ + port: 5000\ + targetPort: 5000\ +---\ +apiVersion: apps/v1\ +kind: Deployment\ +metadata:\ + namespace: testing\ + name: ui-deployment\ +spec:\ + selector:\ + matchLabels:\ + app: ui\ + replicas: 1\ + template:\ + metadata:\ + labels:\ + app: ui\ + spec:\ + containers:\ + - name: ui\ + image: 100.71.71.71:5000/ui-service:${params.imageTagUI_}\ + ports:\ + - containerPort: 5000\ + env:\ +# - name: POST_SERVICE_URL\ +# valueFrom:\ +# configMapKeyRef:\ +# name: services-address\ +# key: POST_SERVICE_URL\ + - name: VIEW_SERVICE_URL\ + valueFrom:\ + configMapKeyRef:\ + name: services-address\ + key: VIEW_SERVICE_URL\ +---\ +kind: Service\ +apiVersion: v1\ +metadata:\ + namespace: testing\ + name: get-service\ + labels:\ + app: get\ +spec:\ + selector:\ + app: get\ + ports:\ + - protocol: TCP\ + port: 5003\ + targetPort: 5003\ +---\ +apiVersion: apps/v1\ +kind: Deployment\ +metadata:\ + namespace: testing\ + name: get-deployment\ +spec:\ + selector:\ + matchLabels:\ + app: get\ + replicas: 1\ + template:\ + metadata:\ + labels:\ + app: get\ + spec:\ + containers:\ + - name: get\ + image: 100.71.71.71:5000/get-service:${params.imageTagGET_}\ + ports:\ + - containerPort: 5003\ + env:\ + - name: URL_DB\ + valueFrom:\ + configMapKeyRef:\ + name: services-address\ + key: URL_DB\ +--- """ + +properties([ + parameters([ + stringParam( + defaultValue: "***", + description: '', + name: 'imageTagGET_'), + stringParam( + defaultValue: "***", + description: '', + name: 'imageTagUI_'), + stringParam( + defaultValue: "***", + description: '', + name: 'imageTagDB_'), + stringParam( + defaultValue: '***', + description: '', + name: 'namespace') + ]) +]) + +podTemplate(label: label, containers: [ + containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', command: 'cat', ttyEnabled: true), + containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', 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") +{ + + +node(label) +{ + try{ + + stage("E2E Test - Stage 1"){ + container('kubectl'){ + sh (script: "echo ${e2e_YAML} | kubectl apply -n namespace -f -", returnStdout: true) + sh "kubectl get pods --namespace=testing" + } + } + sleep 20 + stage ("E2E Tests - Stage 2"){ + container('python-alpine'){ + // sh 'echo "Here is e2e test"' + //sh "python3 ${pathTocodeget}/e2e-test-test.py" + } + } + + stage ("Deploy"){ + + //build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET", value: "${params.imageTagGET}"], + //[$class: 'StringParameterValue', name:"imageTagUI", value: "${params.imageTagUI}"], + //[$class: 'StringParameterValue', name:"imageTagDB", value: "${params.imageTagDB}"], + //[$class: 'StringParameterValue', name:"imageTagPOST", value: "${params.imageTagPOST}"]], wait: true) + } + + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} From 312c171d8afdeab480e5d11b1aed5e4bbb75b2d6 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 6 Feb 2019 14:01:41 -0500 Subject: [PATCH 141/241] Without pull --- Jenkinsfile_e2e_test | 585 +++++++++++++++++++++++-------------------- 1 file changed, 317 insertions(+), 268 deletions(-) diff --git a/Jenkinsfile_e2e_test b/Jenkinsfile_e2e_test index a4bac91..e1614b2 100644 --- a/Jenkinsfile_e2e_test +++ b/Jenkinsfile_e2e_test @@ -2,272 +2,315 @@ def label = "mypod-${UUID.randomUUID().toString()}" def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" -String e2e_YAML = """ ---- \ -apiVersion: v1 \ -kind: Namespace \ -metadata: \ - name: testing \ ---- \ -apiVersion: v1 \ -kind: ConfigMap \ -metadata:\ - namespace: testing\ - name: services-address\ -data:\ - POST_SERVICE_URL: post-service.testing.svc\ - VIEW_SERVICE_URL: get-service.testing.svc\ - DB_URL: db-service.testing.svc\ - URL_DB: db-service.testing.svc\ ----\ -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:\ - 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\ ----\ -apiVersion: extensions/v1beta1\ -kind: Deployment\ -metadata:\ - namespace: testing\ - name: db-service\ -spec:\ - template:\ - metadata:\ - labels:\ - app: db-service\ - spec:\ - initContainers:\ - - image: 100.71.71.71:5000/init-container:${params.imageTagDB_}\ - name: init-container-postgres\ - env:\ - - name: PGDATABASE\ - valueFrom:\ - secretKeyRef:\ - name: db-secret\ - key: dbname\ - - name: PGUSER\ - valueFrom:\ - secretKeyRef:\ - name: db-secret\ - key: username\ - - name: PGPASSWORD\ - valueFrom:\ - secretKeyRef:\ - name: db-secret\ - key: password\ - command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh']\ - containers:\ - - image: 100.71.71.71:5000/db-service:${params.imageTagDB_}\ - name: db-service\ - ports:\ - - containerPort: 5002\ - env:\ - - name: POSTGRES_HOST\ - value: srmsystemdb\ - - name: POSTGRES_PORT\ - value: "5432"\ - - name: PGDATABASE\ - valueFrom:\ - secretKeyRef:\ - name: db-secret\ - key: dbname\ - - name: PGUSER\ - valueFrom:\ - secretKeyRef:\ - name: db-secret\ - key: username\ - - name: PGPASSWORD\ - valueFrom:\ - secretKeyRef:\ - name: db-secret\ - key: password \ ----\ -kind: Service\ -apiVersion: v1\ -metadata:\ - namespace: testing\ - name: db-service\ -spec:\ - selector:\ - app: db-service\ - ports:\ - - protocol: TCP\ - port: 5002\ - targetPort: 5002\ ----\ -kind: Service\ -apiVersion: v1\ -metadata:\ - namespace: testing\ - name: ui-service\ - labels:\ - app: ui\ -spec:\ - selector:\ - app: ui\ - ports:\ - - protocol: TCP\ - port: 5000\ - targetPort: 5000\ ----\ -apiVersion: apps/v1\ -kind: Deployment\ -metadata:\ - namespace: testing\ - name: ui-deployment\ -spec:\ - selector:\ - matchLabels:\ - app: ui\ - replicas: 1\ - template:\ - metadata:\ - labels:\ - app: ui\ - spec:\ - containers:\ - - name: ui\ - image: 100.71.71.71:5000/ui-service:${params.imageTagUI_}\ - ports:\ - - containerPort: 5000\ - env:\ -# - name: POST_SERVICE_URL\ -# valueFrom:\ -# configMapKeyRef:\ -# name: services-address\ -# key: POST_SERVICE_URL\ - - name: VIEW_SERVICE_URL\ - valueFrom:\ - configMapKeyRef:\ - name: services-address\ - key: VIEW_SERVICE_URL\ ----\ -kind: Service\ -apiVersion: v1\ -metadata:\ - namespace: testing\ - name: get-service\ - labels:\ - app: get\ -spec:\ - selector:\ - app: get\ - ports:\ - - protocol: TCP\ - port: 5003\ - targetPort: 5003\ ----\ -apiVersion: apps/v1\ -kind: Deployment\ -metadata:\ - namespace: testing\ - name: get-deployment\ -spec:\ - selector:\ - matchLabels:\ - app: get\ - replicas: 1\ - template:\ - metadata:\ - labels:\ - app: get\ - spec:\ - containers:\ - - name: get\ - image: 100.71.71.71:5000/get-service:${params.imageTagGET_}\ - ports:\ - - containerPort: 5003\ - env:\ - - name: URL_DB\ - valueFrom:\ - configMapKeyRef:\ - name: services-address\ - key: URL_DB\ ---- """ +String e2e_YAML = """--- +apiVersion: v1 +kind: Namespace +metadata: + name: testing +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: testing + name: services-address +data: + POST_SERVICE_URL: post-service.testing.svc + VIEW_SERVICE_URL: get-service.testing.svc + DB_URL: db-service.testing.svc + URL_DB: db-service.testing.svc +--- +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 +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + namespace: testing + name: db-service +spec: + template: + metadata: + labels: + app: db-service + spec: + initContainers: + - image: 100.71.71.71:5000/init-container:${params.imageTagDB_} + name: init-container-postgres + env: + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] + containers: + - image: 100.71.71.71:5000/db-service:${params.imageTagDB_} + name: db-service + ports: + - containerPort: 5002 + env: + - name: POSTGRES_HOST + value: srmsystemdb + - name: POSTGRES_PORT + value: "5432" + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: db-service +spec: + selector: + app: db-service + ports: + - protocol: TCP + port: 5002 + targetPort: 5002 +#--- +#kind: Service +#apiVersion: v1 +#metadata: +# namespace: testing +# name: post-service +# labels: +# app: post +#spec: +# selector: +# app: post +# ports: +# - protocol: TCP +# port: 5001 +# targetPort: 5001 +#--- +#apiVersion: apps/v1 +#kind: Deployment +#metadata: +# namespace: testing +# name: post-deployment +#spec: +# selector: +# matchLabels: +# app: post +# replicas: 1 +# template: +# metadata: +# labels: +# app: post +# spec: +# containers: +# - name: post +# image: 100.71.71.71:5000/post-service:2.1 +# ports: +# - containerPort: 5001 +# env: +# - name: DB_URL +# valueFrom: +# configMapKeyRef: +# name: services-address +# key: DB_URL +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: ui-service + labels: + app: ui +spec: + selector: + app: ui + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: testing + name: ui-deployment +spec: + selector: + matchLabels: + app: ui + replicas: 1 + template: + metadata: + labels: + app: ui + spec: + containers: + - name: ui + image: 100.71.71.71:5000/ui-service:${params.imageTagUI_} + ports: + - containerPort: 5000 + env: +# - name: POST_SERVICE_URL +# valueFrom: +# configMapKeyRef: +# name: services-address +# key: POST_SERVICE_URL + - name: VIEW_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: VIEW_SERVICE_URL +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: testing + name: get-deployment +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: 100.71.71.71:5000/get-service:${params.imageTagGET_} + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB +--- +""" properties([ parameters([ @@ -286,7 +329,11 @@ properties([ stringParam( defaultValue: '***', description: '', - name: 'namespace') + name: 'namespace'), + stringParam( + defaultValue: '***', + description: '', + name: 'service') ]) ]) @@ -307,7 +354,9 @@ node(label) stage("E2E Test - Stage 1"){ container('kubectl'){ - sh (script: "echo ${e2e_YAML} | kubectl apply -n namespace -f -", returnStdout: true) + writeYaml file: 'temp.yaml', data: e2e_YAML + sh "cat temp.yaml" + sh (script: "kubectl apply -n namespace -f temp.yaml", returnStdout: true) sh "kubectl get pods --namespace=testing" } } From f11b72a94935b475f1a16102695b250f6f03911a Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 6 Feb 2019 15:43:36 -0500 Subject: [PATCH 142/241] Without pull#2 --- Jenkinsfile_e2e_test | 52 +------ Jenkinsfile_main | 327 ++----------------------------------------- 2 files changed, 12 insertions(+), 367 deletions(-) diff --git a/Jenkinsfile_e2e_test b/Jenkinsfile_e2e_test index e1614b2..79a2743 100644 --- a/Jenkinsfile_e2e_test +++ b/Jenkinsfile_e2e_test @@ -178,48 +178,6 @@ spec: - protocol: TCP port: 5002 targetPort: 5002 -#--- -#kind: Service -#apiVersion: v1 -#metadata: -# namespace: testing -# name: post-service -# labels: -# app: post -#spec: -# selector: -# app: post -# ports: -# - protocol: TCP -# port: 5001 -# targetPort: 5001 -#--- -#apiVersion: apps/v1 -#kind: Deployment -#metadata: -# namespace: testing -# name: post-deployment -#spec: -# selector: -# matchLabels: -# app: post -# replicas: 1 -# template: -# metadata: -# labels: -# app: post -# spec: -# containers: -# - name: post -# image: 100.71.71.71:5000/post-service:2.1 -# ports: -# - containerPort: 5001 -# env: -# - name: DB_URL -# valueFrom: -# configMapKeyRef: -# name: services-address -# key: DB_URL --- kind: Service apiVersion: v1 @@ -257,11 +215,6 @@ spec: ports: - containerPort: 5000 env: -# - name: POST_SERVICE_URL -# valueFrom: -# configMapKeyRef: -# name: services-address -# key: POST_SERVICE_URL - name: VIEW_SERVICE_URL valueFrom: configMapKeyRef: @@ -355,8 +308,9 @@ node(label) stage("E2E Test - Stage 1"){ container('kubectl'){ writeYaml file: 'temp.yaml', data: e2e_YAML - sh "cat temp.yaml" - sh (script: "kubectl apply -n namespace -f temp.yaml", returnStdout: true) + //sh 'echo "$e2e_YAML"' + echo "$e2e_YAML" + sh """echo "$e2e_YAML" | kubectl apply -f -""" sh "kubectl get pods --namespace=testing" } } diff --git a/Jenkinsfile_main b/Jenkinsfile_main index 355820d..a6585d3 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -2,341 +2,32 @@ def buildResult def paramss = ["GitHub/SRM-GET/PR-3"] def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" - properties([ parameters([ stringParam( defaultValue: 'v2.0', description: 'Current version', - name: 'imageTagGET'), + name: 'imageTagGET_'), stringParam( defaultValue: 'v2.0', description: 'Current version', - name: 'imageTagUI'), + name: 'imageTagUI_'), stringParam( defaultValue: 'v2.0', description: 'Current version', - name: 'imageTagDB'), + name: 'imageTagDB_'), stringParam( defaultValue: 'v2.0', description: 'Current version', - name: 'imageTagPOST'), + name: 'imageTagPOST_'), stringParam( defaultValue: '', description: 'E2E Test', name: 'e2e_YAML') ]) ]) -String e2e_YAML = """--- -apiVersion: v1 -kind: Namespace -metadata: - name: testing ---- -apiVersion: v1 -kind: ConfigMap -metadata: - namespace: testing - name: services-address -data: - POST_SERVICE_URL: post-service.testing.svc - VIEW_SERVICE_URL: get-service.testing.svc - DB_URL: db-service.testing.svc - URL_DB: db-service.testing.svc ---- -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 ---- -apiVersion: extensions/v1beta1 -kind: Deployment -metadata: - namespace: testing - name: db-service -spec: - template: - metadata: - labels: - app: db-service - spec: - initContainers: - - image: 100.71.71.71:5000/init-container:${params.imageTagDB} - name: init-container-postgres - env: - - name: PGDATABASE - valueFrom: - secretKeyRef: - name: db-secret - key: dbname - - name: PGUSER - valueFrom: - secretKeyRef: - name: db-secret - key: username - - name: PGPASSWORD - valueFrom: - secretKeyRef: - name: db-secret - key: password - command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] - containers: - - image: 100.71.71.71:5000/db-service:${params.imageTagDB} - name: db-service - ports: - - containerPort: 5002 - env: - - name: POSTGRES_HOST - value: srmsystemdb - - name: POSTGRES_PORT - value: "5432" - - name: PGDATABASE - valueFrom: - secretKeyRef: - name: db-secret - key: dbname - - name: PGUSER - valueFrom: - secretKeyRef: - name: db-secret - key: username - - name: PGPASSWORD - valueFrom: - secretKeyRef: - name: db-secret - key: password ---- -kind: Service -apiVersion: v1 -metadata: - namespace: testing - name: db-service -spec: - selector: - app: db-service - ports: - - protocol: TCP - port: 5002 - targetPort: 5002 -#--- -#kind: Service -#apiVersion: v1 -#metadata: -# namespace: testing -# name: post-service -# labels: -# app: post -#spec: -# selector: -# app: post -# ports: -# - protocol: TCP -# port: 5001 -# targetPort: 5001 -#--- -#apiVersion: apps/v1 -#kind: Deployment -#metadata: -# namespace: testing -# name: post-deployment -#spec: -# selector: -# matchLabels: -# app: post -# replicas: 1 -# template: -# metadata: -# labels: -# app: post -# spec: -# containers: -# - name: post -# image: 100.71.71.71:5000/post-service:2.1 -# ports: -# - containerPort: 5001 -# env: -# - name: DB_URL -# valueFrom: -# configMapKeyRef: -# name: services-address -# key: DB_URL ---- -kind: Service -apiVersion: v1 -metadata: - namespace: testing - name: ui-service - labels: - app: ui -spec: - selector: - app: ui - ports: - - protocol: TCP - port: 5000 - targetPort: 5000 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: testing - name: ui-deployment -spec: - selector: - matchLabels: - app: ui - replicas: 1 - template: - metadata: - labels: - app: ui - spec: - containers: - - name: ui - image: 100.71.71.71:5000/ui-service:${params.imageTagUI} - ports: - - containerPort: 5000 - env: -# - name: POST_SERVICE_URL -# valueFrom: -# configMapKeyRef: -# name: services-address -# key: POST_SERVICE_URL - - name: VIEW_SERVICE_URL - valueFrom: - configMapKeyRef: - name: services-address - key: VIEW_SERVICE_URL ---- -kind: Service -apiVersion: v1 -metadata: - namespace: testing - name: get-service - labels: - app: get -spec: - selector: - app: get - ports: - - protocol: TCP - port: 5003 - targetPort: 5003 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - namespace: testing - name: get-deployment -spec: - selector: - matchLabels: - app: get - replicas: 1 - template: - metadata: - labels: - app: get - spec: - containers: - - name: get - image: 100.71.71.71:5000/get-service:${params.imageTagGET} - ports: - - containerPort: 5003 - env: - - name: URL_DB - valueFrom: - configMapKeyRef: - name: services-address - key: URL_DB ---- -""" +node { stage('Build and push Docker images') { git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-DB.git', credentialsId: "${Creds}") imageTagDB = sh (script: "git rev-parse --short HEAD", returnStdout: true) @@ -352,11 +43,11 @@ spec: for(i = 0; i < paramss.size(); i += 1) { def param = paramss[i] jobs["Jobs_build_${i}"] = { - build job: param, parameters: [[$class: 'StringParameterValue', name: "imageTagGET", value: "${imageTagGET}"], - [$class: 'StringParameterValue', name: "imageTagUI", value: "${imageTagUI}"], - [$class: 'StringParameterValue', name: "imageTagDB", value: "${imageTagDB}"], - [$class: 'StringParameterValue', name: "e2e_YAML", value: "${e2e_YAML}"]], wait: true + build job: param, parameters: [[$class: 'StringParameterValue', name: "imageTagGET_", value: "${imageTagGET}"], + [$class: 'StringParameterValue', name: "imageTagUI_", value: "${imageTagUI}"], + [$class: 'StringParameterValue', name: "imageTagDB_", value: "${imageTagDB}"]], wait: true } } parallel jobs } +} From b255aa10ceb06a35853d8b3c9d0f5e68348713f4 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 6 Feb 2019 15:53:36 -0500 Subject: [PATCH 143/241] Without pull --- E2E.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/E2E.yaml b/E2E.yaml index e9a3eba..d998acd 100644 --- a/E2E.yaml +++ b/E2E.yaml @@ -1,12 +1,9 @@ --- - apiVersion: v1 kind: Namespace metadata: name: testing - --- - apiVersion: v1 kind: ConfigMap metadata: @@ -17,9 +14,7 @@ data: VIEW_SERVICE_URL: get-service.testing.svc DB_URL: db-service.testing.svc URL_DB: db-service.testing.svc - --- - apiVersion: v1 kind: Secret metadata: @@ -30,7 +25,6 @@ data: password: UGFzc3dvcmQ= dbname: c3Jtc3lzdGVt type: Opaque - --- apiVersion: v1 kind: PersistentVolumeClaim From 9e8452fa39a9ecaa6963538834d64c36fb14497c Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 6 Feb 2019 16:45:39 -0500 Subject: [PATCH 144/241] Without pull --- Jenkinsfile_e2e_test | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile_e2e_test b/Jenkinsfile_e2e_test index 79a2743..77451b6 100644 --- a/Jenkinsfile_e2e_test +++ b/Jenkinsfile_e2e_test @@ -38,7 +38,6 @@ metadata: app: pvc-postgres name: postgres-pvc spec: - #storageClassName: slow accessModes: - ReadWriteOnce resources: @@ -61,7 +60,7 @@ spec: initContainers: - name: volume-mount-hack image: busybox - command: ["sh", "-c", "chown -R 999:999 /var/lib/postgresql/"] + command: ["sh", "-c", "chown -R 999.999 /var/lib/postgresql/"] volumeMounts: - name: postgres-pv-claim mountPath: /var/lib/postgresql/data @@ -109,12 +108,15 @@ spec: port: 5432 targetPort: 5432 --- -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: namespace: testing name: db-service spec: + selector: + matchLabels: + app: db-service template: metadata: labels: @@ -149,7 +151,7 @@ spec: - name: POSTGRES_HOST value: srmsystemdb - name: POSTGRES_PORT - value: "5432" + value: '5432' - name: PGDATABASE valueFrom: secretKeyRef: From 668830a1a2310e9f8a3d00bb87bcd321645c8d94 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 7 Feb 2019 04:22:15 -0500 Subject: [PATCH 145/241] Without pull#3 --- E2E.yaml | 147 +++++++++++++++++++++++++++-------------------- Jenkinsfile | 1 + Jenkinsfile_main | 2 +- 3 files changed, 87 insertions(+), 63 deletions(-) diff --git a/E2E.yaml b/E2E.yaml index d998acd..aa9f39a 100644 --- a/E2E.yaml +++ b/E2E.yaml @@ -1,4 +1,8 @@ ---- +def label = "mypod-${UUID.randomUUID().toString()}" +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + +String e2e_YAML = """--- apiVersion: v1 kind: Namespace metadata: @@ -34,13 +38,11 @@ metadata: app: pvc-postgres name: postgres-pvc spec: - #storageClassName: slow accessModes: - ReadWriteOnce resources: requests: storage: 2Gi - --- apiVersion: extensions/v1beta1 kind: Deployment @@ -58,7 +60,7 @@ spec: initContainers: - name: volume-mount-hack image: busybox - command: ["sh", "-c", "chown -R 999:999 /var/lib/postgresql/"] + command: ["sh", "-c", "chown -R 999.999 /var/lib/postgresql/"] volumeMounts: - name: postgres-pv-claim mountPath: /var/lib/postgresql/data @@ -92,7 +94,6 @@ spec: - name: postgres-pv-claim persistentVolumeClaim: claimName: postgres-pvc - --- kind: Service apiVersion: v1 @@ -107,19 +108,22 @@ spec: port: 5432 targetPort: 5432 --- -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: namespace: testing name: db-service spec: + selector: + matchLabels: + app: db-service template: metadata: labels: app: db-service spec: initContainers: - - image: 100.71.71.71:5000/init-container:latest + - image: 100.71.71.71:5000/init-container:${params.imageTagDB_} name: init-container-postgres env: - name: PGDATABASE @@ -139,7 +143,7 @@ spec: key: password command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] containers: - - image: 100.71.71.71:5000/db-service:latest + - image: 100.71.71.71:5000/db-service:${params.imageTagDB_} name: db-service ports: - containerPort: 5002 @@ -147,7 +151,7 @@ spec: - name: POSTGRES_HOST value: srmsystemdb - name: POSTGRES_PORT - value: "5432" + value: '5432' - name: PGDATABASE valueFrom: secretKeyRef: @@ -176,50 +180,6 @@ spec: - protocol: TCP port: 5002 targetPort: 5002 - -#--- -#kind: Service -#apiVersion: v1 -#metadata: -# namespace: testing -# name: post-service -# labels: -# app: post -#spec: -# selector: -# app: post -# ports: -# - protocol: TCP -# port: 5001 -# targetPort: 5001 - -#--- -#apiVersion: apps/v1 -#kind: Deployment -#metadata: -# namespace: testing -# name: post-deployment -#spec: -# selector: -# matchLabels: -# app: post -# replicas: 1 -# template: -# metadata: -# labels: -# app: post -# spec: -# containers: -# - name: post -# image: 100.71.71.71:5000/post-service:2.1 -# ports: -# - containerPort: 5001 -# env: -# - name: DB_URL -# valueFrom: -# configMapKeyRef: -# name: services-address -# key: DB_URL --- kind: Service apiVersion: v1 @@ -235,7 +195,6 @@ spec: - protocol: TCP port: 5000 targetPort: 5000 - --- apiVersion: apps/v1 kind: Deployment @@ -254,15 +213,10 @@ spec: spec: containers: - name: ui - image: 100.71.71.71:5000/ui-service:latest + image: 100.71.71.71:5000/ui-service:${params.imageTagUI_} ports: - containerPort: 5000 env: -# - name: POST_SERVICE_URL -# valueFrom: -# configMapKeyRef: -# name: services-address -# key: POST_SERVICE_URL - name: VIEW_SERVICE_URL valueFrom: configMapKeyRef: @@ -283,7 +237,6 @@ spec: - protocol: TCP port: 5003 targetPort: 5003 - --- apiVersion: apps/v1 kind: Deployment @@ -302,7 +255,7 @@ spec: spec: containers: - name: get - image: 100.71.71.71:5000/get-service:v2 + image: 100.71.71.71:5000/get-service:${params.imageTagGET_} ports: - containerPort: 5003 env: @@ -312,4 +265,74 @@ spec: name: services-address key: URL_DB --- +""" + +properties([ + parameters([ + stringParam( + defaultValue: "***", + description: '', + name: 'imageTagGET_'), + stringParam( + defaultValue: "***", + description: '', + name: 'imageTagUI_'), + stringParam( + defaultValue: "***", + description: '', + name: 'imageTagDB_'), + stringParam( + defaultValue: '***', + description: '', + name: 'namespace'), + stringParam( + defaultValue: '***', + description: '', + name: 'service') + ]) +]) + +podTemplate(label: label, containers: [ + containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v2', command: 'cat', ttyEnabled: true), + containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', 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") +{ + + +node(label) +{ + try{ + + stage("E2E Test - Stage 1"){ + container('kubectl'){ + //echo "$e2e_YAML" + sh """echo "$e2e_YAML" | kubectl apply -f -""" + sh "kubectl get pods --namespace=testing" + } + } + sleep 20 + stage ("E2E Tests - Stage 2"){ + container('python-alpine'){ + // sh 'echo "Here is e2e test"' + sh "python3 /e2e-test-test.py" + } + } + stage ("Deploy"){ + + //build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET", value: "${params.imageTagGET}"], + //[$class: 'StringParameterValue', name:"imageTagUI", value: "${params.imageTagUI}"], + //[$class: 'StringParameterValue', name:"imageTagDB", value: "${params.imageTagDB}"], + //[$class: 'StringParameterValue', name:"imageTagPOST", value: "${params.imageTagPOST}"]], wait: true) + } + + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} diff --git a/Jenkinsfile b/Jenkinsfile index 6384a90..984ac83 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -84,6 +84,7 @@ node(label) sh "docker images" sh "cat /etc/docker/daemon.json" sh "docker push ${imageN}${imageTagGET}" + sleep 20 build(job: 'test_e2e', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${imageTagGET}"], [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], diff --git a/Jenkinsfile_main b/Jenkinsfile_main index a6585d3..f3334b3 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -1,5 +1,5 @@ def buildResult -def paramss = ["GitHub/SRM-GET/PR-3"] +def paramss = ["GitHub/SRM-GET/PR-3", "GitHub/SRM-UI/test", "GitHub/SRM-DB/PR-2"] def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" properties([ From 3bb08e4b769c8b2dd484bbca08ee9fa738931689 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 8 Feb 2019 05:08:14 -0500 Subject: [PATCH 146/241] Without pull --- E2E.yaml | 77 +------------------------------------------------------- 1 file changed, 1 insertion(+), 76 deletions(-) diff --git a/E2E.yaml b/E2E.yaml index aa9f39a..911b9ce 100644 --- a/E2E.yaml +++ b/E2E.yaml @@ -1,8 +1,4 @@ -def label = "mypod-${UUID.randomUUID().toString()}" -def dockerRegistry = "100.71.71.71:5000" -def Creds = "git_cred" - -String e2e_YAML = """--- +--- apiVersion: v1 kind: Namespace metadata: @@ -265,74 +261,3 @@ spec: name: services-address key: URL_DB --- -""" - -properties([ - parameters([ - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagGET_'), - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagUI_'), - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagDB_'), - stringParam( - defaultValue: '***', - description: '', - name: 'namespace'), - stringParam( - defaultValue: '***', - description: '', - name: 'service') - ]) -]) - -podTemplate(label: label, containers: [ - containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v2', command: 'cat', ttyEnabled: true), - containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', 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") -{ - - -node(label) -{ - try{ - - stage("E2E Test - Stage 1"){ - container('kubectl'){ - //echo "$e2e_YAML" - sh """echo "$e2e_YAML" | kubectl apply -f -""" - sh "kubectl get pods --namespace=testing" - } - } - sleep 20 - stage ("E2E Tests - Stage 2"){ - container('python-alpine'){ - // sh 'echo "Here is e2e test"' - sh "python3 /e2e-test-test.py" - } - } - - stage ("Deploy"){ - - //build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET", value: "${params.imageTagGET}"], - //[$class: 'StringParameterValue', name:"imageTagUI", value: "${params.imageTagUI}"], - //[$class: 'StringParameterValue', name:"imageTagDB", value: "${params.imageTagDB}"], - //[$class: 'StringParameterValue', name:"imageTagPOST", value: "${params.imageTagPOST}"]], wait: true) - } - - } - catch(err){ - currentBuild.result = 'Failure' - } -} -} From 04d0e6340a864b5d1fd758b4bc80326c7b4d06cc Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 8 Feb 2019 05:38:11 -0500 Subject: [PATCH 147/241] Without pull 08.02.2019 --- e2e-test-test.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e-test-test.py b/e2e-test-test.py index 6740e50..2ae928f 100644 --- a/e2e-test-test.py +++ b/e2e-test-test.py @@ -14,13 +14,13 @@ def check_services(): print("Test UI successfull pass") else: raise Exception("Fucking bitch!!!! Opssss") - URL_GET = "http://ui-service.testing.svc:5000/salaries" - time.sleep(5) - reques = requests.get(URL_GET) - if reques.status_code == 200: - print("UI success to GET") - else: - raise Exception("Fucking bitch again!!!! Opssss. You are unclever animal") +# URL_GET = "http://ui-service.testing.svc:5000/salaries" +# time.sleep(5) +# reques = requests.get(URL_GET) +# if reques.status_code == 200: +# print("UI success to GET") +# else: +# raise Exception("Fucking bitch again!!!! Opssss. You are unclever animal") if __name__ == '__main__': main() From 8f2e525436c7da810a354a0c3749d5692b5deaed Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 8 Feb 2019 06:04:37 -0500 Subject: [PATCH 148/241] Without pull 08.02.2018#1 --- Jenkinsfile | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 984ac83..72d47e4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ def label = "mypod-${UUID.randomUUID().toString()}" podTemplate(label: label, containers: [ - containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v2', command: 'cat', ttyEnabled: true), + 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: [ @@ -19,26 +19,6 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagGET_'), - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagUI_'), - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagDB_'), - stringParam( - defaultValue: '***', - description: 'Name', - name: 'namespace'), - stringParam( - defaultValue: '***', - description: '###', - name: 'e2e_YAML'), stringParam( defaultValue: '', description: 'TAG', From cbd0c7860649c151f92950c43aaeb6e73bea6cd0 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 8 Feb 2019 06:17:05 -0500 Subject: [PATCH 149/241] Without pull 08.02.2018#1 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 72d47e4..0b4ab87 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ properties([ parameters([ stringParam( defaultValue: '', - description: 'TAG', + description: 'TAG_Change', name: 'service') ]) ]) From f68b1ef3846a49a5d3b4de09a8c30441771dc6cc Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 8 Feb 2019 07:20:56 -0500 Subject: [PATCH 150/241] Without pull 08.02.2019#3 --- Jenkinsfile_deploy | 256 ++++++++++++++++++++++++++++++++----------- Jenkinsfile_e2e_test | 31 ++---- 2 files changed, 198 insertions(+), 89 deletions(-) diff --git a/Jenkinsfile_deploy b/Jenkinsfile_deploy index ee14102..a89795e 100644 --- a/Jenkinsfile_deploy +++ b/Jenkinsfile_deploy @@ -3,29 +3,191 @@ def label = "mypod-${UUID.randomUUID().toString()}" def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" +String deploy_db = """ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: production + name: db-service +spec: + selector: + matchLabels: + app: db-service + template: + metadata: + labels: + app: db-service + spec: + initContainers: + - image: 100.71.71.71:5000/init-container:${params.imageTagDB_} + name: init-container-postgres + env: + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] + containers: + - image: 100.71.71.71:5000/db-service:${params.imageTagDB_} + name: db-service + ports: + - containerPort: 5002 + env: + - name: POSTGRES_HOST + value: srmsystemdb + - name: POSTGRES_PORT + value: '5432' + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: db-service +spec: + selector: + app: db-service + ports: + - protocol: TCP + port: 5002 + targetPort: 5002 +--- +""" + +String deploy_ui = """ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: ui-service + labels: + app: ui +spec: + selector: + app: ui + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: production + name: ui-deployment +spec: + selector: + matchLabels: + app: ui + replicas: 1 + template: + metadata: + labels: + app: ui + spec: + containers: + - name: ui + image: 100.71.71.71:5000/ui-service:${params.imageTagUI_} + ports: + - containerPort: 5000 + env: + - name: POST_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: POST_SERVICE_URL + - name: VIEW_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: VIEW_SERVICE_URL +""" + +String deploy_get = """ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: production + name: get-deployment +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: 100.71.71.71:5000/get-service:${params.imageTagGET_} + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB +""" + properties([ parameters([ - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagGET'), - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagUI'), - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagDB'), stringParam( defaultValue: '***', description: '', - name: 'namespace') + name: 'service') ]) ]) podTemplate(label: label, containers: [ - containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', command: 'cat', ttyEnabled: true), + containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v3', command: 'cat', ttyEnabled: true), containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true) ], volumes: [ @@ -37,71 +199,33 @@ volumes: [ 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) - pathTocodedb=pwd() - } - dir('ui'){ - git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-UI.git', credentialsId: "${Creds}") - imageTagUI = sh (script: "git rev-parse --short HEAD", returnStdout: true) - pathTocodeui=pwd() - } - dir('post'){ - git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-POST.git', credentialsId: "${Creds}") - imageTagPOST = sh (script: "git rev-parse --short HEAD", returnStdout: true) - pathTocodepost=pwd() - } - dir('ini'){ - git(branch: "master", url: 'https://github.com/Kv-045DevOps/Kubik-DB.git', credentialsId: "${Creds}") - imageTagINI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) - pathTocodeini=pwd() - } - dir('get'){ - git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") - imageTagGET = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) - pathTocodeget = pwd() - } - - } stage("Deploy to Kubernetes"){ - if(params.imageTagDB != "***"){ - container("python-alpine"){ - sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/db-service ${params.imageTagDB}" - sh "python3 ${pathTocodedb}/sed_python.py ${pathTocodedb}/template.yaml ${dockerRegistry}/init-container ${params.imageTagDB}" - } + build(job: 'GitHub/Kubik-DB/master', parameters: [[$class: 'StringParameterValue', name:"service", value: "***"]], wait: true) + if(params.service == "db"){ container ("kubectl"){ - sh "kubectl apply -f ${pathTocodeini}/template.yaml" - sh "kubectl apply -f ${pathTocodedb}/template.yaml" + sh """echo "$deploy_db" | kubectl apply -f -""" } } - if(params.imageTagGET != "***"){ - container("python-alpine"){ - sh "python3 ${pathTocodeget}/sed_python.py ${pathTocodeget}/template.yaml ${dockerRegistry}/get-service ${params.imageTagGET}" - } + if(params.service == "get"){ container ("kubectl"){ - sh "kubectl apply -f ${pathTocodeget}/template.yaml" - } + sh """echo "$deploy_get" | kubectl apply -f -""" + } - if(params.imageTagUI != "***"){ - container("python-alpine"){ - sh "python3 ${pathTocodeui}/sed_python.py ${pathTocodeui}/template.yaml ${dockerRegistry}/ui-service ${params.imageTagUI}" } + if(params.service == "ui"){ container ("kubectl"){ - sh "kubectl apply -f ${pathTocodeui}/template.yaml" + sh """echo "$deploy_ui" | kubectl apply -f -""" + } } - if(params.imageTagPOST != "***"){ - container("python-alpine"){ - //sh "python3 ${pathTocodepost}/sed_python.py ${pathTocodepost}/template.yaml ${dockerRegistry}/post-service ${imageTagPOST}" - } + if(params.service == "post"){ container ("kubectl"){ - //sh "kubectl apply -f ${pathTocodepost}/template.yaml" + sh """echo "$deploy_post" | kubectl apply -f -""" + } - } + } } sleep 30 @@ -109,7 +233,7 @@ node(label) stage ("Prod Tests"){ container('python-alpine'){ sh 'echo "Here is prod test"' - sh "python3 ${pathTocodeget}/e2e-test-prod.py" + sh "python3 /e2e-test-prod.py" } } diff --git a/Jenkinsfile_e2e_test b/Jenkinsfile_e2e_test index 77451b6..c445c5c 100644 --- a/Jenkinsfile_e2e_test +++ b/Jenkinsfile_e2e_test @@ -269,22 +269,6 @@ spec: properties([ parameters([ - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagGET_'), - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagUI_'), - stringParam( - defaultValue: "***", - description: '', - name: 'imageTagDB_'), - stringParam( - defaultValue: '***', - description: '', - name: 'namespace'), stringParam( defaultValue: '***', description: '', @@ -293,7 +277,7 @@ properties([ ]) podTemplate(label: label, containers: [ - containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v1', command: 'cat', ttyEnabled: true), + 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), containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true) ], @@ -319,17 +303,18 @@ node(label) sleep 20 stage ("E2E Tests - Stage 2"){ container('python-alpine'){ - // sh 'echo "Here is e2e test"' - //sh "python3 ${pathTocodeget}/e2e-test-test.py" + sh 'echo "Here is e2e test"' + sh "python3 /e2e-test-test.py" } } stage ("Deploy"){ - //build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET", value: "${params.imageTagGET}"], - //[$class: 'StringParameterValue', name:"imageTagUI", value: "${params.imageTagUI}"], - //[$class: 'StringParameterValue', name:"imageTagDB", value: "${params.imageTagDB}"], - //[$class: 'StringParameterValue', name:"imageTagPOST", value: "${params.imageTagPOST}"]], wait: true) + build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], + [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], + [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], + [$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], + [$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) } } From 9beb828f54c74751a16bc0f0b7929189a93491aa Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 8 Feb 2019 07:40:14 -0500 Subject: [PATCH 151/241] Last without helm --- Jenkinsfile_deploy | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile_deploy b/Jenkinsfile_deploy index a89795e..a9dd326 100644 --- a/Jenkinsfile_deploy +++ b/Jenkinsfile_deploy @@ -228,12 +228,11 @@ node(label) } } - sleep 30 + sleep 10 stage ("Prod Tests"){ container('python-alpine'){ - sh 'echo "Here is prod test"' - sh "python3 /e2e-test-prod.py" + //sh "python3 /e2e-test-prod.py" } } From d4e057dc540d83d36edd2852267ee0cc21a29e97 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 11:21:17 -0500 Subject: [PATCH 152/241] Test Jenkinsfile Helm E2E-testing --- DockerFolder/HELM_KUBECTL/Dockerfile | 28 ++ .../jenkins_docker_image | 0 E2E-Test.yaml | 11 - Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 59 ++++ List-Helm-Charts/e2e-testing/.helmignore | 22 ++ List-Helm-Charts/e2e-testing/Chart.yaml | 5 + .../e2e-testing/templates/templates-e2e.yaml | 298 ++++++------------ .../templates/tests/test-connection.yaml | 18 ++ List-Helm-Charts/e2e-testing/values.yaml | 34 ++ 9 files changed, 266 insertions(+), 209 deletions(-) create mode 100644 DockerFolder/HELM_KUBECTL/Dockerfile rename dockerfile_jenkins_image => DockerFolder/jenkins_docker_image (100%) delete mode 100644 E2E-Test.yaml create mode 100644 Jenkinsfiles_Helm/Jenkinsfile_e2e_test create mode 100644 List-Helm-Charts/e2e-testing/.helmignore create mode 100644 List-Helm-Charts/e2e-testing/Chart.yaml rename Kuben.yml => List-Helm-Charts/e2e-testing/templates/templates-e2e.yaml (64%) create mode 100644 List-Helm-Charts/e2e-testing/templates/tests/test-connection.yaml create mode 100644 List-Helm-Charts/e2e-testing/values.yaml diff --git a/DockerFolder/HELM_KUBECTL/Dockerfile b/DockerFolder/HELM_KUBECTL/Dockerfile new file mode 100644 index 0000000..d61dcfe --- /dev/null +++ b/DockerFolder/HELM_KUBECTL/Dockerfile @@ -0,0 +1,28 @@ +FROM alpine + +ARG VCS_REF +ARG BUILD_DATE + +# Metadata +LABEL org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.name="helm-kubectl" \ + org.label-schema.url="https://hub.docker.com/r/dtzar/helm-kubectl/" \ + org.label-schema.vcs-url="https://github.com/dtzar/helm-kubectl" \ + org.label-schema.build-date=$BUILD_DATE + +# Note: Latest version of kubectl may be found at: +# https://aur.archlinux.org/packages/kubectl-bin/ +ENV KUBE_LATEST_VERSION="v1.13.2" +# Note: Latest version of helm may be found at: +# https://github.com/kubernetes/helm/releases +ENV HELM_VERSION="v2.12.3" + +RUN apk add --no-cache ca-certificates bash git \ + && wget -q https://storage.googleapis.com/kubernetes-release/release/${KUBE_LATEST_VERSION}/bin/linux/amd64/kubectl -O /usr/local/bin/kubectl \ + && chmod +x /usr/local/bin/kubectl \ + && wget -q https://storage.googleapis.com/kubernetes-helm/helm-${HELM_VERSION}-linux-amd64.tar.gz -O - | tar -xzO linux-amd64/helm > /usr/local/bin/helm \ + && chmod +x /usr/local/bin/helm + +WORKDIR /config + +CMD bash diff --git a/dockerfile_jenkins_image b/DockerFolder/jenkins_docker_image similarity index 100% rename from dockerfile_jenkins_image rename to DockerFolder/jenkins_docker_image diff --git a/E2E-Test.yaml b/E2E-Test.yaml deleted file mode 100644 index 977ea8f..0000000 --- a/E2E-Test.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: db-secret - namespace: testing -data: - username: ZGJhZG1pbg== - password: UGFzc3dvcmQ= - dbname: c3Jtc3lzdGVt -type: Opaque - diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test new file mode 100644 index 0000000..e51ba0c --- /dev/null +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -0,0 +1,59 @@ +def label = "mypod-${UUID.randomUUID().toString()}" +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + +String e2e_YAML = """ """ + +properties([ + parameters([ + stringParam( + defaultValue: '***', + description: '', + name: 'service') + ]) +]) + +podTemplate(label: label, 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), + containerTemplate(name: 'helm', image: 'ghostgoose33/kubectl_helm:v1', command: 'cat', ttyEnabled: true) +], +volumes: [ + hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') +], serviceAccount: "jenkins") +{ + + +node(label) +{ + try{ + + stage("E2E Test - Stage 1"){ + container('helm'){ + sh "helm upgrade --install --namespace production --name e2e-testing ${pathTocodeui}/ui-service --set Values.deploy.version=v1 --set image.tag=${imageTagUI}" + sh "kubectl get pods --namespace=testing" + } + } + sleep 20 + stage ("E2E Tests - Stage 2"){ + container('python-alpine'){ + sh 'echo "Here is e2e test"' + sh "python3 /e2e-test-test.py" + } + } + + stage ("Deploy"){ + + build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], + [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], + [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], + [$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], + [$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) + } + + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} diff --git a/List-Helm-Charts/e2e-testing/.helmignore b/List-Helm-Charts/e2e-testing/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/e2e-testing/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/e2e-testing/Chart.yaml b/List-Helm-Charts/e2e-testing/Chart.yaml new file mode 100644 index 0000000..b08cc5a --- /dev/null +++ b/List-Helm-Charts/e2e-testing/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: e2e-testing +version: 0.1.0 diff --git a/Kuben.yml b/List-Helm-Charts/e2e-testing/templates/templates-e2e.yaml similarity index 64% rename from Kuben.yml rename to List-Helm-Charts/e2e-testing/templates/templates-e2e.yaml index 69a6844..8ba8317 100644 --- a/Kuben.yml +++ b/List-Helm-Charts/e2e-testing/templates/templates-e2e.yaml @@ -1,98 +1,49 @@ +--- apiVersion: v1 kind: Namespace metadata: - name: testing - + name: {{ .Values.namespace }} --- apiVersion: v1 kind: ConfigMap metadata: - namespace: testing + namespace: {{ .Values.namespace }} name: services-address data: - POST_SERVICE_URL: post-service.production.svc - VIEW_SERVICE_URL: get-service.production.svc - DB_URL: db-service.production.svc - URL_DB: db-service.production.svc - ---- - -#Test secret + POST_SERVICE_URL: post-service.testing.svc + VIEW_SERVICE_URL: get-service.testing.svc + DB_URL: db-service.testing.svc + URL_DB: db-service.testing.svc +--- apiVersion: v1 kind: Secret metadata: - name: db-secret - namespace: testing + name: db-secret + namespace: {{ .Values.namespace }} data: - username: ZGJhZG1pbg== - password: UGFzc3dvcmQ= - dbname: c3Jtc3lzdGVt + username: ZGJhZG1pbg== + password: UGFzc3dvcmQ= + dbname: c3Jtc3lzdGVt type: Opaque - -# --- -# kind: PersistentVolume -# apiVersion: v1 -# metadata: -# name: postgres-pv -# labels: -# type: local -# spec: -# storageClassName: manual -# capacity: -# storage: 100M -# accessModes: -# - ReadWriteOnce -# hostPath: -# path: "/mnt/data" - -# --- -# kind: StorageClass -# apiVersion: storage.k8s.io/v1 -# metadata: -# name: slow -# provisioner: kubernetes.io/aws-ebs -# parameters: -# type: gp2 -# zone: sa-east-1a -# fsType: ext4 -# reclaimPolicy: Retain - --- apiVersion: v1 kind: PersistentVolumeClaim metadata: - namespace: testing + namespace: {{ .Values.namespace }} labels: app: pvc-postgres name: postgres-pvc spec: - #storageClassName: slow accessModes: - ReadWriteOnce resources: requests: storage: 2Gi - -# --- -# apiVersion: v1 -# kind: PersistentVolumeClaim -# metadata: -# labels: -# service: postgresdb -# namespace: production -# name: postgres-pvc -# spec: -# accessModes: -# - ReadWriteOnce -# resources: -# requests: -# storage: 2Gi - --- apiVersion: extensions/v1beta1 kind: Deployment metadata: - namespace: testing + namespace: {{ .Values.namespace }} name: postgres labels: service: postgresdb @@ -105,7 +56,7 @@ spec: initContainers: - name: volume-mount-hack image: busybox - command: ["sh", "-c", "chown -R 999:999 /var/lib/postgresql/"] + command: ["sh", "-c", "chown -R 999.999 /var/lib/postgresql/"] volumeMounts: - name: postgres-pv-claim mountPath: /var/lib/postgresql/data @@ -139,12 +90,11 @@ spec: - name: postgres-pv-claim persistentVolumeClaim: claimName: postgres-pvc - --- kind: Service apiVersion: v1 metadata: - namespace: testing + namespace: {{ .Values.namespace }} name: srmsystemdb spec: selector: @@ -154,98 +104,84 @@ spec: port: 5432 targetPort: 5432 --- - -kind: Service -apiVersion: v1 -metadata: - name: post-service - namespace: testing - labels: - app: post -spec: - selector: - app: post - ports: - - protocol: TCP - port: 5001 - targetPort: 5001 - ---- apiVersion: apps/v1 kind: Deployment metadata: - name: post-deployment - namespace: testing + namespace: {{ .Values.namespace }} + name: db-service spec: selector: matchLabels: - app: post - replicas: 1 + app: db-service template: metadata: labels: - app: post + app: db-service spec: + initContainers: + - image: "{{ .Values.image.repository }}/init-container:{{ .Values.image.tag.db }}" + name: init-container-postgres + env: + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] containers: - - name: post - image: 100.71.71.71:5000/post-service:2.1 + - image: "{{ .Values.image.repository }}/db-service:{{ .Values.image.tag.db }}" + name: db-service ports: - - containerPort: 5001 + - containerPort: 5002 env: - - name: DB_URL + - name: POSTGRES_HOST + value: srmsystemdb + - name: POSTGRES_PORT + value: '5432' + - name: PGDATABASE valueFrom: - configMapKeyRef: - name: services-address - key: DB_URL + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password --- kind: Service apiVersion: v1 metadata: - name: get-service - namespace: testing - labels: - app: get + namespace: {{ .Values.namespace }} + name: db-service spec: selector: - app: get + app: db-service ports: - protocol: TCP - port: 5003 - targetPort: 5003 - ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: get-deployment - namespace: testing -spec: - selector: - matchLabels: - app: get - replicas: 1 - template: - metadata: - labels: - app: get - spec: - containers: - - name: get - image: 100.71.71.71:5000/get-service:v2 - ports: - - containerPort: 5003 - env: - - name: URL_DB - valueFrom: - configMapKeyRef: - name: services-address - key: URL_DB + port: 5002 + targetPort: 5002 --- kind: Service apiVersion: v1 metadata: + namespace: {{ .Values.namespace }} name: ui-service - namespace: testing labels: app: ui spec: @@ -255,13 +191,12 @@ spec: - protocol: TCP port: 5000 targetPort: 5000 - --- apiVersion: apps/v1 kind: Deployment metadata: + namespace: {{ .Values.namespace }} name: ui-deployment - namespace: testing spec: selector: matchLabels: @@ -274,88 +209,55 @@ spec: spec: containers: - name: ui - image: 100.71.71.71:5000/ui-service:latest + image: "{{ .Values.image.repository }}/ui-service:{{ .Values.image.tag.ui }}" ports: - containerPort: 5000 env: - - name: POST_SERVICE_URL - valueFrom: - configMapKeyRef: - name: services-address - key: POST_SERVICE_URL - name: VIEW_SERVICE_URL valueFrom: configMapKeyRef: name: services-address key: VIEW_SERVICE_URL - --- -apiVersion: extensions/v1beta1 +kind: Service +apiVersion: v1 +metadata: + namespace: {{ .Values.namespace }} + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 +--- +apiVersion: apps/v1 kind: Deployment metadata: - namespace: testing - name: db-service + namespace: {{ .Values.namespace }} + name: get-deployment spec: + selector: + matchLabels: + app: get + replicas: 1 template: metadata: labels: - app: db-service + app: get spec: - initContainers: - - image: 100.71.71.71:5000/init-container:latest - name: init-container-postgres - env: - - name: PGDATABASE - valueFrom: - secretKeyRef: - name: db-secret - key: dbname - - name: PGUSER - valueFrom: - secretKeyRef: - name: db-secret - key: username - - name: PGPASSWORD - valueFrom: - secretKeyRef: - name: db-secret - key: password - command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] containers: - - image: 100.71.71.71:5000/db-service:latest - name: db-service + - name: get + image: "{{ .Values.image.repository }}/get-service:{{ .Values.image.tag.get }}" ports: - - containerPort: 5002 + - containerPort: 5003 env: - - name: POSTGRES_HOST - value: srmsystemdb - - name: POSTGRES_PORT - value: "5432" - - name: PGDATABASE - valueFrom: - secretKeyRef: - name: db-secret - key: dbname - - name: PGUSER - valueFrom: - secretKeyRef: - name: db-secret - key: username - - name: PGPASSWORD + - name: URL_DB valueFrom: - secretKeyRef: - name: db-secret - key: password + configMapKeyRef: + name: services-address + key: URL_DB --- -kind: Service -apiVersion: v1 -metadata: - namespace: testing - name: db-service -spec: - selector: - app: db-service - ports: - - protocol: TCP - port: 5002 - targetPort: 5002 diff --git a/List-Helm-Charts/e2e-testing/templates/tests/test-connection.yaml b/List-Helm-Charts/e2e-testing/templates/tests/test-connection.yaml new file mode 100644 index 0000000..b91da22 --- /dev/null +++ b/List-Helm-Charts/e2e-testing/templates/tests/test-connection.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "e2e-testing.fullname" . }}-test-connection" + labels: + app.kubernetes.io/name: {{ include "e2e-testing.name" . }} + helm.sh/chart: {{ include "e2e-testing.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "e2e-testing.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/List-Helm-Charts/e2e-testing/values.yaml b/List-Helm-Charts/e2e-testing/values.yaml new file mode 100644 index 0000000..5aab868 --- /dev/null +++ b/List-Helm-Charts/e2e-testing/values.yaml @@ -0,0 +1,34 @@ +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: + ui: "" + get: "" + db: "" + post: "" + +app: + name: ui + +service: + type: ClusterIP + port: 5000 + +namespace: testing + +deploy: + version: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + From 97e5d3bc2515e53c30aff99210276a953b24788e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 11:46:51 -0500 Subject: [PATCH 153/241] Test Jenkinsfile Helm E2E-testing --- Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test index e51ba0c..9ed133e 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -2,7 +2,7 @@ def label = "mypod-${UUID.randomUUID().toString()}" def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" -String e2e_YAML = """ """ +String e2e_YAML = """empty""" properties([ parameters([ From 8f82e4e7d20d424b6ffbaca0bdf9bfd96bea7c74 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 11:55:54 -0500 Subject: [PATCH 154/241] Test Jenkinsfile Helm E2E-testing --- Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test index 9ed133e..e51ba0c 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -2,7 +2,7 @@ def label = "mypod-${UUID.randomUUID().toString()}" def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" -String e2e_YAML = """empty""" +String e2e_YAML = """ """ properties([ parameters([ From d0c28e50ec074c8d2e6ac5ef9cc3293f85a8a4de Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 12:02:40 -0500 Subject: [PATCH 155/241] Test Jenkinsfile Helm E2E-testing --- .../templates/tests/test-connection.yaml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 List-Helm-Charts/e2e-testing/templates/tests/test-connection.yaml diff --git a/List-Helm-Charts/e2e-testing/templates/tests/test-connection.yaml b/List-Helm-Charts/e2e-testing/templates/tests/test-connection.yaml deleted file mode 100644 index b91da22..0000000 --- a/List-Helm-Charts/e2e-testing/templates/tests/test-connection.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "e2e-testing.fullname" . }}-test-connection" - labels: - app.kubernetes.io/name: {{ include "e2e-testing.name" . }} - helm.sh/chart: {{ include "e2e-testing.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} - annotations: - "helm.sh/hook": test-success -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "e2e-testing.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never From b94928b2895b49f6cb9d694f8cc99202d95751be Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 12:08:45 -0500 Subject: [PATCH 156/241] Test Jenkinsfile Helm E2E-testing --- List-Helm-Charts/e2e-testing/templates/templates-e2e.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/List-Helm-Charts/e2e-testing/templates/templates-e2e.yaml b/List-Helm-Charts/e2e-testing/templates/templates-e2e.yaml index 8ba8317..4f6bbc5 100644 --- a/List-Helm-Charts/e2e-testing/templates/templates-e2e.yaml +++ b/List-Helm-Charts/e2e-testing/templates/templates-e2e.yaml @@ -1,10 +1,5 @@ --- apiVersion: v1 -kind: Namespace -metadata: - name: {{ .Values.namespace }} ---- -apiVersion: v1 kind: ConfigMap metadata: namespace: {{ .Values.namespace }} From 8c5bbc0993869a08fa758325de3f2b85c0fa22f3 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 12:15:28 -0500 Subject: [PATCH 157/241] Test Jenkinsfile Helm E2E-testing --- Jenkinsfile_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_main b/Jenkinsfile_main index f3334b3..0f3b84d 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -21,7 +21,7 @@ properties([ description: 'Current version', name: 'imageTagPOST_'), stringParam( - defaultValue: '', + defaultValue: '*', description: 'E2E Test', name: 'e2e_YAML') ]) From c5812384dc12e7c3f3ac2dcc3543b4b8626685a5 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 12:28:15 -0500 Subject: [PATCH 158/241] Test Jenkinsfile Helm E2E-testing --- Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test index e51ba0c..dc03dab 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -27,10 +27,17 @@ volumes: [ node(label) { try{ - + stage("Pre-Test"){ + dir('get'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + tmp = "1" + pathTocodeget = pwd() + } + } stage("E2E Test - Stage 1"){ container('helm'){ - sh "helm upgrade --install --namespace production --name e2e-testing ${pathTocodeui}/ui-service --set Values.deploy.version=v1 --set image.tag=${imageTagUI}" + sh "helm upgrade --install --force --namespace testing e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set deploy.version=v1 --set image.tag.ui=${params.imageTagUI_} --set image.tag.get=${params.imageTagGET_} --set image.tag.db=${params.imageTagDB_}" sh "kubectl get pods --namespace=testing" } } @@ -44,11 +51,11 @@ node(label) stage ("Deploy"){ - build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], - [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], - [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], - [$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], - [$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) + //build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], + //[$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], + //[$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], + //[$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], + //[$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) } } From bd9523973479195a77826a882a81c2e41652fea9 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 12:40:59 -0500 Subject: [PATCH 159/241] Test Jenkinsfile Helm E2E-testing --- Jenkinsfile_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_main b/Jenkinsfile_main index 0f3b84d..f3334b3 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -21,7 +21,7 @@ properties([ description: 'Current version', name: 'imageTagPOST_'), stringParam( - defaultValue: '*', + defaultValue: '', description: 'E2E Test', name: 'e2e_YAML') ]) From 9b94f1cf1351034e49f87df28815258996544f1d Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 12:48:42 -0500 Subject: [PATCH 160/241] Test Jenkinsfile Helm E2E-testing --- Jenkinsfile_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_main b/Jenkinsfile_main index f3334b3..0f3b84d 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -21,7 +21,7 @@ properties([ description: 'Current version', name: 'imageTagPOST_'), stringParam( - defaultValue: '', + defaultValue: '*', description: 'E2E Test', name: 'e2e_YAML') ]) From eb123897306c03b8fa36e629c44e78c99eb9d814 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 12:56:22 -0500 Subject: [PATCH 161/241] Test Jenkinsfile Helm E2E-testing --- Jenkinsfile_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_main b/Jenkinsfile_main index 0f3b84d..f3334b3 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -21,7 +21,7 @@ properties([ description: 'Current version', name: 'imageTagPOST_'), stringParam( - defaultValue: '*', + defaultValue: '', description: 'E2E Test', name: 'e2e_YAML') ]) From 5b9bd84e7b4484c737740ba770970c8d4d2b3bfb Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 13:09:59 -0500 Subject: [PATCH 162/241] Test Jenkinsfile Helm E2E-testing --- Jenkinsfile_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_main b/Jenkinsfile_main index f3334b3..0f3b84d 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -21,7 +21,7 @@ properties([ description: 'Current version', name: 'imageTagPOST_'), stringParam( - defaultValue: '', + defaultValue: '*', description: 'E2E Test', name: 'e2e_YAML') ]) From 40f4f252f8a411104eb5f3d462a12ddb1d239a57 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 13:24:25 -0500 Subject: [PATCH 163/241] Test Jenkinsfile Helm E2E-testing --- Jenkinsfile_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_main b/Jenkinsfile_main index 0f3b84d..f3334b3 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -21,7 +21,7 @@ properties([ description: 'Current version', name: 'imageTagPOST_'), stringParam( - defaultValue: '*', + defaultValue: '', description: 'E2E Test', name: 'e2e_YAML') ]) From f1583fb1646181e36dc43933bb9f979f1a41a3fd Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 16:56:12 -0500 Subject: [PATCH 164/241] Add testing helm charts for Deploy --- Jenkinsfiles_Helm/Jenkinsfile_deploy | 72 ++++++++++++++++++ Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 3 +- List-Helm-Charts/db-service/.helmignore | 22 ++++++ List-Helm-Charts/db-service/Chart.yaml | 5 ++ .../db-service/templates/template.yaml | 74 +++++++++++++++++++ List-Helm-Charts/db-service/values.yaml | 31 ++++++++ List-Helm-Charts/get-service/.helmignore | 22 ++++++ List-Helm-Charts/get-service/Chart.yaml | 5 ++ .../get-service/templates/template.yaml | 43 +++++++++++ List-Helm-Charts/get-service/values.yaml | 31 ++++++++ List-Helm-Charts/post-service/.helmignore | 22 ++++++ List-Helm-Charts/post-service/Chart.yaml | 5 ++ .../post-service/templates/template.yaml | 51 +++++++++++++ List-Helm-Charts/post-service/values.yaml | 31 ++++++++ List-Helm-Charts/ui-service/.helmignore | 22 ++++++ List-Helm-Charts/ui-service/Chart.yaml | 5 ++ .../ui-service/templates/template.yaml | 51 +++++++++++++ List-Helm-Charts/ui-service/values.yaml | 31 ++++++++ 18 files changed, 525 insertions(+), 1 deletion(-) create mode 100644 Jenkinsfiles_Helm/Jenkinsfile_deploy create mode 100644 List-Helm-Charts/db-service/.helmignore create mode 100644 List-Helm-Charts/db-service/Chart.yaml create mode 100644 List-Helm-Charts/db-service/templates/template.yaml create mode 100644 List-Helm-Charts/db-service/values.yaml create mode 100644 List-Helm-Charts/get-service/.helmignore create mode 100644 List-Helm-Charts/get-service/Chart.yaml create mode 100644 List-Helm-Charts/get-service/templates/template.yaml create mode 100644 List-Helm-Charts/get-service/values.yaml create mode 100644 List-Helm-Charts/post-service/.helmignore create mode 100644 List-Helm-Charts/post-service/Chart.yaml create mode 100644 List-Helm-Charts/post-service/templates/template.yaml create mode 100644 List-Helm-Charts/post-service/values.yaml create mode 100644 List-Helm-Charts/ui-service/.helmignore create mode 100644 List-Helm-Charts/ui-service/Chart.yaml create mode 100644 List-Helm-Charts/ui-service/templates/template.yaml create mode 100644 List-Helm-Charts/ui-service/values.yaml diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy new file mode 100644 index 0000000..d24ac02 --- /dev/null +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -0,0 +1,72 @@ + +def label = "mypod-${UUID.randomUUID().toString()}" +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + + +properties([ + parameters([ + stringParam( + defaultValue: '***', + description: '', + name: 'service') + ]) +]) + +podTemplate(label: label, containers: [ + containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v3', command: 'cat', ttyEnabled: true), + containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true), + containerTemplate(name: 'helm', image: 'ghostgoose33/kubectl_helm:v1', command: 'cat', ttyEnabled: true) +], +volumes: [ + hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') +], serviceAccount: "jenkins") +{ + + +node(label) +{ + try{ + stage("Pre-Test"){ + dir('get'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + tmp = "1" + pathTocodeget = pwd() + } + } + stage("Deploy to Kubernetes"){ + build(job: 'GitHub/Kubik-DB/master', parameters: [[$class: 'StringParameterValue', name:"service", value: "***"]], wait: true) + if(params.service == "db"){ + container ("helm"){ + sh """helm upgrade --install --force --namespace production db-service ${pathTocodeget}/List-Helm-Charts/db-service --set deploy.version=v1 --set image.tag="$params.imageTagDB_" """ + + } + } + if(params.service == "get"){ + container ("helm"){ + sh """helm upgrade --install --force --namespace production get-service ${pathTocodeget}/List-Helm-Charts/get-service --set deploy.version=v1 --set image.tag="$params.imageTagGET_" """ + + } + } + if(params.service == "ui"){ + container ("helm"){ + sh """helm upgrade --install --force --namespace production ui-service ${pathTocodeget}/List-Helm-Charts/ui-service --set deploy.version=v1 --set image.tag="$params.imageTagUI_" """ + + } + } + + if(params.service == "post"){ + container ("helm"){ + sh """helm upgrade --install --force --namespace production post-service ${pathTocodeget}/List-Helm-Charts/post-service --set deploy.version=v1 --set image.tag="$params.imageTagPOST_" """ + + } + } + } + + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test index dc03dab..97959c4 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -37,7 +37,8 @@ node(label) } stage("E2E Test - Stage 1"){ container('helm'){ - sh "helm upgrade --install --force --namespace testing e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set deploy.version=v1 --set image.tag.ui=${params.imageTagUI_} --set image.tag.get=${params.imageTagGET_} --set image.tag.db=${params.imageTagDB_}" + sh """helm upgrade --install --force --namespace testing e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set deploy.version=v1 --set image.tag.ui="$params.imageTagUI_" \ + --set image.tag.get="$params.imageTagGET_" --set image.tag.db="$params.imageTagDB_" """ sh "kubectl get pods --namespace=testing" } } diff --git a/List-Helm-Charts/db-service/.helmignore b/List-Helm-Charts/db-service/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/db-service/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/db-service/Chart.yaml b/List-Helm-Charts/db-service/Chart.yaml new file mode 100644 index 0000000..847f529 --- /dev/null +++ b/List-Helm-Charts/db-service/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: db-service +version: 0.1.0 diff --git a/List-Helm-Charts/db-service/templates/template.yaml b/List-Helm-Charts/db-service/templates/template.yaml new file mode 100644 index 0000000..2923a0e --- /dev/null +++ b/List-Helm-Charts/db-service/templates/template.yaml @@ -0,0 +1,74 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: production + name: db-service +spec: + selector: + matchLabels: + app: db-service + template: + metadata: + labels: + app: db-service + spec: + initContainers: + - image: "{{ .Values.image.repository }}/init-container:{{ .Values.image.tag }}" + name: init-container-postgres + env: + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] + containers: + - image: "{{ .Values.image.repository }}/db-service:{{ .Values.image.tag }}" + name: db-service + ports: + - containerPort: 5002 + env: + - name: POSTGRES_HOST + value: srmsystemdb + - name: POSTGRES_PORT + value: '5432' + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: db-service +spec: + selector: + app: db-service + ports: + - protocol: TCP + port: 5002 + targetPort: 5002 +--- diff --git a/List-Helm-Charts/db-service/values.yaml b/List-Helm-Charts/db-service/values.yaml new file mode 100644 index 0000000..3fd9b23 --- /dev/null +++ b/List-Helm-Charts/db-service/values.yaml @@ -0,0 +1,31 @@ +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: "" + +app: + name: db + +service: + type: ClusterIP + port: 5000 + servicename: db-service + +namespace: production + +deploy: + version: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + diff --git a/List-Helm-Charts/get-service/.helmignore b/List-Helm-Charts/get-service/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/get-service/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/get-service/Chart.yaml b/List-Helm-Charts/get-service/Chart.yaml new file mode 100644 index 0000000..53452e8 --- /dev/null +++ b/List-Helm-Charts/get-service/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: get-service +version: 0.1.0 diff --git a/List-Helm-Charts/get-service/templates/template.yaml b/List-Helm-Charts/get-service/templates/template.yaml new file mode 100644 index 0000000..f318b2c --- /dev/null +++ b/List-Helm-Charts/get-service/templates/template.yaml @@ -0,0 +1,43 @@ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: production + name: get-deployment +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: "{{ .Values.image.repository }}/get-service:{{ .Values.image.tag }}" + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB diff --git a/List-Helm-Charts/get-service/values.yaml b/List-Helm-Charts/get-service/values.yaml new file mode 100644 index 0000000..45f3e69 --- /dev/null +++ b/List-Helm-Charts/get-service/values.yaml @@ -0,0 +1,31 @@ +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: "" + +app: + name: get + +service: + type: ClusterIP + port: 5000 + servicename: get-service + +namespace: production + +deploy: + version: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + diff --git a/List-Helm-Charts/post-service/.helmignore b/List-Helm-Charts/post-service/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/post-service/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/post-service/Chart.yaml b/List-Helm-Charts/post-service/Chart.yaml new file mode 100644 index 0000000..c413ed8 --- /dev/null +++ b/List-Helm-Charts/post-service/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: post-service +version: 0.1.0 diff --git a/List-Helm-Charts/post-service/templates/template.yaml b/List-Helm-Charts/post-service/templates/template.yaml new file mode 100644 index 0000000..9b2de82 --- /dev/null +++ b/List-Helm-Charts/post-service/templates/template.yaml @@ -0,0 +1,51 @@ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: {{ .Values.namespace }} + name: {{ .Values.service.servicename }} + labels: + app: {{ .Values.app.name }} + version: {{ .Values.deploy.version }} +spec: + selector: + app: {{ .Values.app.name }} + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: ui-deployment +spec: + selector: + matchLabels: + app: {{ .Values.app.name }} + version: {{ .Values.deploy.version }} + replicas: 1 + template: + metadata: + labels: + app: {{ .Values.app.name }} + version: {{ .Values.deploy.version }} + spec: + containers: + - name: {{ .Values.app.name }} + image: "{{ .Values.image.repository }}/{{ .Values.service.servicename }}:{{ .Values.image.tag }}" + ports: + - containerPort: 5000 + env: + - name: POST_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: POST_SERVICE_URL + - name: VIEW_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: VIEW_SERVICE_URL diff --git a/List-Helm-Charts/post-service/values.yaml b/List-Helm-Charts/post-service/values.yaml new file mode 100644 index 0000000..2a71e87 --- /dev/null +++ b/List-Helm-Charts/post-service/values.yaml @@ -0,0 +1,31 @@ +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: "" + +app: + name: ui + +service: + type: ClusterIP + port: 5000 + servicename: ui-service + +namespace: production + +deploy: + version: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + diff --git a/List-Helm-Charts/ui-service/.helmignore b/List-Helm-Charts/ui-service/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/ui-service/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/ui-service/Chart.yaml b/List-Helm-Charts/ui-service/Chart.yaml new file mode 100644 index 0000000..d5aae26 --- /dev/null +++ b/List-Helm-Charts/ui-service/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: ui-service +version: 0.1.0 diff --git a/List-Helm-Charts/ui-service/templates/template.yaml b/List-Helm-Charts/ui-service/templates/template.yaml new file mode 100644 index 0000000..9b2de82 --- /dev/null +++ b/List-Helm-Charts/ui-service/templates/template.yaml @@ -0,0 +1,51 @@ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: {{ .Values.namespace }} + name: {{ .Values.service.servicename }} + labels: + app: {{ .Values.app.name }} + version: {{ .Values.deploy.version }} +spec: + selector: + app: {{ .Values.app.name }} + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: ui-deployment +spec: + selector: + matchLabels: + app: {{ .Values.app.name }} + version: {{ .Values.deploy.version }} + replicas: 1 + template: + metadata: + labels: + app: {{ .Values.app.name }} + version: {{ .Values.deploy.version }} + spec: + containers: + - name: {{ .Values.app.name }} + image: "{{ .Values.image.repository }}/{{ .Values.service.servicename }}:{{ .Values.image.tag }}" + ports: + - containerPort: 5000 + env: + - name: POST_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: POST_SERVICE_URL + - name: VIEW_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: VIEW_SERVICE_URL diff --git a/List-Helm-Charts/ui-service/values.yaml b/List-Helm-Charts/ui-service/values.yaml new file mode 100644 index 0000000..2a71e87 --- /dev/null +++ b/List-Helm-Charts/ui-service/values.yaml @@ -0,0 +1,31 @@ +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: "" + +app: + name: ui + +service: + type: ClusterIP + port: 5000 + servicename: ui-service + +namespace: production + +deploy: + version: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + From 479f9495ceaf072ab93d385caa94a4506303162f Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 17:10:43 -0500 Subject: [PATCH 165/241] Add testing helm charts for Deploy --- Jenkinsfile_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_main b/Jenkinsfile_main index f3334b3..0f3b84d 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -21,7 +21,7 @@ properties([ description: 'Current version', name: 'imageTagPOST_'), stringParam( - defaultValue: '', + defaultValue: '*', description: 'E2E Test', name: 'e2e_YAML') ]) From 126dd53acdc74b495adfe8f60f55aca61dde65c4 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 17:26:32 -0500 Subject: [PATCH 166/241] Add testing helm charts for Deploy --- Jenkinsfile_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_main b/Jenkinsfile_main index 0f3b84d..f3334b3 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -21,7 +21,7 @@ properties([ description: 'Current version', name: 'imageTagPOST_'), stringParam( - defaultValue: '*', + defaultValue: '', description: 'E2E Test', name: 'e2e_YAML') ]) From 2c9581f7e175dcfb043c3a4b9986e4ab09fa3594 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 17:54:55 -0500 Subject: [PATCH 167/241] Add testing helm charts for Deploy --- Jenkinsfile_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_main b/Jenkinsfile_main index f3334b3..0f3b84d 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -21,7 +21,7 @@ properties([ description: 'Current version', name: 'imageTagPOST_'), stringParam( - defaultValue: '', + defaultValue: '*', description: 'E2E Test', name: 'e2e_YAML') ]) From 930c1aafbaad66b9f7cd13f374e5e2d200519dc8 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 18:13:44 -0500 Subject: [PATCH 168/241] Add testing helm charts for Deploy --- Jenkinsfiles_Helm/Jenkinsfile_deploy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy index d24ac02..1b947a2 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_deploy +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -39,26 +39,26 @@ node(label) build(job: 'GitHub/Kubik-DB/master', parameters: [[$class: 'StringParameterValue', name:"service", value: "***"]], wait: true) if(params.service == "db"){ container ("helm"){ - sh """helm upgrade --install --force --namespace production db-service ${pathTocodeget}/List-Helm-Charts/db-service --set deploy.version=v1 --set image.tag="$params.imageTagDB_" """ + sh """helm upgrade --install --force --namespace production db-service ${pathTocodeget}/List-Helm-Charts/db-service --set deploy.version=v1 --set image.tag="$params.imageTagDB_" --wait""" } } if(params.service == "get"){ container ("helm"){ - sh """helm upgrade --install --force --namespace production get-service ${pathTocodeget}/List-Helm-Charts/get-service --set deploy.version=v1 --set image.tag="$params.imageTagGET_" """ + sh """helm upgrade --install --force --namespace production get-service ${pathTocodeget}/List-Helm-Charts/get-service --set deploy.version=v1 --set image.tag="$params.imageTagGET_" --wait""" } } if(params.service == "ui"){ container ("helm"){ - sh """helm upgrade --install --force --namespace production ui-service ${pathTocodeget}/List-Helm-Charts/ui-service --set deploy.version=v1 --set image.tag="$params.imageTagUI_" """ + sh """helm upgrade --install --force --namespace production ui-service ${pathTocodeget}/List-Helm-Charts/ui-service --set deploy.version=v1 --set image.tag="$params.imageTagUI_" --wait""" } } if(params.service == "post"){ container ("helm"){ - sh """helm upgrade --install --force --namespace production post-service ${pathTocodeget}/List-Helm-Charts/post-service --set deploy.version=v1 --set image.tag="$params.imageTagPOST_" """ + sh """helm upgrade --install --force --namespace production post-service ${pathTocodeget}/List-Helm-Charts/post-service --set deploy.version=v1 --set image.tag="$params.imageTagPOST_" --wait""" } } From 9af5bc5113c80336dd7384fd0183f483ea5bd2ee Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 18:22:42 -0500 Subject: [PATCH 169/241] Add testing helm charts for Deploy --- Jenkinsfiles_Helm/Jenkinsfile_deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy index 1b947a2..ca9d50b 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_deploy +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -7,7 +7,7 @@ def Creds = "git_cred" properties([ parameters([ stringParam( - defaultValue: '***', + defaultValue: '*', description: '', name: 'service') ]) From 5be762b7cd8dd547af38015b1dc09413a9664dd6 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 18:28:08 -0500 Subject: [PATCH 170/241] Add testing helm charts for Deploy --- Jenkinsfiles_Helm/Jenkinsfile_deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy index ca9d50b..7b0e2c7 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_deploy +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -7,7 +7,7 @@ def Creds = "git_cred" properties([ parameters([ stringParam( - defaultValue: '*', + defaultValue: '', description: '', name: 'service') ]) From 6bcfb8774afd29ef2835fc7d5eea22a2c22c6d2b Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 18:33:39 -0500 Subject: [PATCH 171/241] Add testing helm charts for Deploy --- Jenkinsfiles_Helm/Jenkinsfile_deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy index 7b0e2c7..ca9d50b 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_deploy +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -7,7 +7,7 @@ def Creds = "git_cred" properties([ parameters([ stringParam( - defaultValue: '', + defaultValue: '*', description: '', name: 'service') ]) From 6ded879fe234324c05baf1b474ca172a63a36fbd Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 18:44:17 -0500 Subject: [PATCH 172/241] Add testing helm charts for Deploy --- Jenkinsfiles_Helm/Jenkinsfile_deploy | 61 +++++++++++++--------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy index ca9d50b..d76c285 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_deploy +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -1,13 +1,13 @@ - def label = "mypod-${UUID.randomUUID().toString()}" def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" +String e2e_YAML = """ """ properties([ parameters([ - stringParam( - defaultValue: '*', + stringParam( + defaultValue: '***', description: '', name: 'service') ]) @@ -15,7 +15,7 @@ properties([ podTemplate(label: label, containers: [ containerTemplate(name: 'python-alpine', image: 'ghostgoose33/python-alp:v3', command: 'cat', ttyEnabled: true), - containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.8.8', command: 'cat', ttyEnabled: true), + containerTemplate(name: 'docker', image: 'ghostgoose33/docker-in:v1', command: 'cat', ttyEnabled: true), containerTemplate(name: 'helm', image: 'ghostgoose33/kubectl_helm:v1', command: 'cat', ttyEnabled: true) ], volumes: [ @@ -27,41 +27,38 @@ volumes: [ node(label) { try{ - stage("Pre-Test"){ - dir('get'){ + stage("Pre-Test"){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) tmp = "1" pathTocodeget = pwd() + + } + stage("E2E Test - Stage 1"){ + container('helm'){ + sh "helm version" + sh """helm upgrade --install --force --namespace testing e2e-testing List-Helm-Charts/e2e-testing --set image.tag.ui="$params.imageTagUI_", image.tag.get="$params.imageTagGET_", image.tag.db='$params.imageTagDB_'""" } } - stage("Deploy to Kubernetes"){ - build(job: 'GitHub/Kubik-DB/master', parameters: [[$class: 'StringParameterValue', name:"service", value: "***"]], wait: true) - if(params.service == "db"){ - container ("helm"){ - sh """helm upgrade --install --force --namespace production db-service ${pathTocodeget}/List-Helm-Charts/db-service --set deploy.version=v1 --set image.tag="$params.imageTagDB_" --wait""" - - } - } - if(params.service == "get"){ - container ("helm"){ - sh """helm upgrade --install --force --namespace production get-service ${pathTocodeget}/List-Helm-Charts/get-service --set deploy.version=v1 --set image.tag="$params.imageTagGET_" --wait""" - - } - } - if(params.service == "ui"){ - container ("helm"){ - sh """helm upgrade --install --force --namespace production ui-service ${pathTocodeget}/List-Helm-Charts/ui-service --set deploy.version=v1 --set image.tag="$params.imageTagUI_" --wait""" - - } - } + sleep 30 + stage ("E2E Tests - Stage 2"){ + container('helm'){ + sh "kubectl get pods --namespace=testing" + } + container('python-alpine'){ + sh 'echo "Here is e2e test"' + sh "python3 /e2e-test-test.py" + } + } + + stage ("Deploy"){ - if(params.service == "post"){ - container ("helm"){ - sh """helm upgrade --install --force --namespace production post-service ${pathTocodeget}/List-Helm-Charts/post-service --set deploy.version=v1 --set image.tag="$params.imageTagPOST_" --wait""" - - } - } + build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], + [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], + [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], + [$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], + [$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) } } From 875d5af508634669b6b913ed83bda48f9d3c8831 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 18:51:27 -0500 Subject: [PATCH 173/241] Add testing helm charts for Deploy --- Jenkinsfiles_Helm/Jenkinsfile_deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy index d76c285..0f4aaf6 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_deploy +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -38,7 +38,7 @@ node(label) stage("E2E Test - Stage 1"){ container('helm'){ sh "helm version" - sh """helm upgrade --install --force --namespace testing e2e-testing List-Helm-Charts/e2e-testing --set image.tag.ui="$params.imageTagUI_", image.tag.get="$params.imageTagGET_", image.tag.db='$params.imageTagDB_'""" + sh "helm upgrade --install --force e2e-testing List-Helm-Charts/e2e-testing --set image.tag.ui=${params.imageTagUI_},image.tag.get=${params.imageTagGET_},image.tag.db=${params.imageTagDB_} --namespace testing" } } sleep 30 From 35a3ffbb823d857655049721393be59f858b2a14 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 18:58:53 -0500 Subject: [PATCH 174/241] Add testing helm charts for Deploy --- Jenkinsfiles_Helm/Jenkinsfile_deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy index 0f4aaf6..4b140c2 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_deploy +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -38,7 +38,7 @@ node(label) stage("E2E Test - Stage 1"){ container('helm'){ sh "helm version" - sh "helm upgrade --install --force e2e-testing List-Helm-Charts/e2e-testing --set image.tag.ui=${params.imageTagUI_},image.tag.get=${params.imageTagGET_},image.tag.db=${params.imageTagDB_} --namespace testing" + sh """helm upgrade --install --force e2e-testing List-Helm-Charts/e2e-testing --set image.tag.ui="$params.imageTagUI_",image.tag.get="$params.imageTagGET_",image.tag.db="$params.imageTagDB_" --namespace testing""" } } sleep 30 From 420ee7fc771678e86d277760b286f1cffbc54f07 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Sun, 10 Feb 2019 19:05:28 -0500 Subject: [PATCH 175/241] Add testing helm charts for Deploy --- Jenkinsfiles_Helm/Jenkinsfile_deploy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy index 4b140c2..b97fc8f 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_deploy +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -2,7 +2,7 @@ def label = "mypod-${UUID.randomUUID().toString()}" def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" -String e2e_YAML = """ """ +String e2e_YAML = """a""" properties([ parameters([ From ff076c2001eebff008b19a3958c5c4598521bb0e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 07:23:11 -0500 Subject: [PATCH 176/241] String HELM JENKINS --- Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test index 97959c4..e6d865e 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -37,8 +37,7 @@ node(label) } stage("E2E Test - Stage 1"){ container('helm'){ - sh """helm upgrade --install --force --namespace testing e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set deploy.version=v1 --set image.tag.ui="$params.imageTagUI_" \ - --set image.tag.get="$params.imageTagGET_" --set image.tag.db="$params.imageTagDB_" """ + sh "helm upgrade --install --force --namespace testing e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set deploy.version=v1,image.tag.ui=${params.imageTagUI_},image.tag.get=${params.imageTagGET_},image.tag.db=${params.imageTagDB_}" sh "kubectl get pods --namespace=testing" } } From 614bfeafbba6d2fde9e4a12635247502f2e67604 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 07:30:28 -0500 Subject: [PATCH 177/241] String HELM JENKINS --- Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test index e6d865e..5f9387b 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -37,7 +37,8 @@ node(label) } stage("E2E Test - Stage 1"){ container('helm'){ - sh "helm upgrade --install --force --namespace testing e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set deploy.version=v1,image.tag.ui=${params.imageTagUI_},image.tag.get=${params.imageTagGET_},image.tag.db=${params.imageTagDB_}" + sh """helm upgrade --install --force --namespace testing e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set deploy.version=v1,\ + image.tag.ui=${params.imageTagUI_},image.tag.get=${params.imageTagGET_},image.tag.db=${params.imageTagDB_}""" sh "kubectl get pods --namespace=testing" } } From f4d9a82f18db603325befecacba04dada8fb2054 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 07:39:45 -0500 Subject: [PATCH 178/241] String HELM JENKINS --- Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test index 5f9387b..1b6f701 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -37,8 +37,7 @@ node(label) } stage("E2E Test - Stage 1"){ container('helm'){ - sh """helm upgrade --install --force --namespace testing e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set deploy.version=v1,\ - image.tag.ui=${params.imageTagUI_},image.tag.get=${params.imageTagGET_},image.tag.db=${params.imageTagDB_}""" + sh "helm upgrade --install --force --namespace testing e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set=deploy.version=v1,image.tag.ui=${params.imageTagUI_},image.tag.get=${params.imageTagGET_},image.tag.db=${params.imageTagDB_}" sh "kubectl get pods --namespace=testing" } } From 8e46658c24610baf44ee57d47e91d6e84b78cf17 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 08:04:28 -0500 Subject: [PATCH 179/241] String HELM JENKINS --- Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test index 1b6f701..068e6cc 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -37,7 +37,7 @@ node(label) } stage("E2E Test - Stage 1"){ container('helm'){ - sh "helm upgrade --install --force --namespace testing e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set=deploy.version=v1,image.tag.ui=${params.imageTagUI_},image.tag.get=${params.imageTagGET_},image.tag.db=${params.imageTagDB_}" + sh "helm upgrade --install --force e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set=deploy.version=v1,image.tag.ui=${params.imageTagUI_},image.tag.get=${params.imageTagGET_},image.tag.db=${params.imageTagDB_} --namespace testing" sh "kubectl get pods --namespace=testing" } } From b66fe6131a5c032f7c8942f1a5c50a9ed3b500c3 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 08:11:55 -0500 Subject: [PATCH 180/241] String HELM JENKINS#2 --- Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test index 068e6cc..355bb2f 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -3,6 +3,9 @@ def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" String e2e_YAML = """ """ +String get = "${params.imageTagGET_}" +String ui = "${params.imageTagUI_}" +String db = "${params.imageTagDB_}" properties([ parameters([ @@ -37,7 +40,7 @@ node(label) } stage("E2E Test - Stage 1"){ container('helm'){ - sh "helm upgrade --install --force e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set=deploy.version=v1,image.tag.ui=${params.imageTagUI_},image.tag.get=${params.imageTagGET_},image.tag.db=${params.imageTagDB_} --namespace testing" + sh "helm upgrade --install --force e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set=deploy.version=v1,image.tag.ui=${ui},image.tag.get=${get},image.tag.db=${db} --namespace testing" sh "kubectl get pods --namespace=testing" } } From f3b1a3ddb6f9be3bf4968c7dbc153b355a38eb51 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 08:17:24 -0500 Subject: [PATCH 181/241] String HELM JENKINS#2 --- Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test index 355bb2f..95bb51f 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -40,7 +40,7 @@ node(label) } stage("E2E Test - Stage 1"){ container('helm'){ - sh "helm upgrade --install --force e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set=deploy.version=v1,image.tag.ui=${ui},image.tag.get=${get},image.tag.db=${db} --namespace testing" + sh """helm upgrade --install --force e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set=deploy.version=v1,image.tag.ui=${ui},image.tag.get=${get},image.tag.db=${db} --namespace testing""" sh "kubectl get pods --namespace=testing" } } From 435a8f0c9f4214de01b41bea5716327775cc315d Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 08:36:26 -0500 Subject: [PATCH 182/241] Different part of E2E --- List-Helm-Charts/e2e-testing-db/.helmignore | 22 +++ List-Helm-Charts/e2e-testing-db/Chart.yaml | 5 + .../e2e-testing-db/templates/template.yaml | 174 ++++++++++++++++++ List-Helm-Charts/e2e-testing-db/values.yaml | 34 ++++ List-Helm-Charts/e2e-testing-get/.helmignore | 22 +++ List-Helm-Charts/e2e-testing-get/Chart.yaml | 5 + .../e2e-testing-get/templates/template.yaml | 43 +++++ List-Helm-Charts/e2e-testing-get/values.yaml | 34 ++++ List-Helm-Charts/e2e-testing-post/.helmignore | 22 +++ List-Helm-Charts/e2e-testing-post/Chart.yaml | 5 + .../e2e-testing-post/templates/NOTES.txt | 21 +++ .../e2e-testing-post/templates/_helpers.tpl | 32 ++++ .../templates/deployment.yaml | 51 +++++ .../e2e-testing-post/templates/ingress.yaml | 40 ++++ .../e2e-testing-post/templates/service.yaml | 19 ++ .../templates/tests/test-connection.yaml | 18 ++ List-Helm-Charts/e2e-testing-post/values.yaml | 34 ++++ List-Helm-Charts/e2e-testing-ui/.helmignore | 22 +++ List-Helm-Charts/e2e-testing-ui/Chart.yaml | 5 + .../e2e-testing-ui/templates/template.yaml | 43 +++++ List-Helm-Charts/e2e-testing-ui/values.yaml | 48 +++++ 21 files changed, 699 insertions(+) create mode 100644 List-Helm-Charts/e2e-testing-db/.helmignore create mode 100644 List-Helm-Charts/e2e-testing-db/Chart.yaml create mode 100644 List-Helm-Charts/e2e-testing-db/templates/template.yaml create mode 100644 List-Helm-Charts/e2e-testing-db/values.yaml create mode 100644 List-Helm-Charts/e2e-testing-get/.helmignore create mode 100644 List-Helm-Charts/e2e-testing-get/Chart.yaml create mode 100644 List-Helm-Charts/e2e-testing-get/templates/template.yaml create mode 100644 List-Helm-Charts/e2e-testing-get/values.yaml create mode 100644 List-Helm-Charts/e2e-testing-post/.helmignore create mode 100644 List-Helm-Charts/e2e-testing-post/Chart.yaml create mode 100644 List-Helm-Charts/e2e-testing-post/templates/NOTES.txt create mode 100644 List-Helm-Charts/e2e-testing-post/templates/_helpers.tpl create mode 100644 List-Helm-Charts/e2e-testing-post/templates/deployment.yaml create mode 100644 List-Helm-Charts/e2e-testing-post/templates/ingress.yaml create mode 100644 List-Helm-Charts/e2e-testing-post/templates/service.yaml create mode 100644 List-Helm-Charts/e2e-testing-post/templates/tests/test-connection.yaml create mode 100644 List-Helm-Charts/e2e-testing-post/values.yaml create mode 100644 List-Helm-Charts/e2e-testing-ui/.helmignore create mode 100644 List-Helm-Charts/e2e-testing-ui/Chart.yaml create mode 100644 List-Helm-Charts/e2e-testing-ui/templates/template.yaml create mode 100644 List-Helm-Charts/e2e-testing-ui/values.yaml diff --git a/List-Helm-Charts/e2e-testing-db/.helmignore b/List-Helm-Charts/e2e-testing-db/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-db/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/e2e-testing-db/Chart.yaml b/List-Helm-Charts/e2e-testing-db/Chart.yaml new file mode 100644 index 0000000..05690dc --- /dev/null +++ b/List-Helm-Charts/e2e-testing-db/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: e2e-testing-db +version: 0.1.0 diff --git a/List-Helm-Charts/e2e-testing-db/templates/template.yaml b/List-Helm-Charts/e2e-testing-db/templates/template.yaml new file mode 100644 index 0000000..7a85e9d --- /dev/null +++ b/List-Helm-Charts/e2e-testing-db/templates/template.yaml @@ -0,0 +1,174 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: {{ .Values.namespace }} + name: services-address +data: + POST_SERVICE_URL: post-service.testing.svc + VIEW_SERVICE_URL: get-service.testing.svc + DB_URL: db-service.testing.svc + URL_DB: db-service.testing.svc +--- +apiVersion: v1 +kind: Secret +metadata: + name: db-secret + namespace: {{ .Values.namespace }} +data: + username: ZGJhZG1pbg== + password: UGFzc3dvcmQ= + dbname: c3Jtc3lzdGVt +type: Opaque +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + namespace: {{ .Values.namespace }} + labels: + app: pvc-postgres + name: postgres-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi +--- +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + 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: {{ .Values.namespace }} + name: srmsystemdb +spec: + selector: + app: postgres + ports: + - protocol: TCP + port: 5432 + targetPort: 5432 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: db-service +spec: + selector: + matchLabels: + app: db-service + template: + metadata: + labels: + app: db-service + spec: + initContainers: + - image: "{{ .Values.image.repository }}/init-container:{{ .Values.image.tag.db }}" + name: init-container-postgres + env: + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] + containers: + - image: "{{ .Values.image.repository }}/db-service:{{ .Values.image.tag.db }}" + name: db-service + ports: + - containerPort: 5002 + env: + - name: POSTGRES_HOST + value: srmsystemdb + - name: POSTGRES_PORT + value: '5432' + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password +--- +kind: Service +apiVersion: v1 +metadata: + namespace: {{ .Values.namespace }} + name: db-service +spec: + selector: + app: db-service + ports: + - protocol: TCP + port: 5002 + targetPort: 5002 +--- diff --git a/List-Helm-Charts/e2e-testing-db/values.yaml b/List-Helm-Charts/e2e-testing-db/values.yaml new file mode 100644 index 0000000..5aab868 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-db/values.yaml @@ -0,0 +1,34 @@ +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: + ui: "" + get: "" + db: "" + post: "" + +app: + name: ui + +service: + type: ClusterIP + port: 5000 + +namespace: testing + +deploy: + version: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + diff --git a/List-Helm-Charts/e2e-testing-get/.helmignore b/List-Helm-Charts/e2e-testing-get/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-get/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/e2e-testing-get/Chart.yaml b/List-Helm-Charts/e2e-testing-get/Chart.yaml new file mode 100644 index 0000000..96ae34f --- /dev/null +++ b/List-Helm-Charts/e2e-testing-get/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: e2e-testing-get +version: 0.1.0 diff --git a/List-Helm-Charts/e2e-testing-get/templates/template.yaml b/List-Helm-Charts/e2e-testing-get/templates/template.yaml new file mode 100644 index 0000000..3733ba3 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-get/templates/template.yaml @@ -0,0 +1,43 @@ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: {{ .Values.namespace }} + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: get-deployment +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + spec: + containers: + - name: get + image: "{{ .Values.image.repository }}/get-service:{{ .Values.image.tag.get }}" + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB +--- diff --git a/List-Helm-Charts/e2e-testing-get/values.yaml b/List-Helm-Charts/e2e-testing-get/values.yaml new file mode 100644 index 0000000..5aab868 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-get/values.yaml @@ -0,0 +1,34 @@ +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: + ui: "" + get: "" + db: "" + post: "" + +app: + name: ui + +service: + type: ClusterIP + port: 5000 + +namespace: testing + +deploy: + version: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + diff --git a/List-Helm-Charts/e2e-testing-post/.helmignore b/List-Helm-Charts/e2e-testing-post/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-post/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/e2e-testing-post/Chart.yaml b/List-Helm-Charts/e2e-testing-post/Chart.yaml new file mode 100644 index 0000000..0561013 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-post/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: e2e-testing-post +version: 0.1.0 diff --git a/List-Helm-Charts/e2e-testing-post/templates/NOTES.txt b/List-Helm-Charts/e2e-testing-post/templates/NOTES.txt new file mode 100644 index 0000000..4ea37b1 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-post/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range $.Values.ingress.paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "e2e-testing-post.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + 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 {{ include "e2e-testing-post.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "e2e-testing-post.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "e2e-testing-post.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/List-Helm-Charts/e2e-testing-post/templates/_helpers.tpl b/List-Helm-Charts/e2e-testing-post/templates/_helpers.tpl new file mode 100644 index 0000000..89537a3 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-post/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "e2e-testing-post.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). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "e2e-testing-post.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "e2e-testing-post.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/List-Helm-Charts/e2e-testing-post/templates/deployment.yaml b/List-Helm-Charts/e2e-testing-post/templates/deployment.yaml new file mode 100644 index 0000000..842c695 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-post/templates/deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "e2e-testing-post.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} + helm.sh/chart: {{ include "e2e-testing-post.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/List-Helm-Charts/e2e-testing-post/templates/ingress.yaml b/List-Helm-Charts/e2e-testing-post/templates/ingress.yaml new file mode 100644 index 0000000..11639ab --- /dev/null +++ b/List-Helm-Charts/e2e-testing-post/templates/ingress.yaml @@ -0,0 +1,40 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "e2e-testing-post.fullname" . -}} +{{- $ingressPaths := .Values.ingress.paths -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} + helm.sh/chart: {{ include "e2e-testing-post.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . | quote }} + http: + paths: + {{- range $ingressPaths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} + {{- end }} +{{- end }} diff --git a/List-Helm-Charts/e2e-testing-post/templates/service.yaml b/List-Helm-Charts/e2e-testing-post/templates/service.yaml new file mode 100644 index 0000000..5ed0a02 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-post/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "e2e-testing-post.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} + helm.sh/chart: {{ include "e2e-testing-post.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/List-Helm-Charts/e2e-testing-post/templates/tests/test-connection.yaml b/List-Helm-Charts/e2e-testing-post/templates/tests/test-connection.yaml new file mode 100644 index 0000000..defab0d --- /dev/null +++ b/List-Helm-Charts/e2e-testing-post/templates/tests/test-connection.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "e2e-testing-post.fullname" . }}-test-connection" + labels: + app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} + helm.sh/chart: {{ include "e2e-testing-post.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "e2e-testing-post.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/List-Helm-Charts/e2e-testing-post/values.yaml b/List-Helm-Charts/e2e-testing-post/values.yaml new file mode 100644 index 0000000..5aab868 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-post/values.yaml @@ -0,0 +1,34 @@ +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: + ui: "" + get: "" + db: "" + post: "" + +app: + name: ui + +service: + type: ClusterIP + port: 5000 + +namespace: testing + +deploy: + version: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + diff --git a/List-Helm-Charts/e2e-testing-ui/.helmignore b/List-Helm-Charts/e2e-testing-ui/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-ui/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/e2e-testing-ui/Chart.yaml b/List-Helm-Charts/e2e-testing-ui/Chart.yaml new file mode 100644 index 0000000..cf0b9b3 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-ui/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: e2e-testing-ui +version: 0.1.0 diff --git a/List-Helm-Charts/e2e-testing-ui/templates/template.yaml b/List-Helm-Charts/e2e-testing-ui/templates/template.yaml new file mode 100644 index 0000000..080aec9 --- /dev/null +++ b/List-Helm-Charts/e2e-testing-ui/templates/template.yaml @@ -0,0 +1,43 @@ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: {{ .Values.namespace }} + name: ui-service + labels: + app: ui +spec: + selector: + app: ui + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: ui-deployment +spec: + selector: + matchLabels: + app: ui + replicas: 1 + template: + metadata: + labels: + app: ui + spec: + containers: + - name: ui + image: "{{ .Values.image.repository }}/ui-service:{{ .Values.image.tag.ui }}" + ports: + - containerPort: 5000 + env: + - name: VIEW_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: VIEW_SERVICE_URL +--- diff --git a/List-Helm-Charts/e2e-testing-ui/values.yaml b/List-Helm-Charts/e2e-testing-ui/values.yaml new file mode 100644 index 0000000..8a47a3b --- /dev/null +++ b/List-Helm-Charts/e2e-testing-ui/values.yaml @@ -0,0 +1,48 @@ +# Default values for e2e-testing-ui. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nginx + tag: stable + pullPolicy: IfNotPresent + +nameOverride: "" +fullnameOverride: "" + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + paths: [] + hosts: + - chart-example.local + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} From eab5c50b676a38c18caf99900c01ddc774179a7a Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 08:46:13 -0500 Subject: [PATCH 183/241] Different part of E2E --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0b4ab87..bcc7add 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '', + defaultValue: '*', description: 'TAG_Change', name: 'service') ]) From 10dda6a420b5d3a7921d70d3fac7464f8819f008 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 08:51:33 -0500 Subject: [PATCH 184/241] Different part of E2E --- List-Helm-Charts/e2e-testing-ui/values.yaml | 44 +++++++-------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/List-Helm-Charts/e2e-testing-ui/values.yaml b/List-Helm-Charts/e2e-testing-ui/values.yaml index 8a47a3b..5aab868 100644 --- a/List-Helm-Charts/e2e-testing-ui/values.yaml +++ b/List-Helm-Charts/e2e-testing-ui/values.yaml @@ -1,39 +1,30 @@ -# Default values for e2e-testing-ui. +# Default values for UI-SERVICE. # This is a YAML-formatted file. # Declare variables to be passed into your templates. replicaCount: 1 image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent + repository: 100.71.71.71:5000 + tag: + ui: "" + get: "" + db: "" + post: "" -nameOverride: "" -fullnameOverride: "" +app: + name: ui service: type: ClusterIP - port: 80 - -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - paths: [] - hosts: - - chart-example.local - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local + port: 5000 + +namespace: testing + +deploy: + version: "" resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. # limits: # cpu: 100m # memory: 128Mi @@ -41,8 +32,3 @@ resources: {} # cpu: 100m # memory: 128Mi -nodeSelector: {} - -tolerations: [] - -affinity: {} From 85b8d1795c0c627176508b12a4747bbcc9636a2d Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 09:06:48 -0500 Subject: [PATCH 185/241] Different part of E2E --- Jenkinsfiles_Helm/Jenkinsfile_deploy | 75 +++++++++++++++-------- Jenkinsfiles_Helm/Jenkinsfile_e2e_test_v2 | 71 +++++++++++++++++++++ 2 files changed, 119 insertions(+), 27 deletions(-) create mode 100644 Jenkinsfiles_Helm/Jenkinsfile_e2e_test_v2 diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy index b97fc8f..47c0203 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_deploy +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -1,12 +1,23 @@ + def label = "mypod-${UUID.randomUUID().toString()}" def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" -String e2e_YAML = """a""" +String deploy_db = """ + +""" + +String deploy_ui = """ + +""" + +String deploy_get = """ + +""" properties([ parameters([ - stringParam( + stringParam( defaultValue: '***', description: '', name: 'service') @@ -15,7 +26,6 @@ properties([ podTemplate(label: label, 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), containerTemplate(name: 'helm', image: 'ghostgoose33/kubectl_helm:v1', command: 'cat', ttyEnabled: true) ], volumes: [ @@ -27,38 +37,49 @@ volumes: [ node(label) { try{ - stage("Pre-Test"){ - + stage("Pre-Test"){ + dir('get'){ git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) tmp = "1" pathTocodeget = pwd() - - } - stage("E2E Test - Stage 1"){ - container('helm'){ - sh "helm version" - sh """helm upgrade --install --force e2e-testing List-Helm-Charts/e2e-testing --set image.tag.ui="$params.imageTagUI_",image.tag.get="$params.imageTagGET_",image.tag.db="$params.imageTagDB_" --namespace testing""" } } - sleep 30 - stage ("E2E Tests - Stage 2"){ - container('helm'){ - sh "kubectl get pods --namespace=testing" - } - container('python-alpine'){ - sh 'echo "Here is e2e test"' - sh "python3 /e2e-test-test.py" - } + stage("Deploy to Kubernetes"){ + build(job: 'GitHub/Kubik-DB/master', parameters: [[$class: 'StringParameterValue', name:"service", value: "***"]], wait: true) + if(params.service == "db"){ + container ("helm"){ + sh "helm upgrade --install --namespace production --force db-service ${pathTocodeget}/List-Helm-Charts/db-service --set=deploy.version=v1,image.tag=${db}" + + } + } + if(params.service == "get"){ + container ("helm"){ + sh "helm upgrade --install --namespace production --force get-service ${pathTocodeget}/List-Helm-Charts/get-service --set=deploy.version=v1,image.tag=${get}" + + } + } + if(params.service == "ui"){ + container ("helm"){ + sh "helm upgrade --install --namespace production --force ui-service ${pathTocodeget}/List-Helm-Charts/ui-service --set=deploy.version=v1,image.tag=${ui}" + + } + } + + if(params.service == "post"){ + container ("helm"){ + sh "helm upgrade --install --namespace production --force post-service ${pathTocodeget}/List-Helm-Charts/post-service --set=deploy.version=v1,image.tag=${post}" + + } + } } - stage ("Deploy"){ - - build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], - [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], - [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], - [$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], - [$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) + sleep 10 + + stage ("Prod Tests"){ + container('python-alpine'){ + //sh "python3 /e2e-test-prod.py" + } } } diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test_v2 b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test_v2 new file mode 100644 index 0000000..11d8230 --- /dev/null +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test_v2 @@ -0,0 +1,71 @@ +def label = "mypod-${UUID.randomUUID().toString()}" +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + +String e2e_YAML = """ """ +String get = "${params.imageTagGET_}" +String ui = "${params.imageTagUI_}" +String db = "${params.imageTagDB_}" + +properties([ + parameters([ + stringParam( + defaultValue: '***', + description: '', + name: 'service') + ]) +]) + +podTemplate(label: label, 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), + containerTemplate(name: 'helm', image: 'ghostgoose33/kubectl_helm:v1', command: 'cat', ttyEnabled: true) +], +volumes: [ + hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') +], serviceAccount: "jenkins") +{ + + +node(label) +{ + try{ + stage("Pre-Test"){ + dir('get'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + tmp = "1" + pathTocodeget = pwd() + } + } + stage("E2E Test - Stage 1"){ + container('helm'){ + sh "helm upgrade --install --namespace testing --force e2e-testing-db ${pathTocodeget}/List-Helm-Charts/e2e-testing-db --set=deploy.version=v1,image.tag.db=${db}" + sh "helm upgrade --install --namespace testing --force e2e-testing-get ${pathTocodeget}/List-Helm-Charts/e2e-testing-get --set=deploy.version=v1,image.tag.get=${get}" + sh "helm upgrade --install --namespace testing --force e2e-testing-ui ${pathTocodeget}/List-Helm-Charts/e2e-testing-ui --set=deploy.version=v1,image.tag.ui=${ui}" + sh "kubectl get pods --namespace=testing" + } + } + sleep 40 + stage ("E2E Tests - Stage 2"){ + container('python-alpine'){ + sh 'echo "Here is e2e test"' + sh "python3 /e2e-test-test.py" + } + } + + stage ("Deploy"){ + + //build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], + //[$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], + //[$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], + //[$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], + //[$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) + } + + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} From f8bf63be8104c0aa2de120aa88e893d7345ccae1 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 11:43:36 -0500 Subject: [PATCH 186/241] Helm --- Jenkinsfiles_Helm/Jenkinsfile_deploy | 31 +++++--------------------- Jenkinsfiles_Helm/Jenkinsfile_e2e_test | 24 ++++++-------------- 2 files changed, 12 insertions(+), 43 deletions(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy index 47c0203..3d1d4dd 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_deploy +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -1,19 +1,5 @@ def label = "mypod-${UUID.randomUUID().toString()}" -def dockerRegistry = "100.71.71.71:5000" -def Creds = "git_cred" - -String deploy_db = """ - -""" - -String deploy_ui = """ - -""" - -String deploy_get = """ - -""" properties([ parameters([ @@ -37,38 +23,31 @@ volumes: [ node(label) { try{ - stage("Pre-Test"){ - dir('get'){ - git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") - imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) - tmp = "1" - pathTocodeget = pwd() - } - } + stage("Deploy to Kubernetes"){ build(job: 'GitHub/Kubik-DB/master', parameters: [[$class: 'StringParameterValue', name:"service", value: "***"]], wait: true) if(params.service == "db"){ container ("helm"){ - sh "helm upgrade --install --namespace production --force db-service ${pathTocodeget}/List-Helm-Charts/db-service --set=deploy.version=v1,image.tag=${db}" + sh "helm upgrade --install --namespace production --force db-service chartmuseum/db-service --set=deploy.version=v1,image.tag=${params.imageTagDB_}" } } if(params.service == "get"){ container ("helm"){ - sh "helm upgrade --install --namespace production --force get-service ${pathTocodeget}/List-Helm-Charts/get-service --set=deploy.version=v1,image.tag=${get}" + sh "helm upgrade --install --namespace production --force get-service chartmuseum/get-service --set=deploy.version=v1,image.tag=${params.imageTagGET_}}" } } if(params.service == "ui"){ container ("helm"){ - sh "helm upgrade --install --namespace production --force ui-service ${pathTocodeget}/List-Helm-Charts/ui-service --set=deploy.version=v1,image.tag=${ui}" + sh "helm upgrade --install --namespace production --force ui-service chartmuseum/ui-service --set=deploy.version=v1,image.tag=${params.imageTagUI_}}" } } if(params.service == "post"){ container ("helm"){ - sh "helm upgrade --install --namespace production --force post-service ${pathTocodeget}/List-Helm-Charts/post-service --set=deploy.version=v1,image.tag=${post}" + sh "helm upgrade --install --namespace production --force post-service chartmuseum/post-service --set=deploy.version=v1,image.tag=${params.imageTagPOST_}}" } } diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test index 95bb51f..e0c5141 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test @@ -1,8 +1,5 @@ def label = "mypod-${UUID.randomUUID().toString()}" -def dockerRegistry = "100.71.71.71:5000" -def Creds = "git_cred" -String e2e_YAML = """ """ String get = "${params.imageTagGET_}" String ui = "${params.imageTagUI_}" String db = "${params.imageTagDB_}" @@ -30,17 +27,10 @@ volumes: [ node(label) { try{ - stage("Pre-Test"){ - dir('get'){ - git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") - imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) - tmp = "1" - pathTocodeget = pwd() - } - } + stage("E2E Test - Stage 1"){ container('helm'){ - sh """helm upgrade --install --force e2e-testing ${pathTocodeget}/List-Helm-Charts/e2e-testing --set=deploy.version=v1,image.tag.ui=${ui},image.tag.get=${get},image.tag.db=${db} --namespace testing""" + sh """helm upgrade --install --force e2e-testing chartmuseum/e2e-testing --set=deploy.version=v1,image.tag.ui=${ui},image.tag.get=${get},image.tag.db=${db} --namespace testing""" sh "kubectl get pods --namespace=testing" } } @@ -54,11 +44,11 @@ node(label) stage ("Deploy"){ - //build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], - //[$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], - //[$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], - //[$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], - //[$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) + build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], + [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], + [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], + [$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], + [$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) } } From 7899c58c4847b8adacea13657efbf8c4f4aaf520 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 11:46:12 -0500 Subject: [PATCH 187/241] Helm --- Jenkinsfiles_Helm/Jenkinsfile_e2e_test_v2 | 27 +++++++---------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test_v2 b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test_v2 index 11d8230..18ede2d 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_e2e_test_v2 +++ b/Jenkinsfiles_Helm/Jenkinsfile_e2e_test_v2 @@ -1,8 +1,5 @@ def label = "mypod-${UUID.randomUUID().toString()}" -def dockerRegistry = "100.71.71.71:5000" -def Creds = "git_cred" -String e2e_YAML = """ """ String get = "${params.imageTagGET_}" String ui = "${params.imageTagUI_}" String db = "${params.imageTagDB_}" @@ -30,19 +27,11 @@ volumes: [ node(label) { try{ - stage("Pre-Test"){ - dir('get'){ - git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") - imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) - tmp = "1" - pathTocodeget = pwd() - } - } stage("E2E Test - Stage 1"){ container('helm'){ - sh "helm upgrade --install --namespace testing --force e2e-testing-db ${pathTocodeget}/List-Helm-Charts/e2e-testing-db --set=deploy.version=v1,image.tag.db=${db}" - sh "helm upgrade --install --namespace testing --force e2e-testing-get ${pathTocodeget}/List-Helm-Charts/e2e-testing-get --set=deploy.version=v1,image.tag.get=${get}" - sh "helm upgrade --install --namespace testing --force e2e-testing-ui ${pathTocodeget}/List-Helm-Charts/e2e-testing-ui --set=deploy.version=v1,image.tag.ui=${ui}" + sh "helm upgrade --install --namespace testing --force e2e-testing-db chartmuseum/e2e-testing-db --set=deploy.version=v1,image.tag.db=${db}" + sh "helm upgrade --install --namespace testing --force e2e-testing-get chartmuseum/e2e-testing-get --set=deploy.version=v1,image.tag.get=${get}" + sh "helm upgrade --install --namespace testing --force e2e-testing-ui chartmuseum/e2e-testing-ui --set=deploy.version=v1,image.tag.ui=${ui}" sh "kubectl get pods --namespace=testing" } } @@ -56,11 +45,11 @@ node(label) stage ("Deploy"){ - //build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], - //[$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], - //[$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], - //[$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], - //[$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) + build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], + [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], + [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], + [$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], + [$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) } } From 326d208e3ff86a2ba93448ba412203a1d7f3dd83 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 13:49:33 -0500 Subject: [PATCH 188/241] Final testing --- .../e2e-testing-db/templates/template.yaml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/List-Helm-Charts/e2e-testing-db/templates/template.yaml b/List-Helm-Charts/e2e-testing-db/templates/template.yaml index 7a85e9d..c6dc763 100644 --- a/List-Helm-Charts/e2e-testing-db/templates/template.yaml +++ b/List-Helm-Charts/e2e-testing-db/templates/template.yaml @@ -11,17 +11,6 @@ data: URL_DB: db-service.testing.svc --- apiVersion: v1 -kind: Secret -metadata: - name: db-secret - namespace: {{ .Values.namespace }} -data: - username: ZGJhZG1pbg== - password: UGFzc3dvcmQ= - dbname: c3Jtc3lzdGVt -type: Opaque ---- -apiVersion: v1 kind: PersistentVolumeClaim metadata: namespace: {{ .Values.namespace }} From 6ab4081cc61d326cc7e3d9e27e8c3fb715c95726 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 14:28:45 -0500 Subject: [PATCH 189/241] Test ISTIO - add annotations --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bcc7add..909515a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ def label = "mypod-${UUID.randomUUID().toString()}" -podTemplate(label: label, containers: [ +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) ], From 0f18a6924a55829bf93e696d954742a196f121f2 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 14:41:52 -0500 Subject: [PATCH 190/241] Add db-secret --- .../e2e-testing-db/templates/template.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/List-Helm-Charts/e2e-testing-db/templates/template.yaml b/List-Helm-Charts/e2e-testing-db/templates/template.yaml index c6dc763..7a85e9d 100644 --- a/List-Helm-Charts/e2e-testing-db/templates/template.yaml +++ b/List-Helm-Charts/e2e-testing-db/templates/template.yaml @@ -11,6 +11,17 @@ data: URL_DB: db-service.testing.svc --- apiVersion: v1 +kind: Secret +metadata: + name: db-secret + namespace: {{ .Values.namespace }} +data: + username: ZGJhZG1pbg== + password: UGFzc3dvcmQ= + dbname: c3Jtc3lzdGVt +type: Opaque +--- +apiVersion: v1 kind: PersistentVolumeClaim metadata: namespace: {{ .Values.namespace }} From e60459f06918f684905e18d18619183371d5fe61 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 15:04:07 -0500 Subject: [PATCH 191/241] Troubleshooting DB --- List-Helm-Charts/e2e-testing-db/templates/template.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/List-Helm-Charts/e2e-testing-db/templates/template.yaml b/List-Helm-Charts/e2e-testing-db/templates/template.yaml index 7a85e9d..32a058e 100644 --- a/List-Helm-Charts/e2e-testing-db/templates/template.yaml +++ b/List-Helm-Charts/e2e-testing-db/templates/template.yaml @@ -122,6 +122,10 @@ spec: secretKeyRef: name: db-secret key: dbname + - name: PGHOST + value: srmsystemdb + - name: PGPORT + value: '5432' - name: PGUSER valueFrom: secretKeyRef: From 40493a8f495375b3d2c88d574fcc06209b41eeba Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 15:16:06 -0500 Subject: [PATCH 192/241] Test Deploy --- .../db-service/templates/template.yaml | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/List-Helm-Charts/db-service/templates/template.yaml b/List-Helm-Charts/db-service/templates/template.yaml index 2923a0e..0cfb6d6 100644 --- a/List-Helm-Charts/db-service/templates/template.yaml +++ b/List-Helm-Charts/db-service/templates/template.yaml @@ -14,9 +14,14 @@ spec: app: db-service spec: initContainers: - - image: "{{ .Values.image.repository }}/init-container:{{ .Values.image.tag }}" + - image: 100.71.71.71:5000/init-container:{{ .Values.image.tag }} name: init-container-postgres env: + - name: PGHOST + valueFrom: + secretKeyRef: + name: db-secret + key: dbhost - name: PGDATABASE valueFrom: secretKeyRef: @@ -32,17 +37,22 @@ spec: secretKeyRef: name: db-secret key: password + - name: PGPORT + value: "5432" command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] containers: - - image: "{{ .Values.image.repository }}/db-service:{{ .Values.image.tag }}" + - image: 100.71.71.71:5000/db-service:{{ .Values.image.tag }} name: db-service ports: - containerPort: 5002 env: - name: POSTGRES_HOST - value: srmsystemdb + valueFrom: + secretKeyRef: + name: db-secret + key: dbhost - name: POSTGRES_PORT - value: '5432' + value: "5432" - name: PGDATABASE valueFrom: secretKeyRef: @@ -57,7 +67,7 @@ spec: valueFrom: secretKeyRef: name: db-secret - key: password + key: password --- kind: Service apiVersion: v1 From 7b858727f2cabc2aa6f886b3949edc1425383710 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 15:24:42 -0500 Subject: [PATCH 193/241] Test Deploy --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 909515a..d784dde 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '*', + defaultValue: '', description: 'TAG_Change', name: 'service') ]) From 8658663a1db0728f1345ac0f903d4a3d268d6d5c Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Mon, 11 Feb 2019 15:42:21 -0500 Subject: [PATCH 194/241] Test Deploy Final --- List-Helm-Charts/ui-service/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/List-Helm-Charts/ui-service/values.yaml b/List-Helm-Charts/ui-service/values.yaml index 2a71e87..d9ea035 100644 --- a/List-Helm-Charts/ui-service/values.yaml +++ b/List-Helm-Charts/ui-service/values.yaml @@ -14,7 +14,7 @@ app: service: type: ClusterIP port: 5000 - servicename: ui-service + servicename: ui namespace: production From 29584b9d7917c3a6714e0427c98c0d43feded226 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 12 Feb 2019 08:10:06 -0500 Subject: [PATCH 195/241] BG - Arch --- .../Blue-Green/Jenkinsfile_deploy_bg | 94 +++++++++++++++++++ Jenkinsfiles_Helm/Jenkinsfile_deploy | 7 +- List-Helm-Charts/get-service-bg/.helmignore | 22 +++++ List-Helm-Charts/get-service-bg/Chart.yaml | 5 + .../get-service-bg/templates/template.yaml | 28 ++++++ List-Helm-Charts/get-service-bg/values.yaml | 32 +++++++ .../get-service/templates/template.yaml | 3 +- List-Helm-Charts/get-service/values.yaml | 1 + 8 files changed, 187 insertions(+), 5 deletions(-) create mode 100644 Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg create mode 100644 List-Helm-Charts/get-service-bg/.helmignore create mode 100644 List-Helm-Charts/get-service-bg/Chart.yaml create mode 100644 List-Helm-Charts/get-service-bg/templates/template.yaml create mode 100644 List-Helm-Charts/get-service-bg/values.yaml diff --git a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg new file mode 100644 index 0000000..9cf7261 --- /dev/null +++ b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg @@ -0,0 +1,94 @@ + +def label = "mypod-${UUID.randomUUID().toString()}" +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + +properties([ + parameters([ + stringParam( + defaultValue: '***', + description: '', + name: 'service') + ]) +]) + +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: 'helm', image: 'ghostgoose33/kubectl_helm:v1', command: 'cat', ttyEnabled: true) +], +volumes: [ + hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') +], serviceAccount: "jenkins") +{ + + +node(label) +{ + try{ + stage("Pre-Test"){ + dir('get'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + tmp = "1" + pathTocodeget = pwd() + } + } + stage("Deploy to Kubernetes"){ + if(params.service == "db"){ + container ("helm"){ + check = sh(script: """helm list -c db-service | awk '{ print \$1 }' | grep v1""", returnStdout:true) + echo "${check}" + if (check){ + sh "helm upgrade --install --namespace production --force db-service-v2 ${pathTocodeget}/List-Helm-Charts/db-service-v2 --set=deploy.version=v2,image.tag=${params.imageTagDB_}" + sh "helm upgrade --install --namespace production --force istio-rules-db chartmuseum/istio --set weight.v1=0,--set weight.v2=100, --set app=db" + else{ + sh "helm upgrade --install --namespace production --force db-service-v1 ${pathTocodeget}/List-Helm-Charts/db-service --set=deploy.version=v1,image.tag=${params.imageTagDB_}" + } + } + } + if(params.service == "get"){ + container ("helm"){ + check = sh(script: """helm list -c get-service | awk '{ print \$1 }' | grep v1""", returnStdout:true) + echo "${check}" + if (check){ + sh "helm upgrade --install --namespace production --force get-service-v2 ${pathTocodeget}/List-Helm-Charts/get-service-v2 --set=deploy.version=v2,image.tag=${params.imageTagGET_}" + sh "helm upgrade --install --namespace production --force istio-rules-get chartmuseum/istio --set weight.v1=0,--set weight.v2=100, --set app=get" + else{ + sh "helm upgrade --install --namespace production --force get-service-v1 ${pathTocodeget}/List-Helm-Charts/get-service --set=deploy.version=v1,image.tag=${params.imageTagGET_}" + } + } + } + if(params.service == "ui"){ + container ("helm"){ + check = sh(script: """helm list -c ui-service | awk '{ print \$1 }' | grep v1""", returnStdout:true) + echo "${check}" + if (check){ + sh "helm upgrade --install --namespace production --force ui-service-v2 ${pathTocodeget}/List-Helm-Charts/ui-service-v2 --set=deploy.version=v2,image.tag=${params.imageTagUI_}" + sh "helm upgrade --install --namespace production --force istio-rules-ui chartmuseum/istio --set weight.v1=0,--set weight.v2=100, --set app=ui" + else{ + sh "helm upgrade --install --namespace production --force ui-service-v1 ${pathTocodeget}/List-Helm-Charts/ui-service --set=deploy.version=v1,image.tag=${params.imageTagUI_}" + } + } + } + + if(params.service == "post"){ + container ("helm"){ + + } + } + } + + sleep 10 + + stage ("Prod Tests"){ + container('python-alpine'){ + //sh "python3 /e2e-test-prod.py" + } + } + + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} diff --git a/Jenkinsfiles_Helm/Jenkinsfile_deploy b/Jenkinsfiles_Helm/Jenkinsfile_deploy index 3d1d4dd..d58ced1 100644 --- a/Jenkinsfiles_Helm/Jenkinsfile_deploy +++ b/Jenkinsfiles_Helm/Jenkinsfile_deploy @@ -25,7 +25,6 @@ node(label) try{ stage("Deploy to Kubernetes"){ - build(job: 'GitHub/Kubik-DB/master', parameters: [[$class: 'StringParameterValue', name:"service", value: "***"]], wait: true) if(params.service == "db"){ container ("helm"){ sh "helm upgrade --install --namespace production --force db-service chartmuseum/db-service --set=deploy.version=v1,image.tag=${params.imageTagDB_}" @@ -34,20 +33,20 @@ node(label) } if(params.service == "get"){ container ("helm"){ - sh "helm upgrade --install --namespace production --force get-service chartmuseum/get-service --set=deploy.version=v1,image.tag=${params.imageTagGET_}}" + sh "helm upgrade --install --namespace production --force get-service chartmuseum/get-service --set=deploy.version=v1,image.tag=${params.imageTagGET_}" } } if(params.service == "ui"){ container ("helm"){ - sh "helm upgrade --install --namespace production --force ui-service chartmuseum/ui-service --set=deploy.version=v1,image.tag=${params.imageTagUI_}}" + sh "helm upgrade --install --namespace production --force ui-service chartmuseum/ui-service --set=deploy.version=v1,image.tag=${params.imageTagUI_}" } } if(params.service == "post"){ container ("helm"){ - sh "helm upgrade --install --namespace production --force post-service chartmuseum/post-service --set=deploy.version=v1,image.tag=${params.imageTagPOST_}}" + sh "helm upgrade --install --namespace production --force post-service chartmuseum/post-service --set=deploy.version=v1,image.tag=${params.imageTagPOST_}" } } diff --git a/List-Helm-Charts/get-service-bg/.helmignore b/List-Helm-Charts/get-service-bg/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/get-service-bg/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/get-service-bg/Chart.yaml b/List-Helm-Charts/get-service-bg/Chart.yaml new file mode 100644 index 0000000..9c558c7 --- /dev/null +++ b/List-Helm-Charts/get-service-bg/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: get-service-bg +version: 0.1.0 diff --git a/List-Helm-Charts/get-service-bg/templates/template.yaml b/List-Helm-Charts/get-service-bg/templates/template.yaml new file mode 100644 index 0000000..72a2484 --- /dev/null +++ b/List-Helm-Charts/get-service-bg/templates/template.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: production + name: get-deployment-{{ .Values.deploy.version }} +spec: + selector: + matchLabels: + app: get + replicas: 1 + template: + metadata: + labels: + app: get + version: {{ .Values.deploy.version }} + spec: + containers: + - name: get + image: "{{ .Values.image.repository }}/get-service:{{ .Values.image.tag }}" + ports: + - containerPort: 5003 + env: + - name: URL_DB + valueFrom: + configMapKeyRef: + name: services-address + key: URL_DB diff --git a/List-Helm-Charts/get-service-bg/values.yaml b/List-Helm-Charts/get-service-bg/values.yaml new file mode 100644 index 0000000..a5eef87 --- /dev/null +++ b/List-Helm-Charts/get-service-bg/values.yaml @@ -0,0 +1,32 @@ +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: "" + +app: + name: get + version: "" + +service: + type: ClusterIP + port: 5000 + servicename: get-service + +namespace: production + +deploy: + version: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + diff --git a/List-Helm-Charts/get-service/templates/template.yaml b/List-Helm-Charts/get-service/templates/template.yaml index f318b2c..bd9bc8e 100644 --- a/List-Helm-Charts/get-service/templates/template.yaml +++ b/List-Helm-Charts/get-service/templates/template.yaml @@ -19,7 +19,7 @@ apiVersion: apps/v1 kind: Deployment metadata: namespace: production - name: get-deployment + name: get-deployment-{{ .Values.deploy.version }} spec: selector: matchLabels: @@ -29,6 +29,7 @@ spec: metadata: labels: app: get + version: {{ .Values.deploy.version }} spec: containers: - name: get diff --git a/List-Helm-Charts/get-service/values.yaml b/List-Helm-Charts/get-service/values.yaml index 45f3e69..a5eef87 100644 --- a/List-Helm-Charts/get-service/values.yaml +++ b/List-Helm-Charts/get-service/values.yaml @@ -10,6 +10,7 @@ image: app: name: get + version: "" service: type: ClusterIP From 98a77f42ce42a1928e23f1ae14fe214444a983e8 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 12 Feb 2019 11:50:53 -0500 Subject: [PATCH 196/241] Add Delete Pod Job --- .../Blue-Green/Jenkinsfile_delete_pod | 93 +++++++++++++++++++ .../Blue-Green/Jenkinsfile_deploy_bg | 12 +-- .../Jenkinsfiles_deploy_helm_loc | 77 +++++++++++++++ Jenkinsfiles_Helm/Jenkinsfiles_e2e_helm_loc | 71 ++++++++++++++ List-Helm-Charts/db-service-bg/.helmignore | 22 +++++ List-Helm-Charts/db-service-bg/Chart.yaml | 5 + .../db-service-bg/templates/template.yaml | 72 ++++++++++++++ List-Helm-Charts/db-service-bg/values.yaml | 32 +++++++ .../db-service/templates/template.yaml | 1 + List-Helm-Charts/istio-rules/.helmignore | 22 +++++ List-Helm-Charts/istio-rules/Chart.yaml | 5 + .../istio-rules/templates/template.yaml | 35 +++++++ List-Helm-Charts/istio-rules/values.yaml | 15 +++ List-Helm-Charts/ui-service-bg/.helmignore | 22 +++++ List-Helm-Charts/ui-service-bg/Chart.yaml | 5 + .../ui-service-bg/templates/template.yaml | 35 +++++++ List-Helm-Charts/ui-service-bg/values.yaml | 32 +++++++ 17 files changed, 550 insertions(+), 6 deletions(-) create mode 100644 Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod create mode 100644 Jenkinsfiles_Helm/Jenkinsfiles_deploy_helm_loc create mode 100644 Jenkinsfiles_Helm/Jenkinsfiles_e2e_helm_loc create mode 100644 List-Helm-Charts/db-service-bg/.helmignore create mode 100644 List-Helm-Charts/db-service-bg/Chart.yaml create mode 100644 List-Helm-Charts/db-service-bg/templates/template.yaml create mode 100644 List-Helm-Charts/db-service-bg/values.yaml create mode 100644 List-Helm-Charts/istio-rules/.helmignore create mode 100644 List-Helm-Charts/istio-rules/Chart.yaml create mode 100644 List-Helm-Charts/istio-rules/templates/template.yaml create mode 100644 List-Helm-Charts/istio-rules/values.yaml create mode 100644 List-Helm-Charts/ui-service-bg/.helmignore create mode 100644 List-Helm-Charts/ui-service-bg/Chart.yaml create mode 100644 List-Helm-Charts/ui-service-bg/templates/template.yaml create mode 100644 List-Helm-Charts/ui-service-bg/values.yaml diff --git a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod new file mode 100644 index 0000000..ec6cdd4 --- /dev/null +++ b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod @@ -0,0 +1,93 @@ + +def label = "mypod-${UUID.randomUUID().toString()}" +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + +properties([ + parameters([ + stringParam( + defaultValue: '***', + description: '', + name: 'service'), + choice(choices: ['db', 'ui', 'get'], description: 'What Service?', name: 'service-del'), + choice(choices: ['v1', 'v2'], description: 'What version?', name: 'version-del') + ]) +]) + +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: 'helm', image: 'ghostgoose33/kubectl_helm:v1', command: 'cat', ttyEnabled: true) +], +volumes: [ + hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') +], serviceAccount: "jenkins") +{ + + +node(label) +{ + try{ + stage("Pre-Test"){ + dir('get'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + tmp = "1" + pathTocodeget = pwd() + } + } + stage("Deploy to Kubernetes"){ + if(params.service-del == "db"){ + container ("helm"){ + if (params.version-del == "v2"){ + sh "helm delete db-service-v2 --purge" + sh "helm upgrade --install --namespace production --force istio-rules-db ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=db-service" + } + if (params.version-del == "v1"){ + sh "helm delete db-service-v1 --purge" + } + } + } + if(params.service-del == "get"){ + container ("helm"){ + if (params.version-del == "v2"){ + sh "helm delete get-service-v2 --purge" + sh "helm upgrade --install --namespace production --force istio-rules-get ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=get" + } + if (params.version-del == "v1"){ + sh "helm delete get-service-v1 --purge" + } + } + } + if(params.service-del == "ui"){ + container ("helm"){ + if (params.version-del == "v2"){ + sh "helm delete ui-service-v2 --purge" + sh "helm upgrade --install --namespace production --force istio-rules-ui ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=ui" + } + if (params.version-del == "v1"){ + sh "helm delete ui-service-v1 --purge" + } + } + } + + if(params.service == "post"){ + container ("helm"){ + + } + } + } + + sleep 10 + + stage ("Prod Tests"){ + container('python-alpine'){ + //sh "python3 /e2e-test-prod.py" + } + } + + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} diff --git a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg index 9cf7261..0ac5d88 100644 --- a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg +++ b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg @@ -39,8 +39,8 @@ node(label) check = sh(script: """helm list -c db-service | awk '{ print \$1 }' | grep v1""", returnStdout:true) echo "${check}" if (check){ - sh "helm upgrade --install --namespace production --force db-service-v2 ${pathTocodeget}/List-Helm-Charts/db-service-v2 --set=deploy.version=v2,image.tag=${params.imageTagDB_}" - sh "helm upgrade --install --namespace production --force istio-rules-db chartmuseum/istio --set weight.v1=0,--set weight.v2=100, --set app=db" + sh "helm upgrade --install --namespace production --force db-service-v2 ${pathTocodeget}/List-Helm-Charts/db-service-bg --set=deploy.version=v2,image.tag=${params.imageTagDB_}" + sh "helm upgrade --install --namespace production --force istio-rules-db ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=0,--set weight.v2=100, --set app=db-service"} else{ sh "helm upgrade --install --namespace production --force db-service-v1 ${pathTocodeget}/List-Helm-Charts/db-service --set=deploy.version=v1,image.tag=${params.imageTagDB_}" } @@ -51,8 +51,8 @@ node(label) check = sh(script: """helm list -c get-service | awk '{ print \$1 }' | grep v1""", returnStdout:true) echo "${check}" if (check){ - sh "helm upgrade --install --namespace production --force get-service-v2 ${pathTocodeget}/List-Helm-Charts/get-service-v2 --set=deploy.version=v2,image.tag=${params.imageTagGET_}" - sh "helm upgrade --install --namespace production --force istio-rules-get chartmuseum/istio --set weight.v1=0,--set weight.v2=100, --set app=get" + sh "helm upgrade --install --namespace production --force get-service-v2 ${pathTocodeget}/List-Helm-Charts/get-service-bg --set=deploy.version=v2,image.tag=${params.imageTagGET_}" + sh "helm upgrade --install --namespace production --force istio-rules-get ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=0 --set weight.v2=100 --set app.name=get"} else{ sh "helm upgrade --install --namespace production --force get-service-v1 ${pathTocodeget}/List-Helm-Charts/get-service --set=deploy.version=v1,image.tag=${params.imageTagGET_}" } @@ -63,8 +63,8 @@ node(label) check = sh(script: """helm list -c ui-service | awk '{ print \$1 }' | grep v1""", returnStdout:true) echo "${check}" if (check){ - sh "helm upgrade --install --namespace production --force ui-service-v2 ${pathTocodeget}/List-Helm-Charts/ui-service-v2 --set=deploy.version=v2,image.tag=${params.imageTagUI_}" - sh "helm upgrade --install --namespace production --force istio-rules-ui chartmuseum/istio --set weight.v1=0,--set weight.v2=100, --set app=ui" + sh "helm upgrade --install --namespace production --force ui-service-v2 ${pathTocodeget}/List-Helm-Charts/ui-service-bg --set=deploy.version=v2,image.tag=${params.imageTagUI_}" + sh "helm upgrade --install --namespace production --force istio-rules-ui ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=0,--set weight.v2=100, --set app.name=ui"} else{ sh "helm upgrade --install --namespace production --force ui-service-v1 ${pathTocodeget}/List-Helm-Charts/ui-service --set=deploy.version=v1,image.tag=${params.imageTagUI_}" } diff --git a/Jenkinsfiles_Helm/Jenkinsfiles_deploy_helm_loc b/Jenkinsfiles_Helm/Jenkinsfiles_deploy_helm_loc new file mode 100644 index 0000000..1119c5e --- /dev/null +++ b/Jenkinsfiles_Helm/Jenkinsfiles_deploy_helm_loc @@ -0,0 +1,77 @@ + +def label = "mypod-${UUID.randomUUID().toString()}" +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + +properties([ + parameters([ + stringParam( + defaultValue: '***', + description: '', + name: 'service') + ]) +]) + +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: 'helm', image: 'ghostgoose33/kubectl_helm:v1', command: 'cat', ttyEnabled: true) +], +volumes: [ + hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') +], serviceAccount: "jenkins") +{ + + +node(label) +{ + try{ + stage("Pre-Test"){ + dir('get'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + tmp = "1" + pathTocodeget = pwd() + } + } + stage("Deploy to Kubernetes"){ + if(params.service == "db"){ + container ("helm"){ + sh "helm upgrade --install --namespace production --force db-service ${pathTocodeget}/List-Helm-Charts/db-service --set=deploy.version=v1,image.tag=${params.imageTagDB_}" + + } + } + if(params.service == "get"){ + container ("helm"){ + sh "helm upgrade --install --namespace production --force get-service ${pathTocodeget}/List-Helm-Charts/get-service --set=deploy.version=v1,image.tag=${params.imageTagGET_}" + + } + } + if(params.service == "ui"){ + container ("helm"){ + sh "helm upgrade --install --namespace production --force ui-service ${pathTocodeget}/List-Helm-Charts/ui-service --set=deploy.version=v1,image.tag=${params.imageTagUI_}" + + } + } + + if(params.service == "post"){ + container ("helm"){ + sh "helm upgrade --install --namespace production --force post-service ${pathTocodeget}/List-Helm-Charts/post-service --set=deploy.version=v1,image.tag=${post}" + + } + } + } + + sleep 10 + + stage ("Prod Tests"){ + container('python-alpine'){ + //sh "python3 /e2e-test-prod.py" + } + } + + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} diff --git a/Jenkinsfiles_Helm/Jenkinsfiles_e2e_helm_loc b/Jenkinsfiles_Helm/Jenkinsfiles_e2e_helm_loc new file mode 100644 index 0000000..1ba90ce --- /dev/null +++ b/Jenkinsfiles_Helm/Jenkinsfiles_e2e_helm_loc @@ -0,0 +1,71 @@ +def label = "mypod-${UUID.randomUUID().toString()}" +def dockerRegistry = "100.71.71.71:5000" +def Creds = "git_cred" + +String e2e_YAML = """ """ +String get = "${params.imageTagGET_}" +String ui = "${params.imageTagUI_}" +String db = "${params.imageTagDB_}" + +properties([ + parameters([ + stringParam( + defaultValue: '***', + description: '', + name: 'service') + ]) +]) + +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), + containerTemplate(name: 'helm', image: 'ghostgoose33/kubectl_helm:v1', command: 'cat', ttyEnabled: true) +], +volumes: [ + hostPathVolume(mountPath: '/var/run/docker.sock', hostPath: '/var/run/docker.sock') +], serviceAccount: "jenkins") +{ + + +node(label) +{ + try{ + stage("Pre-Test"){ + dir('get'){ + git(branch: "test", url: 'https://github.com/Kv-045DevOps/SRM-GET.git', credentialsId: "${Creds}") + imageTagUI = (sh (script: "git rev-parse --short HEAD", returnStdout: true)) + tmp = "1" + pathTocodeget = pwd() + } + } + stage("E2E Test - Stage 1"){ + container('helm'){ + sh "helm upgrade --install --namespace testing --force e2e-testing-db ${pathTocodeget}/List-Helm-Charts/e2e-testing-db --set=deploy.version=v1,image.tag.db=${db}" + sh "helm upgrade --install --namespace testing --force e2e-testing-get ${pathTocodeget}/List-Helm-Charts/e2e-testing-get --set=deploy.version=v1,image.tag.get=${get}" + sh "helm upgrade --install --namespace testing --force e2e-testing-ui ${pathTocodeget}/List-Helm-Charts/e2e-testing-ui --set=deploy.version=v1,image.tag.ui=${ui}" + sh "kubectl get pods --namespace=testing" + } + } + sleep 40 + stage ("E2E Tests - Stage 2"){ + container('python-alpine'){ + sh 'echo "Here is e2e test"' + sh "python3 /e2e-test-test.py" + } + } + + stage ("Deploy"){ + + build(job: 'test_deploy', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${params.imageTagGET_}"], + [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], + [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], + [$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], + [$class: 'StringParameterValue', name:"service", value: "${params.service}"]], wait: true) + } + + } + catch(err){ + currentBuild.result = 'Failure' + } +} +} diff --git a/List-Helm-Charts/db-service-bg/.helmignore b/List-Helm-Charts/db-service-bg/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/db-service-bg/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/db-service-bg/Chart.yaml b/List-Helm-Charts/db-service-bg/Chart.yaml new file mode 100644 index 0000000..008107a --- /dev/null +++ b/List-Helm-Charts/db-service-bg/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: db-service-bg +version: 0.1.0 diff --git a/List-Helm-Charts/db-service-bg/templates/template.yaml b/List-Helm-Charts/db-service-bg/templates/template.yaml new file mode 100644 index 0000000..1bf156b --- /dev/null +++ b/List-Helm-Charts/db-service-bg/templates/template.yaml @@ -0,0 +1,72 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: production + name: db-service +spec: + selector: + matchLabels: + app: db-service + template: + metadata: + labels: + app: db-service + version: {{ .Values.deploy.version }} + spec: + initContainers: + - image: 100.71.71.71:5000/init-container:{{ .Values.image.tag }} + name: init-container-postgres + env: + - name: PGHOST + valueFrom: + secretKeyRef: + name: db-secret + key: dbhost + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password + - name: PGPORT + value: "5432" + command: ['sh', '-c', '/bin/bash /tmp/check_dump.sh'] + containers: + - image: 100.71.71.71:5000/db-service:{{ .Values.image.tag }} + name: db-service + ports: + - containerPort: 5002 + env: + - name: POSTGRES_HOST + valueFrom: + secretKeyRef: + name: db-secret + key: dbhost + - name: POSTGRES_PORT + value: "5432" + - name: PGDATABASE + valueFrom: + secretKeyRef: + name: db-secret + key: dbname + - name: PGUSER + valueFrom: + secretKeyRef: + name: db-secret + key: username + - name: PGPASSWORD + valueFrom: + secretKeyRef: + name: db-secret + key: password +--- diff --git a/List-Helm-Charts/db-service-bg/values.yaml b/List-Helm-Charts/db-service-bg/values.yaml new file mode 100644 index 0000000..a5eef87 --- /dev/null +++ b/List-Helm-Charts/db-service-bg/values.yaml @@ -0,0 +1,32 @@ +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: "" + +app: + name: get + version: "" + +service: + type: ClusterIP + port: 5000 + servicename: get-service + +namespace: production + +deploy: + version: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + diff --git a/List-Helm-Charts/db-service/templates/template.yaml b/List-Helm-Charts/db-service/templates/template.yaml index 0cfb6d6..5fe3cdf 100644 --- a/List-Helm-Charts/db-service/templates/template.yaml +++ b/List-Helm-Charts/db-service/templates/template.yaml @@ -12,6 +12,7 @@ spec: metadata: labels: app: db-service + version: {{ .Values.deploy.version }} spec: initContainers: - image: 100.71.71.71:5000/init-container:{{ .Values.image.tag }} diff --git a/List-Helm-Charts/istio-rules/.helmignore b/List-Helm-Charts/istio-rules/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/istio-rules/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/istio-rules/Chart.yaml b/List-Helm-Charts/istio-rules/Chart.yaml new file mode 100644 index 0000000..4628561 --- /dev/null +++ b/List-Helm-Charts/istio-rules/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: istio-rules +version: 0.1.0 diff --git a/List-Helm-Charts/istio-rules/templates/template.yaml b/List-Helm-Charts/istio-rules/templates/template.yaml new file mode 100644 index 0000000..2d42ea3 --- /dev/null +++ b/List-Helm-Charts/istio-rules/templates/template.yaml @@ -0,0 +1,35 @@ +--- +apiVersion: networking.istio.io/v1alpha3 +kind: DestinationRule +metadata: + name: {{ .Values.app.name }} +spec: + host: {{ .Values.app.name }} + subsets: + - name: v1 + labels: + version: v1 + - name: v2 + labels: + version: v2 +--- +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: {{ .Values.app.name }} +spec: + hosts: + - "*" + gateways: + - app-gateway + http: + - route: + - destination: + host: {{ .Values.app.name }} + subset: v1 + weight: {{ .Values.weight.v1 }} + - destination: + host: {{ .Values.app.name }} + subset: v2 + weight: {{ .Values.weight.v2 }} +--- diff --git a/List-Helm-Charts/istio-rules/values.yaml b/List-Helm-Charts/istio-rules/values.yaml new file mode 100644 index 0000000..b1802d4 --- /dev/null +++ b/List-Helm-Charts/istio-rules/values.yaml @@ -0,0 +1,15 @@ +# Default values for istio-rules. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: "" + + +service: + type: ClusterIP + port: 80 + diff --git a/List-Helm-Charts/ui-service-bg/.helmignore b/List-Helm-Charts/ui-service-bg/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/ui-service-bg/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/ui-service-bg/Chart.yaml b/List-Helm-Charts/ui-service-bg/Chart.yaml new file mode 100644 index 0000000..10ef83a --- /dev/null +++ b/List-Helm-Charts/ui-service-bg/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: ui-service-bg +version: 0.1.0 diff --git a/List-Helm-Charts/ui-service-bg/templates/template.yaml b/List-Helm-Charts/ui-service-bg/templates/template.yaml new file mode 100644 index 0000000..a01bf87 --- /dev/null +++ b/List-Helm-Charts/ui-service-bg/templates/template.yaml @@ -0,0 +1,35 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Values.namespace }} + name: ui-deployment +spec: + selector: + matchLabels: + app: {{ .Values.app.name }} + version: {{ .Values.deploy.version }} + replicas: 1 + template: + metadata: + labels: + app: {{ .Values.app.name }} + version: {{ .Values.deploy.version }} + spec: + containers: + - name: {{ .Values.app.name }} + image: "{{ .Values.image.repository }}/{{ .Values.service.servicename }}:{{ .Values.image.tag }}" + ports: + - containerPort: 5000 + env: + - name: POST_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: POST_SERVICE_URL + - name: VIEW_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: VIEW_SERVICE_URL +--- diff --git a/List-Helm-Charts/ui-service-bg/values.yaml b/List-Helm-Charts/ui-service-bg/values.yaml new file mode 100644 index 0000000..a5eef87 --- /dev/null +++ b/List-Helm-Charts/ui-service-bg/values.yaml @@ -0,0 +1,32 @@ +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: 100.71.71.71:5000 + tag: "" + +app: + name: get + version: "" + +service: + type: ClusterIP + port: 5000 + servicename: get-service + +namespace: production + +deploy: + version: "" + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + From 67e44b420122afeb0addc9fb8b7a25a84670c5dd Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 12 Feb 2019 13:35:08 -0500 Subject: [PATCH 197/241] Result not local --- Jenkinsfile | 2 +- .../db-service-bg/templates/template.yaml | 15 ++++++++++++++- .../db-service/templates/template.yaml | 2 +- .../get-service-bg/templates/template.yaml | 17 +++++++++++++++++ .../get-service/templates/template.yaml | 2 +- .../istio-rules/templates/template.yaml | 6 +++++- .../ui-service-bg/templates/template.yaml | 18 +++++++++++++++++- 7 files changed, 56 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d784dde..bbad847 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -65,7 +65,7 @@ node(label) sh "cat /etc/docker/daemon.json" sh "docker push ${imageN}${imageTagGET}" sleep 20 - build(job: 'test_e2e', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${imageTagGET}"], + build(job: 'GitHub/GET-SERVICES/test1', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${imageTagGET}"], [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], [$class: 'StringParameterValue', name:"service", value: "get"]], wait: true) diff --git a/List-Helm-Charts/db-service-bg/templates/template.yaml b/List-Helm-Charts/db-service-bg/templates/template.yaml index 1bf156b..5866fa6 100644 --- a/List-Helm-Charts/db-service-bg/templates/template.yaml +++ b/List-Helm-Charts/db-service-bg/templates/template.yaml @@ -1,9 +1,22 @@ --- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: db-service-{{ .Values.deploy.version }} +spec: + selector: + app: db-service + ports: + - protocol: TCP + port: 5002 + targetPort: 5002 +--- apiVersion: apps/v1 kind: Deployment metadata: namespace: production - name: db-service + name: db-service-{{ .Values.deploy.version }} spec: selector: matchLabels: diff --git a/List-Helm-Charts/db-service/templates/template.yaml b/List-Helm-Charts/db-service/templates/template.yaml index 5fe3cdf..f7d2835 100644 --- a/List-Helm-Charts/db-service/templates/template.yaml +++ b/List-Helm-Charts/db-service/templates/template.yaml @@ -74,7 +74,7 @@ kind: Service apiVersion: v1 metadata: namespace: production - name: db-service + name: db-service-{{ .Values.deploy.version }} spec: selector: app: db-service diff --git a/List-Helm-Charts/get-service-bg/templates/template.yaml b/List-Helm-Charts/get-service-bg/templates/template.yaml index 72a2484..537dfb7 100644 --- a/List-Helm-Charts/get-service-bg/templates/template.yaml +++ b/List-Helm-Charts/get-service-bg/templates/template.yaml @@ -26,3 +26,20 @@ spec: configMapKeyRef: name: services-address key: URL_DB +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: get-service-{{ .Values.deploy.version }} + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 + +--- diff --git a/List-Helm-Charts/get-service/templates/template.yaml b/List-Helm-Charts/get-service/templates/template.yaml index bd9bc8e..0ecdfd3 100644 --- a/List-Helm-Charts/get-service/templates/template.yaml +++ b/List-Helm-Charts/get-service/templates/template.yaml @@ -3,7 +3,7 @@ kind: Service apiVersion: v1 metadata: namespace: production - name: get-service + name: get-service-{{ .Values.deploy.version }} labels: app: get spec: diff --git a/List-Helm-Charts/istio-rules/templates/template.yaml b/List-Helm-Charts/istio-rules/templates/template.yaml index 2d42ea3..d063376 100644 --- a/List-Helm-Charts/istio-rules/templates/template.yaml +++ b/List-Helm-Charts/istio-rules/templates/template.yaml @@ -21,15 +21,19 @@ spec: hosts: - "*" gateways: - - app-gateway + - srm-gateway http: - route: - destination: host: {{ .Values.app.name }} subset: v1 + port: + number: {{ .Values.port }} weight: {{ .Values.weight.v1 }} - destination: host: {{ .Values.app.name }} subset: v2 + port: + number: {{ .Values.port }} weight: {{ .Values.weight.v2 }} --- diff --git a/List-Helm-Charts/ui-service-bg/templates/template.yaml b/List-Helm-Charts/ui-service-bg/templates/template.yaml index a01bf87..3789321 100644 --- a/List-Helm-Charts/ui-service-bg/templates/template.yaml +++ b/List-Helm-Charts/ui-service-bg/templates/template.yaml @@ -3,7 +3,7 @@ apiVersion: apps/v1 kind: Deployment metadata: namespace: {{ .Values.namespace }} - name: ui-deployment + name: ui-deployment-{{ .Values.deploy.version }} spec: selector: matchLabels: @@ -33,3 +33,19 @@ spec: name: services-address key: VIEW_SERVICE_URL --- +--- +kind: Service +apiVersion: v1 +metadata: + namespace: {{ .Values.namespace }} + name: "{{ .Values.service.servicename }}-{{ .Values.deploy.version }} + labels: + app: {{ .Values.app.name }} + version: {{ .Values.deploy.version }} +spec: + selector: + app: {{ .Values.app.name }} + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 From 5a3e7780543748986788a6190a9b7bb99c68b892 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 12 Feb 2019 13:51:48 -0500 Subject: [PATCH 198/241] Test Helm charts --- .../e2e-testing-db/templates/template.yaml | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/List-Helm-Charts/e2e-testing-db/templates/template.yaml b/List-Helm-Charts/e2e-testing-db/templates/template.yaml index 32a058e..3e2b7d5 100644 --- a/List-Helm-Charts/e2e-testing-db/templates/template.yaml +++ b/List-Helm-Charts/e2e-testing-db/templates/template.yaml @@ -1,15 +1,15 @@ --- -apiVersion: v1 -kind: ConfigMap -metadata: - namespace: {{ .Values.namespace }} - name: services-address -data: - POST_SERVICE_URL: post-service.testing.svc - VIEW_SERVICE_URL: get-service.testing.svc - DB_URL: db-service.testing.svc - URL_DB: db-service.testing.svc ---- +#apiVersion: v1 +#kind: ConfigMap +#metadata: +# namespace: {{ .Values.namespace }} +# name: services-address +#data: +# POST_SERVICE_URL: post-service.testing.svc +# VIEW_SERVICE_URL: get-service.testing.svc +# DB_URL: db-service.testing.svc +# URL_DB: db-service.testing.svc +#--- apiVersion: v1 kind: Secret metadata: From bc0c4efb136bb6cf2ce305327e002ef67dcd7b64 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 12 Feb 2019 14:08:51 -0500 Subject: [PATCH 199/241] Test Git Jenkinsfile Istio --- List-Helm-Charts/db-service/templates/template.yaml | 4 +++- List-Helm-Charts/get-service/templates/template.yaml | 2 ++ List-Helm-Charts/ui-service/templates/template.yaml | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/List-Helm-Charts/db-service/templates/template.yaml b/List-Helm-Charts/db-service/templates/template.yaml index f7d2835..07a6789 100644 --- a/List-Helm-Charts/db-service/templates/template.yaml +++ b/List-Helm-Charts/db-service/templates/template.yaml @@ -3,7 +3,7 @@ apiVersion: apps/v1 kind: Deployment metadata: namespace: production - name: db-service + name: db-service-{{ .Values.deploy.version }} spec: selector: matchLabels: @@ -13,6 +13,8 @@ spec: labels: app: db-service version: {{ .Values.deploy.version }} + annotations: + sidecar.istio.io/inject: "false" spec: initContainers: - image: 100.71.71.71:5000/init-container:{{ .Values.image.tag }} diff --git a/List-Helm-Charts/get-service/templates/template.yaml b/List-Helm-Charts/get-service/templates/template.yaml index 0ecdfd3..5a9bad8 100644 --- a/List-Helm-Charts/get-service/templates/template.yaml +++ b/List-Helm-Charts/get-service/templates/template.yaml @@ -30,6 +30,8 @@ spec: labels: app: get version: {{ .Values.deploy.version }} + annotations: + sidecar.istio.io/inject: "false" spec: containers: - name: get diff --git a/List-Helm-Charts/ui-service/templates/template.yaml b/List-Helm-Charts/ui-service/templates/template.yaml index 9b2de82..b56a971 100644 --- a/List-Helm-Charts/ui-service/templates/template.yaml +++ b/List-Helm-Charts/ui-service/templates/template.yaml @@ -20,7 +20,9 @@ apiVersion: apps/v1 kind: Deployment metadata: namespace: {{ .Values.namespace }} - name: ui-deployment + name: ui-deployment-{{ .Values.deploy.version }} + annotations: + sidecar.istio.io/inject: "false" spec: selector: matchLabels: From f6289a508e6c9f11c99f9c641766a301591d7891 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 12 Feb 2019 14:28:06 -0500 Subject: [PATCH 200/241] Bug resolve --- List-Helm-Charts/ui-service/templates/template.yaml | 2 +- List-Helm-Charts/ui-service/values.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/List-Helm-Charts/ui-service/templates/template.yaml b/List-Helm-Charts/ui-service/templates/template.yaml index b56a971..02f7da8 100644 --- a/List-Helm-Charts/ui-service/templates/template.yaml +++ b/List-Helm-Charts/ui-service/templates/template.yaml @@ -37,7 +37,7 @@ spec: spec: containers: - name: {{ .Values.app.name }} - image: "{{ .Values.image.repository }}/{{ .Values.service.servicename }}:{{ .Values.image.tag }}" + image: "{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag }}" ports: - containerPort: 5000 env: diff --git a/List-Helm-Charts/ui-service/values.yaml b/List-Helm-Charts/ui-service/values.yaml index d9ea035..50555ec 100644 --- a/List-Helm-Charts/ui-service/values.yaml +++ b/List-Helm-Charts/ui-service/values.yaml @@ -7,6 +7,7 @@ replicaCount: 1 image: repository: 100.71.71.71:5000 tag: "" + name: ui-service app: name: ui From 8a5476ea73ab93b9d350f9d64d3f0d5a9d23bb17 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 12 Feb 2019 14:34:04 -0500 Subject: [PATCH 201/241] Add ISTION ANN --- List-Helm-Charts/db-service/templates/template.yaml | 3 +-- List-Helm-Charts/get-service/templates/template.yaml | 3 +-- List-Helm-Charts/ui-service/templates/template.yaml | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/List-Helm-Charts/db-service/templates/template.yaml b/List-Helm-Charts/db-service/templates/template.yaml index 07a6789..a65008a 100644 --- a/List-Helm-Charts/db-service/templates/template.yaml +++ b/List-Helm-Charts/db-service/templates/template.yaml @@ -13,8 +13,7 @@ spec: labels: app: db-service version: {{ .Values.deploy.version }} - annotations: - sidecar.istio.io/inject: "false" + spec: initContainers: - image: 100.71.71.71:5000/init-container:{{ .Values.image.tag }} diff --git a/List-Helm-Charts/get-service/templates/template.yaml b/List-Helm-Charts/get-service/templates/template.yaml index 5a9bad8..3817f96 100644 --- a/List-Helm-Charts/get-service/templates/template.yaml +++ b/List-Helm-Charts/get-service/templates/template.yaml @@ -30,8 +30,7 @@ spec: labels: app: get version: {{ .Values.deploy.version }} - annotations: - sidecar.istio.io/inject: "false" + spec: containers: - name: get diff --git a/List-Helm-Charts/ui-service/templates/template.yaml b/List-Helm-Charts/ui-service/templates/template.yaml index 02f7da8..2bfd0a9 100644 --- a/List-Helm-Charts/ui-service/templates/template.yaml +++ b/List-Helm-Charts/ui-service/templates/template.yaml @@ -21,8 +21,7 @@ kind: Deployment metadata: namespace: {{ .Values.namespace }} name: ui-deployment-{{ .Values.deploy.version }} - annotations: - sidecar.istio.io/inject: "false" + spec: selector: matchLabels: From e37aed701c09679d0326126f6cde1ef395a8a1b2 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 12 Feb 2019 14:51:05 -0500 Subject: [PATCH 202/241] TEST --- List-Helm-Charts/ui-service/templates/template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/List-Helm-Charts/ui-service/templates/template.yaml b/List-Helm-Charts/ui-service/templates/template.yaml index 2bfd0a9..11a2309 100644 --- a/List-Helm-Charts/ui-service/templates/template.yaml +++ b/List-Helm-Charts/ui-service/templates/template.yaml @@ -36,7 +36,7 @@ spec: spec: containers: - name: {{ .Values.app.name }} - image: "{{ .Values.image.repository }}/{{ .Values.image.name }}:{{ .Values.image.tag }}" + image: "{{ .Values.image.repository }}/ui-service:{{ .Values.image.tag }}" ports: - containerPort: 5000 env: From 5ad8c0eac6a84d9ac373a2beb96786801ef8da99 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 12 Feb 2019 15:45:47 -0500 Subject: [PATCH 203/241] Versions --- List-Helm-Charts/get-service/templates/template.yaml | 2 +- List-Helm-Charts/get-service/values.yaml | 3 +++ List-Helm-Charts/ui-service/templates/template.yaml | 4 ++-- List-Helm-Charts/ui-service/values.yaml | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/List-Helm-Charts/get-service/templates/template.yaml b/List-Helm-Charts/get-service/templates/template.yaml index 3817f96..d6293e5 100644 --- a/List-Helm-Charts/get-service/templates/template.yaml +++ b/List-Helm-Charts/get-service/templates/template.yaml @@ -41,5 +41,5 @@ spec: - name: URL_DB valueFrom: configMapKeyRef: - name: services-address + name: services-address-{{ .Values.conf.ver }} key: URL_DB diff --git a/List-Helm-Charts/get-service/values.yaml b/List-Helm-Charts/get-service/values.yaml index a5eef87..46fdf65 100644 --- a/List-Helm-Charts/get-service/values.yaml +++ b/List-Helm-Charts/get-service/values.yaml @@ -8,6 +8,9 @@ image: repository: 100.71.71.71:5000 tag: "" +conf: + ver: "" + app: name: get version: "" diff --git a/List-Helm-Charts/ui-service/templates/template.yaml b/List-Helm-Charts/ui-service/templates/template.yaml index 11a2309..45febe8 100644 --- a/List-Helm-Charts/ui-service/templates/template.yaml +++ b/List-Helm-Charts/ui-service/templates/template.yaml @@ -43,10 +43,10 @@ spec: - name: POST_SERVICE_URL valueFrom: configMapKeyRef: - name: services-address + name: services-address-{{ .Values.conf.ver }} key: POST_SERVICE_URL - name: VIEW_SERVICE_URL valueFrom: configMapKeyRef: - name: services-address + name: services-address-{{ .Values.conf.ver }} key: VIEW_SERVICE_URL diff --git a/List-Helm-Charts/ui-service/values.yaml b/List-Helm-Charts/ui-service/values.yaml index 50555ec..c7c2baa 100644 --- a/List-Helm-Charts/ui-service/values.yaml +++ b/List-Helm-Charts/ui-service/values.yaml @@ -9,6 +9,9 @@ image: tag: "" name: ui-service +conf: + ver: "" + app: name: ui From f34bdbbd18883ab2885cba120147ebcb555d1c9e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Tue, 12 Feb 2019 15:58:42 -0500 Subject: [PATCH 204/241] Bug resolve --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bbad847..e95aa80 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '', + defaultValue: '*', description: 'TAG_Change', name: 'service') ]) From d9fe9aa82dcd8076595911d86a192c22f58bdb1e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 05:12:06 -0500 Subject: [PATCH 205/241] Add POST to deploy --- Jenkinsfile_main | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile_main b/Jenkinsfile_main index 0f3b84d..f8205a3 100644 --- a/Jenkinsfile_main +++ b/Jenkinsfile_main @@ -1,5 +1,5 @@ def buildResult -def paramss = ["GitHub/SRM-GET/PR-3", "GitHub/SRM-UI/test", "GitHub/SRM-DB/PR-2"] +def paramss = ["GitHub/SRM-GET/PR-3", "GitHub/SRM-UI/test", "GitHub/SRM-DB/PR-2", "GitHub/SRM-POST/test"] def dockerRegistry = "100.71.71.71:5000" def Creds = "git_cred" properties([ From 0727a9900155c5d61913d68473b6724f6fbcc8cd Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 05:19:11 -0500 Subject: [PATCH 206/241] Add POST to deploy --- .../e2e-testing-post/templates/template.yaml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 List-Helm-Charts/e2e-testing-post/templates/template.yaml diff --git a/List-Helm-Charts/e2e-testing-post/templates/template.yaml b/List-Helm-Charts/e2e-testing-post/templates/template.yaml new file mode 100644 index 0000000..1891c9d --- /dev/null +++ b/List-Helm-Charts/e2e-testing-post/templates/template.yaml @@ -0,0 +1,44 @@ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: testing + name: post-service + labels: + app: post +spec: + selector: + app: post + ports: + - protocol: TCP + port: 5001 + targetPort: 5001 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: testing + name: post-deployment +spec: + selector: + matchLabels: + app: post + replicas: 1 + template: + metadata: + labels: + app: post + spec: + containers: + - name: post + image: 100.71.71.71:5000/post-service:{{ .Values.image.tag }} + ports: + - containerPort: 5001 + env: + - name: DB_URL + valueFrom: + configMapKeyRef: + name: services-address + key: DB_URL +--- From 7868ea9caaa87af8d6dac2403234b9a2e1e825c5 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 05:19:59 -0500 Subject: [PATCH 207/241] Add POST to deploy --- List-Helm-Charts/e2e-testing-post/values.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/List-Helm-Charts/e2e-testing-post/values.yaml b/List-Helm-Charts/e2e-testing-post/values.yaml index 5aab868..06ab2bf 100644 --- a/List-Helm-Charts/e2e-testing-post/values.yaml +++ b/List-Helm-Charts/e2e-testing-post/values.yaml @@ -13,7 +13,7 @@ image: post: "" app: - name: ui + name: post service: type: ClusterIP From 2a269c189f598a2a056ebdcaeab4c33a3cc133e0 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 11:08:17 -0500 Subject: [PATCH 208/241] Add POST to deploy-prod --- .../post-service/templates/template.yaml | 39 ++++++++----------- List-Helm-Charts/post-service/values.yaml | 8 +++- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/List-Helm-Charts/post-service/templates/template.yaml b/List-Helm-Charts/post-service/templates/template.yaml index 9b2de82..8311e4c 100644 --- a/List-Helm-Charts/post-service/templates/template.yaml +++ b/List-Helm-Charts/post-service/templates/template.yaml @@ -2,50 +2,43 @@ kind: Service apiVersion: v1 metadata: - namespace: {{ .Values.namespace }} - name: {{ .Values.service.servicename }} + namespace: production + name: post-service-{{ .Values.deploy.version }} labels: - app: {{ .Values.app.name }} - version: {{ .Values.deploy.version }} + app: post spec: selector: - app: {{ .Values.app.name }} + app: post ports: - protocol: TCP - port: 5000 - targetPort: 5000 + port: 5001 + targetPort: 5001 --- apiVersion: apps/v1 kind: Deployment metadata: - namespace: {{ .Values.namespace }} - name: ui-deployment + namespace: production + name: post-deployment-{{ .Values.deploy.version }} spec: selector: matchLabels: - app: {{ .Values.app.name }} - version: {{ .Values.deploy.version }} + app: post replicas: 1 template: metadata: labels: - app: {{ .Values.app.name }} + app: post version: {{ .Values.deploy.version }} spec: containers: - - name: {{ .Values.app.name }} - image: "{{ .Values.image.repository }}/{{ .Values.service.servicename }}:{{ .Values.image.tag }}" + - name: post + image: 100.71.71.71:5000/post-service:{{ .Values.image.tag }} ports: - - containerPort: 5000 + - containerPort: 5001 env: - - name: POST_SERVICE_URL + - name: DB_URL valueFrom: configMapKeyRef: - name: services-address - key: POST_SERVICE_URL - - name: VIEW_SERVICE_URL - valueFrom: - configMapKeyRef: - name: services-address - key: VIEW_SERVICE_URL + name: services-address-{{ .Values.conf.ver }} + key: DB_URL diff --git a/List-Helm-Charts/post-service/values.yaml b/List-Helm-Charts/post-service/values.yaml index 2a71e87..e4f9449 100644 --- a/List-Helm-Charts/post-service/values.yaml +++ b/List-Helm-Charts/post-service/values.yaml @@ -8,13 +8,17 @@ image: repository: 100.71.71.71:5000 tag: "" +conf: + ver: "" + app: - name: ui + name: post + version: "" service: type: ClusterIP port: 5000 - servicename: ui-service + servicename: post-service namespace: production From 67df5ea88099e90a08a9fb8a678a116288cfb54f Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 12:59:17 -0500 Subject: [PATCH 209/241] Add deploy POST --- Final_Magic/DeployCluster.sh | 21 + Final_Magic/DeployRegistry.yaml | 54 ++ Final_Magic/cluster.yaml | 58 ++ Final_Magic/magic.sh | 16 + Final_Magic/myjob.yaml | 649 ++++++++++++++++++ List-Helm-Charts/post-service-bg/.helmignore | 22 + List-Helm-Charts/post-service-bg/Chart.yaml | 5 + .../post-service-bg/templates/NOTES.txt | 21 + .../post-service-bg/templates/_helpers.tpl | 32 + .../post-service-bg/templates/deployment.yaml | 51 ++ .../post-service-bg/templates/ingress.yaml | 40 ++ .../post-service-bg/templates/service.yaml | 19 + .../templates/tests/test-connection.yaml | 18 + List-Helm-Charts/post-service-bg/values.yaml | 48 ++ .../post-service/templates/template.yaml | 8 +- 15 files changed, 1058 insertions(+), 4 deletions(-) create mode 100755 Final_Magic/DeployCluster.sh create mode 100644 Final_Magic/DeployRegistry.yaml create mode 100644 Final_Magic/cluster.yaml create mode 100755 Final_Magic/magic.sh create mode 100644 Final_Magic/myjob.yaml create mode 100644 List-Helm-Charts/post-service-bg/.helmignore create mode 100644 List-Helm-Charts/post-service-bg/Chart.yaml create mode 100644 List-Helm-Charts/post-service-bg/templates/NOTES.txt create mode 100644 List-Helm-Charts/post-service-bg/templates/_helpers.tpl create mode 100644 List-Helm-Charts/post-service-bg/templates/deployment.yaml create mode 100644 List-Helm-Charts/post-service-bg/templates/ingress.yaml create mode 100644 List-Helm-Charts/post-service-bg/templates/service.yaml create mode 100644 List-Helm-Charts/post-service-bg/templates/tests/test-connection.yaml create mode 100644 List-Helm-Charts/post-service-bg/values.yaml diff --git a/Final_Magic/DeployCluster.sh b/Final_Magic/DeployCluster.sh new file mode 100755 index 0000000..d9634a9 --- /dev/null +++ b/Final_Magic/DeployCluster.sh @@ -0,0 +1,21 @@ +#!/bin/bash +export NAME=kubern.cluster.k8s.local +export KOPS_STATE_STORE=s3://crm-system-k8s +kops create cluster --zones eu-west-1a ${NAME} --master-size=t2.small --node-size=t2.small --node-count=2 --master-volume-size=8 --node-volume-size=8 +sleep 10 +kops get cluster --name ${NAME} -oyaml > cluster.yaml +cat <<__EOF__>> cluster.yaml + fileAssets: + - content: | + { + "insecure-registries" : ["100.71.71.71:5000"] + } + name: insecure-registries + path: /etc/docker/daemon.json + roles: + - Master + - Node +__EOF__ +sleep 5 +kops replace -f cluster.yaml +kops update cluster ${NAME} --yes diff --git a/Final_Magic/DeployRegistry.yaml b/Final_Magic/DeployRegistry.yaml new file mode 100644 index 0000000..48a533d --- /dev/null +++ b/Final_Magic/DeployRegistry.yaml @@ -0,0 +1,54 @@ +--- +apiVersion: v1 +kind: Service +apiVersion: v1 +metadata: + name: docker-registry +spec: + clusterIP: "100.71.71.71" + selector: + app: docker-registry + ports: + - name: http + protocol: TCP + port: 5000 + targetPort: 5000 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: registry +spec: + replicas: 1 + selector: + matchLabels: + app: docker-registry + template: + metadata: + labels: + app: docker-registry + spec: + containers: + - name: registry + image: registry:2 + ports: + - name: registry-port + containerPort: 5000 + volumeMounts: + - mountPath: /var/lib/registry + name: images + volumes: + - name: images + persistentVolumeClaim: + claimName: registry-pv-claim +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: registry-pv-claim +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi diff --git a/Final_Magic/cluster.yaml b/Final_Magic/cluster.yaml new file mode 100644 index 0000000..ae849ca --- /dev/null +++ b/Final_Magic/cluster.yaml @@ -0,0 +1,58 @@ +apiVersion: kops/v1alpha2 +kind: Cluster +metadata: + creationTimestamp: 2019-02-13T16:21:27Z + name: kubern.cluster.k8s.local +spec: + api: + loadBalancer: + type: Public + authorization: + rbac: {} + channel: stable + cloudProvider: aws + configBase: s3://crm-system-k8s/kubern.cluster.k8s.local + etcdClusters: + - etcdMembers: + - instanceGroup: master-eu-west-1a + name: a + name: main + - etcdMembers: + - instanceGroup: master-eu-west-1a + name: a + name: events + iam: + allowContainerRegistry: true + legacy: false + kubelet: + anonymousAuth: false + kubernetesApiAccess: + - 0.0.0.0/0 + kubernetesVersion: 1.11.6 + masterPublicName: api.kubern.cluster.k8s.local + networkCIDR: 172.20.0.0/16 + networking: + kubenet: {} + nonMasqueradeCIDR: 100.64.0.0/10 + sshAccess: + - 0.0.0.0/0 + subnets: + - cidr: 172.20.32.0/19 + name: eu-west-1a + type: Public + zone: eu-west-1a + topology: + dns: + type: Public + masters: public + nodes: public + fileAssets: + - content: | + { + "insecure-registries" : ["100.71.71.71:5000"] + } + name: insecure-registries + path: /etc/docker/daemon.json + roles: + - Master + - Node diff --git a/Final_Magic/magic.sh b/Final_Magic/magic.sh new file mode 100755 index 0000000..b7336a7 --- /dev/null +++ b/Final_Magic/magic.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +. DeployCluster.sh + +sleep 3m + +kubectl apply -f DeployRegistry.yaml +kubectl apply -f myjob.yaml + +sleep 5m + +kubectl -n kube-system create serviceaccount tiller +kubectl create clusterrolebinding tiller \ + --clusterrole cluster-admin \ + --serviceaccount=kube-system:tiller +helm init --service-account tiller diff --git a/Final_Magic/myjob.yaml b/Final_Magic/myjob.yaml new file mode 100644 index 0000000..e2a7d3e --- /dev/null +++ b/Final_Magic/myjob.yaml @@ -0,0 +1,649 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: production + +--- + +apiVersion: v1 +kind: Namespace +metadata: + name: testing + +--- +#apiVersion: v1 +#kind: Secret +#metadata: +# name: db-secret +# namespace: production +#data: +# username: ZGJhZG1pbg== +# password: UGFzc3dvcmQ= +# dbname: c3Jtc3lzdGVt +#type: Opaque + +#--- + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: jenkins + namespace: production + +--- + +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: jenkins + namespace: production +rules: +- apiGroups: [""] + resources: ["pods"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/exec"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/log"] + verbs: ["get","list","watch"] +- apiGroups: [""] + resources: ["services"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["extensions"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["persistentvolumeclaims"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["secrets"] + verbs: ["get"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: jenkins + namespace: production +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: jenkins +subjects: +- kind: ServiceAccount + name: jenkins +--- + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: jenkins + namespace: testing + +--- + +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: jenkins-test + namespace: testing +rules: +- apiGroups: [""] + resources: ["pods"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/exec"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/log"] + verbs: ["get","list","watch"] +- apiGroups: [""] + resources: ["services"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["extensions"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["persistentvolumeclaims"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["secrets"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["namespaces"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["configmaps"] + verbs: ["create","delete","get","list","patch","update","watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: jenkins-test + namespace: testing +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: jenkins-test +subjects: +- kind: ServiceAccount + name: jenkins + namespace: production + +--- + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: jenkins + namespace: kube-system + +--- + +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: jenkins-kube + namespace: kube-system +rules: +- apiGroups: [""] + resources: ["pods"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/exec"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/log"] + verbs: ["get","list","watch"] +- apiGroups: [""] + resources: ["services"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["extensions"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["persistentvolumeclaims"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["secrets"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["namespaces"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["configmaps"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/portforward"] + verbs: ["create","delete","get","list","patch","update","watch"] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: jenkins-kube + namespace: kube-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: jenkins-kube +subjects: +- kind: ServiceAccount + name: jenkins + namespace: production +--- + + + +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: production + name: services-address-v1 +data: + POST_SERVICE_URL: post-service-v1.production.svc + VIEW_SERVICE_URL: get-service-v1.production.svc + DB_URL: db-service-v1.production.svc + URL_DB: db-service-v1.production.svc + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: production + name: services-address-v2 +data: + POST_SERVICE_URL: post-service-v2.production.svc + VIEW_SERVICE_URL: get-service-v2.production.svc + DB_URL: db-service-v2.production.svc + URL_DB: db-service-v2.production.svc +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: testing + name: services-address +data: + POST_SERVICE_URL: post-service.testing.svc + VIEW_SERVICE_URL: get-service.testing.svc + DB_URL: db-service.testing.svc + URL_DB: db-service.testing.svc + +--- + +apiVersion: v1 +data: + GitHub.xml: |- + + + + + GitHub + + + + + + + + + + git + + admgolovin + Slider256$ + + + github-1 + + admgolovin + $GITPWD + + + + + + + + + + + + + + + + false + + + + + + + true + 1 + 1 + + + + H/5 * * * * + 900000 + + + false + + + Kv-045DevOps + github-1 + + + Kubik-DB|SRM-GET|SRM-UI|SRM-DB + + + 1 + + + 1 + + + 1 + + + + + + + + Jenkinsfile + + + + + + + .* + true + + + + + +kind: ConfigMap +metadata: + creationTimestamp: "2019-01-18T03:22:02Z" + name: stark2 + namespace: production + resourceVersion: "96672" + selfLink: /api/v1/namespaces/default/configmaps/stark + uid: b70d8525-17fd-11e9-b845-02d08d5f4672 + +--- + +apiVersion: v1 +data: + config.xml: |- + + + + 2.150.2 + RUNNING + 2 + NORMAL + true + + false + + + true + false + + false + + ${JENKINS_HOME}/workspace/${ITEM_FULL_NAME} + ${ITEM_ROOTDIR}/builds + + + + + + kubernetes + + + https://kubernetes.default.svc + false + false + false + production + http://127.0.0.1:8080/ + kube-login + 10 + 5 + 0 + 0 + false + 32 + 600 + + + + 5 + 0 + + + + all + false + false + + + + all + 50000 + + + + + credentials.xml: |- + + + + + + + + + + GLOBAL + kube-login + + admin + $PASSWORD + + + GLOBAL + git_cred + + Maxghost33 + {AQAAABAAAAAg1cMYtdzX0b8pqPwU99XFsHEZtmsDLQy8n/RBMOnJnAj9ScoSD8i87dXfnx7TD0m+} + + + GLOBAL + docker_registry + + ghostgoose33 + {AQAAABAAAAAg8qaRTgg3fvfezKNrIlbz5LAhL3/WI0W5Nl4MLFgrPxYFSb8qACvkxcMFGvbtFQYx} + + + + + +kind: ConfigMap +metadata: + creationTimestamp: "2019-01-17T19:47:40Z" + name: jenconf + namespace: production + resourceVersion: "5227" + selfLink: /api/v1/namespaces/production/configmaps/jenconf + uid: bfec9ca6-1a90-11e9-a5b8-020fccbfb056 + +--- + +apiVersion: v1 +kind: Pod +metadata: + name: jenkins2 + namespace: production + labels: + service: jenkins2 +spec: + tolerations: + - key: "node" + operator: "Equal" + value: "boubde" + effect: "NoSchedule" + containers: + - name: stark-jenkins2 + image: admgolovin/myjenkins:v12 + volumeMounts: + - name: jenkins-config + mountPath: /var/jenkins_home/2/jobs/GitHub/ + - name: jenconf + mountPath: /var/jenkins_home/2 + lifecycle: + postStart: + exec: + command: ["/bin/sh","-c", "cp /var/jenkins_home/2/config.xml /var/jenkins_home/; cp /var/jenkins_home/2/credentials.xml /var/jenkins_home/; cp /var/jenkins_home/2/hudson.util.Secret /var/jenkins_home/secrets/; cp /var/jenkins_home/2/master.key /var/jenkins_home/secrets/; sleep 5m; java -jar /tools/jenkins-cli.jar -s http://127.0.0.1:8080 -auth admin:admin create-job GitHub < /var/jenkins_home/2/jobs/GitHub/GitHub.xml"] + serviceAccount: jenkins + serviceAccountName: jenkins + volumes: + - name: jenkins-config + configMap: + name: stark2 + - name: jenconf + configMap: + name: jenconf + restartPolicy: OnFailure + +# --- +# kind: Endpoints +# apiVersion: v1 +# metadata: +# name: my-service2 +# namespace: production +# subsets: +# - addresses: +# - ip: 10.0.0.1 +# targetRef: +# kind: Node +# name: node1 +# ports: +# - name: myjenkins +# port: 8080 +# protocol: TCP + +--- +kind: Service +apiVersion: v1 +metadata: + name: my-service + namespace: production +spec: + selector: + service: jenkins2 + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 + type: LoadBalancer + +--- + +kind: Service +apiVersion: v1 +metadata: + name: jenkins-agent + namespace: production +spec: + selector: + service: jenkins2 + ports: + - protocol: TCP + port: 50000 + targetPort: 50000 + type: LoadBalancer + +--- + +apiVersion: v1 +kind: Secret +metadata: + name: test-secret + namespace: production +data: + password: YWRtaW4= + +--- + +# apiVersion: v1 +# kind: Pod +# metadata: +# name: dind-jen +# namespace: production +# spec: +# containers: +# - name: jnlp +# image: '/myjenkins:jenslave' +# args: ['\$(JENKINS_SECRET)'] +# env: +# - name: DOCKER_HOST +# value: tcp://localhost:2375 +# - name: dind +# image: docker:stable-dind +# securityContext: +# privileged: true +# volumeMounts: +# - name: dind-storage +# mountPath: /var/lib/docker +# volumes: +# - name: dind-storage +# emptyDir: {} + +--- + +# apiVersion: v1 +# kind: Pod +# metadata: +# name: jenslave +# namespace: production +# labels: +# service: jenkins +# spec: +# containers: +# - name: jnlp +# image: /myjenkins:jenslave +# resources: +# limits: +# memory: "600Mi" +# requests: +# memory: "500Mi" + +# apiVersion: apps/v1 +# kind: Deployment +# metadata: +# name: jenkins-storage +# namespace: production +# spec: +# selector: +# matchLabels: +# service: jenkins +# template: +# metadata: +# labels: +# service: jenkins +# spec: +# containers: +# - name: stark-jenkins +# image: ghostgoose33/jenkins-alp:v2 +# volumeMounts: +# - name: jenkins-config +# mountPath: /var/lib/jenkins/job/GitHub +# volumes: +# - name: jenkins-config +# configMap: +# name: stark2 + +--- + +# apiVersion: v1 +# kind: Pod +# metadata: +# name: jenkins2 +# namespace: production +# labels: +# service: jenkins2 +# spec: +# containers: +# - name: stark-jenkins2 +# image: ghostgoose33/jenkins-alp:v2 + +# restartPolicy: OnFailure + +--- diff --git a/List-Helm-Charts/post-service-bg/.helmignore b/List-Helm-Charts/post-service-bg/.helmignore new file mode 100644 index 0000000..50af031 --- /dev/null +++ b/List-Helm-Charts/post-service-bg/.helmignore @@ -0,0 +1,22 @@ +# 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 +.vscode/ diff --git a/List-Helm-Charts/post-service-bg/Chart.yaml b/List-Helm-Charts/post-service-bg/Chart.yaml new file mode 100644 index 0000000..4c36a96 --- /dev/null +++ b/List-Helm-Charts/post-service-bg/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: A Helm chart for Kubernetes +name: post-service-bg +version: 0.1.0 diff --git a/List-Helm-Charts/post-service-bg/templates/NOTES.txt b/List-Helm-Charts/post-service-bg/templates/NOTES.txt new file mode 100644 index 0000000..cbe3ae2 --- /dev/null +++ b/List-Helm-Charts/post-service-bg/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range $.Values.ingress.paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "post-service-bg.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + 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 {{ include "post-service-bg.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "post-service-bg.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "post-service-bg.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/List-Helm-Charts/post-service-bg/templates/_helpers.tpl b/List-Helm-Charts/post-service-bg/templates/_helpers.tpl new file mode 100644 index 0000000..957c698 --- /dev/null +++ b/List-Helm-Charts/post-service-bg/templates/_helpers.tpl @@ -0,0 +1,32 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "post-service-bg.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). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "post-service-bg.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "post-service-bg.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/List-Helm-Charts/post-service-bg/templates/deployment.yaml b/List-Helm-Charts/post-service-bg/templates/deployment.yaml new file mode 100644 index 0000000..ad6c8f6 --- /dev/null +++ b/List-Helm-Charts/post-service-bg/templates/deployment.yaml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "post-service-bg.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "post-service-bg.name" . }} + helm.sh/chart: {{ include "post-service-bg.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "post-service-bg.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "post-service-bg.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/List-Helm-Charts/post-service-bg/templates/ingress.yaml b/List-Helm-Charts/post-service-bg/templates/ingress.yaml new file mode 100644 index 0000000..5173626 --- /dev/null +++ b/List-Helm-Charts/post-service-bg/templates/ingress.yaml @@ -0,0 +1,40 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "post-service-bg.fullname" . -}} +{{- $ingressPaths := .Values.ingress.paths -}} +apiVersion: extensions/v1beta1 +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + app.kubernetes.io/name: {{ include "post-service-bg.name" . }} + helm.sh/chart: {{ include "post-service-bg.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ . | quote }} + http: + paths: + {{- range $ingressPaths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: http + {{- end }} + {{- end }} +{{- end }} diff --git a/List-Helm-Charts/post-service-bg/templates/service.yaml b/List-Helm-Charts/post-service-bg/templates/service.yaml new file mode 100644 index 0000000..a458e2d --- /dev/null +++ b/List-Helm-Charts/post-service-bg/templates/service.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "post-service-bg.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "post-service-bg.name" . }} + helm.sh/chart: {{ include "post-service-bg.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app.kubernetes.io/name: {{ include "post-service-bg.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/List-Helm-Charts/post-service-bg/templates/tests/test-connection.yaml b/List-Helm-Charts/post-service-bg/templates/tests/test-connection.yaml new file mode 100644 index 0000000..34d5655 --- /dev/null +++ b/List-Helm-Charts/post-service-bg/templates/tests/test-connection.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "post-service-bg.fullname" . }}-test-connection" + labels: + app.kubernetes.io/name: {{ include "post-service-bg.name" . }} + helm.sh/chart: {{ include "post-service-bg.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "post-service-bg.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/List-Helm-Charts/post-service-bg/values.yaml b/List-Helm-Charts/post-service-bg/values.yaml new file mode 100644 index 0000000..7e5b7d2 --- /dev/null +++ b/List-Helm-Charts/post-service-bg/values.yaml @@ -0,0 +1,48 @@ +# Default values for post-service-bg. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nginx + tag: stable + pullPolicy: IfNotPresent + +nameOverride: "" +fullnameOverride: "" + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + paths: [] + hosts: + - chart-example.local + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/List-Helm-Charts/post-service/templates/template.yaml b/List-Helm-Charts/post-service/templates/template.yaml index 8311e4c..1b47116 100644 --- a/List-Helm-Charts/post-service/templates/template.yaml +++ b/List-Helm-Charts/post-service/templates/template.yaml @@ -3,7 +3,7 @@ kind: Service apiVersion: v1 metadata: namespace: production - name: post-service-{{ .Values.deploy.version }} + name: post-service-{{ .Values.conf.ver }} labels: app: post spec: @@ -11,7 +11,7 @@ spec: app: post ports: - protocol: TCP - port: 5001 + port: 80 targetPort: 5001 --- @@ -29,7 +29,6 @@ spec: metadata: labels: app: post - version: {{ .Values.deploy.version }} spec: containers: - name: post @@ -40,5 +39,6 @@ spec: - name: DB_URL valueFrom: configMapKeyRef: - name: services-address-{{ .Values.conf.ver }} + name: services-address-{{ .Values.con.ver }} key: DB_URL +--- From 6f1ccc7d471c8aca4b87c077bf0c1346276b977f Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 13:20:14 -0500 Subject: [PATCH 210/241] TEST --- .../e2e-testing-post/templates/NOTES.txt | 21 -------- .../e2e-testing-post/templates/_helpers.tpl | 32 ------------ .../templates/deployment.yaml | 51 ------------------- .../e2e-testing-post/templates/ingress.yaml | 40 --------------- .../e2e-testing-post/templates/service.yaml | 19 ------- .../templates/tests/test-connection.yaml | 18 ------- .../post-service-bg/templates/NOTES.txt | 21 -------- .../post-service-bg/templates/_helpers.tpl | 32 ------------ .../post-service-bg/templates/deployment.yaml | 51 ------------------- .../post-service-bg/templates/ingress.yaml | 40 --------------- .../post-service-bg/templates/service.yaml | 19 ------- .../templates/tests/test-connection.yaml | 18 ------- 12 files changed, 362 deletions(-) delete mode 100644 List-Helm-Charts/e2e-testing-post/templates/NOTES.txt delete mode 100644 List-Helm-Charts/e2e-testing-post/templates/_helpers.tpl delete mode 100644 List-Helm-Charts/e2e-testing-post/templates/deployment.yaml delete mode 100644 List-Helm-Charts/e2e-testing-post/templates/ingress.yaml delete mode 100644 List-Helm-Charts/e2e-testing-post/templates/service.yaml delete mode 100644 List-Helm-Charts/e2e-testing-post/templates/tests/test-connection.yaml delete mode 100644 List-Helm-Charts/post-service-bg/templates/NOTES.txt delete mode 100644 List-Helm-Charts/post-service-bg/templates/_helpers.tpl delete mode 100644 List-Helm-Charts/post-service-bg/templates/deployment.yaml delete mode 100644 List-Helm-Charts/post-service-bg/templates/ingress.yaml delete mode 100644 List-Helm-Charts/post-service-bg/templates/service.yaml delete mode 100644 List-Helm-Charts/post-service-bg/templates/tests/test-connection.yaml diff --git a/List-Helm-Charts/e2e-testing-post/templates/NOTES.txt b/List-Helm-Charts/e2e-testing-post/templates/NOTES.txt deleted file mode 100644 index 4ea37b1..0000000 --- a/List-Helm-Charts/e2e-testing-post/templates/NOTES.txt +++ /dev/null @@ -1,21 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range $.Values.ingress.paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "e2e-testing-post.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - 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 {{ include "e2e-testing-post.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "e2e-testing-post.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "e2e-testing-post.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} diff --git a/List-Helm-Charts/e2e-testing-post/templates/_helpers.tpl b/List-Helm-Charts/e2e-testing-post/templates/_helpers.tpl deleted file mode 100644 index 89537a3..0000000 --- a/List-Helm-Charts/e2e-testing-post/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "e2e-testing-post.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). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "e2e-testing-post.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "e2e-testing-post.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/List-Helm-Charts/e2e-testing-post/templates/deployment.yaml b/List-Helm-Charts/e2e-testing-post/templates/deployment.yaml deleted file mode 100644 index 842c695..0000000 --- a/List-Helm-Charts/e2e-testing-post/templates/deployment.yaml +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "e2e-testing-post.fullname" . }} - labels: - app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} - helm.sh/chart: {{ include "e2e-testing-post.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - template: - metadata: - labels: - app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - spec: - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/List-Helm-Charts/e2e-testing-post/templates/ingress.yaml b/List-Helm-Charts/e2e-testing-post/templates/ingress.yaml deleted file mode 100644 index 11639ab..0000000 --- a/List-Helm-Charts/e2e-testing-post/templates/ingress.yaml +++ /dev/null @@ -1,40 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "e2e-testing-post.fullname" . -}} -{{- $ingressPaths := .Values.ingress.paths -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} - helm.sh/chart: {{ include "e2e-testing-post.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . | quote }} - http: - paths: - {{- range $ingressPaths }} - - path: {{ . }} - backend: - serviceName: {{ $fullName }} - servicePort: http - {{- end }} - {{- end }} -{{- end }} diff --git a/List-Helm-Charts/e2e-testing-post/templates/service.yaml b/List-Helm-Charts/e2e-testing-post/templates/service.yaml deleted file mode 100644 index 5ed0a02..0000000 --- a/List-Helm-Charts/e2e-testing-post/templates/service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "e2e-testing-post.fullname" . }} - labels: - app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} - helm.sh/chart: {{ include "e2e-testing-post.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/List-Helm-Charts/e2e-testing-post/templates/tests/test-connection.yaml b/List-Helm-Charts/e2e-testing-post/templates/tests/test-connection.yaml deleted file mode 100644 index defab0d..0000000 --- a/List-Helm-Charts/e2e-testing-post/templates/tests/test-connection.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "e2e-testing-post.fullname" . }}-test-connection" - labels: - app.kubernetes.io/name: {{ include "e2e-testing-post.name" . }} - helm.sh/chart: {{ include "e2e-testing-post.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} - annotations: - "helm.sh/hook": test-success -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "e2e-testing-post.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never diff --git a/List-Helm-Charts/post-service-bg/templates/NOTES.txt b/List-Helm-Charts/post-service-bg/templates/NOTES.txt deleted file mode 100644 index cbe3ae2..0000000 --- a/List-Helm-Charts/post-service-bg/templates/NOTES.txt +++ /dev/null @@ -1,21 +0,0 @@ -1. Get the application URL by running these commands: -{{- if .Values.ingress.enabled }} -{{- range $host := .Values.ingress.hosts }} - {{- range $.Values.ingress.paths }} - http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host }}{{ . }} - {{- end }} -{{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "post-service-bg.fullname" . }}) - export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") - echo http://$NODE_IP:$NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} - 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 {{ include "post-service-bg.fullname" . }}' - export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "post-service-bg.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}') - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} - export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "post-service-bg.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - echo "Visit http://127.0.0.1:8080 to use your application" - kubectl port-forward $POD_NAME 8080:80 -{{- end }} diff --git a/List-Helm-Charts/post-service-bg/templates/_helpers.tpl b/List-Helm-Charts/post-service-bg/templates/_helpers.tpl deleted file mode 100644 index 957c698..0000000 --- a/List-Helm-Charts/post-service-bg/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "post-service-bg.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). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "post-service-bg.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "post-service-bg.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/List-Helm-Charts/post-service-bg/templates/deployment.yaml b/List-Helm-Charts/post-service-bg/templates/deployment.yaml deleted file mode 100644 index ad6c8f6..0000000 --- a/List-Helm-Charts/post-service-bg/templates/deployment.yaml +++ /dev/null @@ -1,51 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "post-service-bg.fullname" . }} - labels: - app.kubernetes.io/name: {{ include "post-service-bg.name" . }} - helm.sh/chart: {{ include "post-service-bg.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -spec: - replicas: {{ .Values.replicaCount }} - selector: - matchLabels: - app.kubernetes.io/name: {{ include "post-service-bg.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - template: - metadata: - labels: - app.kubernetes.io/name: {{ include "post-service-bg.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - spec: - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - ports: - - name: http - containerPort: 80 - protocol: TCP - livenessProbe: - httpGet: - path: / - port: http - readinessProbe: - httpGet: - path: / - port: http - resources: - {{- toYaml .Values.resources | nindent 12 }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} diff --git a/List-Helm-Charts/post-service-bg/templates/ingress.yaml b/List-Helm-Charts/post-service-bg/templates/ingress.yaml deleted file mode 100644 index 5173626..0000000 --- a/List-Helm-Charts/post-service-bg/templates/ingress.yaml +++ /dev/null @@ -1,40 +0,0 @@ -{{- if .Values.ingress.enabled -}} -{{- $fullName := include "post-service-bg.fullname" . -}} -{{- $ingressPaths := .Values.ingress.paths -}} -apiVersion: extensions/v1beta1 -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - app.kubernetes.io/name: {{ include "post-service-bg.name" . }} - helm.sh/chart: {{ include "post-service-bg.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: -{{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} -{{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ . | quote }} - http: - paths: - {{- range $ingressPaths }} - - path: {{ . }} - backend: - serviceName: {{ $fullName }} - servicePort: http - {{- end }} - {{- end }} -{{- end }} diff --git a/List-Helm-Charts/post-service-bg/templates/service.yaml b/List-Helm-Charts/post-service-bg/templates/service.yaml deleted file mode 100644 index a458e2d..0000000 --- a/List-Helm-Charts/post-service-bg/templates/service.yaml +++ /dev/null @@ -1,19 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ include "post-service-bg.fullname" . }} - labels: - app.kubernetes.io/name: {{ include "post-service-bg.name" . }} - helm.sh/chart: {{ include "post-service-bg.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ .Values.service.port }} - targetPort: http - protocol: TCP - name: http - selector: - app.kubernetes.io/name: {{ include "post-service-bg.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/List-Helm-Charts/post-service-bg/templates/tests/test-connection.yaml b/List-Helm-Charts/post-service-bg/templates/tests/test-connection.yaml deleted file mode 100644 index 34d5655..0000000 --- a/List-Helm-Charts/post-service-bg/templates/tests/test-connection.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: v1 -kind: Pod -metadata: - name: "{{ include "post-service-bg.fullname" . }}-test-connection" - labels: - app.kubernetes.io/name: {{ include "post-service-bg.name" . }} - helm.sh/chart: {{ include "post-service-bg.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} - annotations: - "helm.sh/hook": test-success -spec: - containers: - - name: wget - image: busybox - command: ['wget'] - args: ['{{ include "post-service-bg.fullname" . }}:{{ .Values.service.port }}'] - restartPolicy: Never From 0992b7d86512d4592bae9cbe688cabf615c93c60 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 13:33:24 -0500 Subject: [PATCH 211/241] TEST --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e95aa80..bbad847 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '*', + defaultValue: '', description: 'TAG_Change', name: 'service') ]) From a2b784abc523f6d365385d50ec8a7993d07b386b Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 13:44:24 -0500 Subject: [PATCH 212/241] TEST POST --- List-Helm-Charts/e2e-testing-post/templates/template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/List-Helm-Charts/e2e-testing-post/templates/template.yaml b/List-Helm-Charts/e2e-testing-post/templates/template.yaml index 1891c9d..c0bbc6d 100644 --- a/List-Helm-Charts/e2e-testing-post/templates/template.yaml +++ b/List-Helm-Charts/e2e-testing-post/templates/template.yaml @@ -32,7 +32,7 @@ spec: spec: containers: - name: post - image: 100.71.71.71:5000/post-service:{{ .Values.image.tag }} + image: 100.71.71.71:5000/post-service:{{ .Values.image.tag.post }} ports: - containerPort: 5001 env: From 615801d1e28001c0a4b2893c500ec3c02faffe81 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 14:01:22 -0500 Subject: [PATCH 213/241] TEST DEPLOY POST --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index bbad847..053063c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -68,6 +68,7 @@ node(label) build(job: 'GitHub/GET-SERVICES/test1', parameters: [[$class: 'StringParameterValue', name:"imageTagGET_", value: "${imageTagGET}"], [$class: 'StringParameterValue', name:"imageTagUI_", value: "${params.imageTagUI_}"], [$class: 'StringParameterValue', name:"imageTagDB_", value: "${params.imageTagDB_}"], + [$class: 'StringParameterValue', name:"imageTagPOST_", value: "${params.imageTagPOST_}"], [$class: 'StringParameterValue', name:"service", value: "get"]], wait: true) } else { echo "NO" From c7ec7e94970ed12fa79ddda25c856551bba33af2 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 14:27:34 -0500 Subject: [PATCH 214/241] DEPLOY POST --- List-Helm-Charts/post-service/templates/template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/List-Helm-Charts/post-service/templates/template.yaml b/List-Helm-Charts/post-service/templates/template.yaml index 1b47116..aeb66a3 100644 --- a/List-Helm-Charts/post-service/templates/template.yaml +++ b/List-Helm-Charts/post-service/templates/template.yaml @@ -39,6 +39,6 @@ spec: - name: DB_URL valueFrom: configMapKeyRef: - name: services-address-{{ .Values.con.ver }} + name: services-address-{{ .Values.conf.ver }} key: DB_URL --- From 20c0205f0d6ad9528c0f03bfaa0b7be676737913 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 15:16:00 -0500 Subject: [PATCH 215/241] TEST BG DEPLOY --- List-Helm-Charts/db-service-bg/values.yaml | 3 +- .../get-service-bg/templates/template.yaml | 2 +- List-Helm-Charts/get-service-bg/values.yaml | 2 + .../post-service-bg/templates/template.yaml | 44 ++++++++++++++++++ List-Helm-Charts/post-service-bg/values.yaml | 46 ++++++++----------- .../ui-service-bg/templates/template.yaml | 3 +- List-Helm-Charts/ui-service-bg/values.yaml | 3 +- 7 files changed, 70 insertions(+), 33 deletions(-) create mode 100644 List-Helm-Charts/post-service-bg/templates/template.yaml diff --git a/List-Helm-Charts/db-service-bg/values.yaml b/List-Helm-Charts/db-service-bg/values.yaml index a5eef87..1f09568 100644 --- a/List-Helm-Charts/db-service-bg/values.yaml +++ b/List-Helm-Charts/db-service-bg/values.yaml @@ -7,7 +7,8 @@ replicaCount: 1 image: repository: 100.71.71.71:5000 tag: "" - +conf: + ver: "" app: name: get version: "" diff --git a/List-Helm-Charts/get-service-bg/templates/template.yaml b/List-Helm-Charts/get-service-bg/templates/template.yaml index 537dfb7..088a6a7 100644 --- a/List-Helm-Charts/get-service-bg/templates/template.yaml +++ b/List-Helm-Charts/get-service-bg/templates/template.yaml @@ -24,7 +24,7 @@ spec: - name: URL_DB valueFrom: configMapKeyRef: - name: services-address + name: services-address-{{ .Values.conf.ver }} key: URL_DB --- kind: Service diff --git a/List-Helm-Charts/get-service-bg/values.yaml b/List-Helm-Charts/get-service-bg/values.yaml index a5eef87..e182f3a 100644 --- a/List-Helm-Charts/get-service-bg/values.yaml +++ b/List-Helm-Charts/get-service-bg/values.yaml @@ -12,6 +12,8 @@ app: name: get version: "" +conf: + ver: "" service: type: ClusterIP port: 5000 diff --git a/List-Helm-Charts/post-service-bg/templates/template.yaml b/List-Helm-Charts/post-service-bg/templates/template.yaml new file mode 100644 index 0000000..8311e4c --- /dev/null +++ b/List-Helm-Charts/post-service-bg/templates/template.yaml @@ -0,0 +1,44 @@ +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: post-service-{{ .Values.deploy.version }} + labels: + app: post +spec: + selector: + app: post + ports: + - protocol: TCP + port: 5001 + targetPort: 5001 + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: production + name: post-deployment-{{ .Values.deploy.version }} +spec: + selector: + matchLabels: + app: post + replicas: 1 + template: + metadata: + labels: + app: post + version: {{ .Values.deploy.version }} + spec: + containers: + - name: post + image: 100.71.71.71:5000/post-service:{{ .Values.image.tag }} + ports: + - containerPort: 5001 + env: + - name: DB_URL + valueFrom: + configMapKeyRef: + name: services-address-{{ .Values.conf.ver }} + key: DB_URL diff --git a/List-Helm-Charts/post-service-bg/values.yaml b/List-Helm-Charts/post-service-bg/values.yaml index 7e5b7d2..2ea6ea2 100644 --- a/List-Helm-Charts/post-service-bg/values.yaml +++ b/List-Helm-Charts/post-service-bg/values.yaml @@ -4,36 +4,31 @@ replicaCount: 1 +# Default values for UI-SERVICE. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + image: - repository: nginx - tag: stable - pullPolicy: IfNotPresent + repository: 100.71.71.71:5000 + tag: "" -nameOverride: "" -fullnameOverride: "" +app: + name: post + version: "" service: type: ClusterIP - port: 80 - -ingress: - enabled: false - annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" - paths: [] - hosts: - - chart-example.local - tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local + port: 5000 + servicename: post-service + +namespace: production + +deploy: + version: "" resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. # limits: # cpu: 100m # memory: 128Mi @@ -41,8 +36,3 @@ resources: {} # cpu: 100m # memory: 128Mi -nodeSelector: {} - -tolerations: [] - -affinity: {} diff --git a/List-Helm-Charts/ui-service-bg/templates/template.yaml b/List-Helm-Charts/ui-service-bg/templates/template.yaml index 3789321..1a2471f 100644 --- a/List-Helm-Charts/ui-service-bg/templates/template.yaml +++ b/List-Helm-Charts/ui-service-bg/templates/template.yaml @@ -30,10 +30,9 @@ spec: - name: VIEW_SERVICE_URL valueFrom: configMapKeyRef: - name: services-address + name: services-address-{{ .Values.conf.ver }} key: VIEW_SERVICE_URL --- ---- kind: Service apiVersion: v1 metadata: diff --git a/List-Helm-Charts/ui-service-bg/values.yaml b/List-Helm-Charts/ui-service-bg/values.yaml index a5eef87..96b6aab 100644 --- a/List-Helm-Charts/ui-service-bg/values.yaml +++ b/List-Helm-Charts/ui-service-bg/values.yaml @@ -11,7 +11,8 @@ image: app: name: get version: "" - +conf: + ver: "" service: type: ClusterIP port: 5000 From 14ac1060cbe094f9e112d751bffbd5bdcbefa131 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 15:38:32 -0500 Subject: [PATCH 216/241] TEST DEPLOY POST --- List-Helm-Charts/e2e-testing-ui/templates/template.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/List-Helm-Charts/e2e-testing-ui/templates/template.yaml b/List-Helm-Charts/e2e-testing-ui/templates/template.yaml index 080aec9..8d8baf1 100644 --- a/List-Helm-Charts/e2e-testing-ui/templates/template.yaml +++ b/List-Helm-Charts/e2e-testing-ui/templates/template.yaml @@ -40,4 +40,9 @@ spec: configMapKeyRef: name: services-address key: VIEW_SERVICE_URL + - name: POST_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: POST_SERVICE_URL --- From bf8654220f1a41679417def7bed23fde2e6f04dd Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 15:43:41 -0500 Subject: [PATCH 217/241] ADD CHANGE PORT --- List-Helm-Charts/post-service/templates/template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/List-Helm-Charts/post-service/templates/template.yaml b/List-Helm-Charts/post-service/templates/template.yaml index aeb66a3..82610d3 100644 --- a/List-Helm-Charts/post-service/templates/template.yaml +++ b/List-Helm-Charts/post-service/templates/template.yaml @@ -11,7 +11,7 @@ spec: app: post ports: - protocol: TCP - port: 80 + port: 5001 targetPort: 5001 --- From a8447d4d49734fbed4f426c7d4cdbc5d4a829914 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 16:03:46 -0500 Subject: [PATCH 218/241] TEST POST v67 --- List-Helm-Charts/e2e-testing-ui/templates/template.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/List-Helm-Charts/e2e-testing-ui/templates/template.yaml b/List-Helm-Charts/e2e-testing-ui/templates/template.yaml index 8d8baf1..080aec9 100644 --- a/List-Helm-Charts/e2e-testing-ui/templates/template.yaml +++ b/List-Helm-Charts/e2e-testing-ui/templates/template.yaml @@ -40,9 +40,4 @@ spec: configMapKeyRef: name: services-address key: VIEW_SERVICE_URL - - name: POST_SERVICE_URL - valueFrom: - configMapKeyRef: - name: services-address - key: POST_SERVICE_URL --- From a8ca0140d97d6c0bb69e65b5239ae206f4c887d0 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 16:09:04 -0500 Subject: [PATCH 219/241] TEST POST v67 --- List-Helm-Charts/e2e-testing-ui/templates/template.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/List-Helm-Charts/e2e-testing-ui/templates/template.yaml b/List-Helm-Charts/e2e-testing-ui/templates/template.yaml index 080aec9..7630c23 100644 --- a/List-Helm-Charts/e2e-testing-ui/templates/template.yaml +++ b/List-Helm-Charts/e2e-testing-ui/templates/template.yaml @@ -40,4 +40,9 @@ spec: configMapKeyRef: name: services-address key: VIEW_SERVICE_URL + - name: POST_SERVICE_URL + valueFrom: + configMapKeyRef: + name: services-address + key: POST_SERVICE_URL --- From 205635b768fd4c860bac3a6c9722e8f2ded161e9 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Wed, 13 Feb 2019 16:24:48 -0500 Subject: [PATCH 220/241] 23 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 053063c..566ec11 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '', + defaultValue: '*', description: 'TAG_Change', name: 'service') ]) From f0efee5fec153c2266b270eff1587c79f179c986 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 04:53:30 -0500 Subject: [PATCH 221/241] TEST B/G --- Final_Magic/magic.sh | 4 +- Final_Magic/myjob.yaml | 97 +++++++++++++++++++ .../ui-service-bg/templates/template.yaml | 2 +- 3 files changed, 100 insertions(+), 3 deletions(-) diff --git a/Final_Magic/magic.sh b/Final_Magic/magic.sh index b7336a7..26d1e8c 100755 --- a/Final_Magic/magic.sh +++ b/Final_Magic/magic.sh @@ -1,8 +1,8 @@ #!/bin/bash -. DeployCluster.sh +#. DeployCluster.sh -sleep 3m +#sleep 3m kubectl apply -f DeployRegistry.yaml kubectl apply -f myjob.yaml diff --git a/Final_Magic/myjob.yaml b/Final_Magic/myjob.yaml index e2a7d3e..0fd9c40 100644 --- a/Final_Magic/myjob.yaml +++ b/Final_Magic/myjob.yaml @@ -11,6 +11,12 @@ metadata: name: testing --- + +apiVersion: v1 +kind: Namespace +metadata: + name: production-bg +--- #apiVersion: v1 #kind: Secret #metadata: @@ -24,6 +30,13 @@ metadata: #--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: jenkins + namespace: production-bg +--- + apiVersion: v1 kind: ServiceAccount metadata: @@ -212,6 +225,64 @@ subjects: --- +kind: Role +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: jenkins-bg + namespace: production-bg +rules: +- apiGroups: [""] + resources: ["pods"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/exec"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/log"] + verbs: ["get","list","watch"] +- apiGroups: [""] + resources: ["services"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["apps"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: ["extensions"] + resources: ["deployments"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["persistentvolumeclaims"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["secrets"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["namespaces"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["configmaps"] + verbs: ["create","delete","get","list","patch","update","watch"] +- apiGroups: [""] + resources: ["pods/portforward"] + verbs: ["create","delete","get","list","patch","update","watch"] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: jenkins-bg + namespace: production-bg +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: jenkins-kube +subjects: +- kind: ServiceAccount + name: jenkins + namespace: production +--- apiVersion: v1 kind: ConfigMap @@ -247,8 +318,34 @@ data: DB_URL: db-service.testing.svc URL_DB: db-service.testing.svc + +--- + +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: production-bg + name: services-address-v1 +data: + POST_SERVICE_URL: post-service-v1.production-bg.svc + VIEW_SERVICE_URL: get-service-v1.production-bg.svc + DB_URL: db-service-v1.production-bg.svc + URL_DB: db-service-v1.production-bg.svc + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: production-bg + name: services-address-v2 +data: + POST_SERVICE_URL: post-service-v2.production-bg.svc + VIEW_SERVICE_URL: get-service-v2.production-bg.svc + DB_URL: db-service-v2.production-bg.svc + URL_DB: db-service-v2.production-bg.svc --- + apiVersion: v1 data: GitHub.xml: |- diff --git a/List-Helm-Charts/ui-service-bg/templates/template.yaml b/List-Helm-Charts/ui-service-bg/templates/template.yaml index 1a2471f..9da046a 100644 --- a/List-Helm-Charts/ui-service-bg/templates/template.yaml +++ b/List-Helm-Charts/ui-service-bg/templates/template.yaml @@ -25,7 +25,7 @@ spec: - name: POST_SERVICE_URL valueFrom: configMapKeyRef: - name: services-address + name: services-address-{{ .Values.conf.ver }} key: POST_SERVICE_URL - name: VIEW_SERVICE_URL valueFrom: From 51e996e15a113d90d516723168c7bfa6b24b149c Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 05:34:58 -0500 Subject: [PATCH 222/241] TEST B/G Ver1 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 566ec11..053063c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '*', + defaultValue: '', description: 'TAG_Change', name: 'service') ]) From 85cc7ace5c75396eb5eac9f4d5545154990b2837 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 06:04:18 -0500 Subject: [PATCH 223/241] GIT HUB PERIOD#2 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 053063c..566ec11 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '', + defaultValue: '*', description: 'TAG_Change', name: 'service') ]) From c631bfc7f56a1c1e23edae4d738c3f48ba57cb58 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 06:13:42 -0500 Subject: [PATCH 224/241] B/G Ver 2 --- List-Helm-Charts/get-service-bg/templates/template.yaml | 2 +- List-Helm-Charts/post-service-bg/templates/template.yaml | 2 +- List-Helm-Charts/ui-service-bg/templates/template.yaml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/List-Helm-Charts/get-service-bg/templates/template.yaml b/List-Helm-Charts/get-service-bg/templates/template.yaml index 088a6a7..e931fce 100644 --- a/List-Helm-Charts/get-service-bg/templates/template.yaml +++ b/List-Helm-Charts/get-service-bg/templates/template.yaml @@ -24,7 +24,7 @@ spec: - name: URL_DB valueFrom: configMapKeyRef: - name: services-address-{{ .Values.conf.ver }} + name: services-address-{{ .Values.deploy.version }} key: URL_DB --- kind: Service diff --git a/List-Helm-Charts/post-service-bg/templates/template.yaml b/List-Helm-Charts/post-service-bg/templates/template.yaml index 8311e4c..27ddddf 100644 --- a/List-Helm-Charts/post-service-bg/templates/template.yaml +++ b/List-Helm-Charts/post-service-bg/templates/template.yaml @@ -40,5 +40,5 @@ spec: - name: DB_URL valueFrom: configMapKeyRef: - name: services-address-{{ .Values.conf.ver }} + name: services-address-{{ .Values.deploy.version }} key: DB_URL diff --git a/List-Helm-Charts/ui-service-bg/templates/template.yaml b/List-Helm-Charts/ui-service-bg/templates/template.yaml index 9da046a..8dfe380 100644 --- a/List-Helm-Charts/ui-service-bg/templates/template.yaml +++ b/List-Helm-Charts/ui-service-bg/templates/template.yaml @@ -25,12 +25,12 @@ spec: - name: POST_SERVICE_URL valueFrom: configMapKeyRef: - name: services-address-{{ .Values.conf.ver }} + name: services-address-{{ .Values.deploy.version }} key: POST_SERVICE_URL - name: VIEW_SERVICE_URL valueFrom: configMapKeyRef: - name: services-address-{{ .Values.conf.ver }} + name: services-address-{{ .Values.deploy.version }} key: VIEW_SERVICE_URL --- kind: Service From f86ff8889693cbe67daa9508c037f06775b93c9d Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 06:26:28 -0500 Subject: [PATCH 225/241] B/G v3 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 566ec11..053063c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '*', + defaultValue: '', description: 'TAG_Change', name: 'service') ]) From 27f96bcd68e851d62182a665cca097a14b54c5b4 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 06:37:13 -0500 Subject: [PATCH 226/241] TEST B/G Ver4 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 053063c..566ec11 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '', + defaultValue: '*', description: 'TAG_Change', name: 'service') ]) From dae0b9d14b764b581bcb94f3c00d193b9a73d941 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 06:45:35 -0500 Subject: [PATCH 227/241] B/G v5 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 566ec11..053063c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '*', + defaultValue: '', description: 'TAG_Change', name: 'service') ]) From f38486bb6422ab544bb985f16db2aa3adf0eb180 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 07:29:55 -0500 Subject: [PATCH 228/241] TEST B/G v6 --- List-Helm-Charts/ui-service/templates/template.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/List-Helm-Charts/ui-service/templates/template.yaml b/List-Helm-Charts/ui-service/templates/template.yaml index 45febe8..b8d65eb 100644 --- a/List-Helm-Charts/ui-service/templates/template.yaml +++ b/List-Helm-Charts/ui-service/templates/template.yaml @@ -5,11 +5,11 @@ metadata: namespace: {{ .Values.namespace }} name: {{ .Values.service.servicename }} labels: - app: {{ .Values.app.name }} + app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" version: {{ .Values.deploy.version }} spec: selector: - app: {{ .Values.app.name }} + app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" ports: - protocol: TCP port: 5000 @@ -25,17 +25,17 @@ metadata: spec: selector: matchLabels: - app: {{ .Values.app.name }} + app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" version: {{ .Values.deploy.version }} replicas: 1 template: metadata: labels: - app: {{ .Values.app.name }} + app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" version: {{ .Values.deploy.version }} spec: containers: - - name: {{ .Values.app.name }} + - name: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" image: "{{ .Values.image.repository }}/ui-service:{{ .Values.image.tag }}" ports: - containerPort: 5000 From d9b125473fff80d79b10f30885fec9947e2dc007 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 07:39:39 -0500 Subject: [PATCH 229/241] TEST B/G v6 --- .../Blue-Green/Jenkinsfile_delete_pod | 27 ++++++++----------- .../ui-service-bg/templates/template.yaml | 10 +++---- List-Helm-Charts/ui-service-bg/values.yaml | 4 +-- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod index ec6cdd4..19c11f1 100644 --- a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod +++ b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod @@ -9,8 +9,8 @@ properties([ defaultValue: '***', description: '', name: 'service'), - choice(choices: ['db', 'ui', 'get'], description: 'What Service?', name: 'service-del'), - choice(choices: ['v1', 'v2'], description: 'What version?', name: 'version-del') + choice(choices: ["db", "ui", "get"], description: 'What Service?', name: "servicedel"), + choice(choices: ["v1", "v2"], description: 'What version?', name: "versiondel") ]) ]) @@ -36,45 +36,40 @@ node(label) } } stage("Deploy to Kubernetes"){ - if(params.service-del == "db"){ + if(params.servicedel == "db"){ container ("helm"){ - if (params.version-del == "v2"){ + if (params.versiondel == "v2"){ sh "helm delete db-service-v2 --purge" sh "helm upgrade --install --namespace production --force istio-rules-db ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=db-service" } - if (params.version-del == "v1"){ + if (params.versiondel == "v1"){ sh "helm delete db-service-v1 --purge" } } } - if(params.service-del == "get"){ + if(params.servicedel == "get"){ container ("helm"){ - if (params.version-del == "v2"){ + if (params.versiondel == "v2"){ sh "helm delete get-service-v2 --purge" sh "helm upgrade --install --namespace production --force istio-rules-get ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=get" } - if (params.version-del == "v1"){ + if (params.versiondel == "v1"){ sh "helm delete get-service-v1 --purge" } } } - if(params.service-del == "ui"){ + if(params.servicedel == "ui"){ container ("helm"){ - if (params.version-del == "v2"){ + if (params.versiondel == "v2"){ sh "helm delete ui-service-v2 --purge" sh "helm upgrade --install --namespace production --force istio-rules-ui ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=ui" } - if (params.version-del == "v1"){ + if (params.versiondel == "v1"){ sh "helm delete ui-service-v1 --purge" } } } - if(params.service == "post"){ - container ("helm"){ - - } - } } sleep 10 diff --git a/List-Helm-Charts/ui-service-bg/templates/template.yaml b/List-Helm-Charts/ui-service-bg/templates/template.yaml index 8dfe380..a8df535 100644 --- a/List-Helm-Charts/ui-service-bg/templates/template.yaml +++ b/List-Helm-Charts/ui-service-bg/templates/template.yaml @@ -13,11 +13,11 @@ spec: template: metadata: labels: - app: {{ .Values.app.name }} + app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" version: {{ .Values.deploy.version }} spec: containers: - - name: {{ .Values.app.name }} + - name: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" image: "{{ .Values.image.repository }}/{{ .Values.service.servicename }}:{{ .Values.image.tag }}" ports: - containerPort: 5000 @@ -37,13 +37,13 @@ kind: Service apiVersion: v1 metadata: namespace: {{ .Values.namespace }} - name: "{{ .Values.service.servicename }}-{{ .Values.deploy.version }} + name: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" labels: - app: {{ .Values.app.name }} + app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" version: {{ .Values.deploy.version }} spec: selector: - app: {{ .Values.app.name }} + app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" ports: - protocol: TCP port: 5000 diff --git a/List-Helm-Charts/ui-service-bg/values.yaml b/List-Helm-Charts/ui-service-bg/values.yaml index 96b6aab..1b0552a 100644 --- a/List-Helm-Charts/ui-service-bg/values.yaml +++ b/List-Helm-Charts/ui-service-bg/values.yaml @@ -9,14 +9,14 @@ image: tag: "" app: - name: get + name: ui version: "" conf: ver: "" service: type: ClusterIP port: 5000 - servicename: get-service + servicename: ui-service namespace: production From a5367d79d4fb9be0b4a3300bd591a9b7748818c5 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 07:53:04 -0500 Subject: [PATCH 230/241] TEST B/G v6 --- List-Helm-Charts/ui-service/templates/template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/List-Helm-Charts/ui-service/templates/template.yaml b/List-Helm-Charts/ui-service/templates/template.yaml index b8d65eb..c30a4c1 100644 --- a/List-Helm-Charts/ui-service/templates/template.yaml +++ b/List-Helm-Charts/ui-service/templates/template.yaml @@ -3,7 +3,7 @@ kind: Service apiVersion: v1 metadata: namespace: {{ .Values.namespace }} - name: {{ .Values.service.servicename }} + name: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" labels: app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" version: {{ .Values.deploy.version }} From 71461e7862c5ddd1c21ad0923b1f800622aa58ae Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 15:15:12 -0500 Subject: [PATCH 231/241] ISTIO FUCKING RELEASE --- Final_Magic/cluster.yaml | 2 +- Final_Magic/magic.sh | 5 +- Jenkinsfile | 2 +- .../Blue-Green/Jenkinsfile_delete_pod | 13 +++- .../Blue-Green/Jenkinsfile_deploy_bg | 65 ++++++++++--------- 5 files changed, 52 insertions(+), 35 deletions(-) diff --git a/Final_Magic/cluster.yaml b/Final_Magic/cluster.yaml index ae849ca..8334512 100644 --- a/Final_Magic/cluster.yaml +++ b/Final_Magic/cluster.yaml @@ -1,7 +1,7 @@ apiVersion: kops/v1alpha2 kind: Cluster metadata: - creationTimestamp: 2019-02-13T16:21:27Z + creationTimestamp: 2019-02-14T17:33:50Z name: kubern.cluster.k8s.local spec: api: diff --git a/Final_Magic/magic.sh b/Final_Magic/magic.sh index 26d1e8c..0119f89 100755 --- a/Final_Magic/magic.sh +++ b/Final_Magic/magic.sh @@ -1,8 +1,8 @@ #!/bin/bash -#. DeployCluster.sh +. DeployCluster.sh -#sleep 3m +sleep 3m kubectl apply -f DeployRegistry.yaml kubectl apply -f myjob.yaml @@ -14,3 +14,4 @@ kubectl create clusterrolebinding tiller \ --clusterrole cluster-admin \ --serviceaccount=kube-system:tiller helm init --service-account tiller + diff --git a/Jenkinsfile b/Jenkinsfile index 053063c..566ec11 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '', + defaultValue: '*', description: 'TAG_Change', name: 'service') ]) diff --git a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod index 19c11f1..d2c8f77 100644 --- a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod +++ b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod @@ -9,7 +9,7 @@ properties([ defaultValue: '***', description: '', name: 'service'), - choice(choices: ["db", "ui", "get"], description: 'What Service?', name: "servicedel"), + choice(choices: ["db", "ui", "get", "post"], description: 'What Service?', name: "servicedel"), choice(choices: ["v1", "v2"], description: 'What version?', name: "versiondel") ]) ]) @@ -69,6 +69,17 @@ node(label) } } } + if(params.servicedel == "post"){ + container ("helm"){ + if (params.versiondel == "v2"){ + sh "helm delete post-service-v2 --purge" + sh "helm upgrade --install --namespace production --force istio-rules-post ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=post" + } + if (params.versiondel == "v1"){ + sh "helm delete post-service-v1 --purge" + } + } + } } diff --git a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg index 0ac5d88..ef0120e 100644 --- a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg +++ b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_deploy_bg @@ -8,7 +8,9 @@ properties([ stringParam( defaultValue: '***', description: '', - name: 'service') + name: 'service'), + choice(choices: ["db", "ui", "get", "post"], description: 'What Service?', name: "servicedel"), + choice(choices: ["v1", "v2"], description: 'What version?', name: "versiondel") ]) ]) @@ -34,48 +36,51 @@ node(label) } } stage("Deploy to Kubernetes"){ - if(params.service == "db"){ + if(params.servicedel == "db"){ container ("helm"){ - check = sh(script: """helm list -c db-service | awk '{ print \$1 }' | grep v1""", returnStdout:true) - echo "${check}" - if (check){ - sh "helm upgrade --install --namespace production --force db-service-v2 ${pathTocodeget}/List-Helm-Charts/db-service-bg --set=deploy.version=v2,image.tag=${params.imageTagDB_}" - sh "helm upgrade --install --namespace production --force istio-rules-db ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=0,--set weight.v2=100, --set app=db-service"} - else{ - sh "helm upgrade --install --namespace production --force db-service-v1 ${pathTocodeget}/List-Helm-Charts/db-service --set=deploy.version=v1,image.tag=${params.imageTagDB_}" + if (params.versiondel == "v2"){ + sh "helm delete db-service-v2 --purge" + sh "helm upgrade --install --namespace production --force istio-rules-db ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100 --set weight.v2=0 --set app=db-service" + } + if (params.versiondel == "v1"){ + sh "helm delete db-service-v1 --purge" } } } - if(params.service == "get"){ + if(params.servicedel == "get"){ container ("helm"){ - check = sh(script: """helm list -c get-service | awk '{ print \$1 }' | grep v1""", returnStdout:true) - echo "${check}" - if (check){ - sh "helm upgrade --install --namespace production --force get-service-v2 ${pathTocodeget}/List-Helm-Charts/get-service-bg --set=deploy.version=v2,image.tag=${params.imageTagGET_}" - sh "helm upgrade --install --namespace production --force istio-rules-get ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=0 --set weight.v2=100 --set app.name=get"} - else{ - sh "helm upgrade --install --namespace production --force get-service-v1 ${pathTocodeget}/List-Helm-Charts/get-service --set=deploy.version=v1,image.tag=${params.imageTagGET_}" + if (params.versiondel == "v2"){ + sh "helm delete get-service-v2 --purge" + sh "helm upgrade --install --namespace production --force istio-rules-get ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100 --set weight.v2=0 --set app=get" + } + if (params.versiondel == "v1"){ + sh "helm delete get-service-v1 --purge" } } } - if(params.service == "ui"){ + if(params.servicedel == "ui"){ container ("helm"){ - check = sh(script: """helm list -c ui-service | awk '{ print \$1 }' | grep v1""", returnStdout:true) - echo "${check}" - if (check){ - sh "helm upgrade --install --namespace production --force ui-service-v2 ${pathTocodeget}/List-Helm-Charts/ui-service-bg --set=deploy.version=v2,image.tag=${params.imageTagUI_}" - sh "helm upgrade --install --namespace production --force istio-rules-ui ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=0,--set weight.v2=100, --set app.name=ui"} - else{ - sh "helm upgrade --install --namespace production --force ui-service-v1 ${pathTocodeget}/List-Helm-Charts/ui-service --set=deploy.version=v1,image.tag=${params.imageTagUI_}" + if (params.versiondel == "v2"){ + sh "helm delete ui-service-v2 --purge" + sh "helm upgrade --install --namespace production --force istio-rules-ui ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100 --set weight.v2=0 --set app=ui" + } + if (params.versiondel == "v1"){ + sh "helm delete ui-service-v1 --purge" } } } - - if(params.service == "post"){ - container ("helm"){ - + if(params.servicedel == "post"){ + container ("helm"){ + if (params.versiondel == "v2"){ + sh "helm delete post-service-v2 --purge" + sh "helm upgrade --install --namespace production --force istio-rules-post ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100 --set weight.v2=0 --set app=post" + } + if (params.versiondel == "v1"){ + sh "helm delete post-service-v1 --purge" + } + } } - } + } sleep 10 From ab16a651a21adc9f5296679cc0826128bbe386cc Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 16:52:45 -0500 Subject: [PATCH 232/241] TEST B/G v45 --- Final_Magic/myjob.yaml | 70 ++++++++++++++++++- Jenkinsfile | 2 +- .../db-service/templates/template.yaml | 13 ---- .../get-service/templates/template.yaml | 18 +---- .../post-service/templates/template.yaml | 18 +---- .../ui-service/templates/template.yaml | 21 +----- 6 files changed, 74 insertions(+), 68 deletions(-) diff --git a/Final_Magic/myjob.yaml b/Final_Magic/myjob.yaml index 0fd9c40..d155b15 100644 --- a/Final_Magic/myjob.yaml +++ b/Final_Magic/myjob.yaml @@ -294,7 +294,17 @@ data: VIEW_SERVICE_URL: get-service-v1.production.svc DB_URL: db-service-v1.production.svc URL_DB: db-service-v1.production.svc - +--- +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: production + name: services-address +data: + POST_SERVICE_URL: post-service.production.svc + VIEW_SERVICE_URL: get-service.production.svc + DB_URL: db-service.production.svc + URL_DB: db-service.production.svc --- apiVersion: v1 kind: ConfigMap @@ -744,3 +754,61 @@ data: # restartPolicy: OnFailure --- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: ui + labels: + app: ui +spec: + selector: + app: ui + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: get-service + labels: + app: get +spec: + selector: + app: get + ports: + - protocol: TCP + port: 5003 + targetPort: 5003 +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: post-service + labels: + app: post +spec: + selector: + app: post + ports: + - protocol: TCP + port: 5001 + targetPort: 5001 +--- +kind: Service +apiVersion: v1 +metadata: + namespace: production + name: db-service +spec: + selector: + app: db-service + ports: + - protocol: TCP + port: 5002 + targetPort: 5002 +--- diff --git a/Jenkinsfile b/Jenkinsfile index 566ec11..6e63cfc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '*', + defaultValue: '***', description: 'TAG_Change', name: 'service') ]) diff --git a/List-Helm-Charts/db-service/templates/template.yaml b/List-Helm-Charts/db-service/templates/template.yaml index a65008a..eeb2970 100644 --- a/List-Helm-Charts/db-service/templates/template.yaml +++ b/List-Helm-Charts/db-service/templates/template.yaml @@ -71,16 +71,3 @@ spec: name: db-secret key: password --- -kind: Service -apiVersion: v1 -metadata: - namespace: production - name: db-service-{{ .Values.deploy.version }} -spec: - selector: - app: db-service - ports: - - protocol: TCP - port: 5002 - targetPort: 5002 ---- diff --git a/List-Helm-Charts/get-service/templates/template.yaml b/List-Helm-Charts/get-service/templates/template.yaml index d6293e5..e6234dd 100644 --- a/List-Helm-Charts/get-service/templates/template.yaml +++ b/List-Helm-Charts/get-service/templates/template.yaml @@ -1,19 +1,3 @@ ---- -kind: Service -apiVersion: v1 -metadata: - namespace: production - name: get-service-{{ .Values.deploy.version }} - labels: - app: get -spec: - selector: - app: get - ports: - - protocol: TCP - port: 5003 - targetPort: 5003 - --- apiVersion: apps/v1 kind: Deployment @@ -41,5 +25,5 @@ spec: - name: URL_DB valueFrom: configMapKeyRef: - name: services-address-{{ .Values.conf.ver }} + name: services-address key: URL_DB diff --git a/List-Helm-Charts/post-service/templates/template.yaml b/List-Helm-Charts/post-service/templates/template.yaml index 82610d3..add40f3 100644 --- a/List-Helm-Charts/post-service/templates/template.yaml +++ b/List-Helm-Charts/post-service/templates/template.yaml @@ -1,19 +1,3 @@ ---- -kind: Service -apiVersion: v1 -metadata: - namespace: production - name: post-service-{{ .Values.conf.ver }} - labels: - app: post -spec: - selector: - app: post - ports: - - protocol: TCP - port: 5001 - targetPort: 5001 - --- apiVersion: apps/v1 kind: Deployment @@ -39,6 +23,6 @@ spec: - name: DB_URL valueFrom: configMapKeyRef: - name: services-address-{{ .Values.conf.ver }} + name: services-address key: DB_URL --- diff --git a/List-Helm-Charts/ui-service/templates/template.yaml b/List-Helm-Charts/ui-service/templates/template.yaml index c30a4c1..e76de7b 100644 --- a/List-Helm-Charts/ui-service/templates/template.yaml +++ b/List-Helm-Charts/ui-service/templates/template.yaml @@ -1,20 +1,3 @@ ---- -kind: Service -apiVersion: v1 -metadata: - namespace: {{ .Values.namespace }} - name: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" - labels: - app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" - version: {{ .Values.deploy.version }} -spec: - selector: - app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" - ports: - - protocol: TCP - port: 5000 - targetPort: 5000 - --- apiVersion: apps/v1 kind: Deployment @@ -43,10 +26,10 @@ spec: - name: POST_SERVICE_URL valueFrom: configMapKeyRef: - name: services-address-{{ .Values.conf.ver }} + name: services-address key: POST_SERVICE_URL - name: VIEW_SERVICE_URL valueFrom: configMapKeyRef: - name: services-address-{{ .Values.conf.ver }} + name: services-address key: VIEW_SERVICE_URL From 050c6ab5cd5cebb9b3cedf3e693688750cbe64f9 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 17:04:34 -0500 Subject: [PATCH 233/241] TEST B/G v45 --- List-Helm-Charts/ui-service/templates/template.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/List-Helm-Charts/ui-service/templates/template.yaml b/List-Helm-Charts/ui-service/templates/template.yaml index e76de7b..3adeeab 100644 --- a/List-Helm-Charts/ui-service/templates/template.yaml +++ b/List-Helm-Charts/ui-service/templates/template.yaml @@ -8,13 +8,13 @@ metadata: spec: selector: matchLabels: - app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" + app: ui version: {{ .Values.deploy.version }} replicas: 1 template: metadata: labels: - app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" + app: ui version: {{ .Values.deploy.version }} spec: containers: From 986c49499d956c939420523ae26c5b73c1cedaac Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 17:24:06 -0500 Subject: [PATCH 234/241] Deploy B/G --- List-Helm-Charts/istio-rules/templates/template.yaml | 3 +++ List-Helm-Charts/istio-rules/values.yaml | 11 ++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/List-Helm-Charts/istio-rules/templates/template.yaml b/List-Helm-Charts/istio-rules/templates/template.yaml index d063376..0d953c8 100644 --- a/List-Helm-Charts/istio-rules/templates/template.yaml +++ b/List-Helm-Charts/istio-rules/templates/template.yaml @@ -23,6 +23,9 @@ spec: gateways: - srm-gateway http: + - match: + - uri: + prefix: "/" - route: - destination: host: {{ .Values.app.name }} diff --git a/List-Helm-Charts/istio-rules/values.yaml b/List-Helm-Charts/istio-rules/values.yaml index b1802d4..21d9029 100644 --- a/List-Helm-Charts/istio-rules/values.yaml +++ b/List-Helm-Charts/istio-rules/values.yaml @@ -7,9 +7,14 @@ replicaCount: 1 image: repository: 100.71.71.71:5000 tag: "" +app: + name: "" +deploy: + version: "" -service: - type: ClusterIP - port: 80 +weight: + v1: "" + v2: "" +port: "" From abdb10cfb5e9a3ff156f131f226744a3e4ea89a6 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 18:13:30 -0500 Subject: [PATCH 235/241] TEST B/G v51 --- List-Helm-Charts/istio-rules/templates/template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/List-Helm-Charts/istio-rules/templates/template.yaml b/List-Helm-Charts/istio-rules/templates/template.yaml index 0d953c8..b1ce8eb 100644 --- a/List-Helm-Charts/istio-rules/templates/template.yaml +++ b/List-Helm-Charts/istio-rules/templates/template.yaml @@ -26,7 +26,7 @@ spec: - match: - uri: prefix: "/" - - route: + route: - destination: host: {{ .Values.app.name }} subset: v1 From 558b0f0c6b5aadbc5a8b923355647f39488d6d6b Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 18:33:36 -0500 Subject: [PATCH 236/241] TEST B/G --- .../db-service-bg/templates/template.yaml | 13 ---------- .../get-service-bg/templates/template.yaml | 25 +++---------------- .../get-service/templates/template.yaml | 6 ++--- .../post-service-bg/templates/template.yaml | 25 ++++--------------- .../post-service/templates/template.yaml | 6 ++--- .../ui-service-bg/templates/template.yaml | 25 ++++--------------- List-Helm-Charts/ui-service-bg/values.yaml | 2 +- 7 files changed, 21 insertions(+), 81 deletions(-) diff --git a/List-Helm-Charts/db-service-bg/templates/template.yaml b/List-Helm-Charts/db-service-bg/templates/template.yaml index 5866fa6..696c27a 100644 --- a/List-Helm-Charts/db-service-bg/templates/template.yaml +++ b/List-Helm-Charts/db-service-bg/templates/template.yaml @@ -1,17 +1,4 @@ --- -kind: Service -apiVersion: v1 -metadata: - namespace: production - name: db-service-{{ .Values.deploy.version }} -spec: - selector: - app: db-service - ports: - - protocol: TCP - port: 5002 - targetPort: 5002 ---- apiVersion: apps/v1 kind: Deployment metadata: diff --git a/List-Helm-Charts/get-service-bg/templates/template.yaml b/List-Helm-Charts/get-service-bg/templates/template.yaml index e931fce..472405e 100644 --- a/List-Helm-Charts/get-service-bg/templates/template.yaml +++ b/List-Helm-Charts/get-service-bg/templates/template.yaml @@ -7,16 +7,16 @@ metadata: spec: selector: matchLabels: - app: get + app: get-service replicas: 1 template: metadata: labels: - app: get + app: get-service version: {{ .Values.deploy.version }} spec: containers: - - name: get + - name: get-service image: "{{ .Values.image.repository }}/get-service:{{ .Values.image.tag }}" ports: - containerPort: 5003 @@ -24,22 +24,5 @@ spec: - name: URL_DB valueFrom: configMapKeyRef: - name: services-address-{{ .Values.deploy.version }} + name: services-address key: URL_DB ---- -kind: Service -apiVersion: v1 -metadata: - namespace: production - name: get-service-{{ .Values.deploy.version }} - labels: - app: get -spec: - selector: - app: get - ports: - - protocol: TCP - port: 5003 - targetPort: 5003 - ---- diff --git a/List-Helm-Charts/get-service/templates/template.yaml b/List-Helm-Charts/get-service/templates/template.yaml index e6234dd..04a5805 100644 --- a/List-Helm-Charts/get-service/templates/template.yaml +++ b/List-Helm-Charts/get-service/templates/template.yaml @@ -7,17 +7,17 @@ metadata: spec: selector: matchLabels: - app: get + app: get-service replicas: 1 template: metadata: labels: - app: get + app: get-service version: {{ .Values.deploy.version }} spec: containers: - - name: get + - name: get-service image: "{{ .Values.image.repository }}/get-service:{{ .Values.image.tag }}" ports: - containerPort: 5003 diff --git a/List-Helm-Charts/post-service-bg/templates/template.yaml b/List-Helm-Charts/post-service-bg/templates/template.yaml index 27ddddf..2a5958a 100644 --- a/List-Helm-Charts/post-service-bg/templates/template.yaml +++ b/List-Helm-Charts/post-service-bg/templates/template.yaml @@ -1,19 +1,3 @@ ---- -kind: Service -apiVersion: v1 -metadata: - namespace: production - name: post-service-{{ .Values.deploy.version }} - labels: - app: post -spec: - selector: - app: post - ports: - - protocol: TCP - port: 5001 - targetPort: 5001 - --- apiVersion: apps/v1 kind: Deployment @@ -23,16 +7,16 @@ metadata: spec: selector: matchLabels: - app: post + app: post-service replicas: 1 template: metadata: labels: - app: post + app: post-service version: {{ .Values.deploy.version }} spec: containers: - - name: post + - name: post-service image: 100.71.71.71:5000/post-service:{{ .Values.image.tag }} ports: - containerPort: 5001 @@ -40,5 +24,6 @@ spec: - name: DB_URL valueFrom: configMapKeyRef: - name: services-address-{{ .Values.deploy.version }} + name: services-address key: DB_URL +--- diff --git a/List-Helm-Charts/post-service/templates/template.yaml b/List-Helm-Charts/post-service/templates/template.yaml index add40f3..63c3b28 100644 --- a/List-Helm-Charts/post-service/templates/template.yaml +++ b/List-Helm-Charts/post-service/templates/template.yaml @@ -7,15 +7,15 @@ metadata: spec: selector: matchLabels: - app: post + app: post-service replicas: 1 template: metadata: labels: - app: post + app: post-service spec: containers: - - name: post + - name: post-service image: 100.71.71.71:5000/post-service:{{ .Values.image.tag }} ports: - containerPort: 5001 diff --git a/List-Helm-Charts/ui-service-bg/templates/template.yaml b/List-Helm-Charts/ui-service-bg/templates/template.yaml index a8df535..10ac6f8 100644 --- a/List-Helm-Charts/ui-service-bg/templates/template.yaml +++ b/List-Helm-Charts/ui-service-bg/templates/template.yaml @@ -7,17 +7,17 @@ metadata: spec: selector: matchLabels: - app: {{ .Values.app.name }} + app: ui version: {{ .Values.deploy.version }} replicas: 1 template: metadata: labels: - app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" + app: {{ .Values.app.name }} version: {{ .Values.deploy.version }} spec: containers: - - name: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" + - name: {{ .Values.app.name }} image: "{{ .Values.image.repository }}/{{ .Values.service.servicename }}:{{ .Values.image.tag }}" ports: - containerPort: 5000 @@ -25,26 +25,11 @@ spec: - name: POST_SERVICE_URL valueFrom: configMapKeyRef: - name: services-address-{{ .Values.deploy.version }} + name: services-address key: POST_SERVICE_URL - name: VIEW_SERVICE_URL valueFrom: configMapKeyRef: - name: services-address-{{ .Values.deploy.version }} + name: services-address key: VIEW_SERVICE_URL --- -kind: Service -apiVersion: v1 -metadata: - namespace: {{ .Values.namespace }} - name: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" - labels: - app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" - version: {{ .Values.deploy.version }} -spec: - selector: - app: "{{ .Values.app.name }}-{{ .Values.deploy.version }}" - ports: - - protocol: TCP - port: 5000 - targetPort: 5000 diff --git a/List-Helm-Charts/ui-service-bg/values.yaml b/List-Helm-Charts/ui-service-bg/values.yaml index 1b0552a..d5d6815 100644 --- a/List-Helm-Charts/ui-service-bg/values.yaml +++ b/List-Helm-Charts/ui-service-bg/values.yaml @@ -16,7 +16,7 @@ conf: service: type: ClusterIP port: 5000 - servicename: ui-service + servicename: ui namespace: production From 6b680199249e83204c4bd9ac8cb1ae409d474376 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 19:42:11 -0500 Subject: [PATCH 237/241] TEST BG 02:42 15.02.2019 --- Final_Magic/myjob.yaml | 8 ++++---- Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod | 8 ++++---- List-Helm-Charts/istio-rules/templates/template.yaml | 5 +---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Final_Magic/myjob.yaml b/Final_Magic/myjob.yaml index d155b15..77f5377 100644 --- a/Final_Magic/myjob.yaml +++ b/Final_Magic/myjob.yaml @@ -775,10 +775,10 @@ metadata: namespace: production name: get-service labels: - app: get + app: get-service spec: selector: - app: get + app: get-service ports: - protocol: TCP port: 5003 @@ -790,10 +790,10 @@ metadata: namespace: production name: post-service labels: - app: post + app: post-service spec: selector: - app: post + app: post-service ports: - protocol: TCP port: 5001 diff --git a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod index d2c8f77..b8336b6 100644 --- a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod +++ b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod @@ -40,7 +40,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete db-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-db ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=db-service" + sh "helm upgrade --install --namespace production --force istio-rules-db ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=db-service, --set port=5002" } if (params.versiondel == "v1"){ sh "helm delete db-service-v1 --purge" @@ -51,7 +51,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete get-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-get ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=get" + sh "helm upgrade --install --namespace production --force istio-rules-get ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=get, --set port=5003" } if (params.versiondel == "v1"){ sh "helm delete get-service-v1 --purge" @@ -62,7 +62,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete ui-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-ui ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=ui" + sh "helm upgrade --install --namespace production --force istio-rules-ui ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=ui, --set port=5000" } if (params.versiondel == "v1"){ sh "helm delete ui-service-v1 --purge" @@ -73,7 +73,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete post-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-post ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=post" + sh "helm upgrade --install --namespace production --force istio-rules-post ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=post, --set port=5003" } if (params.versiondel == "v1"){ sh "helm delete post-service-v1 --purge" diff --git a/List-Helm-Charts/istio-rules/templates/template.yaml b/List-Helm-Charts/istio-rules/templates/template.yaml index b1ce8eb..d063376 100644 --- a/List-Helm-Charts/istio-rules/templates/template.yaml +++ b/List-Helm-Charts/istio-rules/templates/template.yaml @@ -23,10 +23,7 @@ spec: gateways: - srm-gateway http: - - match: - - uri: - prefix: "/" - route: + - route: - destination: host: {{ .Values.app.name }} subset: v1 From 19727b20c79a5d1fa4e09493a2ccb7b3c681c8e9 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 21:01:15 -0500 Subject: [PATCH 238/241] TEST --- Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod | 8 ++++---- List-Helm-Charts/istio-rules/templates/template.yaml | 4 ++-- List-Helm-Charts/istio-rules/values.yaml | 5 +++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod index b8336b6..978534e 100644 --- a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod +++ b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod @@ -40,7 +40,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete db-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-db ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=db-service, --set port=5002" + sh "helm upgrade --install --namespace production --force istio-rules-db ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app=db-service, --set port=5002" } if (params.versiondel == "v1"){ sh "helm delete db-service-v1 --purge" @@ -51,7 +51,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete get-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-get ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=get, --set port=5003" + sh "helm upgrade --install --namespace production --force istio-rules-get ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app=get-service, --set port=5003" } if (params.versiondel == "v1"){ sh "helm delete get-service-v1 --purge" @@ -62,7 +62,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete ui-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-ui ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=ui, --set port=5000" + sh "helm upgrade --install --namespace production --force istio-rules-ui ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app=ui, --set port=5000" } if (params.versiondel == "v1"){ sh "helm delete ui-service-v1 --purge" @@ -73,7 +73,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete post-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-post ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100,--set weight.v2=0, --set app=post, --set port=5003" + sh "helm upgrade --install --namespace production --force istio-rules-post ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app=post-service, --set port=5003" } if (params.versiondel == "v1"){ sh "helm delete post-service-v1 --purge" diff --git a/List-Helm-Charts/istio-rules/templates/template.yaml b/List-Helm-Charts/istio-rules/templates/template.yaml index d063376..f4a7112 100644 --- a/List-Helm-Charts/istio-rules/templates/template.yaml +++ b/List-Helm-Charts/istio-rules/templates/template.yaml @@ -2,7 +2,7 @@ apiVersion: networking.istio.io/v1alpha3 kind: DestinationRule metadata: - name: {{ .Values.app.name }} + name: {{ .Values.app.name }}-{{ .Values.vers }} spec: host: {{ .Values.app.name }} subsets: @@ -16,7 +16,7 @@ spec: apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: - name: {{ .Values.app.name }} + name: {{ .Values.app.name }}-{{ .Values.vers }} spec: hosts: - "*" diff --git a/List-Helm-Charts/istio-rules/values.yaml b/List-Helm-Charts/istio-rules/values.yaml index 21d9029..961801a 100644 --- a/List-Helm-Charts/istio-rules/values.yaml +++ b/List-Helm-Charts/istio-rules/values.yaml @@ -7,12 +7,17 @@ replicaCount: 1 image: repository: 100.71.71.71:5000 tag: "" + + app: name: "" +vers: "" + deploy: version: "" + weight: v1: "" v2: "" From b3dfe9b70a17e8dcbb55274f4c0a0b8291bc04a2 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 21:05:40 -0500 Subject: [PATCH 239/241] TEST --- Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod index 978534e..40f7ccf 100644 --- a/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod +++ b/Jenkinsfiles_Helm/Blue-Green/Jenkinsfile_delete_pod @@ -40,7 +40,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete db-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-db ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app=db-service, --set port=5002" + sh "helm upgrade --install --namespace production --force istio-rules-db-v1 ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app.name=db-service, --set port=5002, --set vers=v1" } if (params.versiondel == "v1"){ sh "helm delete db-service-v1 --purge" @@ -51,7 +51,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete get-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-get ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app=get-service, --set port=5003" + sh "helm upgrade --install --namespace production --force istio-rules-get-v1 ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app.name=get-service, --set port=5003, --set vers=v1" } if (params.versiondel == "v1"){ sh "helm delete get-service-v1 --purge" @@ -62,7 +62,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete ui-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-ui ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app=ui, --set port=5000" + sh "helm upgrade --install --namespace production --force istio-rules-ui-v1 ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app.name=ui, --set port=5000, --set vers=v1" } if (params.versiondel == "v1"){ sh "helm delete ui-service-v1 --purge" @@ -73,7 +73,7 @@ node(label) container ("helm"){ if (params.versiondel == "v2"){ sh "helm delete post-service-v2 --purge" - sh "helm upgrade --install --namespace production --force istio-rules-post ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app=post-service, --set port=5003" + sh "helm upgrade --install --namespace production --force istio-rules-post-v1 ${pathTocodeget}/List-Helm-Charts/istio-rules --set weight.v1=100, --set weight.v2=0, --set app.name=post-service, --set port=5001, --set vers=v1" } if (params.versiondel == "v1"){ sh "helm delete post-service-v1 --purge" From e1bc302da7b4bce6a85d899528dba46d3a2baae1 Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Thu, 14 Feb 2019 21:13:18 -0500 Subject: [PATCH 240/241] TEST --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6e63cfc..566ec11 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '***', + defaultValue: '*', description: 'TAG_Change', name: 'service') ]) From 6f947e11d386934e3a8cd603e76eda351ccdef5e Mon Sep 17 00:00:00 2001 From: Maxghost33 Date: Fri, 15 Feb 2019 12:51:29 -0500 Subject: [PATCH 241/241] DEMO --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 566ec11..6e63cfc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -20,7 +20,7 @@ def imageN = '100.71.71.71:5000/get-service:' properties([ parameters([ stringParam( - defaultValue: '*', + defaultValue: '***', description: 'TAG_Change', name: 'service') ])