helm repo add loki https://grafana.github.io/loki/charts
helm repo add banzaicloud-stable https://kubernetes-charts.banzaicloud.com
helm repo update
helm install --name loki loki/loki
helm install --name grafana stable/grafana \
--set "datasources.datasources\\.yaml.apiVersion=1" \
--set "datasources.datasources\\.yaml.datasources[0].name=Loki" \
--set "datasources.datasources\\.yaml.datasources[0].type=loki" \
--set "datasources.datasources\\.yaml.datasources[0].url=http://loki:3100" \
--set "datasources.datasources\\.yaml.datasources[0].access=proxy"
helm install --name logging banzaicloud-stable/logging-operator
You can install
logging
resource via Helm chart with built-in TLS generation.
helm install --name nginx-demo banzaicloud-stable/nginx-logging-loki-demo
cat <<EOF | kubectl apply -f -
apiVersion: logging.banzaicloud.io/v1beta1
kind: Logging
metadata:
name: default-logging-simple
spec:
fluentd: {}
fluentbit: {}
controlNamespace: default
EOF
Note:
ClusterOutput
andClusterFlow
resource will only be accepted in thecontrolNamespace
cat <<EOF | kubectl apply -f -
apiVersion: logging.banzaicloud.io/v1beta1
kind: Output
metadata:
name: loki-output
namespace: default
spec:
loki:
url: http://loki:3100
buffer:
path: /tmp/buffer
timekey: 1m
timekey_wait: 30s
timekey_use_utc: true
EOF
Note: For production set-up we recommend using longer
timekey
interval to avoid generating too many object.
cat <<EOF | kubectl apply -f -
apiVersion: logging.banzaicloud.io/v1beta1
kind: Flow
metadata:
name: loki-flow
namespace: default
spec:
filters:
- tag_normaliser: {}
- parser:
key_name: message
remove_key_name_field: true
reserve_data: true
parsers:
- type: nginx
selectors:
app: nginx
outputRefs:
- loki-output
EOF
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
name: http
protocol: TCP
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: http
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
readinessProbe:
failureThreshold: 3
httpGet:
path: /
port: http
scheme: HTTP
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
EOF
kubectl get secrets grafana -o json | jq '.data | map_values(@base64d)'
kubectl port-forward svc/grafana 3000:80