Code Monkey home page Code Monkey logo

gatekeeper's Introduction

GateKeeper

CircleCI

Gatekeeper is currently an implementation of a Kubernetes Operator for installing, configuring and managing Open Policy Agent to provide dynamic admission controllers in a cluster.

Getting Started

The recommended way to configure Gatekeeper is to use Replicated Ship:

brew install ship
ship init https://github.com/replicatedhq/gatekeeper/tree/master/docs/gatekeeper-k8s

Ship will download and give you an opportunity to review the Kubernetes manifests included to run Gatekeeper. You can create patches and overlays to make any changes necessary for your environment. Once finished, follow the instructions in Ship and kubectl apply -f rendered.yaml.

You can then use ship watch && ship update to watch and configure updates as they are shipped here.

For more information on the components, and other methods to install Gatekeeper, read the docs.

Deploying Policies

After installing Gatekeeper to a cluster, a policy can be deployed using kubectl apply -f ./config/samples/policies_v1alpha2_admissionpolicy.yaml. (This is a sample policy that prevents any pod from using images tagged :latest). When the policy is applied, if OPA is running in the same namespace, the controller will deploy the policy from the YAML to the OPA instance. If OPA is not found, the controller will provision a new OPA instance, and deploy the policy to that new instance, whne it's ready.

Gatekeeper provisions Open Policy Agent with all of the necessary TLS configuration, webhook configuration, and underlying Kubernetes resources that are required to create a dynamic admission controller.

Motivations

The Open Policy Agent (OPA) project is an ambitious project that does much more than just Kubernetes Admission Controllers.

Simplify the task of installing and configuring OPA in Kubernetes.

Installing OPA into a Kubernetes cluster is more complex than many applications. The recommended installation includes creating a new certificate authority (CA) and then creating a cert, signed by that CA. This TLS configuration should be deployed and referenced in the openpolicyagent deployment and also manually copied into the webhook configuration. Managing this through automation can be difficult and prone to errors. The Gatekeeper operator manages this in-cluster, so the keys never have to be transferred to the cluster, and the CA and certs are properly configured every time.

Dynamic admission controllers in Kubernetes are powerful, but can also be difficult to troubleshoot and configure. A goal of the Gatekeeper operator is to make it easier to roll out new admission policies, with as little risk as possible.

Provide a custom resource to manage policy files (.rego) instead of using ConfigMaps

This allows for easier listing and management of individual policies. Instead of using the existing ConfigMap and in-cluster sync, the Gatekeeper operator introduces a new type named admissionpolicies.policies.replicated.com. This makes it easy to just kubectl get admissionpolicies.policies.replicated.com and view all dynamic admission policies installed in the cluster.

Validation of policies before deployment

One future goal of Gatekeeper is to validate new policies and changes to existing policies before deploying. This includes compiling the policy and also backtesting it against previous requests received to ensure that the policy will have the expected effects.

Architecture and Roadmap

Gatekeeper is still an early project that's evolving. To see our roadmap and better understand the current and planned architecture, architecture doc and the roadmap doc in this repo.

Contributing

Fork and clone this repo, and you can run it locally on a Kubernetes cluster:

make install  # this will install the CRDs to your cluster
skaffold dev  # this will start the manager and controllers in your cluster, and watch for file changes and redeploy

gatekeeper's People

Contributors

dexhorthy avatar laverya avatar marccampbell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gatekeeper's Issues

panic when deploying a new policy

It retried and works still, but:

[gatekeeper-5bc8996876-wn7pk gatekeeper] http2: panic serving 192.168.65.3:47370: runtime error: invalid memory address or nilpointer dereference
[gatekeeper-5bc8996876-wn7pk gatekeeper] goroutine 336 [running]:
[gatekeeper-5bc8996876-wn7pk gatekeeper] net/http.(*http2serverConn).runHandler.func1(0xc4203b6508, 0xc420643faf, 0xc4200d0000)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/h2_bundle.go:5753 +0x190
[gatekeeper-5bc8996876-wn7pk gatekeeper] panic(0x12aa5e0, 0x1da2db0)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/runtime/panic.go:502 +0x229
[gatekeeper-5bc8996876-wn7pk gatekeeper] github.com/replicatedhq/gatekeeper/pkg/proxy.GatekeeperProxy.AdmissionRequest(0xc42032a100, 0x1576c20, 0xc42032ac00, 0x15acdc0, 0xc4201784b0, 0xc4203400b0)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /go/src/github.com/replicatedhq/gatekeeper/pkg/proxy/server.go:157 +0x119d
[gatekeeper-5bc8996876-wn7pk gatekeeper] github.com/replicatedhq/gatekeeper/pkg/proxy.(GatekeeperProxy).AdmissionRequest-fm(0xc4203400b0)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /go/src/github.com/replicatedhq/gatekeeper/pkg/proxy/server.go:69 +0x56
[gatekeeper-5bc8996876-wn7pk gatekeeper] github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin.(*Context).Next(0xc4203400b0)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /go/src/github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin/context.go:108 +0x43
[gatekeeper-5bc8996876-wn7pk gatekeeper] github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc4200c5320, 0xc4203400b0)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /go/src/github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin/gin.go:361 +0x586
[gatekeeper-5bc8996876-wn7pk gatekeeper] github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc4200c5320, 0x158f400, 0xc4203b6508, 0xc4203e5900)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /go/src/github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin/gin.go:326 +0x153
[gatekeeper-5bc8996876-wn7pk gatekeeper] net/http.serverHandler.ServeHTTP(0xc4201d8f70, 0x158f400, 0xc4203b6508, 0xc4203e5900)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/server.go:2694 +0xbc
[gatekeeper-5bc8996876-wn7pk gatekeeper] net/http.initNPNRequest.ServeHTTP(0xc420104000, 0xc4201d8f70, 0x158f400, 0xc4203b6508, 0xc4203e5900)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/server.go:3260 +0x9a
[gatekeeper-5bc8996876-wn7pk gatekeeper] net/http.(Handler).ServeHTTP-fm(0x158f400, 0xc4203b6508, 0xc4203e5900)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/h2_bundle.go:5475 +0x4d
[gatekeeper-5bc8996876-wn7pk gatekeeper] net/http.(*http2serverConn).runHandler(0xc4200d0000, 0xc4203b6508, 0xc4203e5900, 0xc4203b5ba0)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/h2_bundle.go:5760 +0x89
[gatekeeper-5bc8996876-wn7pk gatekeeper] created by net/http.(*http2serverConn).processHeaders
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/h2_bundle.go:5494 +0x46b
[gatekeeper-5bc8996876-wn7pk gatekeeper] ts=2018-11-27T00:00:36.4596327Z caller=github.com/replicatedhq/gatekeeper/pkg/proxy/server.go level=warn method=GatekeeperProxy.AdmissionRequest event="send request upstream" err="Post https://gatekeeper-opa.gatekeeper-system.svc: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
[gatekeeper-5bc8996876-wn7pk gatekeeper] ts=2018-11-27T00:00:36.7319066Z caller=github.com/replicatedhq/gatekeeper/pkg/proxy/server.go level=warn method=GatekeeperProxy.AdmissionRequest event="send request upstream" err="Post https://gatekeeper-opa.gatekeeper-system.svc: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
[gatekeeper-5bc8996876-wn7pk gatekeeper] http2: panic serving 192.168.65.3:47370: runtime error: invalid memory address or nilpointer dereference
[gatekeeper-5bc8996876-wn7pk gatekeeper] goroutine 394 [running]:
[gatekeeper-5bc8996876-wn7pk gatekeeper] net/http.(*http2serverConn).runHandler.func1(0xc4204a2158, 0xc420643faf, 0xc4200d0000)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/h2_bundle.go:5753 +0x190
[gatekeeper-5bc8996876-wn7pk gatekeeper] panic(0x12aa5e0, 0x1da2db0)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/runtime/panic.go:502 +0x229
[gatekeeper-5bc8996876-wn7pk gatekeeper] github.com/replicatedhq/gatekeeper/pkg/proxy.GatekeeperProxy.AdmissionRequest(0xc42032a100, 0x1576c20, 0xc42032ac00, 0x15acdc0, 0xc4201784b0, 0xc420340160)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /go/src/github.com/replicatedhq/gatekeeper/pkg/proxy/server.go:157 +0x119d
[gatekeeper-5bc8996876-wn7pk gatekeeper] github.com/replicatedhq/gatekeeper/pkg/proxy.(GatekeeperProxy).AdmissionRequest-fm(0xc420340160)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /go/src/github.com/replicatedhq/gatekeeper/pkg/proxy/server.go:69 +0x56
[gatekeeper-5bc8996876-wn7pk gatekeeper] github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin.(*Context).Next(0xc420340160)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /go/src/github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin/context.go:108 +0x43
[gatekeeper-5bc8996876-wn7pk gatekeeper] github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc4200c5320, 0xc420340160)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /go/src/github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin/gin.go:361 +0x586
[gatekeeper-5bc8996876-wn7pk gatekeeper] github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc4200c5320, 0x158f400, 0xc4204a2158, 0xc4205d2800)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /go/src/github.com/replicatedhq/gatekeeper/vendor/github.com/gin-gonic/gin/gin.go:326 +0x153
[gatekeeper-5bc8996876-wn7pk gatekeeper] net/http.serverHandler.ServeHTTP(0xc4201d8f70, 0x158f400, 0xc4204a2158, 0xc4205d2800)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/server.go:2694 +0xbc
[gatekeeper-5bc8996876-wn7pk gatekeeper] net/http.initNPNRequest.ServeHTTP(0xc420104000, 0xc4201d8f70, 0x158f400, 0xc4204a2158, 0xc4205d2800)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/server.go:3260 +0x9a
[gatekeeper-5bc8996876-wn7pk gatekeeper] net/http.(Handler).ServeHTTP-fm(0x158f400, 0xc4204a2158, 0xc4205d2800)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/h2_bundle.go:5475 +0x4d
[gatekeeper-5bc8996876-wn7pk gatekeeper] net/http.(*http2serverConn).runHandler(0xc4200d0000, 0xc4204a2158, 0xc4205d2800, 0xc4204c56a0)
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/h2_bundle.go:5760 +0x89
[gatekeeper-5bc8996876-wn7pk gatekeeper] created by net/http.(*http2serverConn).processHeaders
[gatekeeper-5bc8996876-wn7pk gatekeeper]        /usr/local/go/src/net/http/h2_bundle.go:5494 +0x46b
[gatekeeper-controller-manager-0 manager] ts=2018-11-27T00:00:37.1089826Z caller=github.com/replicatedhq/gatekeeper/pkg/controller/admissionpolicy/opa_reconciler.go level=info method=ensureOPARunning event="ensure opa instance running"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.