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

monitoring deployment revision #65

Merged
merged 6 commits into from
Sep 5, 2020
Merged
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
47 changes: 27 additions & 20 deletions infra/hack/kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
### notes

#### dashboard login duration

fix dashboard login ttl by adding `'--token-ttl=0'` to args in the kubernetes-dashboard container template
#### deploying
in `infra/hack/kubernetes/monitoring` run
```
./deploy-monitoring.sh
```

#### monitoring
in `infra/hack/kubernetes/prometheus`
#### accessing services
retrieve grafana admin username and password
```
echo "Admin User:" $(kubectl get secret -n monitoring grafana-admin -o jsonpath="{.data.admin-user}" | base64 --decode) && \
echo "Admin Password:" $(kubectl get secret -n monitoring grafana-admin -o jsonpath="{.data.admin-password}" | base64 --decode)
```
go get -u github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
go get github.com/google/go-jsonnet/cmd/jsonnet
go get github.com/brancz/gojsontoyaml

jb init
./build.sh
kubectl create -f manifests/setup
kubectl create -f manifests
add an entry to /etc/hosts
```
<node ip> strims.monitoring.local
```
replacing node ip with the ip address of the node that's hosting the ingress

#
access grafana at http://strims.monitoring.local/grafana/

#
access prometheus at http://strims.monitoring.local/prometheus


#### dashboard login duration

fix dashboard login ttl by adding `'--token-ttl=0'` to args in the kubernetes-dashboard container template

#### dashboards
##### kubernetes
```
kube proxy
```
http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
##### grafana
```
kubectl --namespace monitoring port-forward svc/grafana 3000
```
##### prometheus
```
kubectl --namespace monitoring port-forward svc/prometheus-k8s 9090
```


9 changes: 0 additions & 9 deletions infra/hack/kubernetes/local-storage.yaml

This file was deleted.

33 changes: 33 additions & 0 deletions infra/hack/kubernetes/monitoring/deploy_monitoring.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -e

kubectl create namespace monitoring

#add repos
sudo helm repo add stable https://kubernetes-charts.storage.googleapis.com
sudo helm repo add loki https://grafana.github.io/loki/charts
sudo helm repo update


#generate grafana credentials
export grafana_user=$(pwgen 30 1 -s)
export grafana_password=$(pwgen 30 1 -s)

< grafana/grafana-admin.yaml envsubst | kubectl apply -f -

unset grafana_user
unset grafana_password

#install
#https://github.com/helm/charts/tree/master/stable/prometheus-operator
sudo helm install prometheus-operator -n monitoring stable/prometheus-operator -f prometheus/prom-operator-values.yaml

#https://github.com/grafana/loki/tree/master/production/helm/loki
sudo helm install loki -n monitoring -f loki/loki-values.yaml loki/loki

#https://github.com/grafana/loki/tree/master/production/helm/promtail
sudo helm install loki-promtail -n monitoring --set 'loki.serviceName=loki' loki/promtail




15 changes: 15 additions & 0 deletions infra/hack/kubernetes/monitoring/grafana/grafana-admin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Secret
metadata:
name: grafana-admin
namespace: monitoring
type: Opaque
stringData:
admin-user: ${grafana_user}
admin-password: ${grafana_password}






38 changes: 38 additions & 0 deletions infra/hack/kubernetes/monitoring/loki/loki-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
replicas: 1

resources: {
"requests":
{"memory":"128Mi", "cpu":"100m"},
"limits":
{"memory":"1024Mi", "cpu":"500m"}
}

persistence:
enabled: true
storageClassName: local-path
size: 10Gi

config:
schema_config:
configs:
- from: 2018-04-15
store: boltdb
object_store: filesystem
schema: v9
index:
prefix: index_
period: 168h

table_manager:
retention_deletes_enabled: true
retention_period: 168h #7 day retention period

affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- controller
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
alertmanager:
enabled: false

kube-state-metrics:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- controller

prometheusOperator:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- controller

prometheus:
prometheusSpec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- controller
storageSpec:
volumeClaimTemplate:
spec:
storageClassName: local-path
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 10Gi #storage requests don't actually do anything when using storage provisioned on a node locally
routePrefix: /prometheus
externalUrl: 'http://strims.monitoring.local/prometheus'
ingress:
enabled: true
hosts:
- strims.monitoring.local
path: "/prometheus"

grafana:
admin:
existingSecret: grafana-admin

persistence:
storageClassName: local-path
enabled: true
size: 10Gi

ingress:
hosts:
- strims.monitoring.local
enabled: true
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$1
path: "/grafana/(.*)"

grafana.ini:
server:
root_url: http://strims.monitoring.local/grafana/
serve_from_sub_path: true
domain: strims.monitoring.local
additionalDataSources:
- name: Loki
type: loki
url: http://loki:3100/
access: proxy

affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- controller
1 change: 0 additions & 1 deletion infra/hack/kubernetes/prometheus/.gitattributes

This file was deleted.

2 changes: 0 additions & 2 deletions infra/hack/kubernetes/prometheus/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion infra/hack/kubernetes/prometheus/README.md

This file was deleted.

23 changes: 0 additions & 23 deletions infra/hack/kubernetes/prometheus/build.sh

This file was deleted.

44 changes: 0 additions & 44 deletions infra/hack/kubernetes/prometheus/grafana-storage.libsonnet

This file was deleted.

15 changes: 0 additions & 15 deletions infra/hack/kubernetes/prometheus/jsonnetfile.json

This file was deleted.

Loading