prepare complete

This commit is contained in:
Matthos Denys 2021-03-12 13:59:41 +03:00
parent a440c7ed6c
commit 1f39908e1c
9 changed files with 669 additions and 624 deletions

View File

@ -4,13 +4,11 @@ kubectl delete svc mariadb-service
kubectl delete svc phpmyadmin-service
kubectl delete svc ftps
kubectl delete svc wp-service
kubectl delete deployment telegraf
kubectl delete deployment nginx-deployment
kubectl delete deployment mariadb
kubectl delete deployment wp
kubectl delete deployment phpmyadmin-deployment
kubectl delete deployment ftps
kubectl delete pods --all
# eval $(minikube docker-env)
# docker stop $(docker ps -a -q)
# docker rm $(docker ps -a -q)
kubectl delete pv --all

View File

@ -5,6 +5,6 @@ RUN apk add grafana --repository http://dl-cdn.alpinelinux.org/alpine/edge/c
COPY cfg/grafana.ini /usr/share/grafana/conf/custom.ini
COPY cfg/datasources.yaml /usr/share/grafana/conf/provisioning/datasources/influxdb.yaml
COPY cfg/dashboards.yaml /usr/share/grafana/conf/provisioning/dashboards/dashboards.yaml
COPY cfg/mdenys-dashboard.json /var/lib/grafana/dashboards/mdenys-dashboard.json
COPY cfg/mdenys-dashboard.json /var/lib/grafana/dashboards/dashboard.json
EXPOSE 3000
CMD /usr/sbin/grafana-server --homepath=/usr/share/grafana

View File

@ -1,7 +1,6 @@
# # config file version
apiVersion: 1
providers:
- name: 'mdenys dashboard'
- name: 'dashboards'
options:
path: /var/lib/grafana/dashboards

View File

@ -1,13 +1,9 @@
apiVersion: 1
datasources:
- name: influxdb
- name: influxDB
type: influxdb
orgId: 1
url: http://influxdb-service:8086
url: http://influxdb:8086
password: telegraf
user: telegraf
database: telegraf
version: 1
editable: false
isDefault: true
basicAuth: true
basicAuthUser: user
basicAuthPassword: user

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,15 @@
FROM alpine:3.12
RUN apk update && apk upgrade
RUN apk add wget
RUN wget https://dl.influxdata.com/telegraf/releases/telegraf-1.16.2_linux_amd64.tar.gz
RUN tar xf telegraf-1.16.2_linux_amd64.tar.gz
RUN cp -r ./telegraf-1.16.2/* /
RUN apk update && apk add openrc
ADD https://dl.influxdata.com/telegraf/releases/telegraf-1.17.3_linux_amd64.tar.gz /etc/
RUN tar -xzf /etc/telegraf-1.17.3_linux_amd64.tar.gz -C /etc/ ; \
rm -rf /etc/telegraf-1.17.3_linux_amd64.tar.gz
RUN mv /etc/telegraf-1.17.3 /telegraf
RUN cp -r telegraf/* ./
RUN rm -rf /telegraf
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub \
https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk
RUN apk add glibc-2.28-r0.apk
RUN telegraf -sample-config telegraf.conf --input-filter cpu:mem --output-filter influxdb > telegraf.conf
COPY telegraf.conf /etc/telegraf/
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-2.32-r0.apk
RUN apk add glibc-2.32-r0.apk
CMD telegraf

View File

@ -1,105 +1,37 @@
[global_tags]
# Telegraf has a few options you can configure under the [agent] section of the config.
[agent]
# Default data collection interval for all inputs
interval = "10s"
# Rounds collection interval to interval.
# For example, if interval is set to 10s then always collect on :00, :10, :20, etc.
round_interval = true
# Telegraf will send metrics to output in batch of at most metric_batch_size metrics.
metric_batch_size = 1000
# Telegraf will cache metric_buffer_limit metrics for each output, and will flush this buffer on a successful write.
# This should be a multiple of metric_batch_size and could not be less than 2 times metric_batch_size.
metric_buffer_limit = 10000
# Collection jitter is used to jitter the collection by a random amount.
# Each plugin will sleep for a random time within jitter before collecting. This can be used to avoid many plugins
# querying things like sysfs at the same time, which can have a measurable effect on the system.
collection_jitter = "0s"
# Default data flushing interval for all outputs.
# You should not set this below interval. Maximum flush_interval will be flush_interval + flush_jitter
flush_interval = "10s"
# Jitter the flush interval by a random amount. This is primarily to avoid large write spikes for users running a large number of Telegraf instances.
# For example, a flush_jitter of 5s and flush_interval of 10s means flushes will happen every 10-15s.
flush_jitter = "0s"
# By default, precision will be set to the same timestamp order as the collection interval, with the maximum being 1s.
# Precision will NOT be used for service inputs, such as logparser and statsd. Valid values are ns, us (or µs), ms, and s.
precision = ""
# Override default hostname, if empty use os.Hostname().
hostname = ""
# If true, do no set the host tag in the Telegraf agent
omit_hostname = false
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
## The full HTTP or UDP URL for your InfluxDB instance.
##
## Multiple URLs can be specified for a single cluster, only ONE of the
## urls will be written to each interval.
urls = ["http://influxdb-service:8086"]
## The target database for metrics; will be created as needed.
## For UDP url endpoint database needs to be configured on server side.
urls = ["http://influxdb:8086"]
database = "telegraf"
## HTTP Basic Auth
username = "mdenys"
password = "mdenys"
username = "telegraf"
password = "telegraf"
[[inputs.cpu]]
## Whether to report per-cpu stats or not
percpu = true
## Whether to report total system cpu stats or not
totalcpu = true
## If true, collect raw CPU time metrics.
collect_cpu_time = false
## If true, compute and report the sum of all non-idle CPU states.
report_active = false
[[inputs.disk]]
## By default stats will be gathered for all mount points.
## Set mount_points will restrict the stats to only the specified mount points.
# mount_points = ["/"]
## Ignore mount points by filesystem type.
ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
# REF: https://github.com/influxdata/telegraf/tree/master/plugins/inputs/docker
# Read metrics about docker containers
[[inputs.docker]]
## Docker Endpoint
## To use TCP, set endpoint = "tcp://[ip]:[port]"
## To use environment variables (ie, docker-machine), set endpoint = "ENV"
endpoint = "unix:///var/run/docker.sock"
## Set to true to collect Swarm metrics(desired_replicas, running_replicas)
## Note: configure this in one of the manager nodes in a Swarm cluster.
## configuring in multiple Swarm managers results in duplication of metrics.
gather_services = false
## Only collect metrics for these containers. Values will be appended to
## container_name_include.
## Deprecated (1.4.0), use container_name_include
container_names = []
## Set the source tag for the metrics to the container ID hostname, eg first 12 chars
source_tag = false
## Containers to include and exclude. Collect all if empty. Globs accepted.
container_name_include = []
container_name_exclude = []
## Timeout for docker list, info, and stats commands
timeout = "5s"
## Whether to report for each container per-device blkio (8:0, 8:1...) and
## network (eth0, eth1, ...) stats or not
perdevice = true
## Whether to report for each container total blkio and network stats or not
total = false
## docker labels to include and exclude as tags. Globs accepted.
## Note that an empty array for both will include all labels as tags
docker_label_include = []
docker_label_exclude = ["annotation.kubernetes*"]
## Which environment variables should we use as a tag
tag_env = ["JAVA_HOME", "HEAP_SIZE"]
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false

View File

@ -1,15 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: influxdb-service
name: influxdb
labels:
app: influxdb
spec:
type: ClusterIP
ports:
- port: 8086
name: influxdb
targetPort: 8086
name: http
selector:
app: influxdb
---
@ -23,79 +23,82 @@ spec:
selector:
matchLabels:
app: influxdb
strategy:
type: Recreate
template:
metadata:
labels:
app: influxdb
spec:
restartPolicy: Always
containers:
- name: influxdb-container
- name: influxdb
image: influxdb-image
imagePullPolicy: Never
ports:
- containerPort: 8086
volumeMounts:
- mountPath: "/var/lib/influxdb"
name: influxdb-pv
- name: influxdb-conf
name: influxdb-data
- name: influxdb
mountPath: /etc/influxdb/influxdb.conf
subPath: influxdb.conf
readOnly: true
volumes:
- name: influxdb-pv
- name: influxdb-data
persistentVolumeClaim:
claimName: influxdb-pvc
- name: influxdb-conf
claimName: influxdb-data-disk
- name: influxdb
configMap:
name: influxdb-conf
name: influxdb
---
apiVersion: v1
kind: ConfigMap
metadata:
name: influxdb
labels:
app: influxdb
data:
influxdb.conf: |
bind-adress="172.17.0.1:8088"
[meta]
dir="/var/lib/influxdb/meta"
[data]
dir="/var/lib/influxdb/data"
wal-dir = "/var/lib/influxdb/wal"
trace-logging-enable=true
[http]
bind-addres=":8086"
log-enabled=true
[[graphite]]
database="telegraf"
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: influxdb-pv
name: influxdb-data
labels:
type: local
spec:
storageClassName: fast
capacity:
storage: 500Mi
storageClassName: manual
accessModes:
- ReadWriteOnce
capacity:
storage: 1Gi
hostPath:
path: "/var/lib/influxdb"
path: "/mnt/influx"
type: DirectoryOrCreate
claimRef:
name: mysql-pvc
name: influxdb-data-disk
namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: influxdb-pvc
labels:
app: influxdb
name: influxdb-data-disk
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi
---
apiVersion: v1
kind: ConfigMap
metadata:
name: influxdb-conf
labels:
app: influxdb
data:
influxdb.conf: |
bind-address = "127.0.0.1:8088"
[meta]
dir = "/var/lib/influxdb/meta"
[data]
dir = "/var/lib/influxdb/data"
wal-dir = "/var/lib/influxdb/wal"
trace-logging-enabled = true
[http]
bind-address = ":8086"
log-enabled = true
[[graphite]]
database = "telegraf"
storage: 1Gi

View File

@ -8,6 +8,10 @@ spec:
selector:
matchLabels:
app: telegraf
replicas: 1
strategy:
type: Recreate
minReadySeconds: 5
template:
metadata:
name: telegraf
@ -15,7 +19,7 @@ spec:
app: telegraf
spec:
containers:
- name: telegraf-container
- name: telegraf
image: telegraf-image
imagePullPolicy: Never
volumeMounts: