Skip to content

Commit

Permalink
Merge pull request #1 from nats-io/travis-config
Browse files Browse the repository at this point in the history
Add Travis
  • Loading branch information
wallyqs authored Jul 27, 2018
2 parents 1b108b1 + cb7b6a9 commit 1a2ec35
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sudo: required

env:
- KUBERNETES_CONFIG_FILE=$HOME/.kube/config CHANGE_MINIKUBE_NONE_USER=true

before_script:
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.11.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
- sudo minikube start --vm-driver=none --kubernetes-version=v1.10.0 --bootstrapper=localkube --feature-gates="TokenRequest=true,PodShareProcessNamespace=true" --extra-config=apiserver.service-account-signing-key-file=/var/lib/localkube/certs/apiserver.key --extra-config=apiserver.service-account-issuer=api --extra-config=apiserver.service-account-api-audiences=api --extra-config=apiserver.service-account-key-file=/var/lib/localkube/certs/sa.pub
- minikube update-context
- 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
- ./test/operator/deploy.sh
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# NATS Streaming Operator

[![License Apache 2.0](https://img.shields.io/badge/License-Apache2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Build Status](https://travis-ci.org/nats-io/nats-streaming-operator.svg?branch=master)](https://travis-ci.org/nats-io/nats-streaming-operator)
[![Version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=go&type=5&v=0.1.0)](https://github.com/nats-io/nats-operator/releases/tag/v0.1.0)

Operator for managing NATS Streaming clusters running on [Kubernetes](http://kubernetes.io).
Expand Down
91 changes: 91 additions & 0 deletions test/operator/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

# Wait once again for cluster to be 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

# Bootstrap own user policy
kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --serviceaccount=kube-system:default

# Confirm delete the CRD in case present right now
kubectl get crd | grep natscluster && {
kubectl delete crd natsclusters.nats.io
}

# Deploy the NATS cluster manifest with RBAC enabled
kubectl -n nats-io apply -f https://raw.githubusercontent.com/nats-io/nats-operator/master/example/deployment-rbac.yaml

# Wait until the CRD is ready
attempts=0
until kubectl get crd natsclusters.nats.io -o yaml | grep InitialNamesAccepted; do
if [[ attempts -eq 60 ]]; then
echo "Gave up waiting for CRD to be ready..."
kubectl -n nats-io logs deployment/nats-operator
exit 1
fi
((++attempts))

echo "Waiting for CRD... ($attempts attempts)"
sleep 1
done

# Deploy the NATS Streaming CRD with RBAC enabled
kubectl apply -f deploy/deployment-rbac.yaml

# Wait until the CRD is ready
attempts=0
until kubectl get crd natsstreamingclusters.streaming.nats.io -o yaml | grep InitialNamesAccepted; do
if [[ attempts -eq 60 ]]; then
echo "Gave up waiting for CRD to be ready..."
kubectl -n nats-io logs deployment/nats-streaming-operator
exit 1
fi
((++attempts))

echo "Waiting for CRD... ($attempts attempts)"
sleep 1
done

# Deploy an example manifest and wait for pods to appear
kubectl -n nats-io apply -f deploy/examples/example-nats-cluster.yaml

# Wait until 3 pods appear
attempts=0
until kubectl -n nats-io get pods | grep -v operator | grep nats | grep Running | wc -l | grep 3; do
if [[ attempts -eq 60 ]]; then
echo "Gave up waiting for NatsCluster to be ready..."
kubectl -n nats-io logs deployment/nats-operator
kubectl -n nats-io logs -l nats_cluster=example-nats
exit 1
fi

echo "Waiting for pods to appear ($attempts attempts)..."
((++attempts))
sleep 1
done

# Show output to confirm.
kubectl -n nats-io logs -l nats_cluster=example-nats

# Next, deploy the NATS Streaming Cluster
kubectl -n nats-io apply -f deploy/examples/example-stan-cluster.yaml

# Wait until 3 pods appear
attempts=0
until kubectl -n nats-io get pods | grep -v operator | grep stan | wc -l | grep 3; do
if [[ attempts -eq 120 ]]; then
echo "Gave up waiting for NatsStreamingCluster to be ready..."
kubectl -n nats-io get pods
kubectl -n nats-io logs deployment/nats-streaming-operator
kubectl -n nats-io logs -l stan_cluster=example-stan
exit 1
fi

echo "Waiting for pods to appear ($attempts attempts)..."
((++attempts))
sleep 1
done

0 comments on commit 1a2ec35

Please sign in to comment.