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

Additional Pod Controller Scans #166

Merged
merged 32 commits into from
Jul 31, 2019
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
eb3741c
Additions
Jul 6, 2019
bbec130
Added additionally supported Controllers to test config
Jul 16, 2019
b92d7c7
Added docs pages per request
nickfw Jul 23, 2019
c7702e6
Merge branch 'master' into nh/add-more-controller-support
nickfw Jul 23, 2019
18b9f6d
Copyright rename
nickfw Jul 23, 2019
8d3c08e
Adjusted office hours name
nickfw Jul 23, 2019
824d210
Adjustments
nickfw Jul 23, 2019
355b8da
Adjusted docs movement which apparently affects the dashboard :?
nickfw Jul 23, 2019
2f72309
Added functionality to webhook
nickfw Jul 23, 2019
4dc3b0c
Added testing for getting supported controllers from string
nickfw Jul 23, 2019
f0b7ce9
Adjustments
nickfw Jul 24, 2019
4ac9257
Added RBAC changes
nickfw Jul 24, 2019
6f73ffb
Adjusted version
nickfw Jul 24, 2019
77293c4
Adjusted version in main.go
nickfw Jul 24, 2019
8f7def8
added testing for binary image
nickfw Jul 24, 2019
5204b14
Adjustements getting tag filter back
nickfw Jul 24, 2019
832142c
Adjusted sha
nickfw Jul 24, 2019
c066dea
Merge branch 'master' into nh/add-more-controller-support
Jul 25, 2019
7963b3c
Merge branch 'master' into nh/add-more-controller-support
nickfw Jul 31, 2019
641ed8c
Adjusted naming to match master
nickfw Jul 31, 2019
05ae1e8
matching license naming
nickfw Jul 31, 2019
770017f
adjusted copyright info
nickfw Jul 31, 2019
b815b54
Added new supported type to tests
nickfw Jul 31, 2019
fb8e5ed
Added supported controllers to webhook
nickfw Jul 31, 2019
15b8ef2
Adjusted version in webhook accidentally
nickfw Jul 31, 2019
bbdd924
Added refactor of webhook registration
nickfw Jul 31, 2019
f16bc3d
Adjusted naming of webhooks to conform to DNS-1123
nickfw Jul 31, 2019
59531c8
Adjust method of registration
nickfw Jul 31, 2019
9e398a2
Adjusted webhook and dashboard plus fixed view of new controllers
nickfw Jul 31, 2019
ea06a36
Adjusted request
nickfw Jul 31, 2019
b64c03c
Merge branch 'master' into nh/add-more-controller-support
Jul 31, 2019
c168c01
Added requested change
nickfw Jul 31, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ references:
run:
name: Test Dashboard
command: |
sed -ri "s|'(quay.io/reactiveops/polaris:).+'|'\1${CIRCLE_SHA1}'|" ./deploy/dashboard.yaml
kubectl apply -f ./deploy/dashboard.yaml
sleep 10
kubectl get pods --namespace polaris
Expand Down Expand Up @@ -172,11 +173,6 @@ workflows:
build:
jobs:
- test
- test_k8s:
# Ignore update-version branch, which changes deploy/ image references before the images are built
filters:
branches:
ignore: /.*\/update-version/
- build:
requires:
- test
Expand All @@ -185,6 +181,9 @@ workflows:
filters:
tags:
only: /^testing-.*/
- test_k8s:
requires:
- build
release:
jobs:
- release_binary:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# x.x.x (next release)

# 0.4.0
* Added additional Pod Controllers to scan PodSpec (`jobs`, `cronjobs`, `daemonsets`, `replicationcontrollers`)

# 0.3.1
* Changed dashboard branding to refer to new org name Fairwinds

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2019 ReactiveOps
Copyright 2019 Fairwinds

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
156 changes: 11 additions & 145 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,19 @@ problems in the future. Polaris can be run in a few different modes:
- An experimental validating webhook that can prevent any future deployments that do not live up to a configured standard.
- A command-line audit that can be incorporated into your CI/CD pipeline

**Want to learn more?** ReactiveOps holds [office hours on Zoom](https://zoom.us/j/242508205) the first Friday of every month, at 12pm Eastern. You can also reach out via email at `opensource@fairwinds.com`
**Want to learn more?** Fairwinds holds [office hours on Zoom](https://zoom.us/j/242508205) the first Friday of every month, at 12pm Eastern. You can also reach out via email at `opensource@fairwinds.com`

## Quickstart
# Quickstart Dashboard
endzyme marked this conversation as resolved.
Show resolved Hide resolved

```
kubectl apply -f https://github.com/reactiveops/polaris/releases/latest/download/dashboard.yaml
kubectl port-forward --namespace polaris svc/polaris-dashboard 8080:80
```
With the port forwarding in place, you can open http://localhost:8080 in your browser to view the dashboard.

* * *

# Components
## Dashboard

The Polaris dashboard is a way to get a simple visual overview of the current state of your Kubernetes deployments as well as a roadmap for what can be improved. The dashboard provides a cluster wide overview as well as breaking out results by category, namespace, and deployment.
Expand All @@ -42,162 +45,25 @@ The Polaris dashboard is a way to get a simple visual overview of the current st

Our default standards in Polaris are rather high, so don’t be surprised if your score is lower than you might expect. A key goal for Polaris was to set a high standard and aim for great configuration by default. If the defaults we’ve included are too strict, it’s easy to adjust the configuration as part of the deployment configuration to better suit your workloads.


## Webhook

Polaris includes experimental support for an optional validating webhook. This accepts the same configuration as the dashboard, and can run the same validations. This webhook will reject any deployments that trigger a validation error. This is indicative of the greater goal of Polaris, not just to encourage better configuration through dashboard visibility, but to actually enforce it with this webhook. *Although we are working towards greater stability and better test coverage, we do not currently consider this webhook component production ready.*

Unfortunately we have not found a way to display warnings as part of `kubectl` output unless we are rejecting a deployment altogether. That means that any checks with a severity of `warning` will still pass webhook validation, and the only evidence of that warning will either be in the Polaris dashboard or the Polaris webhook logs.

## Installation and Usage
Polaris can be installed on your cluster using kubectl or Helm. It can also
be run as a local binary, which will use your kubeconfig to connect to the cluster
or run against local YAML files.

### kubectl
#### Dashboard
```
kubectl apply -f https://github.com/reactiveops/polaris/releases/latest/download/dashboard.yaml
kubectl port-forward --namespace polaris svc/polaris-dashboard 8080:80
```

#### Webhook
```
kubectl apply -f https://github.com/reactiveops/polaris/releases/latest/download/webhook.yaml
```

### Helm
Start by adding the ReactiveOps Helm repo:
```
helm repo add reactiveops-stable https://charts.reactiveops.com/stable
```

#### Dashboard
```
helm upgrade --install polaris reactiveops-stable/polaris --namespace polaris
kubectl port-forward --namespace polaris svc/polaris-dashboard 8080:80
```

#### Webhook
```
helm upgrade --install polaris reactiveops-stable/polaris --namespace polaris \
--set webhook.enable=true --set dashboard.enable=false
```

### Local Binary
#### Installation
Binary releases are available on the [releases page](https://github.com/reactiveops/polaris/releases) or can be installed with [Homebrew](https://brew.sh/):
```
brew tap reactiveops/tap
brew install reactiveops/tap/polaris
polaris --version
```

You can run `polaris --help` to see a full list of options.

#### Dashboard
The dashboard can be run on your local machine, without installing anything on the cluster.
Polaris will use your local kubeconfig to connect to the cluster.

```
polaris --dashboard --dashboard-port 8080
```

#### Audits
You can also run audits on the command line and see the output as JSON, YAML, or a raw score:
```
polaris --audit --output-format yaml > report.yaml
polaris --audit --output-format score
# 92
```

Both the dashboard and audits can run against a local directory or YAML file
rather than a cluster:
```
polaris --audit --audit-path ./deploy/
```

##### Running with CI/CD
You can integrate Polaris into CI/CD for repositories containing infrastructure-as-code.
For example, to fail if polaris detects *any* error-level issues, or if the score drops below 90%:
```bash
polaris --audit --audit-path ./deploy/ \
--set-exit-code-on-error \
--set-exit-code-below-score 90
```

## Configuration

Polaris supports a wide range of validations covering a number of Kubernetes best practices. Here's a sample configuration file that includes all currently supported checks. The [default configuration](https://github.com/reactiveops/polaris/blob/master/examples/config.yaml) contains a number of those checks. This repository also includes a sample [full configuration file](https://github.com/reactiveops/polaris/blob/master/examples/config-full.yaml) that enables all available checks.

Each check can be assigned a `severity`. Only checks with a severity of `error` or `warning` will be validated. The results of these validations are visible on the dashboard. In the case of the validating webhook, only failures with a severity of `error` will result in a change being rejected.

Polaris validation checks fall into several different categories:

- [Health Checks](docs/health-checks.md)
- [Images](docs/images.md)
- [Networking](docs/networking.md)
- [Resources](docs/resources.md)
- [Security](docs/security.md)

## CLI Options

```
# high-level flags
-version
Prints the version of Polaris
-config string
Location of Polaris configuration file
-kubeconfig string
Path to a kubeconfig. Only required if out-of-cluster.
-log-level string
Logrus log level (default "info")
-master string
The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.

# dashboard flags
-dashboard
Runs the webserver for Polaris dashboard.
-dashboard-base-path string
Path on which the dashboard is served (default "/")
-dashboard-port int
Port for the dashboard webserver (default 8080)
-display-name string
An optional identifier for the audit

# audit flags
-audit
Runs a one-time audit.
-audit-path string
If specified, audits one or more YAML files instead of a cluster
-output-file string
Destination file for audit results
-output-format string
Output format for results - json, yaml, or score (default "json")
-output-url string
Destination URL to send audit results
-set-exit-code-below-score int
When running with --audit, set an exit code of 4 when the score is below this threshold (1-100)
-set-exit-code-on-error
When running with --audit, set an exit code of 3 when the audit contains error-level issues.

# webhook flags
-webhook
Runs the webhook webserver.
-webhook-port int
Port for the webhook webserver (default 9876)
-disable-webhook-config-installer
disable the installer in the webhook server, so it won't install webhook configuration resources during bootstrapping
```
# Usage Documentation
See the [Usage Guide](/docs/usage.md) in the docs folder.

## Contributing
# Contributing
PRs welcome! Check out the [Contributing Guidelines](CONTRIBUTING.md),
[Code of Conduct](CODE_OF_CONDUCT.md), and [Roadmap](ROADMAP.md) for more information.

## Further Information
# Further Information
A history of changes to this project can be viewed in the [Changelog](CHANGELOG.md)

If you'd like to learn more about Polaris, or if you'd like to speak with
a Kubernetes expert, you can contact `info@fairwinds.com` or [visit our website](https://fairwinds.com)

## License
# License
Apache License 2.0
12 changes: 11 additions & 1 deletion deploy/dashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ rules:
resources:
- 'deployments'
- 'statefulsets'
- 'daemonsets'
verbs:
- 'get'
- 'list'
- apiGroups:
- 'batch'
resources:
- 'jobs'
- 'cronjobs'
verbs:
- 'get'
- 'list'
Expand All @@ -90,6 +99,7 @@ rules:
- 'nodes'
- 'namespaces'
- 'pods'
- 'replicationcontrollers'
verbs:
- 'get'
- 'list'
Expand Down Expand Up @@ -161,7 +171,7 @@ spec:
- --dashboard
- --config
- /opt/app/config.yaml
image: 'quay.io/reactiveops/polaris:0.3'
image: 'quay.io/reactiveops/polaris:0.4'
imagePullPolicy: 'Always'
name: dashboard
ports:
Expand Down
22 changes: 21 additions & 1 deletion deploy/webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,32 @@ metadata:
labels:
app: polaris
rules:
# auditor rules rbac
- apiGroups:
- 'apps'
- 'extensions'
resources:
- 'deployments'
- 'statefulsets'
- 'daemonsets'
verbs:
- 'get'
- 'list'
- apiGroups:
- 'batch'
resources:
- 'jobs'
- 'cronjobs'
verbs:
- 'get'
- 'list'
- apiGroups:
- ''
resources:
- 'nodes'
- 'namespaces'
- 'pods'
- 'replicationcontrollers'
verbs:
- 'get'
- 'list'
Expand Down Expand Up @@ -211,7 +231,7 @@ spec:
- --webhook
- --config
- /opt/app/config.yaml
image: 'quay.io/reactiveops/polaris:0.3'
image: 'quay.io/reactiveops/polaris:0.4'
imagePullPolicy: 'Always'
ports:
- containerPort: 9876
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 13 additions & 0 deletions docs/exit-codes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Polaris Exit Codes for Audit Runs
<dl>
<dt>Exit 0</dt>
<dd>Successful exit code</dd>
<dt>Exit 1</dt>
<dd>Could not run audit, or application had a failure while running.</dd>
<dt>Exit 2</dt>
<dd>Unused</dd>
<dt>Exit 3</dt>
<dd>Exiting due to `--set-exit-code-on-error` being set and at least one error was found after an audit.</dd>
<dt>Edit 4</dd>
<dd>Exiting due to `--set-exit-code-below-score` being set and the audit resulted in a score less than the minimum score value.</dd>
</dl>
Loading