Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Kubernetes logs input-plugin #154

Closed
megastef opened this issue Mar 1, 2019 · 7 comments
Closed

Create Kubernetes logs input-plugin #154

megastef opened this issue Mar 1, 2019 · 7 comments

Comments

@megastef
Copy link
Contributor

megastef commented Mar 1, 2019

Logagent works fine with its docker-plugin on Kubernetes, when docker is used as container runtime. When containerd is used (e.g. IBM Cloud) the log collection via /var/run/docker.sock does not work.

I suggest creating a Kuberntes specific log collection plugin to avoid any trouble when alternative container runtimes are used in Kubernetes.

@megastef megastef changed the title Create Kubernetes logs innput-plugin Create Kubernetes logs input-plugin Mar 1, 2019
@otisg
Copy link
Member

otisg commented Mar 1, 2019

Would it be possible to have a generic container plugin that can detect the runtime and automatically use/do the right thing under the hood without the person having to configure Logagent explicitly for Kubernetes or non-Kubernetes env?

@megastef
Copy link
Contributor Author

megastef commented Mar 1, 2019

The start script can deal with different environments to configure LA.
We can detect the runtime environment and disable docker-collector when docker socket is not available, or running in Kuberntes.

Well, the k8s user must mount /var/log into LA container to make the k8s plugin work.

Therefore we will need Kubernetes specific installation instructions, and use k8s API instead of docker API.

@megastef
Copy link
Contributor Author

megastef commented Apr 1, 2019

The following DaemonSet should work on IBM Cloud.

  • support for containerd log headers
  • file collection and enrichment with podName, namespace, containerName, containerId
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: st-logagent
spec:
  selector:
    matchLabels:
      app: st-logagent
  template:
    metadata:
      labels:
        app: st-logagent
    spec:
      #nodeSelector: {}
      hostNetwork: true
      dnsPolicy: "ClusterFirst"
      restartPolicy: "Always"
      containers:
      - name: st-logagent
        image: sematext/logagent:latest
        # image: sematext/logagent:2.0.143
        imagePullPolicy: "Always"
        env:
          - name: LOG_GLOB
            value: "/var/log/containers/*.log;/var/log/*.log"
          - name: LOGS_TOKEN
            value: "YOUR_SEMATEXT_LOGS_TOKEN"
          - name: LOGS_RECEIVER_URL
            value: "https://logsene-receiver.sematext.com"
        volumeMounts:
          - mountPath: /var/log
            name: var-log
          - mountPath: /var/data/kubeletlogs
            name: kubeletlogs
          - mountPath: /etc/localtime
            name: localtime
        securityContext:
          privileged: true
      volumes:
        - name: var-log
          hostPath:
            path: /var/log
        - name: kubeletlogs
          hostPath:
            path: /var/data/kubeletlogs
        - name: localtime
          hostPath:
            path: /etc/localtime

ibm-cloud-logs-in-sematext

Note, we are still testing and have seen some crashes, which might be unrelated to the new Kubernetes input plugin.

@megastef
Copy link
Contributor Author

megastef commented Apr 2, 2019

It turns out that Logagent restarts are caused by tail-forever on Node 10 mingqi/tailF#12 - sematext/logagent:2.0.146 ignores the uncaughtException until the issue gets fixed by a new release of tail-forever. We will try to create a pull-request or publish a new version of tail-forever node module.

The final daemonset for a more stable deployment requires v2.0.146 or later:

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: st-logagent
spec:
  selector:
    matchLabels:
      app: st-logagent
  template:
    metadata:
      labels:
        app: st-logagent
    spec:
      #nodeSelector: {}
      hostNetwork: true
      dnsPolicy: "ClusterFirst"
      restartPolicy: "Always"
      containers:
      - name: st-logagent
        image: sematext/logagent:2.0.146
        imagePullPolicy: "Always"
        env:
          - name: LOG_GLOB
            value: "/var/log/containers/*.log;/var/log/*.log"
          - name: LOGS_TOKEN
            value: "YOUR_SEMATEXT_LOGS_TOKEN"
          - name: LOGS_RECEIVER_URL
            value: "https://logsene-receiver.sematext.com"
        volumeMounts:
          - mountPath: /var/log
            name: var-log
          - mountPath: /var/data/kubeletlogs
            name: kubeletlogs
          - mountPath: /etc/localtime
            name: localtime
        securityContext:
          privileged: true
      volumes:
        - name: var-log
          hostPath:
            path: /var/log
        - name: kubeletlogs
          hostPath:
            path: /var/data/kubeletlogs
        - name: localtime
          hostPath:
            path: /etc/localtime```

@megastef
Copy link
Contributor Author

megastef commented Apr 2, 2019

Version sematext/loagagent:2.0.149 uses Node 8 and runs stable without exceptions.

@megastef
Copy link
Contributor Author

megastef commented Apr 4, 2019

Problem with Node 10 was fixed mingqi/tailF#12

@megastef megastef closed this as completed Apr 4, 2019
@megastef
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants