Developer Quick Start

Install Gatekeeper

kubectl apply -f https://raw.githubusercontent.com/open-policy-agent/gatekeeper/master/deploy/gatekeeper.yaml

References

https://github.com/open-policy-agent/gatekeeper#installation

Enable DEBUG

Change log level

Edit the deployment.

kubectl -n gatekeeper-system edit deployments gatekeeper-controller-manager

Add --log-level=DEBUG parameter:

...
    spec:
      containers:
      - args:
        - --auditInterval=30
        - --port=8443
        - --logtostderr
        - --log-level=DEBUG
...

Enable tracing

Find out what is your API user name

Method 01

Get the certificate from your kubeconfig file.

If the certificate is already embedded, base64 decode the certificate-authority-data field.

And decode the certificate using a tool such as https://www.sslshopper.com/certificate-decoder.html

The "Common Name" is your user name.

If the certificate is not embedded, it means it is in an external file, just copy the client-certificate file content and decode the certificate and the the "Common Name".

Method 02

Create a Gatekeep ConstraintTemplate just to debug what is your user name.

Create a violation function and return the input.review.userInfo, for example:

Change config

Edit the config.

Edit the validation section.

Test

Create a template.

Create a constraint.

Create a bad object.

Watch gatekeeper-controller-manager pod logs.

Watch template status section:

Last updated