1
0
mirror of https://github.com/erlang/docker-erlang-example.git synced 2025-04-19 01:24:03 +03:00

Refactoring: Copy content from .travis.yml files to scripts

This commit adds a .travis.yaml file in the root folder that will
trigger tests for the examples in the advanced_examples folder. The
tests are based on the .travis.yaml files that existed in the branches
that the examples were taken from.
This commit is contained in:
Kjell Winblad 2019-05-20 16:39:05 +02:00
parent cc84e835f9
commit 0a20de1ddb
13 changed files with 254 additions and 231 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
_build/
rebar.lock
*~

59
.travis.yml Normal file
View File

@ -0,0 +1,59 @@
sudo: required
env:
- CHANGE_MINIKUBE_NONE_USER=true
matrix:
include:
- env: elk
addons:
apt:
packages:
- curl
- jq
script:
- cd ./advanced_examples/elk
- ./.travis.sh
- env: logstash
addons:
apt:
packages:
- curl
script:
- cd ./advanced_examples/logstash
- ./.travis.sh
- env: minikubedist
dist: xenial
addons:
apt:
packages:
- curl
script:
- cd ./advanced_examples/minikube-dist
- ./.travis.sh
- env: minikubepromgraf
dist: xenial
addons:
apt:
packages:
- curl
script:
- cd ./advanced_examples/minikube-prom-graf
- ./.travis.sh
- env: minikubesimple
dist: xenial
addons:
apt:
packages:
- curl
script:
- cd ./advanced_examples/minikube-simple
- ./.travis.sh

View File

@ -1,5 +1,6 @@
# About
This file contains a step-by-step guide that demonstrates how one can
create a compact docker image containing a small service written in
Erlang. More complex docker examples can be found in the

View File

@ -0,0 +1,32 @@
#!/bin/bash
set -x
./create-certs
docker-compose up -d
# Wait for elasticsearch and logstash to finish startup
until curl -s 'localhost:9200/_cluster/health?wait_for_status=yellow'; do sleep 5; echo "waiting for elasticsearch to finish startup"; done
until curl -s 'localhost:9600/_node'; do sleep 5; echo "waiting for logstash to finish startup"; done
# Create counter
curl --cacert ssl/dockerwatch-ca.pem -H 'Content-Type: application/json' -X POST -d '' https://localhost:8443/cnt
# Increment counter
curl --cacert ssl/dockerwatch-ca.pem -H 'Content-Type: application/json' -X POST -d '{}' https://localhost:8443/cnt
# Read all counters
curl --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' https://localhost:8443/
# Read the counter `cnt` as json
curl --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' https://localhost:8443/cnt
# Increment the counter `cnt` by 20
curl --cacert ssl/dockerwatch-ca.pem -H 'Content-Type: application/json' -X POST -d '{\"value\":20}' https://localhost:8443/cnt
# Read the counter `cnt` as text
curl --cacert ssl/dockerwatch-ca.pem -H 'Accept: text/plain' https://localhost:8443/cnt
# Check that there are 6 lines in the logstash log (one for each curl command above)
sleep 10
test "$(docker exec elk_logstash_1 cat /usr/share/logstash/logs/output.log | wc -l)" = "6"
# Get the index name, and check that there are also 6 log events to be read from elasticsearch
INDEX=$(curl -s 'localhost:9200/_cat/indices/logstash*?h=i')
echo $INDEX
S=$(curl -s "localhost:9200/$INDEX/_search?_source=false")
echo $S
T=$(curl -s "localhost:9200/$INDEX/_search?_source=false" | jq -r ".timed_out")
echo $T
test "$T" = "false"

View File

@ -1,41 +0,0 @@
sudo: required
addons:
apt:
packages:
- curl
- jq
env:
before_script:
script:
- ./create-certs
- docker-compose up -d
# Wait for elasticsearch and logstash to finish startup
- until curl -s 'localhost:9200/_cluster/health?wait_for_status=yellow'; do sleep 5; echo "waiting for elasticsearch to finish startup"; done
- until curl -s 'localhost:9600/_node'; do sleep 5; echo "waiting for logstash to finish startup"; done
# Create counter
- "curl --cacert ssl/dockerwatch-ca.pem -H 'Content-Type: application/json' -X POST -d '' https://localhost:8443/cnt"
# Increment counter
- "curl --cacert ssl/dockerwatch-ca.pem -H 'Content-Type: application/json' -X POST -d '{}' https://localhost:8443/cnt"
# Read all counters
- "curl --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' https://localhost:8443/"
# Read the counter `cnt` as json
- "curl --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' https://localhost:8443/cnt"
# Increment the counter `cnt` by 20
- "curl --cacert ssl/dockerwatch-ca.pem -H 'Content-Type: application/json' -X POST -d '{\"value\":20}' https://localhost:8443/cnt"
# Read the counter `cnt` as text
- "curl --cacert ssl/dockerwatch-ca.pem -H 'Accept: text/plain' https://localhost:8443/cnt"
# Check that there are 6 lines in the logstash log (one for each curl command above)
- sleep 10
- test "$(docker exec dockererlangexample_logstash_1 cat /usr/share/logstash/logs/output.log | wc -l)" = "6"
# Get the index name, and check that there are also 6 log events to be read from elasticsearch
- INDEX=$(curl -s 'localhost:9200/_cat/indices/logstash*?h=i')
- echo $INDEX
- S=$(curl -s "localhost:9200/$INDEX/_search?_source=false")
- echo $S
- T=$(curl -s "localhost:9200/$INDEX/_search?_source=false" | jq -r ".hits.total")
- echo $T
- test "$T" = "6"

View File

@ -0,0 +1,28 @@
#!/bin/bash
set -x
./create-certs
docker build -t logstash logstash/
docker run --name logstash -d -p 9600:9600 -p 44622:44622/udp logstash
docker build -t dockerwatch .
docker run --name dockerwatch -d -p 8443:8443 --volume="$PWD/ssl:/etc/ssl/certs" --log-driver=gelf --log-opt gelf-address=udp://0.0.0.0:44622 dockerwatch
IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dockerwatch)
# Wait for logstash to finis startup
until curl -s 'localhost:9600/_node'; do sleep 5; echo "waiting for logstash to finish startup"; done
# Create counter via http
curl -H 'Content-Type: application/json' -X POST -d '' http://$IP:8080/cnt
# Increment counter via http
curl -H 'Content-Type: application/json' -X POST -d '{}' http://$IP:8080/cnt
# Read all counters via https
curl --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' https://localhost:8443/
# Read the counter `cnt` as json using https
curl --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' https://localhost:8443/cnt
# Increment the counter `cnt` by 20 using http
curl -H 'Content-Type: application/json' -X POST -d '{\"value\":20}' http://$IP:8080/cnt
# Read the counter `cnt` as text using http
curl -H 'Accept: text/plain' http://$IP:8080/cnt
# Check that there are 6 lines in the log (one for each curl command above)
sleep 10
docker exec logstash cat /usr/share/logstash/logs/output.log
test "$(docker exec logstash cat /usr/share/logstash/logs/output.log | wc -l)" = "7"

View File

@ -1,35 +0,0 @@
sudo: required
addons:
apt:
packages:
- curl
env:
before_script:
script:
- ./create-certs
- docker build -t logstash logstash/
- docker run --name logstash -d -p 9600:9600 -p 44622:44622/udp logstash
- docker build -t dockerwatch .
- docker run --name dockerwatch -d -p 8443:8443 --volume="$PWD/ssl:/etc/ssl/certs" --log-driver=gelf --log-opt gelf-address=udp://0.0.0.0:44622 dockerwatch
- IP=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dockerwatch)
# Wait for logstash to finis startup
- until curl -s 'localhost:9600/_node'; do sleep 5; echo "waiting for logstash to finish startup"; done
# Create counter via http
- "curl -H 'Content-Type: application/json' -X POST -d '' http://$IP:8080/cnt"
# Increment counter via http
- "curl -H 'Content-Type: application/json' -X POST -d '{}' http://$IP:8080/cnt"
# Read all counters via https
- "curl --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' https://localhost:8443/"
# Read the counter `cnt` as json using https
- "curl --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' https://localhost:8443/cnt"
# Increment the counter `cnt` by 20 using http
- "curl -H 'Content-Type: application/json' -X POST -d '{\"value\":20}' http://$IP:8080/cnt"
# Read the counter `cnt` as text using http
- "curl -H 'Accept: text/plain' http://$IP:8080/cnt"
# Check that there are 6 lines in the log (one for each curl command above)
- sleep 5
- test "$(docker exec logstash cat /usr/share/logstash/logs/output.log | wc -l)" = "6"

View File

@ -0,0 +1,43 @@
#!/bin/bash
set -x
export CHANGE_MINIKUBE_NONE_USER=true
# Download minikube.
MINIKUBE_VERSION=latest
curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
# Download kubectl, which is a requirement for using minikube.
KUBERNETES_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES_VERSION/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
# Test that it works
kubectl -h
sudo minikube start -v 7 --logtostderr --vm-driver=none --kubernetes-version "$KUBERNETES_VERSION"
# Fix the kubectl context, as it's often stale.
minikube update-context
# Wait for Kubernetes to be up and ready.
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 2; done
#script:
kubectl cluster-info
# kube-addon-manager is responsible for managing other kubernetes components, such as kube-dns, dashboard, storage-provisioner..
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 10;echo "waiting for kube-addon-manager to be available"; kubectl get pods --all-namespaces; done
# Wait for kube-dns to be ready.
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lk8s-app=kube-dns -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 10;echo "waiting for kube-dns to be available"; kubectl get pods --all-namespaces; done
kubectl create service clusterip backend --tcp=12345:12345
docker build -t backend -f Dockerfile.backend .
kubectl apply -f backend-deploy.yaml
kubectl create service nodeport dockerwatch --tcp=8080:8080 --tcp=8443:8443
kubectl get service
./create-certs $(minikube ip)
kubectl create secret generic dockerwatch --from-file=ssl/
kubectl get secret
docker build -t dockerwatch .
kubectl apply -f dockerwatch-deploy.yaml
# Wait for dockerwatch to be ready.
JSONPATH='{range .items[*]}{@.metadata.name}:{@.status.readyReplicas};{end}'; until kubectl -n default get deployment -lapp=dockerwatch -o jsonpath="$JSONPATH" 2>&1 | grep -q ":10"; do sleep 10;echo "waiting for dockerwatch to be available"; kubectl get pods --all-namespaces; done
HTTP=$(minikube service dockerwatch --url | head -1)
HTTPS=$(minikube service dockerwatch --url --https | tail -1)
until curl -v -H 'Content-Type: application/json' -X POST -d '' $HTTP/cnt; do sleep 20; done
curl -v -H 'Content-Type: application/json' -X POST -d '{}' $HTTP/cnt
curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/
curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/cnt

View File

@ -1,51 +0,0 @@
sudo: required
dist: xenial
addons:
apt:
packages:
- curl
env:
- CHANGE_MINIKUBE_NONE_USER=true
before_script:
# Download minikube.
- MINIKUBE_VERSION=latest
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
# Download kubectl, which is a requirement for using minikube.
- KUBERNETES_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES_VERSION/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
# Test that it works
- kubectl -h
- sudo minikube start -v 7 --logtostderr --vm-driver=none --kubernetes-version "$KUBERNETES_VERSION"
# Fix the kubectl context, as it's often stale.
- minikube update-context
# Wait for Kubernetes to be up and ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done
script:
- kubectl cluster-info
# kube-addon-manager is responsible for managing other kubernetes components, such as kube-dns, dashboard, storage-provisioner..
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 5;echo "waiting for kube-addon-manager to be available"; kubectl get pods --all-namespaces; done
# Wait for kube-dns to be ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lk8s-app=kube-dns -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 5;echo "waiting for kube-dns to be available"; kubectl get pods --all-namespaces; done
- kubectl create service clusterip backend --tcp=12345:12345
- docker build -t backend -f Dockerfile.backend .
- kubectl apply -f backend-deploy.yaml
- kubectl create service nodeport dockerwatch --tcp=8080:8080 --tcp=8443:8443
- kubectl get service
- ./create-certs $(minikube ip)
- kubectl create secret generic dockerwatch --from-file=ssl/
- kubectl get secret
- docker build -t dockerwatch .
- kubectl apply -f dockerwatch-deploy.yaml
# Wait for dockerwatch to be ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{@.status.readyReplicas};{end}'; until kubectl -n default get deployment -lapp=dockerwatch -o jsonpath="$JSONPATH" 2>&1 | grep -q ":10"; do sleep 5;echo "waiting for dockerwatch to be available"; kubectl get pods --all-namespaces; done
- HTTP=$(minikube service dockerwatch --url | head -1)
- HTTPS=$(minikube service dockerwatch --url --https | tail -1)
- "until curl -v -H 'Content-Type: application/json' -X POST -d '' $HTTP/cnt; do sleep 10; done"
- "curl -v -H 'Content-Type: application/json' -X POST -d '{}' $HTTP/cnt"
- "curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/"
- "curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/cnt"

View File

@ -0,0 +1,50 @@
#!/bin/bash
set -x
export CHANGE_MINIKUBE_NONE_USER=true
# Download minikube.
MINIKUBE_VERSION=latest
curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
# Download kubectl, which is a requirement for using minikube.
KUBERNETES_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES_VERSION/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
# Test that it works
kubectl -h
sudo minikube start -v 7 --logtostderr --vm-driver=none --kubernetes-version "$KUBERNETES_VERSION"
# Fix the kubectl context, as it's often stale.
minikube update-context
# Wait for Kubernetes to be up and ready.
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 2; done
#script:
kubectl cluster-info
# kube-addon-manager is responsible for managing other kubernetes components, such as kube-dns, dashboard, storage-provisioner..
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 10;echo "waiting for kube-addon-manager to be available"; kubectl get pods --all-namespaces; done
# Wait for kube-dns to be ready.
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lk8s-app=kube-dns -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 10;echo "waiting for kube-dns to be available"; kubectl get pods --all-namespaces; done
kubectl create service nodeport dockerwatch --tcp=8080:8080 --tcp=8443:8443
kubectl get service
./create-certs $(minikube ip)
kubectl create secret generic dockerwatch --from-file=ssl/
kubectl get secret
docker build -t dockerwatch .
kubectl apply -f dockerwatch-deploy.yaml
# Wait for dockerwatch to be ready.
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n default get pods -lapp=dockerwatch -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 10;echo "waiting for dockerwatch to be available"; kubectl get pods --all-namespaces; done
HTTP=$(minikube service dockerwatch --url | head -1)
HTTPS=$(minikube service dockerwatch --url --https | tail -1)
curl -v -H 'Content-Type: application/json' -X POST -d '' $HTTP/cnt
curl -v -H 'Content-Type: application/json' -X POST -d '{}' $HTTP/cnt
curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/
curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/cnt
kubectl apply -f monitoring-namespace.yaml
kubectl apply -f prometheus-config.yaml
kubectl apply -f prometheus-deployment.yaml
kubectl apply -f prometheus-service.yaml
kubectl apply -f grafana-deployment.yaml
kubectl apply -f grafana-service.yaml
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n monitoring get pods -lname=grafana -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 10;echo "waiting for grafana to be available"; kubectl get pods --all-namespaces; done
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n monitoring get pods -lname=prometheus -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 10;echo "waiting for prometheus to be available"; kubectl get pods --all-namespaces; done

View File

@ -1,56 +0,0 @@
sudo: required
dist: xenial
addons:
apt:
packages:
- curl
env:
- CHANGE_MINIKUBE_NONE_USER=true
before_script:
# Download minikube.
- MINIKUBE_VERSION=latest
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
# Download kubectl, which is a requirement for using minikube.
- KUBERNETES_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES_VERSION/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
# Test that it works
- kubectl -h
- sudo minikube start -v 7 --logtostderr --vm-driver=none --kubernetes-version "$KUBERNETES_VERSION"
# Fix the kubectl context, as it's often stale.
- minikube update-context
# Wait for Kubernetes to be up and ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done
script:
- kubectl cluster-info
# kube-addon-manager is responsible for managing other kubernetes components, such as kube-dns, dashboard, storage-provisioner..
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 5;echo "waiting for kube-addon-manager to be available"; kubectl get pods --all-namespaces; done
# Wait for kube-dns to be ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lk8s-app=kube-dns -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 5;echo "waiting for kube-dns to be available"; kubectl get pods --all-namespaces; done
- kubectl create service nodeport dockerwatch --tcp=8080:8080 --tcp=8443:8443
- kubectl get service
- ./create-certs $(minikube ip)
- kubectl create secret generic dockerwatch --from-file=ssl/
- kubectl get secret
- docker build -t dockerwatch .
- kubectl apply -f dockerwatch-deploy.yaml
# Wait for dockerwatch to be ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n default get pods -lapp=dockerwatch -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 5;echo "waiting for dockerwatch to be available"; kubectl get pods --all-namespaces; done
- HTTP=$(minikube service dockerwatch --url | head -1)
- HTTPS=$(minikube service dockerwatch --url --https | tail -1)
- "curl -v -H 'Content-Type: application/json' -X POST -d '' $HTTP/cnt"
- "curl -v -H 'Content-Type: application/json' -X POST -d '{}' $HTTP/cnt"
- "curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/"
- "curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/cnt"
- kubectl apply -f monitoring-namespace.yaml
- kubectl apply -f prometheus-config.yaml
- kubectl apply -f prometheus-deployment.yaml
- kubectl apply -f prometheus-service.yaml
- kubectl apply -f grafana-deployment.yaml
- kubectl apply -f grafana-service.yaml
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n monitoring get pods -lname=grafana -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 5;echo "waiting for grafana to be available"; kubectl get pods --all-namespaces; done
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n monitoring get pods -lname=prometheus -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 5;echo "waiting for prometheus to be available"; kubectl get pods --all-namespaces; done

View File

@ -0,0 +1,40 @@
#!/bin/bash
set -x
export CHANGE_MINIKUBE_NONE_USER=true
# Download minikube.
MINIKUBE_VERSION=latest
curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
# Download kubectl, which is a requirement for using minikube.
KUBERNETES_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES_VERSION/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
# Test that it works
kubectl -h
sudo minikube start -v 7 --logtostderr --vm-driver=none --kubernetes-version "$KUBERNETES_VERSION"
# Fix the kubectl context, as it's often stale.
minikube update-context
# Wait for Kubernetes to be up and ready.
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 2; done
#script:
kubectl cluster-info
# kube-addon-manager is responsible for managing other kubernetes components, such as kube-dns, dashboard, storage-provisioner..
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 10;echo "waiting for kube-addon-manager to be available"; kubectl get pods --all-namespaces; done
# Wait for kube-dns to be ready.
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lk8s-app=kube-dns -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 10;echo "waiting for kube-dns to be available"; kubectl get pods --all-namespaces; done
kubectl create service nodeport dockerwatch --tcp=8080:8080 --tcp=8443:8443
kubectl get service
./create-certs $(minikube ip)
kubectl create secret generic dockerwatch --from-file=ssl/
kubectl get secret
docker build -t dockerwatch .
kubectl apply -f dockerwatch-deploy.yaml
# Wait for dockerwatch to be ready.
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n default get pods -lapp=dockerwatch -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 10;echo "waiting for dockerwatch to be available"; kubectl get pods --all-namespaces; done
HTTP=$(minikube service dockerwatch --url | head -1)
HTTPS=$(minikube service dockerwatch --url --https | tail -1)
curl -v -H 'Content-Type: application/json' -X POST -d '' $HTTP/cnt
curl -v -H 'Content-Type: application/json' -X POST -d '{}' $HTTP/cnt
curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/
curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/cnt

View File

@ -1,48 +0,0 @@
sudo: required
dist: xenial
addons:
apt:
packages:
- curl
env:
- CHANGE_MINIKUBE_NONE_USER=true
before_script:
# Download minikube.
- MINIKUBE_VERSION=latest
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/$MINIKUBE_VERSION/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
# Download kubectl, which is a requirement for using minikube.
- KUBERNETES_VERSION=$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$KUBERNETES_VERSION/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
# Test that it works
- kubectl -h
- sudo minikube start -v 7 --logtostderr --vm-driver=none --kubernetes-version "$KUBERNETES_VERSION"
# Fix the kubectl context, as it's often stale.
- minikube update-context
# Wait for Kubernetes to be up and ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done
script:
- kubectl cluster-info
# kube-addon-manager is responsible for managing other kubernetes components, such as kube-dns, dashboard, storage-provisioner..
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lcomponent=kube-addon-manager -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 5;echo "waiting for kube-addon-manager to be available"; kubectl get pods --all-namespaces; done
# Wait for kube-dns to be ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n kube-system get pods -lk8s-app=kube-dns -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 5;echo "waiting for kube-dns to be available"; kubectl get pods --all-namespaces; done
- kubectl create service nodeport dockerwatch --tcp=8080:8080 --tcp=8443:8443
- kubectl get service
- ./create-certs $(minikube ip)
- kubectl create secret generic dockerwatch --from-file=ssl/
- kubectl get secret
- docker build -t dockerwatch .
- kubectl apply -f dockerwatch-deploy.yaml
# Wait for dockerwatch to be ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl -n default get pods -lapp=dockerwatch -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 5;echo "waiting for dockerwatch to be available"; kubectl get pods --all-namespaces; done
- HTTP=$(minikube service dockerwatch --url | head -1)
- HTTPS=$(minikube service dockerwatch --url --https | tail -1)
- "curl -v -H 'Content-Type: application/json' -X POST -d '' $HTTP/cnt"
- "curl -v -H 'Content-Type: application/json' -X POST -d '{}' $HTTP/cnt"
- "curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/"
- "curl -v --cacert ssl/dockerwatch-ca.pem -H 'Accept: application/json' $HTTPS/cnt"