• Stars
    star
    157
  • Rank 238,399 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A linter for Kubernetes resources with a customizable rule set

kube-lint

A linter for Kubernetes resources with a customizable rule set.

Introduction

kube-lint hopes to make it easy to validate that your Kubernetes configuration files and your running resources adhere to a standard that you define. You define a list of rules that you would like to validate against your resources and kube-lint will evaluate those rules against them.

In many organizations you will want to have a standard for what is considered "correct" enough to be deployed into your Kubernetes clusters. You may have conventions for labels or restrictions on certain types of services being created. You can use kube-lint during your CI/CD pipeline to gate resources being created that do not adhere to your standards. Additionally you can use kube-lint to audit against a running set of resources in your cluster.

CONSIDER THIS A PROTOTYPE. PLEASE PROVIDE FEEDBACK IN THE ISSUES

Only Pod linting is currently implemented

Installation

  • Download a release from the releases page that matches your platform.
  • Extract the archive

For MacOS

wget https://github.com/viglesiasce/kube-lint/releases/download/v0.0.1-prototype/kube-lint-prototype-darwin.tgz
tar zxfv kube-lint-prototype-darwin.tgz
./darwin/kube-lint -h

For Linux

wget https://github.com/viglesiasce/kube-lint/releases/download/v0.0.1-prototype/kube-lint-prototype-linux.tgz
tar zxfv kube-lint-prototype-linux.tgz
./linux/kube-lint -h

Rule configuration

The rule configuration file is a YAML formatted list of KubernetesRules. An example config file is available at example/config.yaml in this repository.

A KubernetesRule has the following format:

name: app-label
description: Includes a label with key "app"
kind: Pod
field: .metadata.labels.app
operator: set
valueType: string
tags:
- operations
- security

name is an identifier for this rule.

description provides details about what the rule is checking for.

kind is the type of resource this check should be done against.

field is a jsonpath used to get the value you want to evaluate against.

operator is the check that youd like to do against your expected vs actual values (ie equal, matches, lessthan). For string type the available operators are equal, notequal, set, unset, matches. For bool type the available operators are equal, notequal, set, unset. For float64 type, the available operators are equal, notequal, set, unset, greaterthan, lessthan.

valueType is the type of the value that needs to be evaluated. string is the default. bool and float64 are also implemented.

tags is a list of strings that can be used to decide whether to run this rule or not via the CLI.

Running kube-lint

Basic operation

Once installed you can run kube-lint from this directory as follows:

kube-lint pods --config example/config.yaml

To change the rules edit example/config.yaml. You rulebender you.

Filtering rules by tag

You can evaluate a subset of rules by filtering down to only those that include certain tags. For example:

kube-lint pods --config example/config.yaml --tags security,operations

Filtering resources by namespace

You can also filter which resources are evaluated by passing the --namespace flag as follows:

kube-lint pods --config example/config.yaml --namespace kube-system

TODO if this seems like a reasonable approach to pursue

  • Replace panic everywhere with proper error handling
  • Add tests. Lots of tests.
  • Add docstrings to all exported functions/types/methods
  • Make -f be able to load a directories of yaml files (like kubectl)
  • Decide on how to deal with unset parameters
  • Choose a logging framework and use it
  • Add more resources (services/deployments/etc.)
  • Use ${HOME}/.kube-lint for config params
  • Develop standardized baseline of rules that are useful
  • Vendor dependencies using glide

Contributing

Add an issue to talk about what youd like to see changed. Lets talk about it then come up with a plan of action.

More Repositories

1

helm-gcs

Helm plugin for using GCS as a private chart repository
Shell
74
star
2

continuous-delivery-spinnaker-gke

Tutorial for deploying, configuring and running Spinnaker on GKE for continuous delivery
Go
34
star
3

kubernetes-anchore-image-validator

Validating webhook for checking images against Anchore Engine Policy
Go
21
star
4

gke-toolbox

A Helm Chart with pre-configured tools for your Container Engine clusters
Smarty
20
star
5

cloud-images

Kickstarts and such for various cloud starter images
Shell
15
star
6

testlink

Testcase Management Database and Front-end
PHP
14
star
7

cloudbuild-optimizer

Run builds across all machine types in Cloud Build to find the optimal price/performance tradeoff
Go
11
star
8

jenkins-chart-kustomize

Example of using Kustomize to do last mile customizations to Helm charts
8
star
9

cloudbuild-gitlab-bridge

Run your GitLab CI builds on Google Cloud Build
Shell
7
star
10

tekton-workshop

A workshop to help users get up to speed with Tekton using Google Kubernetes Engine (GKE)
6
star
11

echo-grpc-web-python

JavaScript
6
star
12

skaffold-telepresence-demo

JavaScript
4
star
13

cloud-run-kustomize-example

An example using Kustomize and Skaffold to build images and render config for Cloud Run
HTML
4
star
14

global-cloudfoundry-on-gcp

Example manifests for a globally redundant Cloud Foundry on GCP
HCL
3
star
15

huevos-cookbook

The easiest way to get started with HuevOS+RancherOS
Ruby
3
star
16

sample-app

Sample application written in Go
Go
3
star
17

clickops-to-gitops-demo

Go
2
star
18

cleanpvcs

Clean up PVCs whose namespace has been deleted
Go
2
star
19

remote-builder

Execute builds on remote Compute Engine machines using Container Builder
Shell
2
star
20

tl_RC1

RC1 Release with enhancements
PHP
2
star
21

eucadev

Tools for Eucalyptus developers
Shell
2
star
22

binauthz-tools

Tools for making it easier to work with Binary Authorization in Google Cloud
Shell
2
star
23

chef-provisioning-recipes

Recipes for provisioning software stacks using Chef Provisioning
Ruby
2
star
24

terraform-google-k8s-gce

Kubernetes Cluster on GCE Terraform Module
HCL
1
star
25

deprecation-chart

This chart is used to send the final deprecation notice to users for the official helm/charts repository charts.
1
star
26

concourse-continuous-delivery

Tutorial for creating continuous delivery pipelines using Concourse and Helm
Shell
1
star
27

nilgiri

Cloud management web console
Python
1
star
28

compose-to-skaffold-tutorial

Tutorial showing a transition from Docker Compose to Skaffold+Minikube
1
star
29

jenkins-gce

Install Jenkins on GCE with Terraform
PowerShell
1
star
30

dm-mesos

Shell
1
star
31

tekton-kustomize-example

Shell
1
star
32

euca-deploy

Tool for Deploying Eucalyptus
Python
1
star
33

skaffold-starting-points

Starting points for skaffold initialization
Python
1
star
34

euca-loader

Load Testing Framework for Eucalyptus
Python
1
star
35

terraform-google-examples

Example usage of Terraform modules for Google Cloud
HCL
1
star
36

EucaTest

Euca2ools wrapper with functional validation
Perl
1
star
37

eucatelemetry

Agent for sending stats to a CollectD Server
Python
1
star