lagoon-logging

by uselagoon

Helm chartv0.99.0App 4.11.4Verified publisherOfficial

A Helm chart for Kubernetes which installs the Lagoon container and router logs collection system.

About this chart

Lagoon Logging Helm Chart

This chart installs a logging system that will collect and route logs.

Logs are collated into a single index per lagoon project.

Requirements

  • Helm 3.2.1 or newer

How to install

Run these commands in the charts/ directory (above lagoon-logging/).

  1. Obtain dependency.

    helm repo add banzaicloud-stable https://kubernetes-charts.banzaicloud.com
    helm dependency build lagoon-logging
    
  2. Create a lagoon-logging.values.yaml file inside charts/ directory containing these fields with the relevant values added. For required values and documentation see the comment block at the end of the chart's values.yaml.

    OpenShift only

    You must set allow the fluentbit pods to run in privileged mode, and enable the haproxy logs collector:

    fluentbitPrivileged: true
    openshiftHaproxyLogsCollector:
      enabled: true
    
  3. Test installation.

    helm template --debug --namespace lagoon-logging -f ./lagoon-logging.values.yaml lagoon-logging lagoon-logging
    
    helm upgrade --dry-run --install --debug --create-namespace --namespace lagoon-logging -f ./lagoon-logging.values.yaml lagoon-logging lagoon-logging
    
  4. Run installation.

    helm upgrade --install --debug --create-namespace --namespace lagoon-logging -f ./lagoon-logging.values.yaml lagoon-logging lagoon-logging
    

    OpenShift only

    Give the various serviceaccounts permissions required:

    oc project lagoon-logging
    
    # fluentd statefulset serviceaccount (logging-operator chart)
    oc adm policy add-scc-to-user nonroot -z lagoon-logging-fluentd
    
    # fluentbit daemonset serviceaccount (logging-operator chart)
    oc adm policy add-scc-to-user privileged -z lagoon-logging-fluentbit
    
    # logs-dispatcher statefulset serviceaccount (lagoon-logging chart)
    oc adm policy add-scc-to-user anyuid -z lagoon-logging-logs-dispatcher
    

    And make the project network global:

    oc adm pod-network make-projects-global lagoon-logging
    
  5. Update application-logs and router-logs services

    The application-logs service in the lagoon namespace needs to be updated to point to the lagoon-logging-logs-dispatcher service in the lagoon-logging namespace (or wherever you've installed it).

View logs

For namespaces without a lagoon.sh/project label

Logs will appear in indices matching these patterns:

application-logs-*_$CLUSTERNAME-*
container-logs-*_$CLUSTERNAME-*
router-logs-*_$CLUSTERNAME-*

e.g. if clusterName: test1

application-logs-*_test1-*
container-logs-*_test1-*
router-logs-*_test1-*

For namespaces with a lagoon.sh/project label

Logs will appear in indices matching these patterns:

application-logs-$PROJECT-*
container-logs-$PROJECT-*
router-logs-$PROJECT-*

e.g. if lagoon.sh/project: drupal-example

application-logs-drupal-example-*
container-logs-drupal-example-*
router-logs-drupal-example-*

How to upgrade

NOTE: If the logging-operator chart upgrade doesn't work, just uninstall the helm release and install it again. Logs won't be lost since fluentbit will send the contents of the log files once it is reinstalled.

helm upgrade --debug --namespace lagoon-logging --reuse-values lagoon-logging lagoon-logging

Generating certificates

Some components of this chart use server or client TLS authentication. These can be generated using the instructions in the lagoon-logs-concentrator chart README.

The convention for SAN and CN naming is along the lines of:

  • logs-dispatcher.cluster1.example.com for the lagoon-logging "client" and logs-concentrator.cluster2.example.com for the lagoon-logs-concentrator "server".
  • cdn.cluster1.example.com for the CDN "client" and cdn-logs-collector.cluster1.example.com for the cdn-logs-collector "server".

Log export

The logs-dispatcher includes support for sending logs to external sinks such as cloudwatch or S3. This feature uses the fluentd copy plugin, so see that link for syntax.

For example configure the exportLogs value like so:

exportLogs:
  s3.conf: |
    <store ignore_error>
      @type s3
      ...
    </store>
  cloudwatch.conf: |
    <store ignore_error>
      @type cloudwatch_logs
      ...
    </store>

IMPORTANT: use ignore_error so that the main log flow to elasticsearch is not interrupted.

Optionally you may also set enableDefaultForwarding: false to disable the default logs forwarding to logs-concentrator and Elasticsearch.

Local testing

This is useful for quick local testing of fluent.conf snippets.

Prerequisite: Ruby gems set up correctly with gems /bin dir in $PATH.

Install fluentd.

gem install fluentd

Create fluent.conf:

<source>
  @type                forward
  @id                  in_router_openshift
  tag                  "lagoon.test.router.openshift.unmatched"
</source>

<filter lagoon.*.router.openshift.unmatched>
  @type grep
  <exclude>
    key message
    pattern /my_test_pattern/
  </exclude>
</filter>
# keep the rest
<filter lagoon.*.router.openshift.unmatched>
  @type record_modifier
  <record>
    index_name router-logs-openshift_parse_error_test-${Time.at(time).strftime("%Y.%m")}
  </record>
</filter>

<match lagoon.**>
  @type stdout
</match>

Start fluentd:

fluentd -c fluent.conf

Send some test logs:

fluent-cat --none tag.discard < sample.log

Deploy lagoon-logging with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has lagoon-logging on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartlagoon-logging is pinned at v0.99.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply