preflight

command module
v0.1.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2020 License: Apache-2.0 Imports: 1 Imported by: 0

README

Build Status Go Report Card

Jetstack Preflight

Preflight is a tool to automatically perform Kubernetes cluster configuration checks using Open Policy Agent (OPA).

Table of Contents

Background

Preflight was originally designed to automate Jetstack's production readiness assessments. These are consulting sessions in which a Jetstack engineer inspects a customer's cluster to suggest improvements and identify configuration issues. The product of this assessment is a report which describes any problems and offers remediation advice.

While these assessments have provided a lot of value to many customers, with a complex system like Kubernetes it's hard to thoroughly check everything. Automating the checks allows them to be more comprehensive and much faster.

The automation also allows the checks to be run repeatedly, meaning they can be deployed in-cluster to provide continuous configuration checking. This enables new interesting use cases as policy compliance audits.

Preflight Application

The Preflight application uses data gatherers to collect required data in JSON format. Preflight then checks the gathered data against rules specified in Preflight packages and outputs rule violations with relevant information.

Preflight is designed to run both locally for one-off checking, and in-cluster to for continuous checking.

Preflight Packages

Policies for cluster configuration are encoded into Preflight packages. You can find some examples in ./preflight-packages.

Each package focuses on a different aspect of the cluster. For example, the gke_basic package provides rules for the configuration of a GKE cluster, and the pods package provides rules for the configuration of Kubernetes Pods.

A Preflight package consists of a Policy Manifest and a Rego package.

The Policy Manifest is a YAML file that specifies a package's rules. It gives descriptions of the rules and remediation advice, so the tool can display useful information when a rule doesn't pass.

Rego is OPA's high-level declarative language for specifying rules. Rego rules can be defined in multiples files grouped into logical Rego packages.

Anyone can create new Preflight packages to perform their own checks. The Preflight docs include a guide on how to write packages.

Preflight package structure diagram

Get Preflight

Download

Preflight binaries and bundles, which include a binary and all the packages in this repo, can be downloaded from the releases page.

Build

You can compile Preflight by running make build. It will create the binary in builds/preflight.

Use Preflight

Create your preflight.yaml configuration file. There is full configuration documentation available, as well as several example files in ./examples.

Use Preflight Locally

By default Preflight looks for a configuration at ./preflight.yaml. Once this is set up, run a Preflight check like so:

preflight check

You can try the Pods example ./examples/pods.preflight.yaml without having to change a line, if your kubeconfig is located at ~/.kube/config and is pointing to a working cluster.

preflight check --config-file=./examples/pods.preflight.yaml

You will see a CLI formatted report if everything goes well. Also, you will get a JSON report in ./output.

Use Preflight Web UI

If you want to visualise the report in your browser, you can access the Preflight Web UI and load the JSON report. This is a static website. Your report is not being uploaded to any server. Everything happens in your browser.

You can give it a try without even running the tool, since we provide some report examples, gke.json, and pods.json, ready to be loaded into the Preflight Web UI.

Use Preflight In-Cluster

Preflight can be installed in-cluster to run continuous checks. See the Installation Manual: Preflight In-Cluster.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package api provides types for Preflight reports and some common helpers.
Package api provides types for Preflight reports and some common helpers.
internal
checkconfig
Package checkconfig provides all the necessary components for the `check` command to load its configuration.
Package checkconfig provides all the necessary components for the `check` command to load its configuration.
pkg
datagatherer
Package datagatherer provides the DataGatherer interface.
Package datagatherer provides the DataGatherer interface.
datagatherer/aks
Package aks provides a datagatherer for AKS.
Package aks provides a datagatherer for AKS.
datagatherer/eks
Package eks provides a datagatherer for AWS EKS.
Package eks provides a datagatherer for AWS EKS.
datagatherer/gke
Package gke provides a datagatherer for GKE.
Package gke provides a datagatherer for GKE.
datagatherer/k8s
Package k8s provides datagatherers for different parts of the Kubernetes API.
Package k8s provides datagatherers for different parts of the Kubernetes API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL