forked from cescoffier/reactive-coffeeshop-demo
-
Notifications
You must be signed in to change notification settings - Fork 4
/
.travis.yml
50 lines (47 loc) · 2.73 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
services:
- docker
os: linux
install:
- mkdir -p ~/bin && export PATH=~/bin:$PATH
# Install kind
- curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.6.0/kind-$(uname)-amd64 && chmod +x ./kind && mv ./kind ~/bin
# Install kubectl
- 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 ~/bin
# Install helm
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
script:
# Build docker images for the services
- ./build.sh
# Start a local K8s cluster using kind, configured with a local Docker registry
- ./.ci/local-cluster.sh
# Push images to local registry
- ./.ci/local-registry.sh
# Install kafka via Strimzi helm chart, placing Strimzi operator in strimzi
# namespace, and watching the kafka namespace.
# (Cannot be expressed as a helm dependency, as CRDs must be installed first)
- kubectl create ns strimzi
- kubectl create ns kafka
- helm repo add strimzi https://strimzi.io/charts
- helm install strimzi strimzi/strimzi-kafka-operator -n strimzi --set watchNamespaces={kafka} --wait --timeout 300s
# Install Strimzi custom resource, and wait for cluster creation
- kubectl apply -f kafka-strimzi.yml -n kafka
- kubectl wait --for=condition=Ready kafkas/my-cluster -n kafka --timeout 300s
# Create namespace for Keda
- kubectl create ns keda
# Install Keda Helm chart
- helm repo add kedacore https://kedacore.github.io/charts
- helm install keda kedacore/keda -n keda --wait --timeout 300s
# Wait for Keda apiservice to be ready
- kubectl wait --for=condition=Available --timeout=60s apiservices/v1beta1.external.metrics.k8s.io
# Deploy to local cluster via helm, into coffee namespace.
- kubectl create ns coffee
- helm install coffee-v1 ./coffeeshop-chart -n coffee --wait --timeout 300s --set baristaKafka.image.registry=registry:5000 --set baristaHttp.image.registry=registry:5000 --set coffeeshopService.image.registry=registry:5000
# Display overall system state for kafka and coffee namespaces
- kubectl get all -n kafka
- kubectl get all -n coffee
# Forward local port (kind does not expose NodePort to host network)
- kubectl port-forward service/coffee-v1-coffeeshop-service 8080 -n coffee &
# Wait for port forwarding, test system
- sleep 5 && ./ci-test.sh 8080 coffee ; export TEST_RC=$?
# If the test failed, dump the logs for coffeeshop-service and barista-kafka
- if [ $TEST_RC -ne 0 ]; then kubectl logs deployment/coffee-v1-coffeeshop-service -n coffee ; kubectl logs deployment/coffee-v1-barista-kafka -n coffee ; (exit $TEST_RC) ; fi