Skip to content

Commit

Permalink
Merge pull request #5 from solarwinds/rename-rkubelog
Browse files Browse the repository at this point in the history
Rename to rkubelog
  • Loading branch information
turbo authored Sep 8, 2020
2 parents 08355e7 + fe23b9e commit 9c41c4f
Show file tree
Hide file tree
Showing 20 changed files with 99 additions and 55 deletions.
2 changes: 0 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
db/

.vscode

bin/
5 changes: 4 additions & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: Cabbage
# Copyright 2019 SolarWinds Worldwide, LLC.
# SPDX-License-Identifier: Apache-2.0

name: rkubelog
on:
push:
branches:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2019 SolarWinds Worldwide, LLC.
# SPDX-License-Identifier: Apache-2.0

name: Build Release Docker Image

on:
Expand All @@ -12,7 +15,7 @@ jobs:
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: quay.io/solarwinds/cabbage
name: quay.io/solarwinds/rkubelog
workdir: .
username: turbo
password: ${{ secrets.QUAY_PASSWORD }}
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
run.sh

.vscode

bin/

db/

*.config
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Copyright 2019 SolarWinds Worldwide, LLC.
# SPDX-License-Identifier: Apache-2.0

FROM golang:1.15.0-alpine as main
RUN apk update && apk add --no-cache git ca-certificates wget && update-ca-certificates
RUN wget -O /etc/ssl/certs/papertrail-bundle.pem https://papertrailapp.com/tools/papertrail-bundle.pem
WORKDIR /github.com/solarwinds/cabbage
WORKDIR /github.com/solarwinds/rkubelog
ADD . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags='-w -s -extldflags "-static"' -a -o /cabbage .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags='-w -s -extldflags "-static"' -a -o /rkubelog .

FROM alpine
COPY --from=main /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=main /etc/ssl/certs/papertrail-bundle.pem /etc/ssl/certs/
COPY --from=main /cabbage /app/cabbage
COPY --from=main /rkubelog /app/rkubelog
RUN chmod -R 777 /app
USER 1001
WORKDIR /app
ENTRYPOINT ./cabbage
ENTRYPOINT ./rkubelog
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2019 SolarWinds Worldwide, LLC.
# SPDX-License-Identifier: Apache-2.0

lint:
docker run --rm -v $(PWD):/app -w /app golangci/golangci-lint:v1.27.0 golangci-lint run --allow-parallel-runners --timeout 3m ./...

Expand All @@ -8,7 +11,7 @@ tests:
go test -v ./...

build:
go build -o bin/cabbage
go build -o bin/rkubelog

docker:
DOCKER_BUILDKIT=1 docker build -t quay.io/solarwinds/cabbage .
DOCKER_BUILDKIT=1 docker build -t quay.io/solarwinds/rkubelog .
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Cabbage
# rkubelog

Cabbage is the easiest way to get logs out of your k8s cluster and into [Papertrail](https://www.papertrail.com/) and [Loggly](https://www.loggly.com/). Because it doesn't require DaemonSets, sidecars, fluentd or persistent claims, it's one of the only solutions for logging in nodeless clusters, such as EKS on Fargate. But it's also perfect for smaller, local dev clusters to setup logging within seconds.
rkubelog is the easiest way to get logs out of your k8s cluster and into [Papertrail](https://www.papertrail.com/) and [Loggly](https://www.loggly.com/). Because it doesn't require DaemonSets, sidecars, fluentd or persistent claims, it's one of the only solutions for logging in nodeless clusters, such as EKS on Fargate. But it's also perfect for smaller, local dev clusters to setup logging within seconds.

## Usage

> __Warning:__ You need a pull secret for quay.io/solarwinds in your cluster! If you don't have access to quay, build the image yourself and push it to your registry.
By default, cabbage runs in the `kube-system` namespace and will observe all logs from all pods in all namespaces except from itself or any other service in `kube-system`.
By default, rkubelog runs in the `kube-system` namespace and will observe all logs from all pods in all namespaces except from itself or any other service in `kube-system`.

In `logging-config-patch.yaml` follow the comments to setup the connection to the syslog sink (Papertrail in this example) and set a system tag for the syslog messages.

That's it. Preview with `kubectl apply -k . --dry-run -o yaml` and remove `--dry-run` to apply.

## How it works

Cabbage deploys a customized `kail` in an alpine container, using it to query the k8s API for pods (and keeping the pod list in sync) and their logs. Kail is a command line k8s logging client that lives at the opposite end of the specificity spectrum from `kubectl logs ...`. You can run kail yourself by cloning this repo and running `go run main.go`. This will give you all logs from all pods in all namespaces.
rkubelog deploys a customized `kail` in an alpine container, using it to query the k8s API for pods (and keeping the pod list in sync) and their logs. Kail is a command line k8s logging client that lives at the opposite end of the specificity spectrum from `kubectl logs ...`. You can run kail yourself by cloning this repo and running `go run main.go`. This will give you all logs from all pods in all namespaces.
To learn more about filters, read the [kail usage guide](https://github.com/boz/kail/tree/eb6734178238dc794641e82779855fabc2071e23#usage).

### Papertrail
Expand Down Expand Up @@ -58,7 +58,7 @@ make build

To run the code:
```
bin/cabbage
bin/rkubelog
```

You are free to set the described environment variables or pass run time arguments described above and/or follow [kail usage guide](https://github.com/boz/kail/tree/eb6734178238dc794641e82779855fabc2071e23#usage).
Expand All @@ -78,5 +78,10 @@ To create a Docker image:
make docker
```

# Questions/Comments?
Please [open an issue](https://github.com/solarwinds/cabbage/issues/new), we'd love to hear from you. As a SolarWinds Project, it is supported in a best-effort fashion.
# Feedback

Please [open an issue](https://github.com/solarwinds/rkubelog/issues/new), we'd love to hear from you. As a SolarWinds Project, it is supported in a best-effort fashion.

# Security

If you have identified a security vulnerability, please send an email to [email protected] (monitored 24/7). Please do not open a public issue.
23 changes: 0 additions & 23 deletions cabbage/deployment.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/solarwinds/cabbage
module github.com/solarwinds/rkubelog

go 1.15

Expand Down
9 changes: 6 additions & 3 deletions kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Copyright 2019 SolarWinds Worldwide, LLC.
# SPDX-License-Identifier: Apache-2.0

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

bases:
- ./cabbage
- ./rkubelog

namespace: kube-system

Expand All @@ -23,12 +26,12 @@ patchesJSON6902:
group: apps
version: v1
kind: Deployment
name: cabbage
name: rkubelog
path: logging-config-patch.yaml

- target:
group: rbac.authorization.k8s.io
version: v1
kind: ClusterRoleBinding
name: cabbage-reader-binding
name: rkubelog-reader-binding
path: namespace-binding-config.yaml
5 changes: 4 additions & 1 deletion logging-config-patch.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Copyright 2019 SolarWinds Worldwide, LLC.
# SPDX-License-Identifier: Apache-2.0

# This is the system tag in the syslog msgs sent to PT
- op: add
path: /spec/template/spec/containers/0/args
value: ["swing"]
value: ["rkubelog"]

# Put your Papertrail & Loggly config here
- op: add
Expand Down
3 changes: 3 additions & 0 deletions logshipper/loggly.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2019 SolarWinds Worldwide, LLC.
// SPDX-License-Identifier: Apache-2.0

package logshipper

import (
Expand Down
3 changes: 3 additions & 0 deletions logshipper/models.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2019 SolarWinds Worldwide, LLC.
// SPDX-License-Identifier: Apache-2.0

// Package logshipper contains all the log shippers
package logshipper

Expand Down
3 changes: 3 additions & 0 deletions logshipper/papertrail.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2019 SolarWinds Worldwide, LLC.
// SPDX-License-Identifier: Apache-2.0

package logshipper

import (
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2019 SolarWinds Worldwide, LLC.
// SPDX-License-Identifier: Apache-2.0

package main

import (
Expand All @@ -15,7 +18,7 @@ import (
"github.com/boz/kail"
"github.com/boz/kcache/nsname"
"github.com/sirupsen/logrus"
"github.com/solarwinds/cabbage/logshipper"
"github.com/solarwinds/rkubelog/logshipper"
kingpin "gopkg.in/alecthomas/kingpin.v2"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
3 changes: 3 additions & 0 deletions namespace-binding-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2019 SolarWinds Worldwide, LLC.
# SPDX-License-Identifier: Apache-2.0

# Change this if you've changed the namespace in kustomize
- op: replace
path: /subjects/0/namespace
Expand Down
5 changes: 4 additions & 1 deletion cabbage/clusterrole.yaml → rkubelog/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Copyright 2019 SolarWinds Worldwide, LLC.
# SPDX-License-Identifier: Apache-2.0

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
namespace: default
name: cabbage-reader
name: rkubelog-reader
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods", "pods/log"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Copyright 2019 SolarWinds Worldwide, LLC.
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
kind: ServiceAccount
metadata:
name: cabbage-sa
name: rkubelog-sa
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: cabbage-reader-binding
name: rkubelog-reader-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cabbage-reader
name: rkubelog-reader
subjects:
- kind: ServiceAccount
name: cabbage-sa
name: rkubelog-sa
namespace: kube-system
26 changes: 26 additions & 0 deletions rkubelog/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2019 SolarWinds Worldwide, LLC.
# SPDX-License-Identifier: Apache-2.0

apiVersion: apps/v1
kind: Deployment
metadata:
name: "rkubelog"
namespace: "default"
labels:
app: rkubelog
spec:
replicas: 1
selector:
matchLabels:
app: rkubelog
template:
metadata:
labels:
kail.ignore: "true"
app: rkubelog
spec:
serviceAccountName: rkubelog-sa
containers:
- image: quay.io/solarwinds/rkubelog
imagePullPolicy: Always
name: "rkubelog"
3 changes: 3 additions & 0 deletions cabbage/kustomization.yaml → rkubelog/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright 2019 SolarWinds Worldwide, LLC.
# SPDX-License-Identifier: Apache-2.0

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

Expand Down

0 comments on commit 9c41c4f

Please sign in to comment.