From ea4b2e073f7a026d232f6e7d9edbe8710b318f1a Mon Sep 17 00:00:00 2001 From: Arne Limburg Date: Thu, 24 Aug 2023 18:45:12 +0200 Subject: [PATCH] Update to use pact-broker --- .github/workflows/build.yaml | 14 ++--- address-validation-service/.gitignore | 1 + address-validation-service/Jenkinsfile | 2 +- address-validation-service/pom.xml | 4 +- .../address/AddressValidationServiceTest.java | 15 +++-- billing-service/Jenkinsfile | 2 +- billing-service/pom.xml | 4 +- .../address/BillingAddressServiceTest.java | 6 +- customer-service/.gitignore | 1 + customer-service/Jenkinsfile | 2 +- customer-service/pom.xml | 13 ++++- .../domain/BillingAddressRepositoryTest.java | 2 +- delivery-service/.gitignore | 1 + delivery-service/Jenkinsfile | 2 +- delivery-service/pom.xml | 4 +- .../address/DeliveryAddressServiceTest.java | 6 +- deployment/base/gogs/deployment.yaml | 47 +++++++++++++++ deployment/base/gogs/ingress.yaml | 19 ++++++ deployment/base/gogs/kustomization.yaml | 7 +++ deployment/base/gogs/service.yaml | 28 +++++++++ deployment/base/jenkins/deployment.yaml | 29 ++++++++++ deployment/base/jenkins/ingress.yaml | 19 ++++++ deployment/base/jenkins/kustomization.yaml | 7 +++ deployment/base/jenkins/service.yaml | 14 +++++ deployment/base/kustomization.yaml | 10 ++++ deployment/base/namespaces.yaml | 13 +++++ deployment/base/nginx/kustomization.yaml | 5 ++ deployment/base/pact/deployment.yaml | 35 +++++++++++ deployment/base/pact/ingress.yaml | 19 ++++++ deployment/base/pact/kustomization.yaml | 7 +++ deployment/base/pact/service.yaml | 14 +++++ deployment/base/registry/deployment.yaml | 22 +++++++ deployment/base/registry/ingress.yaml | 19 ++++++ deployment/base/registry/kustomization.yaml | 7 +++ deployment/base/registry/service.yaml | 14 +++++ deployment/cluster-config/kind-config.yml | 58 +++++++++++++++++++ deployment/kustomization.yaml | 6 ++ deployment/setup/job.yaml | 12 ++++ deployment/setup/kustomization.yaml | 5 ++ 39 files changed, 467 insertions(+), 28 deletions(-) create mode 100644 address-validation-service/.gitignore create mode 100644 customer-service/.gitignore create mode 100644 delivery-service/.gitignore create mode 100644 deployment/base/gogs/deployment.yaml create mode 100644 deployment/base/gogs/ingress.yaml create mode 100644 deployment/base/gogs/kustomization.yaml create mode 100644 deployment/base/gogs/service.yaml create mode 100644 deployment/base/jenkins/deployment.yaml create mode 100644 deployment/base/jenkins/ingress.yaml create mode 100644 deployment/base/jenkins/kustomization.yaml create mode 100644 deployment/base/jenkins/service.yaml create mode 100644 deployment/base/kustomization.yaml create mode 100644 deployment/base/namespaces.yaml create mode 100644 deployment/base/nginx/kustomization.yaml create mode 100644 deployment/base/pact/deployment.yaml create mode 100644 deployment/base/pact/ingress.yaml create mode 100644 deployment/base/pact/kustomization.yaml create mode 100644 deployment/base/pact/service.yaml create mode 100644 deployment/base/registry/deployment.yaml create mode 100644 deployment/base/registry/ingress.yaml create mode 100644 deployment/base/registry/kustomization.yaml create mode 100644 deployment/base/registry/service.yaml create mode 100644 deployment/cluster-config/kind-config.yml create mode 100644 deployment/kustomization.yaml create mode 100644 deployment/setup/job.yaml create mode 100644 deployment/setup/kustomization.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1edf713..7223bca 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -16,8 +16,14 @@ jobs: distribution: 'temurin' cache: maven + - name: Build with Docker + run: docker compose build + + - name: Start with Docker + run: docker compose up -d + - name: Build customer-service - run: mvn clean package -f customer-service/pom.xml -Dservice.name=customer-service + run: mvn clean package -f customer-service/pom.xml -Dservice.name=customer-service pact:publish - name: Build billing-service run: mvn clean package -f billing-service/pom.xml -Dservice.name=billing-service @@ -28,11 +34,5 @@ jobs: - name: Build address-validation-service run: mvn clean package -f address-validation-service/pom.xml -Dservice.name=address-validation-service - - name: Build with Docker - run: docker compose build - - - name: Start with Docker - run: docker compose up -d - - name: Stop Docker Containers run: docker compose down diff --git a/address-validation-service/.gitignore b/address-validation-service/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/address-validation-service/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/address-validation-service/Jenkinsfile b/address-validation-service/Jenkinsfile index 4af7ff8..65ed856 100644 --- a/address-validation-service/Jenkinsfile +++ b/address-validation-service/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { } } steps { - sh "mvn test -B" + sh "mvn test -DpactBroker.url=http://pact-service:8080 -Dpact.verifier.publishResults=true -B" } } stage ('Package') { diff --git a/address-validation-service/pom.xml b/address-validation-service/pom.xml index a99dc2c..5ca5e40 100644 --- a/address-validation-service/pom.xml +++ b/address-validation-service/pom.xml @@ -16,8 +16,8 @@ 1.0.0-SNAPSHOT - scm:git:http://openknowledge:workshop@gogs-service:3000/openknowledge/address-validation-service.git - scm:git:http://openknowledge:workshop@gogs-service:3000/openknowledge/address-validation-service.git + scm:git:http://openknowledge:workshop@gogs:3000/openknowledge/address-validation-service.git + scm:git:http://openknowledge:workshop@gogs:3000/openknowledge/address-validation-service.git diff --git a/address-validation-service/src/test/java/de/openknowledge/sample/address/AddressValidationServiceTest.java b/address-validation-service/src/test/java/de/openknowledge/sample/address/AddressValidationServiceTest.java index 6b90980..8c2107f 100644 --- a/address-validation-service/src/test/java/de/openknowledge/sample/address/AddressValidationServiceTest.java +++ b/address-validation-service/src/test/java/de/openknowledge/sample/address/AddressValidationServiceTest.java @@ -15,6 +15,8 @@ */ package de.openknowledge.sample.address; +import static java.util.Optional.ofNullable; + import org.apache.meecrowave.Meecrowave; import org.apache.meecrowave.junit5.MonoMeecrowaveConfig; import org.apache.meecrowave.testing.ConfigurationInject; @@ -25,12 +27,14 @@ import au.com.dius.pact.provider.junit5.HttpTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; +import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; -import au.com.dius.pact.provider.junitsupport.loader.PactFolder; +import au.com.dius.pact.provider.junitsupport.loader.PactBroker; +@IgnoreNoPactsToVerify @Provider("address-validation-service") -@PactFolder("src/test/pacts") +@PactBroker(url = "${pactBroker.url:http://localhost:5000}") @MonoMeecrowaveConfig public class AddressValidationServiceTest { @@ -38,14 +42,15 @@ public class AddressValidationServiceTest { private Meecrowave.Builder config; @BeforeEach - public void setUp(PactVerificationContext context) { - context.setTarget(new HttpTestTarget("localhost", config.getHttpPort(), "/")); + public void setUp(PactVerificationContext verificationContext) { + ofNullable(verificationContext) + .ifPresent(context -> context.setTarget(new HttpTestTarget("localhost", config.getHttpPort(), "/"))); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { - context.verifyInteraction(); + ofNullable(context).ifPresent(PactVerificationContext::verifyInteraction); } @State("Three customers") diff --git a/billing-service/Jenkinsfile b/billing-service/Jenkinsfile index 7916245..f1ec156 100644 --- a/billing-service/Jenkinsfile +++ b/billing-service/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { } } steps { - sh "mvn test -B" + sh "mvn test -DpactBroker.url=http://pact-service:8080 -Dpact.verifier.publishResults=true -B" } } stage ('Package') { diff --git a/billing-service/pom.xml b/billing-service/pom.xml index 3995c8a..f112812 100644 --- a/billing-service/pom.xml +++ b/billing-service/pom.xml @@ -16,8 +16,8 @@ 1.0.0-SNAPSHOT - scm:git:http://openknowledge:workshop@gogs-service:3000/openknowledge/billing-service.git - scm:git:http://openknowledge:workshop@gogs-service:3000/openknowledge/billing-service.git + scm:git:http://openknowledge:workshop@gogs:3000/openknowledge/billing-service.git + scm:git:http://openknowledge:workshop@gogs:3000/openknowledge/billing-service.git diff --git a/billing-service/src/test/java/de/openknowledge/sample/address/BillingAddressServiceTest.java b/billing-service/src/test/java/de/openknowledge/sample/address/BillingAddressServiceTest.java index e7b798b..72d4bd5 100644 --- a/billing-service/src/test/java/de/openknowledge/sample/address/BillingAddressServiceTest.java +++ b/billing-service/src/test/java/de/openknowledge/sample/address/BillingAddressServiceTest.java @@ -25,12 +25,14 @@ import au.com.dius.pact.provider.junit5.HttpTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; +import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; -import au.com.dius.pact.provider.junitsupport.loader.PactFolder; +import au.com.dius.pact.provider.junitsupport.loader.PactBroker; +@IgnoreNoPactsToVerify @Provider("billing-service") -@PactFolder("src/test/pacts") +@PactBroker(url = "${pactBroker.url:http://localhost:5000}") @MonoMeecrowaveConfig public class BillingAddressServiceTest { diff --git a/customer-service/.gitignore b/customer-service/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/customer-service/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/customer-service/Jenkinsfile b/customer-service/Jenkinsfile index f662ba0..738887d 100644 --- a/customer-service/Jenkinsfile +++ b/customer-service/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { } } steps { - sh "mvn test -B" + sh 'mvn test pact:publish -DpactBroker.url=http://pact-service:8080 -B' } } stage ('Package') { diff --git a/customer-service/pom.xml b/customer-service/pom.xml index 61c2d3d..777eed0 100644 --- a/customer-service/pom.xml +++ b/customer-service/pom.xml @@ -16,8 +16,8 @@ 1.0.0-SNAPSHOT - scm:git:http://openknowledge:workshop@gogs-service:3000/openknowledge/customer-service.git - scm:git:http://openknowledge:workshop@gogs-service:3000/openknowledge/customer-service.git + scm:git:http://openknowledge:workshop@gogs:3000/openknowledge/customer-service.git + scm:git:http://openknowledge:workshop@gogs:3000/openknowledge/customer-service.git @@ -26,6 +26,7 @@ 11 false UTF-8 + http://localhost:5000 1.2.15 1.9.6 5.8.2 @@ -189,6 +190,14 @@ + + au.com.dius.pact.provider + maven + 4.3.5 + + ${pactBroker.url} + + diff --git a/customer-service/src/test/java/de/openknowledge/sample/address/domain/BillingAddressRepositoryTest.java b/customer-service/src/test/java/de/openknowledge/sample/address/domain/BillingAddressRepositoryTest.java index b7d329b..1c0f5c4 100644 --- a/customer-service/src/test/java/de/openknowledge/sample/address/domain/BillingAddressRepositoryTest.java +++ b/customer-service/src/test/java/de/openknowledge/sample/address/domain/BillingAddressRepositoryTest.java @@ -103,7 +103,7 @@ public void initializeRepository(MockServer mockServer) { @PactTestFor(pactMethod = "getMax") @Test - public void findDeliveryAddressForExistingCustomer() { + public void findBillingAddressForExistingCustomer() { Optional
address = repository.find(new CustomerNumber("0815")); assertThat(address).isPresent().contains( new Address( diff --git a/delivery-service/.gitignore b/delivery-service/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/delivery-service/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/delivery-service/Jenkinsfile b/delivery-service/Jenkinsfile index a31ff64..589bf08 100644 --- a/delivery-service/Jenkinsfile +++ b/delivery-service/Jenkinsfile @@ -51,7 +51,7 @@ pipeline { } } steps { - sh "mvn test -B" + sh "mvn test pact:publish -DpactBroker.url=http://pact-service:8080 -Dpact.verifier.publishResults=true -B" } } stage ('Package') { diff --git a/delivery-service/pom.xml b/delivery-service/pom.xml index d6597df..7470a7c 100644 --- a/delivery-service/pom.xml +++ b/delivery-service/pom.xml @@ -26,6 +26,7 @@ 11 false UTF-8 + http://localhost:5000 1.2.15 1.9.6 5.4.21.Final @@ -197,6 +198,7 @@ ${project.version} + ${pactBroker.url} jdbc:h2:mem:delivery org.h2.Driver sa @@ -237,7 +239,7 @@ maven 4.3.5 - http://localhost + ${pactBroker.url} diff --git a/delivery-service/src/test/java/de/openknowledge/sample/address/DeliveryAddressServiceTest.java b/delivery-service/src/test/java/de/openknowledge/sample/address/DeliveryAddressServiceTest.java index 91ef351..185cf27 100644 --- a/delivery-service/src/test/java/de/openknowledge/sample/address/DeliveryAddressServiceTest.java +++ b/delivery-service/src/test/java/de/openknowledge/sample/address/DeliveryAddressServiceTest.java @@ -37,16 +37,18 @@ import au.com.dius.pact.provider.junit5.HttpTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; +import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; import au.com.dius.pact.provider.junitsupport.StateChangeAction; -import au.com.dius.pact.provider.junitsupport.loader.PactFolder; +import au.com.dius.pact.provider.junitsupport.loader.PactBroker; import de.openknowledge.sample.address.domain.AddressValidationService; import rocks.limburg.cdimock.MockitoBeans; +@IgnoreNoPactsToVerify @MockitoBeans(types = {AddressValidationService.class}) @Provider("delivery-service") -@PactFolder("src/test/pacts") +@PactBroker(url = "${pactBroker.url:http://localhost:5000}") @MonoMeecrowaveConfig public class DeliveryAddressServiceTest { diff --git a/deployment/base/gogs/deployment.yaml b/deployment/base/gogs/deployment.yaml new file mode 100644 index 0000000..c3b0b38 --- /dev/null +++ b/deployment/base/gogs/deployment.yaml @@ -0,0 +1,47 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: gogs-deployment + labels: + app: gogs-service +spec: + replicas: 1 + selector: + matchLabels: + app: gogs-service + template: + metadata: + labels: + app: gogs-service + spec: + containers: + - name: gogs + image: host.docker.internal:5000/gogs:local + ports: + - containerPort: 3000 + name: http +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: gogs-db-deployment + labels: + app: gogs-db-service +spec: + replicas: 1 + selector: + matchLabels: + app: gogs-db-service + template: + metadata: + labels: + app: gogs-db-service + spec: + containers: + - name: gogs-postgres + image: postgres:15.4-bullseye + ports: + - containerPort: 5432 + env: + - name: POSTGRES_PASSWORD + value: g0g5db diff --git a/deployment/base/gogs/ingress.yaml b/deployment/base/gogs/ingress.yaml new file mode 100644 index 0000000..14cb82f --- /dev/null +++ b/deployment/base/gogs/ingress.yaml @@ -0,0 +1,19 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: gogs-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + ingressClassName: nginx + rules: + - host: gogs.localhost + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: gogs-service + port: + number: 30030 diff --git a/deployment/base/gogs/kustomization.yaml b/deployment/base/gogs/kustomization.yaml new file mode 100644 index 0000000..350ec31 --- /dev/null +++ b/deployment/base/gogs/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - deployment.yaml + - service.yaml + - ingress.yaml \ No newline at end of file diff --git a/deployment/base/gogs/service.yaml b/deployment/base/gogs/service.yaml new file mode 100644 index 0000000..10e7c6e --- /dev/null +++ b/deployment/base/gogs/service.yaml @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: Service +metadata: + name: gogs-service +spec: + selector: + app: gogs-service + type: NodePort + ports: + - protocol: TCP + port: 3000 + targetPort: 3000 + nodePort: 30030 + name: service +--- +apiVersion: v1 +kind: Service +metadata: + name: gogs-db-service +spec: + selector: + app: gogs-db-service + type: NodePort + ports: + - protocol: TCP + port: 5432 + targetPort: 5432 + name: service diff --git a/deployment/base/jenkins/deployment.yaml b/deployment/base/jenkins/deployment.yaml new file mode 100644 index 0000000..f6b3228 --- /dev/null +++ b/deployment/base/jenkins/deployment.yaml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: jenkins-deployment + labels: + app: jenkins-service +spec: + replicas: 1 + selector: + matchLabels: + app: jenkins-service + template: + metadata: + labels: + app: jenkins-service + spec: + containers: + - name: jenkins + image: host.docker.internal:5000/jenkins:local + ports: + - containerPort: 8080 + name: http + volumeMounts: + - mountPath: /var/run + name: docker-sock + volumes: + - name: docker-sock + hostPath: + path: /var/run diff --git a/deployment/base/jenkins/ingress.yaml b/deployment/base/jenkins/ingress.yaml new file mode 100644 index 0000000..d73f18d --- /dev/null +++ b/deployment/base/jenkins/ingress.yaml @@ -0,0 +1,19 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: jenkins-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + ingressClassName: nginx + rules: + - host: jenkins.localhost + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: jenkins-service + port: + number: 30040 diff --git a/deployment/base/jenkins/kustomization.yaml b/deployment/base/jenkins/kustomization.yaml new file mode 100644 index 0000000..350ec31 --- /dev/null +++ b/deployment/base/jenkins/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - deployment.yaml + - service.yaml + - ingress.yaml \ No newline at end of file diff --git a/deployment/base/jenkins/service.yaml b/deployment/base/jenkins/service.yaml new file mode 100644 index 0000000..83006e4 --- /dev/null +++ b/deployment/base/jenkins/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: jenkins-service +spec: + selector: + app: jenkins-service + type: NodePort + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 + nodePort: 30040 + name: service diff --git a/deployment/base/kustomization.yaml b/deployment/base/kustomization.yaml new file mode 100644 index 0000000..14b02c0 --- /dev/null +++ b/deployment/base/kustomization.yaml @@ -0,0 +1,10 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ./namespaces.yaml + - ./nginx + - ./registry + - ./pact + - ./gogs + - ./jenkins diff --git a/deployment/base/namespaces.yaml b/deployment/base/namespaces.yaml new file mode 100644 index 0000000..ab5c6df --- /dev/null +++ b/deployment/base/namespaces.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: prod + labels: + name: prod +--- +apiVersion: v1 +kind: Namespace +metadata: + name: test + labels: + name: test diff --git a/deployment/base/nginx/kustomization.yaml b/deployment/base/nginx/kustomization.yaml new file mode 100644 index 0000000..d603cab --- /dev/null +++ b/deployment/base/nginx/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml diff --git a/deployment/base/pact/deployment.yaml b/deployment/base/pact/deployment.yaml new file mode 100644 index 0000000..3fe5a6e --- /dev/null +++ b/deployment/base/pact/deployment.yaml @@ -0,0 +1,35 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: pact-deployment + labels: + app: pact-service +spec: + replicas: 1 + selector: + matchLabels: + app: pact-service + template: + metadata: + labels: + app: pact-service + spec: + containers: + - name: pact + image: pactfoundation/pact-broker:2.111.0-pactbroker2.107.1 + ports: + - containerPort: 8080 + name: http + env: + - name: PACT_BROKER_PORT + value: "8080" + - name: PACT_BROKER_DATABASE_ADAPTER + value: sqlite + - name: PACT_BROKER_DATABASE_NAME + value: pact_broker.sqlite + - name: PACT_BROKER_WEBHOOK_SCHEME_WHITELIST + value: http + - name: PACT_BROKER_WEBHOOK_HTTP_METHOD_WHITELIST + value: GET + - name: PACT_BROKER_WEBHOOK_HOST_WHITELIST + value: jenkins-service diff --git a/deployment/base/pact/ingress.yaml b/deployment/base/pact/ingress.yaml new file mode 100644 index 0000000..e7a8a1d --- /dev/null +++ b/deployment/base/pact/ingress.yaml @@ -0,0 +1,19 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: pact-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + ingressClassName: nginx + rules: + - host: pact.localhost + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: pact-service + port: + number: 30020 diff --git a/deployment/base/pact/kustomization.yaml b/deployment/base/pact/kustomization.yaml new file mode 100644 index 0000000..350ec31 --- /dev/null +++ b/deployment/base/pact/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - deployment.yaml + - service.yaml + - ingress.yaml \ No newline at end of file diff --git a/deployment/base/pact/service.yaml b/deployment/base/pact/service.yaml new file mode 100644 index 0000000..67e4d39 --- /dev/null +++ b/deployment/base/pact/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: pact-service +spec: + selector: + app: pact-service + type: NodePort + ports: + - protocol: TCP + port: 8080 + targetPort: 8080 + nodePort: 30020 + name: service diff --git a/deployment/base/registry/deployment.yaml b/deployment/base/registry/deployment.yaml new file mode 100644 index 0000000..acd8b8d --- /dev/null +++ b/deployment/base/registry/deployment.yaml @@ -0,0 +1,22 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: registry-deployment + labels: + app: registry-service +spec: + replicas: 1 + selector: + matchLabels: + app: registry-service + template: + metadata: + labels: + app: registry-service + spec: + containers: + - name: registry + image: registry:2.8.2 + ports: + - containerPort: 5000 + name: http diff --git a/deployment/base/registry/ingress.yaml b/deployment/base/registry/ingress.yaml new file mode 100644 index 0000000..650564f --- /dev/null +++ b/deployment/base/registry/ingress.yaml @@ -0,0 +1,19 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: registry-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + ingressClassName: nginx + rules: + - host: registry.localhost + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: registry-service + port: + number: 30010 diff --git a/deployment/base/registry/kustomization.yaml b/deployment/base/registry/kustomization.yaml new file mode 100644 index 0000000..350ec31 --- /dev/null +++ b/deployment/base/registry/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - deployment.yaml + - service.yaml + - ingress.yaml \ No newline at end of file diff --git a/deployment/base/registry/service.yaml b/deployment/base/registry/service.yaml new file mode 100644 index 0000000..7b341e7 --- /dev/null +++ b/deployment/base/registry/service.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: registry-service +spec: + selector: + app: registry-service + type: NodePort + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 + nodePort: 30010 + name: service diff --git a/deployment/cluster-config/kind-config.yml b/deployment/cluster-config/kind-config.yml new file mode 100644 index 0000000..f9ab44f --- /dev/null +++ b/deployment/cluster-config/kind-config.yml @@ -0,0 +1,58 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: + - role: control-plane + kubeadmConfigPatches: + - | + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + extraPortMappings: + - containerPort: 30010 + hostPort: 30010 + protocol: TCP + - containerPort: 30020 + hostPort: 30020 + protocol: TCP + - containerPort: 30030 + hostPort: 30030 + protocol: TCP + - containerPort: 30040 + hostPort: 30040 + protocol: TCP + - containerPort: 30060 + hostPort: 30060 + protocol: TCP + - containerPort: 30070 + hostPort: 30070 + protocol: TCP + - containerPort: 30080 + hostPort: 30080 + protocol: TCP + - containerPort: 30090 + hostPort: 30090 + protocol: TCP + - containerPort: 31060 + hostPort: 31060 + protocol: TCP + - containerPort: 31070 + hostPort: 31070 + protocol: TCP + - containerPort: 31080 + hostPort: 31080 + protocol: TCP + - containerPort: 31090 + hostPort: 31090 + protocol: TCP + extraMounts: + - hostPath: /var/run/docker.sock + containerPath: /var/run/docker.sock + - role: worker + extraMounts: + - hostPath: /var/run/docker.sock + containerPath: /var/run/docker.sock + - role: worker + extraMounts: + - hostPath: /var/run/docker.sock + containerPath: /var/run/docker.sock diff --git a/deployment/kustomization.yaml b/deployment/kustomization.yaml new file mode 100644 index 0000000..8ebfae3 --- /dev/null +++ b/deployment/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - ./base + - ./setup diff --git a/deployment/setup/job.yaml b/deployment/setup/job.yaml new file mode 100644 index 0000000..118bbeb --- /dev/null +++ b/deployment/setup/job.yaml @@ -0,0 +1,12 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: setup +spec: + template: + spec: + containers: + - name: setup + image: host.docker.internal:5000/setup:local + restartPolicy: Never + backoffLimit: 1 diff --git a/deployment/setup/kustomization.yaml b/deployment/setup/kustomization.yaml new file mode 100644 index 0000000..3e6455e --- /dev/null +++ b/deployment/setup/kustomization.yaml @@ -0,0 +1,5 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: + - job.yaml