Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kubernetes tldr #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Quick Start

Clone this repo first. You'll need local files:
```sh
git clone https://github.com/lomik/graphite-clickhouse-tldr
cd graphite-clickhouse-tldr
```

## Docker-Compose
```sh
cd compose
docker-compose up
```
Open http://127.0.0.1/ in browser
Expand All @@ -13,4 +20,30 @@ Host | Container | Service
80 | 80 | [nginx](https://www.nginx.com/resources/admin-guide/)
2003 | 2003 | [carbon receiver - plaintext](http://graphite.readthedocs.io/en/latest/feeding-carbon.html#the-plaintext-protocol)
2004 | 2004 | [carbon receiver - pickle](http://graphite.readthedocs.io/en/latest/feeding-carbon.html#the-pickle-protocol)
2006 | 2006 | [carbon receiver - prometheus remote write](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#%3Cremote_write%3E)
2006 | 2006 | [carbon receiver - prometheus remote write](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#%3Cremote_write%3E)

# Kubernetes

This install assumes you can install the clickhouse-operator in the kube-system namespace.
See https://github.com/Altinity/clickhouse-operator/blob/master/docs/quick_start.md#clickhouse-operator-installation

## Setup

```sh
cd k8s
./ch-operator-install.sh
sleep 10 #wait for operator
kubectl apply -f stats-conf.yaml #note, you may need to tweak
```

## Running

```sh
kubectl apply -f ch-stats.yaml
sleep 10 #you should watch for clickhouse to finish coming up:
watch kubectl get pods # ctrl-c out when the pods are ready
kubectl apply -f services.yaml
watch kubectl get pods # ctrl-c out when services are online
kubectl port-forward service/stat-web 9000:80
```
Open http://127.0.0.1:9000/ in your browser
5 changes: 4 additions & 1 deletion carbon-clickhouse.conf → compose/carbon-clickhouse.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ metric-prefix = "carbon.agents.{host}"
# Endpoint for store internal carbon metrics. Valid values: "" or "local", "tcp://host:port", "udp://host:port"
metric-endpoint = "local"
# Interval of storing internal metrics. Like CARBON_METRIC_INTERVAL
metric-interval = "1m0s"
metric-interval = "5s"
# GOMAXPROCS
max-cpu = 1

[convert_to_tagged]
enabled = false

[logging]
# "stderr", "stdout" can be used as file name
file = "stdout"
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion docker-compose.yaml → compose/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ graphite-clickhouse:
- "./graphite-clickhouse.conf:/etc/graphite-clickhouse/graphite-clickhouse.conf"
links:
- clickhouse
ports:
- "9090:9090" # http api access
graphite-web:
image: graphiteapp/graphite-statsd:1.1.3
image: graphiteapp/graphite-statsd:1.1.7-3
volumes:
- "./graphiteweb_entrypoint.sh:/entrypoint.sh"
- "./graphiteweb.conf:/opt/graphite/webapp/graphite/local_settings.py"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions k8s/ch-operator-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash -e

OPERATOR_NS=${OPERATOR_NS:-kube-system}
kubectl apply -f https://raw.githubusercontent.com/Altinity/clickhouse-operator/master/deploy/operator/clickhouse-operator-install.yaml -n $OPERATOR_NS
96 changes: 96 additions & 0 deletions k8s/ch-stats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
apiVersion: "clickhouse.altinity.com/v1"
kind: "ClickHouseInstallation"
metadata:
name: "stats"
spec:
defaults:
templates:
dataVolumeClaimTemplate: volume-template
logVolumeClaimTemplate: log-volume-template
serviceTemplate: chi-service-template
podTemplate: clickhouse:19.6
configuration:
users:
default/networks/ip:
- "10.0.0.0/8"
- "127.0.0.1/32"
clusters:
- name: "default"
layout:
shardsCount: 1
replicasCount: 1
files:
logs.xml: |
<yandex>
<logger>
<level>warning</level>
<log>/var/log/clickhouse-server/clickhouse-server.log</log>
<errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog>
<size>1000M</size>
<count>10</count>
</logger>
</yandex>
rollup.xml: |
<yandex>
<graphite_rollup>
<path_column_name>Path</path_column_name>
<time_column_name>Time</time_column_name>
<value_column_name>Value</value_column_name>
<version_column_name>Timestamp</version_column_name>
<default>
<function>avg</function>
<retention>
<age>0</age>
<precision>60</precision>
</retention>
<retention>
<age>2592000</age>
<precision>3600</precision>
</retention>
</default>
</graphite_rollup>
</yandex>
templates:
podTemplates:
- name: clickhouse:19.6
spec:
volumes:
- name: stats-conf
configMap:
name: stats-conf
containers:
- name: clickhouse-pod
image: yandex/clickhouse-server:19.6.2.11
volumeMounts:
- name: stats-conf
mountPath: /docker-entrypoint-initdb.d/init.sql
subPath: init.sql
serviceTemplates:
- name: chi-service-template
generateName: "ch-stats"
spec:
ports:
- name: http
port: 80
targetPort: 8123
- name: client
port: 9440
targetPort: 9000
type: ClusterIP
volumeClaimTemplates:
- name: volume-template
spec:
storageClassName: gp2
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 15Gi
- name: log-volume-template
spec:
storageClassName: gp2
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
195 changes: 195 additions & 0 deletions k8s/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: stat-relay
component: carbon
name: stat-relay
namespace: stats
spec:
replicas: 3
revisionHistoryLimit: 10
selector:
matchLabels:
app: stat-relay
component: carbon
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: stat-relay
component: carbon
spec:
containers:
- image: lomik/carbon-clickhouse:v0.10.2
resources: {}
imagePullPolicy: IfNotPresent
name: stat-relay
ports:
- containerPort: 2003
name: plaintext
protocol: TCP
- containerPort: 2004
name: pickle
protocol: TCP
volumeMounts:
- name: stats-conf
mountPath: /etc/carbon-clickhouse/carbon-clickhouse.conf
subPath: carbon.relay.conf
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumes:
- name: stats-conf
configMap:
name: stats-conf
restartPolicy: Always
terminationGracePeriodSeconds: 30
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: stat-api
component: graphite
name: stat-api
namespace: stats
spec:
replicas: 3
revisionHistoryLimit: 10
selector:
matchLabels:
app: stat-api
component: graphite
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: stat-api
component: graphite
spec:
containers:
- image: lomik/graphite-clickhouse:v0.11.1
imagePullPolicy: IfNotPresent
name: stat-api
ports:
- containerPort: 9090
name: http
protocol: TCP
resources:
requests:
cpu: 700m
memory: 6Gi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- name: stats-conf
mountPath: /etc/graphite-clickhouse/graphite-clickhouse.conf
subPath: graphite.api.conf
- name: stats-conf
mountPath: /etc/graphite-clickhouse/rollup.xml
subPath: rollup.xml
restartPolicy: Always
volumes:
- name: stats-conf
configMap:
name: stats-conf
terminationGracePeriodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
labels:
app: stat-api
name: stat-api
namespace: stats
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 9090
selector:
app: stat-api
sessionAffinity: None
type: ClusterIP
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: stat-web
component: web
name: stat-web
namespace: stats
spec:
progressDeadlineSeconds: 2147483647
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: stat-web
component: web
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: stat-web
component: web
spec:
containers:
- image: gographite/carbonapi:v0.13.0
imagePullPolicy: IfNotPresent
name: stat-web
ports:
- containerPort: 80
name: http
protocol: TCP
resources:
requests:
cpu: 300m
memory: 512Mi
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- name: stats-conf
mountPath: /etc/carbonapi.yml
subPath: carbonapi.yml
restartPolicy: Always
volumes:
- name: stats-conf
configMap:
name: stats-conf
terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
labels:
app: stat-web
name: stat-web
namespace: stats
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
selector:
app: stat-web
sessionAffinity: None
type: ClusterIP
Loading