github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/production/helm/README.md (about)

     1  # ⚠️  DEPRECATED - Loki Helm Chart
     2  
     3  This chart was moved to <https://github.com/grafana/helm-charts>.
     4  
     5  ## Prerequisites
     6  
     7  Make sure you have Helm [installed](https://helm.sh/docs/using_helm/#installing-helm) and
     8  [deployed](https://helm.sh/docs/using_helm/#installing-tiller) to your cluster. Then add
     9  Loki's chart repository to Helm:
    10  
    11  ```bash
    12  $ helm repo add loki https://grafana.github.io/loki/charts
    13  ```
    14  
    15  You can update the chart repository by running:
    16  
    17  ```bash
    18  $ helm repo update
    19  ```
    20  
    21  ## Deploy Loki and Promtail to your cluster
    22  
    23  ### Deploy with default config
    24  
    25  ```bash
    26  $ helm upgrade --install loki loki/loki-stack
    27  ```
    28  
    29  ### Deploy in a custom namespace
    30  
    31  ```bash
    32  $ helm upgrade --install loki --namespace=loki-stack loki/loki-stack
    33  ```
    34  
    35  ### Deploy with custom config
    36  
    37  ```bash
    38  $ helm upgrade --install loki loki/loki-stack --set "key1=val1,key2=val2,..."
    39  ```
    40  
    41  ## Deploy Loki only
    42  
    43  ```bash
    44  $ helm upgrade --install loki loki/loki
    45  ```
    46  
    47  ## Deploy Promtail only
    48  
    49  We recommend Promtail to ship your logs to Loki as the configuration is very similar to Prometheus.
    50  This allows you to ensure that labels for metrics and logs are equivalent by re-using the same `scrape_configs` and `relabeling` configuration.
    51  When using Grafana having the same labels will allows you to pivot from Metrics to Logs verify easily by simply switching datasource.
    52  
    53  To only install Promtail use the following command:
    54  
    55  ```bash
    56  $ helm upgrade --install promtail loki/promtail --set "loki.serviceName=loki"
    57  ```
    58  
    59  If you're not familiar with Prometheus and you don't want to migrate your current agent configs from the start,
    60   you can use our output plugins specified below.
    61  
    62  ## Deploy Loki and Fluent Bit to your cluster
    63  
    64  ```bash
    65  $ helm upgrade --install loki loki/loki-stack \
    66      --set fluent-bit.enabled=true,promtail.enabled=false
    67  ```
    68  
    69  ## Deploy Fluent Bit only
    70  
    71  ```bash
    72  $ helm upgrade --install fluent-bit loki/fluent-bit \
    73      --set "loki.serviceName=loki.svc.cluster.local"
    74  ```
    75  
    76  ## Deploy Loki and Filebeat and logstash to your cluster
    77  
    78  ```bash
    79  $ helm upgrade --install loki loki/loki-stack \
    80      --set filebeat.enabled=true,logstash.enabled=true,promtail.enabled=false \
    81      --set loki.fullnameOverride=loki,logstash.fullnameOverride=logstash-loki
    82  ```
    83  
    84  ## Deploy Grafana to your cluster
    85  
    86  To install Grafana on your cluster with helm, use the following command:
    87  
    88  ```bash
    89  # with Helm 2
    90  $ helm install stable/grafana -n loki-grafana --namespace <YOUR-NAMESPACE>
    91  
    92  # with Helm 3
    93  $ helm install loki-grafana stable/grafana -n <YOUR-NAMESPACE>
    94  ```
    95  
    96  > The chart loki-stack contains a pre-configured Grafana, simply use `--set grafana.enabled=true`
    97  
    98  To get the admin password for the Grafana pod, run the following command:
    99  
   100  ```bash
   101  $ kubectl get secret --namespace <YOUR-NAMESPACE> loki-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
   102  ```
   103  
   104  To access the Grafana UI, run the following command:
   105  
   106  ```bash
   107  $ kubectl port-forward --namespace <YOUR-NAMESPACE> service/loki-grafana 3000:80
   108  ```
   109  
   110  Navigate to http://localhost:3000 and login with `admin` and the password output above.
   111  Then follow the [instructions for adding the loki datasource](/docs/getting-started/grafana.md), using the URL `http://loki:3100/`.
   112  
   113  ## Run Loki behind https ingress
   114  
   115  If Loki and Promtail are deployed on different clusters you can add an Ingress in front of Loki.
   116  By adding a certificate you create an https endpoint. For extra security enable basic authentication on the Ingress.
   117  
   118  In Promtail set the following values to communicate with https and basic auth
   119  
   120  ```
   121  loki:
   122    serviceScheme: https
   123    user: user
   124    password: pass
   125  ```
   126  
   127  Sample helm template for ingress:
   128  ```
   129  apiVersion: extensions/v1beta1
   130  kind: Ingress
   131  metadata:
   132  annotations:
   133      kubernetes.io/ingress.class: {{ .Values.ingress.class }}
   134      ingress.kubernetes.io/auth-type: "basic"
   135      ingress.kubernetes.io/auth-secret: {{ .Values.ingress.basic.secret }}
   136  name: loki
   137  spec:
   138  rules:
   139  - host: {{ .Values.ingress.host }}
   140      http:
   141      paths:
   142      - backend:
   143          serviceName: loki
   144          servicePort: 3100
   145  tls:
   146  - secretName: {{ .Values.ingress.cert }}
   147      hosts:
   148      - {{ .Values.ingress.host }}
   149  ```
   150  
   151  ## Run promtail with syslog support
   152  
   153  In order to receive and process syslog message into promtail, the following changes will be necessary:
   154  
   155  * Review the [promtail syslog-receiver configuration documentation](/docs/clients/promtail/scraping.md#syslog-receiver)
   156  
   157  * Configure the promtail helm chart with the syslog configuration added to the `extraScrapeConfigs` section and associated service definition to listen for syslog messages. For example:
   158  
   159  ```yaml
   160  extraScrapeConfigs:
   161    - job_name: syslog
   162      syslog:
   163        listen_address: 0.0.0.0:1514
   164        labels:
   165          job: "syslog"
   166    relabel_configs:
   167      - source_labels: ['__syslog_message_hostname']
   168        target_label: 'host'
   169  syslogService:
   170    enabled: true
   171    type: LoadBalancer
   172    port: 1514
   173  ```
   174  
   175  ## Run promtail with systemd-journal support
   176  
   177  In order to receive and process syslog message into promtail, the following changes will be necessary:
   178  
   179  * Review the [promtail systemd-journal configuration documentation](/docs/clients/promtail/scraping.md#journal-scraping-linux-only)
   180  
   181  * Configure the promtail helm chart with the systemd-journal configuration added to the `extraScrapeConfigs` section and volume mounts for the promtail pods to access the log files. For example:
   182  
   183  ```yaml
   184  # Add additional scrape config
   185  extraScrapeConfigs:
   186    - job_name: journal
   187      journal:
   188        path: /var/log/journal
   189        max_age: 12h
   190        labels:
   191          job: systemd-journal
   192      relabel_configs:
   193        - source_labels: ['__journal__systemd_unit']
   194          target_label: 'unit'
   195        - source_labels: ['__journal__hostname']
   196          target_label: 'hostname'
   197  
   198  # Mount journal directory into promtail pods
   199  extraVolumes:
   200    - name: journal
   201      hostPath:
   202        path: /var/log/journal
   203  
   204  extraVolumeMounts:
   205    - name: journal
   206      mountPath: /var/log/journal
   207      readOnly: true
   208  ```
   209  
   210  ## How to contribute
   211  
   212  After adding your new feature to the appropriate chart, you can build and deploy it locally to test:
   213  
   214  ```bash
   215  $ make helm
   216  $ helm upgrade --install loki ./loki-stack-*.tgz
   217  ```
   218  
   219  After verifying your changes, you need to bump the chart version following [semantic versioning](https://semver.org) rules.
   220  For example, if you update the loki chart, you need to bump the versions as follows:
   221  
   222  - Update version loki/Chart.yaml
   223  - Update version loki-stack/Chart.yaml
   224  
   225  You can use the `make helm-debug` to test and print out all chart templates. If you want to install helm (tiller) in your cluster use `make helm-install`, to install the current build in your Kubernetes cluster run `make helm-upgrade`.