From 60d2470e70ea46fc0dcdec2c6dd1997d087a1afe Mon Sep 17 00:00:00 2001 From: Andrey Kartashov Date: Tue, 2 Oct 2018 22:22:21 +0700 Subject: [PATCH] added papertrail logging --- fluentd-daemonset-papertrail.yaml | 90 +++++++++++++++++++++++++++++++ papertrail-logspout-daemonset.yml | 40 ++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 fluentd-daemonset-papertrail.yaml create mode 100644 papertrail-logspout-daemonset.yml diff --git a/fluentd-daemonset-papertrail.yaml b/fluentd-daemonset-papertrail.yaml new file mode 100644 index 0000000..3173c84 --- /dev/null +++ b/fluentd-daemonset-papertrail.yaml @@ -0,0 +1,90 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + labels: + k8s-app: fluentd + name: fluentd + namespace: kube-system +--- +kind: ClusterRole +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: fluentd-clusterrole +rules: + - apiGroups: + - "" + resources: + - "namespaces" + - "pods" + verbs: + - "list" + - "get" + - "watch" +--- +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1beta1 +metadata: + name: fluentd-clusterrole +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: fluentd-clusterrole +subjects: +- kind: ServiceAccount + name: fluentd + namespace: kube-system +--- +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + name: fluentd + namespace: kube-system + labels: + k8s-app: fluentd-logging + version: v1 + kubernetes.io/cluster-service: "true" +spec: + updateStrategy: + type: RollingUpdate + template: + metadata: + labels: + k8s-app: fluentd-logging + version: v1 + kubernetes.io/cluster-service: "true" + spec: + serviceAccount: fluentd + serviceAccountName: fluentd + containers: + - name: fluentd + image: fluent/fluentd-kubernetes-daemonset:v0.12-debian-papertrail + env: + - name: FLUENT_UID + value: "0" + - name: FLUENT_PAPERTRAIL_HOST + value: "logs7.papertrailapp.com" + - name: FLUENT_PAPERTRAIL_PORT + value: "47843" + - name: FLUENT_HOSTNAME + value: "gfk8s" + resources: + limits: + memory: 200Mi + requests: + cpu: 100m + memory: 200Mi + volumeMounts: + - name: varlog + mountPath: /var/log + - name: varlibdockercontainers + mountPath: /var/lib/docker/containers + readOnly: true + terminationGracePeriodSeconds: 30 + volumes: + - name: varlog + hostPath: + path: /var/log + - name: varlibdockercontainers + hostPath: + path: /var/lib/docker/containers diff --git a/papertrail-logspout-daemonset.yml b/papertrail-logspout-daemonset.yml new file mode 100644 index 0000000..65f75eb --- /dev/null +++ b/papertrail-logspout-daemonset.yml @@ -0,0 +1,40 @@ +apiVersion: extensions/v1beta1 +kind: DaemonSet +metadata: + name: logspout-papertrail +spec: + template: + metadata: + labels: + name: logspout-papertrail + spec: + hostPID: true + hostIPC: true + hostNetwork: true + containers: + - resources: + requests: + cpu: 0.15 + limits: + memory: 500Mi + env: + - name: SYSLOG_TAG + value: '{{ index .Container.Config.Labels "io.kubernetes.pod.namespace" }}[{{ index .Container.Config.Labels "io.kubernetes.pod.name" }}]' + - name: SYSLOG_HOSTNAME + value: '{{ index .Container.Config.Labels "io.kubernetes.container.name" }}' + - name: ROUTE_URIS + valueFrom: + secretKeyRef: + name: papertrail-destination + key: papertrail-destination + - name: ALLOW_TTY + value: "true" + image: gliderlabs/logspout:master + name: logspout + volumeMounts: + - name: log + mountPath: /var/run/docker.sock + volumes: + - name: log + hostPath: + path: /var/run/docker.sock