Skip to content

Commit

Permalink
Beta v0.4
Browse files Browse the repository at this point in the history
Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md

Update README.md
  • Loading branch information
fmdlc committed Oct 21, 2020
1 parent 7d349ce commit a482174
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 77 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## October 20 2020 - v1.4 (Beta)
* Created initial Kubernetes YAML files.
* Updated documentation.

## October 16 2020 - v1.3
* API configuration is now executed using `cURL` [Docker image](https://hub.docker.com/r/curlimages/curl).
* `README.md` updated (Solving [https://github.com/fmdlc/ISP-Checker/issues/14](https://github.com/fmdlc/ISP-Checker/issues/14)).
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ISP-Checker
![License](https://img.shields.io/github/license/fmdlc/ISP-Checker) ![LastCommit](https://img.shields.io/github/last-commit/fmdlc/ISP-Checker) ![Build](https://github.com/fmdlc/ISP-Checker/workflows/Build/badge.svg) ![Docker](https://img.shields.io/badge/Docker-19.03.13-blue)

> A `docker-compose` stack to run a set of ISP controls and collect metrics on a [Raspberry Pi](https://www.raspberrypi.org/).
> A `docker-compose` and `kubernetes` stack to run a set of ISP controls and collect metrics on a [Raspberry Pi](https://www.raspberrypi.org/).
[![Linkedin](https://i.stack.imgur.com/gVE0j.png) LinkedIn](https://www.linkedin.com/in/fmdlc) [![GitHub](https://i.stack.imgur.com/tskMh.png) GitHub](https://github.com/fmdlc)

Expand Down Expand Up @@ -45,6 +45,14 @@ Make sure you have the [Docker-CE](https://phoenixnap.com/kb/docker-on-raspberry
```bash
$ curl -fsSL https://get.docker.com -o get-docker.sh | bash -
```
#### kubernetes
Kubernetes is in `beta` version. To install just run:
```bash
$: kubectl apply -f https://raw.githubusercontent.com/fmdlc/ISP-Checker/master/kubernetes/ISP-Checker-deploy.yaml
```
You need to expose the `grafana` service to get access. You can do it by creating a `LoadBalancer` service type or by using an `IngressController`.

For detailed Kubernetes instructions check [here](https://github.com/fmdlc/ISP-Checker/blob/master/kubernetes/README.md).

#### docker-compose
You need to have `docker-compose` installed. To install it execute:
Expand Down
Binary file added img/cluster.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 21 additions & 37 deletions kubernetes/ISP-Checker-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,6 @@ spec:

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: monitoring
labels:
app: grafana
name: grafana-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
apiVersion: v1
kind: Secret
metadata:
namespace: monitoring
Expand Down Expand Up @@ -129,7 +115,7 @@ data:
debug = false
[[outputs.influxdb]]
urls = ["http://grafana-svc.monitoring.svc.cluster.local:8086/"]
urls = ["http://influxdb-svc.monitoring.svc.cluster.local:8086/"]
database = "$INFLUXDB_DB"
timeout = "60s"
username = "$INFLUXDB_ADMIN_USER"
Expand Down Expand Up @@ -3206,6 +3192,25 @@ data:
"version": 2
}
---
apiVersion: v1
kind: Service
metadata:
labels:
app: influxdb
name: influxdb-svc
namespace: monitoring
spec:
clusterIP: 10.43.37.100
ports:
- port: 8086
protocol: TCP
targetPort: 8086
selector:
app: influxdb
sessionAffinity: None
type: ClusterIP

---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down Expand Up @@ -3288,7 +3293,6 @@ spec:
labels:
app: grafana
spec:
serviceAccountName: grafana-sidecar
containers:
- name: grafana
image: grafana/grafana:7.2.1
Expand All @@ -3302,7 +3306,7 @@ spec:
- name: grafana-dashboard-provisioner
mountPath: /etc/grafana/provisioning/dashboards/
- name: grafana-dashboard
mountPath: /tmp/config/
mountPath: /tmp/config/network-dashboard.json
ports:
- containerPort: 3000
env:
Expand Down Expand Up @@ -3381,23 +3385,3 @@ spec:
- name: telegraf-config-volume
configMap:
name: telegraf-config
---
apiversion: v1
kind: service
metadata:
labels:
app: influxdb
name: influxdb-svc
namespace: monitoring
spec:
ports:
- port: 8086
protocol: tcp
targetport: 8086
selector:
app: influxdb
sessionaffinity: none
type: clusterip
status:
loadbalancer: {}

117 changes: 103 additions & 14 deletions kubernetes/README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,127 @@
## Kubernetes
The following configuration files are used to deploy this stack in Kubernetes.
You need to update them before running in your cluster.
# ISP-Checker on Kubernetes
`ISP-Checker` was ported to run in Kubernetes (`1.18.0`) in a ***Raspberry Pi 4*** cluster (_It's all I have_). For that I've installed [K3s](https://k3s.io).

<div align="center">
<kbd>
<img src="../img/cluster.jpeg" width="430">
</kbd>
</div>


The following `YAML` configuration files are used to deploy this stack in Kubernetes by creating the basic objects to run.
They can widely improved but so far let's say it works. :)

> ***NOTE***: The Kubernetes deployment is in *BETA* version. Don't worry if you see something wrong here.
## Installing, the quick way:

1) Apply the `ISP-Checker-deploy.yaml`
```bash
$: kubectl apply -f ISP-Checker-deploy.yaml
```
$: kubectl apply -f https://raw.githubusercontent.com/fmdlc/ISP-Checker/master/kubernetes/ISP-Checker-deploy.yaml
```
---

### Configuration

1) Edit `secrets.yaml` in order to initialize your InfluxDB database.
2) Edit `configmap.yaml` to configure Telegraf.
3) Apply the other `YAML` files.
4) Expose your deployment or create a LoadBalancer/IngressRule to access Grafana.
> Edit `secrets.yaml` in order to initialize your InfluxDB database.
```yaml
---
apiVersion: v1
kind: Secret
metadata:
namespace: monitoring
name: isp-checker-secrets-rw
type: Opaque
stringData:
INFLUXDB_DB: telegraf
INFLUXDB_ADMIN_USER: admin
INFLUXDB_ADMIN_PASSWORD: VerySecurePassword

---
apiVersion: v1
kind: Secret
metadata:
namespace: monitoring
name: isp-checker-secrets-ro
type: Opaque
stringData:
INFLUXDB_DB: telegraf
INFLUXDB_READ_USER: grafana
INFLUXDB_READ_PASSWORD: VerySecurePassword

```

> Edit `configmap.yaml` to configure Telegraf.
```yaml
---
apiVersion: v1
kind: ConfigMap
metadata:
namespace: monitoring
name: telegraf-config
data:
telegraf.conf: |+
[global_tags]
[agent]
interval = "10s"
round_interval = true
```
> Apply all `YAML` files.
```
$: kubectl apply -f namespace.yaml
namespace/monitoring created

$: kubectl apply -f pvc.yaml
persistentvolumeclaim/influxdb-pvc created

$: kubectl apply -f secrets.yaml
secret/isp-checker-secrets-rw configured
secret/isp-checker-secrets-ro configured
secret/grafana-datasource configured

### Accesing
#### LoadBalancer
$: kubectl apply -f
configmap/grafana-user-config configured
configmap/network-dashboard-provisioner configured
configmap/telegraf-config configured

$: kubectl apply -f services.yaml
service/influxdb-svc created

$: kubectl apply -f network-dashboard.yaml
configmap/grafana-dashboard configured

$: kubectl apply -f deployment.yaml
deployment.apps/influxdb configured
deployment.apps/grafana configured
deployment.apps/telegraf configured
```
> Expose your deployment or create a LoadBalancer/IngressRule to access Grafana (_see bellow_).
#### Exposing
##### LoadBalancer
If you want to use a `LoadBalancer` to access Grafana, run:
```bash
$: kubectl expose deployments/grafana --type=LoadBalancer --name=grafana-svc
```
#### port-foward
If you can't use a LoadBalancer, you can use a `ClusterIP` service and forward to your local port.

##### port-foward
If you can't use a LoadBalancer, you can use a `ClusterIP` service and forward to your local port.
```
$: kubectl expose deployments/grafana --type=ClusterIP --name=grafana-svc
```

And finally use your IngressController to access the service or a `port-forward`:

```
$: kubectl port-forward svc/grafana-svc 3000:3000 -n monitoring
```

---

## ToDo

- [ ] Create Helm Chart.
- [ ] Improve provisioning.
- [ ] Configure Default dashboard in Grafana.
- [ ] Create CRD to interact with Grafana API.
2 changes: 1 addition & 1 deletion kubernetes/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ data:
debug = false
[[outputs.influxdb]]
urls = ["http://grafana-svc.monitoring.svc.cluster.local:8086/"]
urls = ["http://influxdb-svc.monitoring.svc.cluster.local:8086/"]
database = "$INFLUXDB_DB"
timeout = "60s"
username = "$INFLUXDB_ADMIN_USER"
Expand Down
3 changes: 1 addition & 2 deletions kubernetes/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ spec:
labels:
app: grafana
spec:
serviceAccountName: grafana-sidecar
containers:
- name: grafana
image: grafana/grafana:7.2.1
Expand All @@ -95,7 +94,7 @@ spec:
- name: grafana-dashboard-provisioner
mountPath: /etc/grafana/provisioning/dashboards/
- name: grafana-dashboard
mountPath: /tmp/config/
mountPath: /tmp/config/network-dashboard.json
ports:
- containerPort: 3000
env:
Expand Down
14 changes: 0 additions & 14 deletions kubernetes/pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,3 @@ spec:
requests:
storage: 5Gi

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: monitoring
labels:
app: grafana
name: grafana-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
15 changes: 7 additions & 8 deletions kubernetes/services.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
---
apiversion: v1
kind: service
apiVersion: v1
kind: Service
metadata:
labels:
app: influxdb
name: influxdb-svc
namespace: monitoring
spec:
clusterIP: 10.43.37.100
ports:
- port: 8086
protocol: tcp
targetport: 8086
protocol: TCP
targetPort: 8086
selector:
app: influxdb
sessionaffinity: none
type: clusterip
status:
loadbalancer: {}
sessionAffinity: None
type: ClusterIP

0 comments on commit a482174

Please sign in to comment.