Code Monkey home page Code Monkey logo

playground's Introduction

Kyverno Playground

release ci image Go Report Card License: Apache-2.0 GitHub Repo stars

The public version of the Playground is available at https://playground.kyverno.io.

About

The Kyverno Playground is a web service that simulates Kyverno behaviour, you can experiment and play with Kyverno policies directly in your browser

The service receives a configuration, resource and policies definitions, runs the Kyverno engine, and returns the results of evaluating policies against resources.

The playground currently supports:

  • Validation rules
  • Mutation rules
  • Image verification rules
  • Generate rules

NOTES:

  • This tool only works with public image registries
  • No data is gathered, stored, or shared

Features

The playground frontend offers a rich feature set:

  • Supports admission information like username, groups, roles and cluster roles
  • Saving and loading state from the local storage
  • Loading policies and resources from the Kyverno catalog
  • Sharing state with simple links
  • Comes with a tutorial to learn Kyverno easily

Context and Variables

It is currently not possible to add variables from external resources or do actual API calls.

It is only possible to mock variables using the variables configuration in the context input.

Multiple Manifests

It is supported to define multiple policies and/or resources as inputs.

Context and variables will be shared for all executions.

Load Manifests

The "File" Button loads a local YAML file as input.

The "URL" Button loads a manifest from an external URL, example: https://raw.githubusercontent.com/kyverno/policies/main/best-practices/disallow-latest-tag/disallow-latest-tag.yaml

Install

Kyverno Playground releases are available at https://github.com/kyverno/playground/releases.

Additionaly we publish docker images at ghcr.io/kyverno/playground and an helm chart repository is available at https://kyverno.github.io/playground.

Install with Helm

Add kyverno-playground Helm repository:

helm repo add kyverno-playground https://kyverno.github.io/playground/

Install kyverno-playground Helm chart:

helm upgrade --install kyverno-playground --namespace kyverno --create-namespace --wait kyverno-playground/kyverno-playground

Install kyverno-playground Helm chart (without configuring an Helm repository):

helm upgrade --install kyverno-playground --namespace kyverno --create-namespace --wait --repo https://kyverno.github.io/playground kyverno-playground

Install kyverno-playground local Helm chart:

helm upgrade --install kyverno-playground --namespace kyverno --create-namespace --wait ./charts/kyverno-playground

Install and run locally

Alternatively, you can install and run the Playground locally. This will allow you to connect the Playground to a real cluster.

Please read the Cluster connected docs.

Custom resources

The Playground uses openapi schemas to load resources from yaml content. To load a resource correctly the Playground needs the corresponding openapi schema.

By default, all Kubernetes builtin resources are supported. To work with custom resources you need to provide the custom resource definition.

Providing custom resource definitions can be done in different ways:

  • Using the --engine-builtin-crds flag in the backend (see the list of supported built-in CRDs)
  • Using the --engine-local-crds flag in the backend, pointing to a directory containing yaml CRD definitions
  • Paste your CRD yaml definitions directly in the frontend

Supported built-in custom resource definitions

The following CRDs are embedded in the Playground backend and can be enabled with the --builtin-crds flag:

Name Flag
ArgoCD --builtin-crds=argocd
Cert Manager --builtin-crds=cert-manager
Tekton Pipeline --builtin-crds=tekton-pipeline
Prometheus Operator --builtin-crds=prometheus-operator
(Cluster)PolicyReports --builtin-crds=wgpolicyk8s

Build

Instructions for building and running the Playground from source code is available in the docs section.

Screenshots

Kyverno Playground - Layout


Kyverno Playground - Examples


Kyverno Playground - Validation Results


Kyverno Playground - DarkMode


Kyverno Playground - DarkMode

playground's People

Contributors

dependabot[bot] avatar eddycharly avatar fjogeleit avatar mariamfahmy98 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

playground's Issues

Improve mutation tests errors reporting

Mutation tests which throw errors probably don't need the Details icon available since the policy couldn't be evaluated properly. The error should be shown beneath the initial window.

K8s manifest authoring practices

For this to be released in Helm form or other Kubernetes deployment type, it needs to follow certain established practices:

  • Image built with best security (non-root, etc)
  • Manifest conforms to PSS Restricted profile
  • runAsNonRoot if possible
  • etc

Add guided tutorial

It would be awesome to have a guided tutorial, perhaps in place of the "Examples" button (since this does the same thing as opens the "hamburger" menu on the left).

This guided tutorial or wizard would walk the user through the UI and explain what each section does. Even guides them on exploring their first sample, modifying a resource, modifying the policy, and testing. This would be awesome if done in a really nice way!

Fix flashing main icon

Clicking on the main icon or the version in the top left causes it to flash. Seems odd for right now.

Validate variables

Parse the policy, then parse the variables{} area of the Context window. Warn/fail if a user tries to test when one or more variables are missing (which must be manually defined).

Add social media sharing

Add some sort of social media sharing function. Like a Twitter icon that, when clicked, allows a pre-defined tweet with something like, "Look what I made in the Kyverno Playground! <insert shortened URL of the "Share" result>" Something like this. Same thing perhaps with LinkedIn? Could maybe do more like create a GitHub gist or something. Lots of possibilities

Add more template resources

There needs to be more Template resources available. Pod, Deployment, StatefulSet, DaemonSet, Job, CronJob, Secret, ConfigMap, Ingress, Service, Namespace, PersistentVolume, ReplicaSet, ResourceQuota, ServiceAccount, NetworkPolicy, ClusterRoleBinding, ClusterRole, RoleBinding, Role, PriorityClass.

Set title to Kyverno Playground

Title in the center seems like it should be "Kyverno Playground" and not just "Playground". Could use a nicer font/style.

Add more tutorials

  • API/service call
  • ConfigMap context
  • UPDATE operation
  • DELETE operation
  • imageReferences context
  • Subject
  • ClusterRole
  • Namespace labels
  • verifyImages signature
  • verifyImages attestation
  • Custom Resource (like cert-manager or Policy Exception)

Clarify Download Policy button

I don't understand the Download Policy button that's accessible after the results are shown. It suggests that the policy is somehow materially different from its contents on the main page but it of course isn't. What may make more sense in place of just downloading the policy here is to download the test results along with the policy, resource, and context (including vars).

Mobile support

Low priority, but mobile support would be a nice to have feature.

Improve share functionality

Current share function implementation:

  • Combine Resources, Policies and Context as JSON String
  • Compress and encode to base64 string to reduce length using lzstring
  • Adding the content as query param and load it on page loading/mounting

Advantages

  • No expiration
  • Stateless

Disadvantages

  • Very long URL
  • Could not be send as via tools like Slack

Find a way to somehow shorten the URL and improve the UX

Add live policy schema validation

  • Users are often finding it difficult to write valid Kyverno policies, even sometimes as simple as the schema is wrong before getting to more complex issues like deep JMESPath or syntax validations.
  • This has to be prevented and clearly shown to users with like a large red outline around the policy pane. Users shouldn't be able to test policies that aren't schematically valid. See here.

Collapse context panel

I suggest being able to collapse the Context panel. Some policies a user may want more screen space to scroll the Resource panel in cases where contexts aren't needed.

Improve panels

It would be a great UX for every panel to have a small tooltip item to explain what goes on in there.

Sorting results bug

When sorting ascending Status column for a test with many results, have some result bugs. See test for Disallow Capabilities Strict in PSS Restricted profile.

Some navigations cause Resources to not load and scrolling to be stuck

Some navigations cause Resources to not load and scrolling to be stuck. From a fresh window, go to Tutorials => Unique ingress host. Scroll in the Resource to the bottom. Now navigate to Restrict pod count per node. The Resource does not update and scrolling is stuck. Any subsequent navigation from here does not work. Must refresh the page to unfreeze.

Improve imageReferences context vars

imageReferences context vars should work or an error/warning to be thrown. For images which are from private registries or otherwise cannot be resolved from the Playground, vars can be used with an order of precedence: live call => vars. If live call fails and vars not defined, throw an error. Do not score this as a pass, skip, or fail.

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.