Skip to content

Commit

Permalink
Initial working version
Browse files Browse the repository at this point in the history
* Support for all-in-one deployments
* Support for custom CLI options
* Support for in-memory storage
* Tests

Signed-off-by: Juraci Paixão Kröhling <[email protected]>
  • Loading branch information
jpkrohling committed Aug 31, 2018
1 parent 1a8f465 commit 938640e
Show file tree
Hide file tree
Showing 127 changed files with 21,942 additions and 77 deletions.
2 changes: 2 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ignore:
- "pkg/apis/io/v1alpha1/zz_generated.deepcopy.go"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Temporary Build Files
tmp/_output
tmp/_test
deploy/test


# Created by https://www.gitignore.io/api/go,vim,emacs,visualstudiocode
Expand Down
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: go
sudo: required

services:
- docker

go:
- 1.10.1

env:
- BUILD_IMAGE="jaegertracing/jaeger-operator:JOB_${TRAVIS_JOB_NUMBER}" KUBERNETES_CONFIG_FILE=$HOME/.kube/config CHANGE_MINIKUBE_NONE_USER=true

before_script:
- ./.travis/before_script.sh

install:
- ./.travis/install.sh

script:
- ./.travis/script.sh

after_success:
- ./.travis/after_success.sh

after_failure:
- ./.travis/after_failure.sh
13 changes: 13 additions & 0 deletions .travis/after_failure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

kubectl cluster-info
kubectl get deployment
kubectl get pods
kubectl describe pods

if [ -f deploy/test/namespace-manifests.yaml ]; then
echo "Test namespace manifests:"
cat deploy/test/namespace-manifests.yaml
else
echo "Test namespace manifest does not exist."
fi
6 changes: 6 additions & 0 deletions .travis/after_success.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

echo 'Build succeeded, operator was generated, Jaeger operator is running on minikube, and unit/integration tests pass'

echo "Uploading code coverage results"
bash <(curl -s https://codecov.io/bash)
50 changes: 50 additions & 0 deletions .travis/before_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

go version

echo "Installing kubectl"
curl -sLo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.10.0/bin/linux/amd64/kubectl > /dev/null
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

echo "Installing minikube"
curl -sLo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 > /dev/null
chmod +x minikube
sudo mv minikube /usr/local/bin/

echo "Installing go dep"
curl -sLo dep https://github.com/golang/dep/releases/download/v0.5.0/dep-linux-amd64 > /dev/null
chmod +x dep
sudo mv dep /usr/local/bin/

echo "Installing gosec"
go get github.com/securego/gosec/cmd/gosec/...

echo "Installing golint"
go get -u golang.org/x/lint/golint

echo "Installing the operator-sdk command"
mkdir -p $GOPATH/src/github.com/operator-framework
cd $GOPATH/src/github.com/operator-framework
git clone https://github.com/operator-framework/operator-sdk > /dev/null
cd operator-sdk
git checkout master > /dev/null
make dep > /dev/null
make install > /dev/null
cd ${TRAVIS_BUILD_DIR}

echo "Starting a Kubernetes cluster with minikube/localkube"
sudo minikube start --vm-driver=none --kubernetes-version=v1.10.0 --bootstrapper=localkube > /dev/null

echo "Updating minikube context"
minikube update-context > /dev/null

echo "Waiting for the Kubernetes cluster to get 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

echo "Performing a 'docker login' operation"
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

echo "Initializing an Elasticsearch cluster"
make es
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get pods -lapp=jaeger-elasticsearch -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done
6 changes: 6 additions & 0 deletions .travis/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

echo "Using image: ${BUILD_IMAGE}"
sed "s~image: jaegertracing\/jaeger-operator\:.*~image: ${BUILD_IMAGE}~gi" -i deploy/operator.yaml
echo "Resulting operator.yaml:"
cat deploy/operator.yaml
8 changes: 8 additions & 0 deletions .travis/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

make ci BUILD_IMAGE=${BUILD_IMAGE}
RT=$?
if [ ${RT} != 0 ]; then
echo "Failed to build the operator."
exit ${RT}
fi
119 changes: 119 additions & 0 deletions CONTRIBUTING.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
= How to Contribute to the Jaeger Operator for Kubernetes
:toc[]:

We'd love your help!

This project is link:LICENSE[Apache 2.0 licensed] and accepts contributions via GitHub pull requests. This document outlines some of the conventions on development workflow, commit message formatting, contact points and other resources to make it easier to get your contribution accepted.

We gratefully welcome improvements to documentation as well as to code.

== Certificate of Origin

By contributing to this project you agree to the link:https://developercertificate.org/[Developer Certificate of Origin] (DCO). This document was created by the Linux Kernel community and is a simple statement that you, as a contributor, have the legal right to make the contribution. See the [DCO](DCO) file for details.

== Getting Started

This project is a regular link:https://coreos.com/operators/[Kubernetes Operator] built using the Operator SDK. Refer to the Operator SDK documentation to understand the basic architecture of this operator.

=== Installing the Operator SDK command line tool

At the time of this writing, the link:https://github.com/operator-framework/operator-sdk[Operator SDK GitHub page] listed the following commands as required to install the command line tool:

[source,bash]
----
mkdir -p $GOPATH/src/github.com/operator-framework
cd $GOPATH/src/github.com/operator-framework
git clone https://github.com/operator-framework/operator-sdk
cd operator-sdk
git checkout master
make dep
make install
----

=== Developing

As usual for operators following the Operator SDK, the dependencies are checked into the source repository under the `vendor` directory. The dependencies are managed using link:https://github.com/golang/dep[`go dep`]. Refer to that project's documentation for instructions on how to add or update dependencies.

The first step is to get a local Kubernetes instance up and running. The recommended approach is using `minikube`. Refer to the Kubernetes' link:https://kubernetes.io/docs/tasks/tools/install-minikube/[documentation] for instructions on how to install it.

Once `minikube` is installed, it can be started with:

[source,bash]
----
minikube start
----

NOTE: Make sure to read the documentation to learn the performance switches that can be applied to your platform.

Once minikube has finished starting, get the Operator running:

[source,bash]
----
make run
----

At this point, a Jaeger instance can be installed:

[source,bash]
----
kubectl apply -f deploy/simplest.yaml
kubectl get jaegers
kubectl get pods
----

To remove the instance:
[source,bash]
----
kubectl delete -f deploy/simplest.yaml
----

Tests should be simple unit tests and/or end-to-end tests. For small changes, unit tests should be sufficient, but every new feature should be accompanied with end-to-end tests as well. Tests can be executed with:

[source,bash]
----
make test
----

NOTE: you can adjust the Docker image namespace by overriding the variable `NAMESPACE`, like: `make test NAMESPACE=quay.io/my-username`. The full Docker image name can be customized by overriding `BUILD_IMAGE` instead, like: `make test BUILD_IMAGE=quay.io/my-username/jaeger-operator:0.0.1`

==== Model changes

The Operator SDK generates the `pkg/apis/io/v1alpha1/zz_generated.deepcopy.go` file via the command `make generate`. This should be executed whenever there's a model change (`pkg/apis/io/v1alpha1/types.go`)

==== Ingress configuration

Kubernetes comes with no ingress provider by default. For development purposes, when running `minikube`, the following command can be executed to install an ingress provider:

[source,bash]
----
make ingress
----

This will install the `NGINX` ingress provider. It's recommended to wait for the ingress pods to be in the `READY` and `RUNNING` state before starting the operator. You can check it by running:

[source,bash]
----
kubectl get pods -n ingress-nginx
----

To verify that it's working, deploy the `simplest.yaml` and check the ingress routes:

[source,bash]
----
$ kubectl apply -f deploy/examples/simplest.yaml
jaeger.io.jaegertracing/simplest created
$ kubectl get ingress
NAME HOSTS ADDRESS PORTS AGE
simplest-query * 192.168.122.69 80 12s
----

Accessing the provided "address" in your web browser should display the Jaeger UI.

==== Storage configuration

There's a template under the `test` directory that can be used to setup an Elasticsearch cluster. Alternatively, the following command can be executed to install it:

[source,bash]
----
make es
----
Loading

0 comments on commit 938640e

Please sign in to comment.