-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #895 from rax-maas/minikube-support
add a minikube env/config
- Loading branch information
Showing
23 changed files
with
5,430 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Blueflood in minikube | ||
|
||
This is a basic, working Blueflood in minikube, complete with Cassandra, Elasticsearch, and Grafana dashboards. If all | ||
goes as planned, then as long as you've already [installed minikube](https://minikube.sigs.k8s.io/docs/start/), it's | ||
just a few steps to get it running. | ||
|
||
## Getting it started | ||
|
||
> **NOTE**: The commands here assume your working directory is the root of the Blueflood project. If you're in the | ||
`contrib/blueflood-minikube` directory, make sure to adjust the paths accordingly. | ||
|
||
First, start minikube: | ||
|
||
```bash | ||
minikube start | ||
``` | ||
Next, you have to mount the blueflood project directory into minikube with: | ||
|
||
```bash | ||
minikube mount $(pwd):/blueflood | ||
``` | ||
|
||
Then, if you want to run the latest Blueflood image from DockerHub, you can go ahead and start the stack with `kubectl | ||
apply -f contrib/blueflood-minikube/blueflood.yaml`. If you prefer to run a locally built version of Blueflood, you can | ||
build a Docker image inside minikube. You just need to set a couple of variables to do that. First, run `minikube | ||
docker-env`, and note the values of `DOCKER_HOST` and `DOCKER_CERT_PATH` for use in the following commands. Replace | ||
`tcp://` in `DOCKER_HOST` with `https://` when you use it below. Then you can build blueflood and run it with | ||
|
||
```bash | ||
mvn package docker:build -DdockerHost=$MODIFIED_DOCKER_HOST -DdockerCertPath=$DOCKER_CERT_PATH | ||
kubectl apply -f contrib/blueflood-minikubeblueflood.yaml | ||
``` | ||
|
||
> **NOTE**: You can use `-P skip-unit-tests,skip-integration-tests` to skip all the tests and make packaging faster! | ||
This should give you a complete, running Blueflood stack within a minute or two. The longest startup is Cassandra, | ||
possibly because it's looking for other nodes. Configuration might help with that. | ||
|
||
## Talking to it | ||
|
||
Minikube runs Kubernetes in a virtual environment in its own private network. Here are some ways you can communicate | ||
with it. | ||
|
||
### Using minikube IPs | ||
|
||
Most simply, you can get an IP and port reachable from your host machine with | ||
|
||
```bash | ||
minikube service blueflood --url | ||
``` | ||
|
||
This returns three items. The first is the Java debug address. The second is the ingest URL. The third is the query URL. | ||
|
||
### Using port forwarding | ||
|
||
If you prefer to bind it to ports on one of your host's interfaces, you can forward Blueflood's ingest and query ports | ||
with | ||
|
||
```bash | ||
kubectl port-forward blueflood 19000 | ||
kubectl port-forward blueflood 20000 | ||
``` | ||
|
||
If you want to reach Blueflood from a different host interface, like from another running Docker container, just tell it | ||
which interface to use. If your Docker interface has IP `172.17.0.1`, then: | ||
|
||
```bash | ||
kubectl port-forward blueflood --address 172.17.0.1 19000 | ||
kubectl port-forward blueflood --address 172.17.0.1 20000 | ||
``` | ||
|
||
## Seeing it work | ||
|
||
Use any of these methods, and plug the appropriate URLs into the example scripts in the [10 minute | ||
guide](https://github.com/rackerlabs/blueflood/wiki/10-Minute-Guide) to see it working. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
# A basic Blueflood environment in Kubernetes, suitable for deployment to minikube. There's just one pod for each | ||
# dependency, including Blueflood, and a service for each pod so that the pod is reachable from other pods and from the | ||
# host. Thus, for example, there's both a pod and a service named "cassandra". Every service is type NodePort so that | ||
# you can easily reach them from the host. | ||
# | ||
# See the README for more usage info. | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: cassandra | ||
labels: | ||
app: cassandra | ||
spec: | ||
containers: | ||
- name: cassandra | ||
image: cassandra:2.1 | ||
env: | ||
# Tells newer versions of Cassandra to start the Thrift server on port 9160, used by the Astyanax driver. | ||
# Thrift is removed in Cassandra 4.0. We'll have to move to the Datastax driver before then. | ||
- name: CASSANDRA_START_RPC | ||
value: 'true' | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: cassandra | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: cqlsh | ||
port: 9042 | ||
protocol: TCP | ||
- name: thrift | ||
port: 9160 | ||
protocol: TCP | ||
selector: | ||
app: cassandra | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: elasticsearch | ||
labels: | ||
app: elasticsearch | ||
spec: | ||
containers: | ||
- name: elasticsearch | ||
image: elasticsearch:1.7 | ||
args: | ||
- '--cluster.name=blueflood' | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: elasticsearch | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: http | ||
port: 9200 | ||
protocol: TCP | ||
- name: binary | ||
port: 9300 | ||
protocol: TCP | ||
selector: | ||
app: elasticsearch | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: graphite | ||
labels: | ||
app: graphite | ||
spec: | ||
initContainers: | ||
- name: await-source-mount | ||
image: busybox | ||
command: ['sh', '-c', 'date; echo "Checking source mount..."; [ -f /blueflood/opt/graphite/conf/carbon.conf ] && { echo "Blueflood source detected, moving on!"; } || { echo "You need to mount the blueflood source! See README.md"; exit 1; }'] | ||
volumeMounts: | ||
- name: blueflood-source | ||
mountPath: /blueflood | ||
subPath: contrib/blueflood-minikube/mounts/graphite | ||
containers: | ||
- name: graphite | ||
image: graphiteapp/graphite-statsd:1.1.7-11 | ||
# Graphite config is stored in this project so that you can control it. | ||
volumeMounts: | ||
- name: blueflood-source | ||
mountPath: /opt/graphite/conf | ||
subPath: contrib/blueflood-minikube/mounts/graphite/opt/graphite/conf | ||
volumes: | ||
- name: blueflood-source | ||
hostPath: | ||
path: /blueflood | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: graphite | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: http | ||
port: 80 | ||
protocol: TCP | ||
- name: plaintext | ||
port: 2003 | ||
protocol: TCP | ||
- name: pickle | ||
port: 2004 | ||
protocol: TCP | ||
selector: | ||
app: graphite | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: grafana | ||
labels: | ||
app: grafana | ||
spec: | ||
initContainers: | ||
- name: await-source-mount | ||
image: busybox | ||
command: ['sh', '-c', 'date; echo "Checking source mount..."; [ -f /blueflood/etc/grafana/grafana.ini ] && { echo "Blueflood source detected, moving on!"; } || { echo "You need to mount the blueflood source! See README.md"; exit 1; }'] | ||
volumeMounts: | ||
- name: blueflood-source | ||
mountPath: /blueflood | ||
subPath: contrib/blueflood-minikube/mounts/grafana | ||
containers: | ||
- name: grafana | ||
image: grafana/grafana:8.2.6 | ||
# Grafana config is stored in this project so that you can control it. | ||
volumeMounts: | ||
- name: blueflood-source | ||
mountPath: /etc/grafana | ||
subPath: contrib/blueflood-minikube/mounts/grafana/etc/grafana | ||
volumes: | ||
- name: blueflood-source | ||
hostPath: | ||
path: /blueflood | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: grafana | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: http | ||
port: 3000 | ||
protocol: TCP | ||
selector: | ||
app: grafana | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: blueflood | ||
labels: | ||
app: blueflood | ||
spec: | ||
# The Blueflood image has Cassandra and Elasticsearch init built into its entrypoint script, so we don't have to worry | ||
# about that here. If necessary, we could use init containers to initialize them. | ||
containers: | ||
- name: blueflood | ||
image: rackerlabs/blueflood | ||
env: | ||
- name: CASSANDRA_HOST | ||
value: cassandra | ||
- name: ELASTICSEARCH_HOST | ||
value: elasticsearch | ||
- name: GRAPHITE_HOST | ||
value: graphite | ||
# The default port value should work, but something's setting it to "tcp://<ip>:2003" | ||
- name: GRAPHITE_PORT | ||
value: '2003' | ||
# This prefix is prepended to all metrics emitted from Blueflood to Graphite. | ||
- name: GRAPHITE_PREFIX | ||
value: blueflood-minikube | ||
- name: CASSANDRA_DRIVER | ||
value: astyanax # or datastax | ||
# For completeness, turn on the "token search improvement" feature. The /v2.0/{tenantId}/metric_name/search | ||
# endpoint relies on it. | ||
- name: ENABLE_TOKEN_SEARCH_IMPROVEMENTS | ||
value: 'true' | ||
- name: TOKEN_DISCOVERY_MODULES | ||
value: com.rackspacecloud.blueflood.io.ElasticTokensIO | ||
# Set to 'true' to enable remote debugging of the Blueflood process. Use 'minikube service blueflood --url' to | ||
# find the IP and port to connect to. | ||
- name: DEBUG_JAVA | ||
value: 'false' | ||
# Set to 'true' to have the Blueflood JVM wait for a debugger to attach before starting. | ||
- name: DEBUG_JAVA_SUSPEND | ||
value: 'false' | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: blueflood | ||
spec: | ||
type: NodePort | ||
ports: | ||
- name: java-debug | ||
port: 5005 | ||
protocol: TCP | ||
- name: ingest | ||
port: 19000 | ||
protocol: TCP | ||
- name: query | ||
port: 20000 | ||
protocol: TCP | ||
selector: | ||
app: blueflood |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Filesystem mounts for the minikube containers. These are files that let us pre-configure things like Grafana dashboards | ||
so that they're all set up and ready to use as soon as the k8s yaml is deployed to minikube. | ||
|
||
Generally, we get these files by starting up a container, finding its config files or directories, and copying the | ||
default files out of it to here. Then we can tweak the settings to make it work the way we want. | ||
|
||
In particular, Grafana is configured to be ready for local use: | ||
|
||
- It has the Graphite server set as its default datasource. | ||
- It has some useful Blueflood dashboards already set up and ready to display metrics. | ||
- It allows anonymous admin access so that you can go straight to the dashboards and add/change whatever you want. | ||
|
||
Graphite is configured to create up to 1000 new metrics per second instead of the default of 50. Blueflood creates a lot | ||
of metrics. |
Oops, something went wrong.