From b909a054e1556459aa37e644162f5989ebab7cd5 Mon Sep 17 00:00:00 2001 From: BillMills Date: Mon, 6 Jan 2020 16:11:13 -0500 Subject: [PATCH 01/26] testing --- api/Dockerfile | 8 ++++++++ api/pom.xml | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/api/Dockerfile b/api/Dockerfile index 210b75a..3dba7bc 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -5,9 +5,17 @@ RUN mvn -B -f pom.xml -s /usr/share/maven/ref/settings-docker.xml dependency:res COPY . . RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml package -DskipTests +FROM maven:3.6.3-jdk-8 AS test +WORKDIR /usr/src/ddev +COPY unit-pom.xml . +RUN mvn -B -f unit-pom.xml -s /usr/share/maven/ref/settings-docker.xml dependency:resolve +COPY . . +CMD ["mvn", "clean", "test"] + FROM java:8-jdk-alpine RUN adduser -Dh /home/gordon gordon WORKDIR /app COPY --from=appserver /usr/src/ddev/target/ddev-0.0.1-SNAPSHOT.jar . ENTRYPOINT ["java", "-jar", "/app/ddev-0.0.1-SNAPSHOT.jar"] CMD ["--spring.profiles.active=postgres"] + diff --git a/api/pom.xml b/api/pom.xml index 1984e06..cd9e016 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -92,6 +92,16 @@ true + + org.apache.maven.plugins + maven-compiler-plugin + 3.3 + + + **/unit.java + + + \ No newline at end of file From e2e29b884ea2a88f6d25a789f32a92db74e1de91 Mon Sep 17 00:00:00 2001 From: BillMills Date: Mon, 6 Jan 2020 16:11:30 -0500 Subject: [PATCH 02/26] testing --- api/src/test/java/unit.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 api/src/test/java/unit.java diff --git a/api/src/test/java/unit.java b/api/src/test/java/unit.java new file mode 100644 index 0000000..f3d7654 --- /dev/null +++ b/api/src/test/java/unit.java @@ -0,0 +1,12 @@ +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import com.docker.ddev.model.Product; + +class apiUnitTests { + + @Test + void justAnExample() { + Product testProd = new Product((long)9999, "testWidget", 19.95); + assertEquals(testProd.getProductId(), 9999); + } +} From c8057845067d058298d29c2ca97fd8476a517c53 Mon Sep 17 00:00:00 2001 From: BillMills Date: Mon, 6 Jan 2020 16:23:39 -0500 Subject: [PATCH 03/26] set up for unit testing exercise --- api/Dockerfile | 4 +- api/Dockerfile-dev | 13 ------ api/unit-pom.xml | 114 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+), 16 deletions(-) delete mode 100644 api/Dockerfile-dev create mode 100644 api/unit-pom.xml diff --git a/api/Dockerfile b/api/Dockerfile index 3dba7bc..cefca3d 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -7,10 +7,8 @@ RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml package -DskipTests FROM maven:3.6.3-jdk-8 AS test WORKDIR /usr/src/ddev -COPY unit-pom.xml . -RUN mvn -B -f unit-pom.xml -s /usr/share/maven/ref/settings-docker.xml dependency:resolve COPY . . -CMD ["mvn", "clean", "test"] +CMD ["mvn", "-f", "unit-pom.xml", "clean", "test"] FROM java:8-jdk-alpine RUN adduser -Dh /home/gordon gordon diff --git a/api/Dockerfile-dev b/api/Dockerfile-dev deleted file mode 100644 index 5883627..0000000 --- a/api/Dockerfile-dev +++ /dev/null @@ -1,13 +0,0 @@ -FROM maven:latest AS appserver -WORKDIR /usr/src/ddev -COPY pom.xml . -RUN mvn -B -f pom.xml -s /usr/share/maven/ref/settings-docker.xml dependency:resolve -COPY . . -RUN mvn -B -s /usr/share/maven/ref/settings-docker.xml package -DskipTests - -FROM java:8-jdk-alpine -RUN adduser -Dh /home/gordon gordon -WORKDIR /app -COPY --from=appserver /usr/src/ddev/target/ddev-0.0.1-SNAPSHOT.jar . -ENTRYPOINT ["java", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005","-jar", "/app/ddev-0.0.1-SNAPSHOT.jar"] -CMD ["--spring.profiles.active=postgres"] \ No newline at end of file diff --git a/api/unit-pom.xml b/api/unit-pom.xml new file mode 100644 index 0000000..91c67a5 --- /dev/null +++ b/api/unit-pom.xml @@ -0,0 +1,114 @@ + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 1.5.3.RELEASE + + + com.docker.ddev + ddev + 0.0.1-SNAPSHOT + ddev + + + 1.8 + 1.4.187 + + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-core + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + + com.zaxxer + HikariCP + + + + com.h2database + h2 + + + + org.postgresql + postgresql + + + + org.hibernate + hibernate-c3p0 + 5.2.10.Final + + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework + spring-jdbc + + + com.googlecode.json-simple + json-simple + + + org.springframework.boot + spring-boot-starter-security + + + + org.springframework.boot + spring-boot-devtools + + + + org.apache.commons + commons-lang3 + 3.0 + + + org.junit.jupiter + junit-jupiter-api + 5.4.2 + test + + + org.junit.jupiter + junit-jupiter-engine + 5.4.2 + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.1 + + + + \ No newline at end of file From ca132b13af1e8dfd0314c9d4a2fb5861ce6a86b9 Mon Sep 17 00:00:00 2001 From: BillMills Date: Mon, 6 Jan 2020 16:54:28 -0500 Subject: [PATCH 04/26] build and push unittest image in build pipeline --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 1550c92..6902954 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,9 +19,11 @@ pipeline { script { docker image build -t ${DTR_FQDN_PORT}/engineering/db:1.0 database docker image build -t ${DTR_FQDN_PORT}/engineering/api:rc-1.0-build-${BUILD_ID} api + docker image build --target test -t ${DTR_FQDN_PORT}/engineering/api:unittest-1.0-build-${BUILD_ID} api docker login -u jenkins -p ${DTR_ACCESS_KEY} ${DTR_FQDN_PORT} docker image push ${DTR_FQDN_PORT}/engineering/db:1.0 docker image push ${DTR_FQDN_PORT}/engineering/api:rc-1.0-build-${BUILD_ID} + docker image push ${DTR_FQDN_PORT}/engineering/api:unittest-1.0-build-${BUILD_ID} } } } From da0161a61641d4df7a3cb62a6b12fba7e562886d Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Mon, 6 Jan 2020 17:19:46 -0500 Subject: [PATCH 05/26] Update Jenkinsfile --- Jenkinsfile | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6902954..b82b881 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,15 +16,13 @@ pipeline { DTR_ACCESS_KEY = credentials('jenkins-dtr-access-token') } steps { - script { - docker image build -t ${DTR_FQDN_PORT}/engineering/db:1.0 database - docker image build -t ${DTR_FQDN_PORT}/engineering/api:rc-1.0-build-${BUILD_ID} api - docker image build --target test -t ${DTR_FQDN_PORT}/engineering/api:unittest-1.0-build-${BUILD_ID} api - docker login -u jenkins -p ${DTR_ACCESS_KEY} ${DTR_FQDN_PORT} - docker image push ${DTR_FQDN_PORT}/engineering/db:1.0 - docker image push ${DTR_FQDN_PORT}/engineering/api:rc-1.0-build-${BUILD_ID} - docker image push ${DTR_FQDN_PORT}/engineering/api:unittest-1.0-build-${BUILD_ID} - } + sh 'docker image build -t ${DTR_FQDN_PORT}/engineering/db:1.0 database' + sh 'docker image build -t ${DTR_FQDN_PORT}/engineering/api:rc-1.0-build-${BUILD_ID} api' + sh 'docker image build --target test -t ${DTR_FQDN_PORT}/engineering/api:unittest-1.0-build-${BUILD_ID} api' + sh 'docker login -u jenkins -p ${DTR_ACCESS_KEY} ${DTR_FQDN_PORT}' + sh 'docker image push ${DTR_FQDN_PORT}/engineering/db:1.0' + sh 'docker image push ${DTR_FQDN_PORT}/engineering/api:rc-1.0-build-${BUILD_ID}' + sh 'docker image push ${DTR_FQDN_PORT}/engineering/api:unittest-1.0-build-${BUILD_ID}' } } } From 1c108390ecacccc6f85b41a74272818905123550 Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Tue, 7 Jan 2020 15:58:16 -0500 Subject: [PATCH 06/26] Update Jenkinsfile --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b82b881..2eed7ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,12 +17,12 @@ pipeline { } steps { sh 'docker image build -t ${DTR_FQDN_PORT}/engineering/db:1.0 database' - sh 'docker image build -t ${DTR_FQDN_PORT}/engineering/api:rc-1.0-build-${BUILD_ID} api' - sh 'docker image build --target test -t ${DTR_FQDN_PORT}/engineering/api:unittest-1.0-build-${BUILD_ID} api' + sh 'docker image build -t ${DTR_FQDN_PORT}/engineering/api-build:rc-1.0-build-${BUILD_ID} api' + sh 'docker image build --target test -t ${DTR_FQDN_PORT}/engineering/api-build:unittest-1.0-build-${BUILD_ID} api' sh 'docker login -u jenkins -p ${DTR_ACCESS_KEY} ${DTR_FQDN_PORT}' sh 'docker image push ${DTR_FQDN_PORT}/engineering/db:1.0' - sh 'docker image push ${DTR_FQDN_PORT}/engineering/api:rc-1.0-build-${BUILD_ID}' - sh 'docker image push ${DTR_FQDN_PORT}/engineering/api:unittest-1.0-build-${BUILD_ID}' + sh 'docker image push ${DTR_FQDN_PORT}/engineering/api-build:rc-1.0-build-${BUILD_ID}' + sh 'docker image push ${DTR_FQDN_PORT}/engineering/api-build:unittest-1.0-build-${BUILD_ID}' } } } From d919a9a28376dfe41feee74733c5e3d03e2a3e62 Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Tue, 7 Jan 2020 16:03:21 -0500 Subject: [PATCH 07/26] Create Jenkinsfile-testing --- Jenkinsfile-testing | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Jenkinsfile-testing diff --git a/Jenkinsfile-testing b/Jenkinsfile-testing new file mode 100644 index 0000000..4b47dc9 --- /dev/null +++ b/Jenkinsfile-testing @@ -0,0 +1,25 @@ +pipeline { + + agent any + + environment { + DOCKER_TLS_VERIFY='1' + COMPOSE_TLS_VERSION='TLSv1_2' + DOCKER_CERT_PATH='/home/jenkins/admincerts' + DOCKER_HOST='tcp://:443' + DTR_FQDN_PORT=':4443' + } + + stages { + stage('Test') { + environment { + DTR_ACCESS_KEY = credentials('jenkins-dtr-access-token') + } + steps { + sh 'docker login -u jenkins -p ${DTR_ACCESS_KEY} ${DTR_FQDN_PORT}' + sh 'docker image pull ${DTR_FQDN_PORT}/engineering/api-test:${TAG}' + sh 'docker container run ${DTR_FQDN_PORT}/engineering/api-test:${TAG}' + } + } + } +} From 76761eef3a30081b55ae4f2347bf152de7c1bcef Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Thu, 9 Jan 2020 12:15:44 -0500 Subject: [PATCH 08/26] Update Jenkinsfile --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2eed7ea..4ccfc66 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,11 +16,9 @@ pipeline { DTR_ACCESS_KEY = credentials('jenkins-dtr-access-token') } steps { - sh 'docker image build -t ${DTR_FQDN_PORT}/engineering/db:1.0 database' sh 'docker image build -t ${DTR_FQDN_PORT}/engineering/api-build:rc-1.0-build-${BUILD_ID} api' sh 'docker image build --target test -t ${DTR_FQDN_PORT}/engineering/api-build:unittest-1.0-build-${BUILD_ID} api' sh 'docker login -u jenkins -p ${DTR_ACCESS_KEY} ${DTR_FQDN_PORT}' - sh 'docker image push ${DTR_FQDN_PORT}/engineering/db:1.0' sh 'docker image push ${DTR_FQDN_PORT}/engineering/api-build:rc-1.0-build-${BUILD_ID}' sh 'docker image push ${DTR_FQDN_PORT}/engineering/api-build:unittest-1.0-build-${BUILD_ID}' } From fb8a2d02238ec5175dcf1a910e81792d62e55fb2 Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Fri, 10 Jan 2020 11:16:07 -0500 Subject: [PATCH 09/26] Create Dockerfile --- api/integration/Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 api/integration/Dockerfile diff --git a/api/integration/Dockerfile b/api/integration/Dockerfile new file mode 100644 index 0000000..cde5365 --- /dev/null +++ b/api/integration/Dockerfile @@ -0,0 +1,6 @@ +FROM node:8-alpine +WORKDIR /app +COPY package.json . +RUN npm install +COPY . . +CMD npm run test From c888d75b1eb3a77fba11465763df8ee91538e21e Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Fri, 10 Jan 2020 11:16:28 -0500 Subject: [PATCH 10/26] Create package.json --- api/integration/package.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 api/integration/package.json diff --git a/api/integration/package.json b/api/integration/package.json new file mode 100644 index 0000000..e6685d1 --- /dev/null +++ b/api/integration/package.json @@ -0,0 +1,14 @@ +{ + "name": "api-tests-java", + "version": "1.0.0", + "main": "server.js", + "scripts": { + "test": "jasmine-node *.js", + "start": "node server.js" + }, + "dependencies": { + "express": "^4.15.2", + "jasmine-node": "^1.14.5", + "request": "^2.81.0" + } +} From 9cb1f8ae2b2a19c500c554b268dce2f6fbbdabd2 Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Fri, 10 Jan 2020 11:18:04 -0500 Subject: [PATCH 11/26] Create api-spec.js --- api/integration/api-spec.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 api/integration/api-spec.js diff --git a/api/integration/api-spec.js b/api/integration/api-spec.js new file mode 100644 index 0000000..ddc9f35 --- /dev/null +++ b/api/integration/api-spec.js @@ -0,0 +1,12 @@ +var request = require('request'); +var base_url = "http://apitest:8080/"; + +describe("When testing 'api/products/1'", function(){ + it("should respond with the URL of a cat GIF", function(done) { + request(base_url + 'api/products/1', function(error, response, body){ + product = JSON.parse(body) + expect(product["description"]).toMatch('resistor'); + done(); + }); + }); +}); From 12074cdd116a62114498e82beee59e3408b1fb3f Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Fri, 10 Jan 2020 11:19:54 -0500 Subject: [PATCH 12/26] Update api-spec.js --- api/integration/api-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/integration/api-spec.js b/api/integration/api-spec.js index ddc9f35..6240a05 100644 --- a/api/integration/api-spec.js +++ b/api/integration/api-spec.js @@ -2,7 +2,7 @@ var request = require('request'); var base_url = "http://apitest:8080/"; describe("When testing 'api/products/1'", function(){ - it("should respond with the URL of a cat GIF", function(done) { + it("should respond with entry for 'resistor'", function(done) { request(base_url + 'api/products/1', function(error, response, body){ product = JSON.parse(body) expect(product["description"]).toMatch('resistor'); From f85f8f9f8e01216647ebdde4b8495fe3eb631358 Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Fri, 10 Jan 2020 11:26:23 -0500 Subject: [PATCH 13/26] Create integration.yaml --- api/integration/integration.yaml | 61 ++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 api/integration/integration.yaml diff --git a/api/integration/integration.yaml b/api/integration/integration.yaml new file mode 100644 index 0000000..a7ea15d --- /dev/null +++ b/api/integration/integration.yaml @@ -0,0 +1,61 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: db + namespace: test +spec: + replicas: 1 + selector: + matchLabels: + app: db + template: + metadata: + labels: + app: db + spec: + containers: + - name: postgres + image: :4443/engineering/db:1.0 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: api + namespace: test +spec: + replicas: 1 + selector: + matchLabels: + app: api + template: + metadata: + labels: + app: api + spec: + containers: + - name: springboot + image: :4443/engineering/api:rc-1.0-build-30 +--- +apiVersion: v1 +kind: Service +metadata: + name: database + namespace: test +spec: + selector: + app: db + ports: + - port: 5432 + targetPort: 5432 +--- +apiVersion: v1 +kind: Service +metadata: + name: apitest + namespace: test +spec: + selector: + app: api + ports: + - port: 8080 + targetPort: 8080 From b73000bf022c7e925b5e61b3d715755132e7cc1d Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Fri, 10 Jan 2020 12:57:44 -0500 Subject: [PATCH 14/26] Update Jenkinsfile-testing --- Jenkinsfile-testing | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile-testing b/Jenkinsfile-testing index 4b47dc9..fbef52f 100644 --- a/Jenkinsfile-testing +++ b/Jenkinsfile-testing @@ -11,7 +11,7 @@ pipeline { } stages { - stage('Test') { + stage('Unit') { environment { DTR_ACCESS_KEY = credentials('jenkins-dtr-access-token') } From 975ac3e50088e63525d7af921aa21253df1ba67f Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Fri, 10 Jan 2020 13:33:20 -0500 Subject: [PATCH 15/26] Update app.yaml --- app.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.yaml b/app.yaml index 188ef5f..d429928 100644 --- a/app.yaml +++ b/app.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: postgres - image: ci_db:latest + image: :4443/engineering/db:1.0 --- apiVersion: apps/v1 kind: Deployment @@ -32,7 +32,7 @@ spec: spec: containers: - name: springboot - image: ci_api:latest + image: :4443/engineering/api-build:demo --- apiVersion: v1 kind: Service From e75f69e74e3cf2b7d3e9bd25f1335ba6fff6b75d Mon Sep 17 00:00:00 2001 From: BillMills Date: Wed, 22 Jan 2020 14:42:30 -0500 Subject: [PATCH 16/26] helmify --- Jenkinsfile | 2 +- Jenkinsfile-testing | 2 +- app.yaml | 58 --------------------------------- helm/Chart.yaml | 21 ++++++++++++ helm/templates/api.deploy.yaml | 17 ++++++++++ helm/templates/api.service.yaml | 11 +++++++ helm/templates/db.deploy.yaml | 17 ++++++++++ helm/templates/db.service.yaml | 10 ++++++ helm/values.yaml | 9 +++++ 9 files changed, 87 insertions(+), 60 deletions(-) delete mode 100644 app.yaml create mode 100644 helm/Chart.yaml create mode 100644 helm/templates/api.deploy.yaml create mode 100644 helm/templates/api.service.yaml create mode 100644 helm/templates/db.deploy.yaml create mode 100644 helm/templates/db.service.yaml create mode 100644 helm/values.yaml diff --git a/Jenkinsfile b/Jenkinsfile index 4ccfc66..6e73615 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,7 +5,7 @@ pipeline { environment { DOCKER_TLS_VERIFY='1' COMPOSE_TLS_VERSION='TLSv1_2' - DOCKER_CERT_PATH='/home/jenkins/admincerts' + DOCKER_CERT_PATH='/home/jenkins/jenkinscerts' DOCKER_HOST='tcp://:443' DTR_FQDN_PORT=':4443' } diff --git a/Jenkinsfile-testing b/Jenkinsfile-testing index fbef52f..8f5ef2a 100644 --- a/Jenkinsfile-testing +++ b/Jenkinsfile-testing @@ -5,7 +5,7 @@ pipeline { environment { DOCKER_TLS_VERIFY='1' COMPOSE_TLS_VERSION='TLSv1_2' - DOCKER_CERT_PATH='/home/jenkins/admincerts' + DOCKER_CERT_PATH='/home/jenkins/jenkinscerts' DOCKER_HOST='tcp://:443' DTR_FQDN_PORT=':4443' } diff --git a/app.yaml b/app.yaml deleted file mode 100644 index d429928..0000000 --- a/app.yaml +++ /dev/null @@ -1,58 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: db -spec: - replicas: 1 - selector: - matchLabels: - app: db - template: - metadata: - labels: - app: db - spec: - containers: - - name: postgres - image: :4443/engineering/db:1.0 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: api -spec: - replicas: 1 - selector: - matchLabels: - app: api - template: - metadata: - labels: - app: api - spec: - containers: - - name: springboot - image: :4443/engineering/api-build:demo ---- -apiVersion: v1 -kind: Service -metadata: - name: database -spec: - selector: - app: db - ports: - - port: 5432 - targetPort: 5432 ---- -apiVersion: v1 -kind: Service -metadata: - name: api-ingress -spec: - type: NodePort - selector: - app: api - ports: - - port: 8080 - targetPort: 8080 diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..3cc7f2f --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,21 @@ +apiVersion: v2 +name: demochart +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. +appVersion: 1.16.0 diff --git a/helm/templates/api.deploy.yaml b/helm/templates/api.deploy.yaml new file mode 100644 index 0000000..5238e94 --- /dev/null +++ b/helm/templates/api.deploy.yaml @@ -0,0 +1,17 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: api +spec: + replicas: 1 + selector: + matchLabels: + app: api + template: + metadata: + labels: + app: api + spec: + containers: + - name: springboot + image: {{ .Values.DTR.FQDN }}:{{ .Values.DTR.port }}/engineering/api-build:{{ .Values.API.tag }} diff --git a/helm/templates/api.service.yaml b/helm/templates/api.service.yaml new file mode 100644 index 0000000..b0309fe --- /dev/null +++ b/helm/templates/api.service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: api-ingress +spec: + type: NodePort + selector: + app: api + ports: + - port: 8080 + targetPort: 8080 diff --git a/helm/templates/db.deploy.yaml b/helm/templates/db.deploy.yaml new file mode 100644 index 0000000..d3f9e90 --- /dev/null +++ b/helm/templates/db.deploy.yaml @@ -0,0 +1,17 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: db +spec: + replicas: 1 + selector: + matchLabels: + app: db + template: + metadata: + labels: + app: db + spec: + containers: + - name: postgres + image: {{ .Values.DTR.FQDN }}:{{ .Values.DTR.port }}/engineering/db:{{ .Values.DB.tag }} diff --git a/helm/templates/db.service.yaml b/helm/templates/db.service.yaml new file mode 100644 index 0000000..7138c32 --- /dev/null +++ b/helm/templates/db.service.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Service +metadata: + name: database +spec: + selector: + app: db + ports: + - port: 5432 + targetPort: 5432 diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 0000000..4cdb1f2 --- /dev/null +++ b/helm/values.yaml @@ -0,0 +1,9 @@ +DTR: + FQDN: + port: 4443 + +DB: + tag: '1.0' + +API: + tag: 'demo' From 5c09fa8080bd158f3c4ea8614e45c54ecda88d24 Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Wed, 22 Jan 2020 15:36:18 -0500 Subject: [PATCH 17/26] Delete integration.yaml --- api/integration/integration.yaml | 61 -------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 api/integration/integration.yaml diff --git a/api/integration/integration.yaml b/api/integration/integration.yaml deleted file mode 100644 index a7ea15d..0000000 --- a/api/integration/integration.yaml +++ /dev/null @@ -1,61 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: db - namespace: test -spec: - replicas: 1 - selector: - matchLabels: - app: db - template: - metadata: - labels: - app: db - spec: - containers: - - name: postgres - image: :4443/engineering/db:1.0 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: api - namespace: test -spec: - replicas: 1 - selector: - matchLabels: - app: api - template: - metadata: - labels: - app: api - spec: - containers: - - name: springboot - image: :4443/engineering/api:rc-1.0-build-30 ---- -apiVersion: v1 -kind: Service -metadata: - name: database - namespace: test -spec: - selector: - app: db - ports: - - port: 5432 - targetPort: 5432 ---- -apiVersion: v1 -kind: Service -metadata: - name: apitest - namespace: test -spec: - selector: - app: api - ports: - - port: 8080 - targetPort: 8080 From bba95e4e675a745ff99e365bd47fc0dd4ced35fb Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Wed, 22 Jan 2020 15:36:42 -0500 Subject: [PATCH 18/26] Update api-spec.js --- api/integration/api-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/integration/api-spec.js b/api/integration/api-spec.js index 6240a05..a0db27f 100644 --- a/api/integration/api-spec.js +++ b/api/integration/api-spec.js @@ -1,5 +1,5 @@ var request = require('request'); -var base_url = "http://apitest:8080/"; +var base_url = "http://api-ingress:8080/"; describe("When testing 'api/products/1'", function(){ it("should respond with entry for 'resistor'", function(done) { From 1056e507416e7298d3cc9a5e71faddf0689408de Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Wed, 22 Jan 2020 15:47:08 -0500 Subject: [PATCH 19/26] Update api.deploy.yaml --- helm/templates/api.deploy.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/helm/templates/api.deploy.yaml b/helm/templates/api.deploy.yaml index 5238e94..d0d3d3e 100644 --- a/helm/templates/api.deploy.yaml +++ b/helm/templates/api.deploy.yaml @@ -15,3 +15,9 @@ spec: containers: - name: springboot image: {{ .Values.DTR.FQDN }}:{{ .Values.DTR.port }}/engineering/api-build:{{ .Values.API.tag }} + livenessProbe: + httpGet: + path: /api/products/1 + port: 8080 + initialDelaySeconds: 20 + periodSeconds: 5 From 742ce684abe23d21615291d9b35f7d8f83706a1c Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Wed, 22 Jan 2020 16:19:44 -0500 Subject: [PATCH 20/26] Update Jenkinsfile-testing --- Jenkinsfile-testing | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile-testing b/Jenkinsfile-testing index 8f5ef2a..ca3fb36 100644 --- a/Jenkinsfile-testing +++ b/Jenkinsfile-testing @@ -8,6 +8,7 @@ pipeline { DOCKER_CERT_PATH='/home/jenkins/jenkinscerts' DOCKER_HOST='tcp://:443' DTR_FQDN_PORT=':4443' + KUBECONFIG='/home/jenkins/jenkinscerts/kube.yml' } stages { From 3c2c7828f6bcace2978eba4fe80731a2cd568247 Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Wed, 29 Jan 2020 16:19:44 -0500 Subject: [PATCH 21/26] Update api.deploy.yaml --- helm/templates/api.deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm/templates/api.deploy.yaml b/helm/templates/api.deploy.yaml index d0d3d3e..b8fa42c 100644 --- a/helm/templates/api.deploy.yaml +++ b/helm/templates/api.deploy.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: springboot - image: {{ .Values.DTR.FQDN }}:{{ .Values.DTR.port }}/engineering/api-build:{{ .Values.API.tag }} + image: {{ .Values.DTR.FQDN }}:{{ .Values.DTR.port }}/{{ .Values.API.repo }}:{{ .Values.API.tag }} livenessProbe: httpGet: path: /api/products/1 From e9d1d8aca84415b8a712590ab9e748f2d99c08c1 Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Wed, 29 Jan 2020 16:20:05 -0500 Subject: [PATCH 22/26] Update values.yaml --- helm/values.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/helm/values.yaml b/helm/values.yaml index 4cdb1f2..681ffbe 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -6,4 +6,5 @@ DB: tag: '1.0' API: + repo: 'engineering/api-build' tag: 'demo' From 9b6cb4d517da042f14ab5fd73ec9cdf9427b1cbd Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Thu, 30 Jan 2020 14:47:52 -0500 Subject: [PATCH 23/26] Update Jenkinsfile --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 6e73615..367f25a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,4 +24,10 @@ pipeline { } } } + + post { + always{ + sh 'rm -rf ${WORKSPACE}/*' + } + } } From 5f86be9e137738b731e7a4a55bb4768f0964512a Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Thu, 30 Jan 2020 14:54:48 -0500 Subject: [PATCH 24/26] Update Jenkinsfile-testing --- Jenkinsfile-testing | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile-testing b/Jenkinsfile-testing index ca3fb36..3b73bbe 100644 --- a/Jenkinsfile-testing +++ b/Jenkinsfile-testing @@ -23,4 +23,10 @@ pipeline { } } } + + post { + always{ + sh 'rm -rf ${WORKSPACE}/*' + } + } } From b08405376104735bf5ed083917cd1d3f12be9450 Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Thu, 30 Jan 2020 16:24:25 -0500 Subject: [PATCH 25/26] Update Jenkinsfile --- Jenkinsfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 367f25a..f8d7b56 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,13 +14,14 @@ pipeline { stage('Build') { environment { DTR_ACCESS_KEY = credentials('jenkins-dtr-access-token') + MAJORMINOR = '0.0' } steps { - sh 'docker image build -t ${DTR_FQDN_PORT}/engineering/api-build:rc-1.0-build-${BUILD_ID} api' - sh 'docker image build --target test -t ${DTR_FQDN_PORT}/engineering/api-build:unittest-1.0-build-${BUILD_ID} api' + sh 'docker image build -t ${DTR_FQDN_PORT}/engineering/api-build:rc-${MAJORMINOR}.${BUILD_ID} api' + sh 'docker image build --target test -t ${DTR_FQDN_PORT}/engineering/api-build:unittest-${MAJORMINOR}.${BUILD_ID} api' sh 'docker login -u jenkins -p ${DTR_ACCESS_KEY} ${DTR_FQDN_PORT}' - sh 'docker image push ${DTR_FQDN_PORT}/engineering/api-build:rc-1.0-build-${BUILD_ID}' - sh 'docker image push ${DTR_FQDN_PORT}/engineering/api-build:unittest-1.0-build-${BUILD_ID}' + sh 'docker image push ${DTR_FQDN_PORT}/engineering/api-build:rc-${MAJORMINOR}.${BUILD_ID}' + sh 'docker image push ${DTR_FQDN_PORT}/engineering/api-build:unittest-${MAJORMINOR}.${BUILD_ID}' } } } From fae3453056d915f8a08cc02f5235952f805f9040 Mon Sep 17 00:00:00 2001 From: Bill Mills Date: Wed, 19 Feb 2020 10:56:36 -0500 Subject: [PATCH 26/26] Update Dockerfile --- database/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/database/Dockerfile b/database/Dockerfile index 8797f2f..60914dc 100644 --- a/database/Dockerfile +++ b/database/Dockerfile @@ -10,4 +10,5 @@ ADD docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d/ # Default values for passwords and database name. Can be overridden on docker run ENV POSTGRES_USER gordonuser +ENV POSTGRES_PASSWORD password ENV POSTGRES_DB ddev