Merge branch 'master' of ssh://gitea.zwackl.de:2222/dominik/k3s

This commit is contained in:
Dominik Chilla 2022-10-03 19:01:37 +02:00
commit 7977f98752
3 changed files with 3470 additions and 7 deletions

View File

@ -23,6 +23,9 @@
* [Deploying a LE-certificate with ingress](#cert-manager-ingress)
* [Deploying a LE-certificate by CRD](#cert-manager-crd)
* [Troubleshooting](#cert-manager-troubleshooting)
* [Cluster monitoring](#cluster-monitoring)
* [Log correlation with Loki-stack](#loki-stack)
* [Metrics with Prometheus-stack + Grafana](#prometheus-grafana)
* [HELM charts](#helm)
* [Create a chart](#helm-create)
* [Install local chart without packaging](#helm-install-without-packaging)
@ -140,12 +143,11 @@ https://k3d.io/:
```
curl -s https://raw.githubusercontent.com/rancher/k3d/main/install.sh | bash
```
Create a K3s cluster without `traefik` as well as `metrics-server`
Create a K3s cluster without `traefik``
```
k3d cluster create cluster1 \
--agents 2 \
--k3s-server-arg '--disable=traefik' \
--k3s-server-arg '--disable=metrics-server' \
--k3s-server-arg '--kube-apiserver-arg=service-node-port-range=1-65535'
```
If you encounter `helm` throwing errors like this one:
@ -558,15 +560,62 @@ After successfull setup perform a TLS-test:
* https://testssl.sh/ (`apt install testssl.sh`)
* https://www.ssllabs.com/ssltest/index.html
# Cluster monitoring <a name="user-content-cluster-monitoring"></a>
Create namespace for monitoring
```
kubectl create ns monitoring
```
## Log correlation with Loki-stack <a name="user-content-loki-stack"></a>
Docs: https://github.com/grafana/helm-charts/tree/main/charts/loki-stack
```
helm repo add grafana https://grafana.github.io/helm-charts
helm repo update
```
Download values file for loki-stack helm chart and replace any macros with corresponding values:
* %PVC_STORAGECLASS% -> your storageclass for persistent storage
* %PVC_STORAGE_SIZE% -> size of persistent storage, e.g. 4Gi
```
wget https://gitea.zwackl.de/dominik/k3s/raw/branch/master/loki-stack-values.yaml
```
Install loki-stack:
```
helm -n monitoring upgrade --install -f loki-stack-values.yaml loki-stack grafana/loki-stack
```
Grafana will be installed with Prometheus-stack...
## Metrics with Prometheus-stack + Grafana <a name="user-content-prometheus-grafana"></a>
```
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
```
Download values file for prometheus-stack helm chart and replace any macros with corresponding values:
* %ADMIN_PASSWORD% -> Grafana admin password
* %SERVICE_FQDN% -> Service FQDN
* %MASTER_NODE_IPV4_ADDR% -> IPv4 address of your cluster master node
* %PVC_STORAGECLASS% -> your storageclass for persistent storage
* %PVC_STORAGE_SIZE% -> size of persistent storage, e.g. 4Gi
* %SMTP_HOST%
* %SMTP_USER%
* %SMTP_PASSWORD%
* %SMTP_SENDER_ADDRESS%
* %SMTP_FROM_HEADER%
```
wget https://gitea.zwackl.de/dominik/k3s/raw/branch/master/prom-stack-values.yaml
```
Install promethous-stack:
```
helm -n monitoring upgrade --install -f prom-stack-values.yaml prom-stack prometheus-community/kube-prometheus-stack
```
Access grafana web ui via port-forwarding at http://localhost:8080 (or configure an ingress instance):
```
kubectl -n monitoring port-forward service/prom-stack-grafana 8080:80
```
# HELM charts <a name="user-content-helm"></a>
Docs:
* https://helm.sh/docs/intro/using_helm/
Prerequisites:
* running kubernetes installation
* kubectl with ENV[KUBECONFIG] pointing to appropriate config file
* helm
## Create a chart <a name="user-content-helm-create"></a>
`helm create helm-test`

5
loki-stack-values.yaml Normal file
View File

@ -0,0 +1,5 @@
loki:
persistence:
enabled: true
storageClassName: "%PVC_STORAGECLASS%"
size: "%PVC_STORAGE_SIZE%"

3409
prom-stack-values.yaml Normal file

File diff suppressed because it is too large Load Diff