• Stars
    star
    350
  • Rank 121,229 (Top 3 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 3 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

jsPolicy - Easier & Faster Kubernetes Policies using JavaScript or TypeScript

WebsiteGetting Started GuideDocumentationBlogTwitterSlack

Latest Release License: Apache-2.0

jsPolicy - Easier & Faster Kubernetes Policies using JavaScript or TypeScript

  • Lightning Fast & Secure Policy Execution - jsPolicy runs policies with Google's super fast V8 JavaScript engine in a pool of pre-heated sandbox environments. Most policies do not even take a single millisecond to execute
  • Great Language For Policies - JavaScript is made for handling and manipulating JSON objects (short for: JavaScript Object Notation!) and Kubernetes uses JSON by converting your YAML to JSON during every API request
  • 3 Policy Types for anything you need:
    • Validating Policies - Request validation that is as easy as calling allow(), deny("This is not allowed"), or warn("We'll let this one slip, but upgrade to the new ingress controller")
    • Mutating Policies - Simple mutations of the kubectl request payload via mutate(modifiedObj)
    • Controller Policies - Run custom JavaScript controllers that react to any changes to the objects in your cluster (controller policies are reactive, so they are not webhooks and part of a Kubernetes API server request but instead react to Events in your cluster after they have happened). With controller policies you can write resource sync mechanisms, enforce objects in namespaces, garbage collectors or fully functional CRD controllers
  • Simple yet Powerful - Create a functional webhook with a single line of JavaScript or write your own fully blown custom StatefulSet controller in TypeScript with jsPolicy. There are no limits and the possibilities are endless
  • Easy Cluster Access - Control cluster state with built-in functions such as get("Pod", "v1", "my-namespace/my-pod"), list("Namespace", "v1"), create(limitRange), update(mySecret) or remove(configMap)
  • Focus on Policy Logic - Jump right in and only focus on writing your own policy logic or simply reuse existing policies. Let jsPolicy do the rest and don't worry about high-availability, performance tuning, auditing, certificate management, webhook registration, prometheus metrics, shared resource caches, controller boilerplate, dynamic policy management etc. anymore
  • Turing Complete Policy Language - Use loops, Promises, generator functions, ? operators, TypeScript Type-Safe practices, hot reloaders, linting, test frameworks and all other modern JS language features and development best practices for writing clean and easy to maintain policy code
  • Huge Ecosystem of Libraries - Use any CommonJS JavaScript or TypeScript library from npmjs or from your private registry
  • Easy Policy Sharing & Reuse - Share entire policies or reusable functions via npmjs or via your private registry
  • Efficient Policy Development - Use any of the dev tools available in JavaScript or TypeScript for a highly efficient workflow

Learn more on www.jspolicy.com.

Join us on Slack!


Architecture

jsPolicy Architecture

jsPolicy Compatibility

Learn more in the documentation.


⭐️ Do you like jsPolicy? Support the project with a star ⭐️


Quick Start

To learn more about jspolicy, open the full getting started guide.

1. Install jsPolicy

Install jsPolicy to your Kubernetes cluster via Helm v3:

helm install jspolicy jspolicy -n jspolicy --create-namespace --repo https://charts.loft.sh

2. Create a Policy

Create the file policy.yaml:

# policy.yaml
apiVersion: policy.jspolicy.com/v1beta1
kind: JsPolicy
metadata:
  name: "deny-default-namespace.company.tld"
spec:
  operations: ["CREATE"]
  resources: ["*"]
  scope: Namespaced
  javascript: |
    if (request.namespace === "default") {
      deny("Creation of resources within the default namespace is not allowed!");
    }

3. Apply The Policy

Apply the policy in your cluster:

kubectl apply -f policy.yaml

4. See Policy In Action

kubectl create deployment nginx-deployment -n default --image=nginx

Contributing

Thank you for your interest in contributing! Please refer to CONTRIBUTING.md for guidance.



This project is open-source and licensed under Apache 2.0, so you can use it in any private or commercial projects.

More Repositories

1

devpod

Codespaces but open-source, client-only and unopinionated: Works with any IDE and lets you use any cloud, kubernetes or just localhost docker.
Go
8,593
star
2

vcluster

vCluster - Create fully functional virtual Kubernetes clusters - Each vcluster runs inside a namespace of the underlying k8s cluster. It's cheaper than creating separate full-blown clusters and it offers better multi-tenancy and isolation than regular namespaces.
Go
6,241
star
3

kiosk

kiosk 🏢 Multi-Tenancy Extension For Kubernetes - Secure Cluster Sharing & Self-Service Namespace Provisioning
Go
1,068
star
4

loft

Namespace & Virtual Cluster Manager for Kubernetes - Lightweight Virtual Clusters, Self-Service Provisioning for Engineers and 70% Cost Savings with Sleep Mode
Go
703
star
5

cluster-api-provider-vcluster

Go
70
star
6

virtual-cluster

Create fully functional virtual Kubernetes clusters - Each vCluster runs inside a Kubernetes namespace and can be started within seconds
Mustache
36
star
7

component-chart

Kubernetes Component Chart - Helm Chart for Application Components in Kubernetes
32
star
8

vcluster-sdk

Provides a toolset to create custom vcluster syncers
Go
25
star
9

devspace-plugin-loft

Loft Plugin for DevSpace - adds commands like `devspace create space` or `devspace create vcluster` to DevSpace
19
star
10

devpod-kubebuilder-template

DevPod KubeBuilder Template
Dockerfile
15
star
11

vcluster-generic-crd-sync-plugin

A vcluster plugin that syncs crds to the host cluster
Go
14
star
12

devpod-provider-aws

DevPod on AWS
Go
13
star
13

devspace-containers

Shell
12
star
14

devpod-provider-kubernetes

DevPod on Kubernetes
Go
12
star
15

vcluster-plugins

The plugin repository for vcluster. Extend virtual Kubernetes clusters with plugins.
Go
11
star
16

k8s-init-containers

Complementary repository to be used with Kubernetes Init Containers Article
Shell
8
star
17

devspace-quickstart-python

A small ready to use python flask application to use with devspace
HTML
8
star
18

devspace-php-laravel-nginx

PHP
7
star
19

jspolicy-sdk

TypeScript
7
star
20

devpod-provider-dockerless

Devpod without Docker/Podman
Go
7
star
21

dockerless

Go
6
star
22

dockerfile-templates

Dockerfile
6
star
23

loftctl

Go
5
star
24

devpod-provider-ssh

DevPod on SSH
Go
5
star
25

create-vcluster

GitHub Action to create a Loft VCluster
TypeScript
5
star
26

devpod-provider-azure

DevPod on Azure
Go
5
star
27

vcluster-dd-extension

This provides an extension integration with Docker Desktop to allow managing vclusters quickly and easily through the Docker Desktop interface.
TypeScript
5
star
28

devpod-kubebuilder-guestbook

KubeBuilder DevPod Example Repository
Go
5
star
29

devpod-provider-gcloud

DevPod on Google Cloud
Go
4
star
30

devspace-quickstart-nodejs

JavaScript
4
star
31

terraform-provider-loft

Terraform Provider for managing Loft Spaces and VCluster
Go
4
star
32

setup-devspace

GitHub Action to Install DevSpace CLI
TypeScript
4
star
33

vcluster-hostpath-mapper

Go
3
star
34

devpod-provider-digitalocean

DevPod on DigitalOcean
Go
3
star
35

tunnel

This is a library that simplifies the implementation and integration of a Tailscale control server into your Go application.
Go
3
star
36

examples

Jupyter Notebook
3
star
37

tilt-devspace-migration

Starlark
2
star
38

delete-vcluster

TypeScript
2
star
39

setup-loft

GitHub Action to Install Loft CLI
TypeScript
2
star
40

cert-issuer

2
star
41

devspace-quickstart-ruby

Ruby
2
star
42

devspace-quickstart-asp-dotnet

C#
2
star
43

devspace-quickstart-golang

Go
2
star
44

devspace-example-python

Python
2
star
45

devpod-templates

Collection of devcontainer json files.
2
star
46

devpod-provider-ecs

DevPod on ECS
Go
2
star
47

devspace-vscode-example

An example project that shows how to develop with DevSpace and VSCode
Go
1
star
48

devspace-example-php

1
star
49

log

The common logger for Loft projects
Go
1
star
50

devspace-go

Go Development with Kubernetes & DevSpace post's example source code
Shell
1
star
51

devspace-example-javascript

Shell
1
star
52

lib

Go
1
star
53

e2e-test-dependency

This is used for DevSpace e2e tests
1
star
54

action-repo-sync

Shell
1
star
55

vue-ts-client-demo

TypeScript
1
star
56

isolation-templates

1
star
57

loft-javascript-client

TypeScript
1
star
58

devspace-quickstart-php

PHP
1
star
59

api

Go
1
star
60

devpod-provider-terraform

DevPod on Terraform
Go
1
star
61

external-types

Go
1
star
62

loft-grafana-dashboards

1
star
63

agentapi

Go
1
star
64

loft-argo-example

An example project which uses Loft and ArgoCD
1
star
65

delete-space

TypeScript
1
star
66

apiserver

Go
1
star
67

vcluster-plugin-example

Go
1
star
68

utils

Go
1
star
69

create-space

GitHub Action to create a Loft Space
TypeScript
1
star
70

programming-language-detection

Small library to guess which programming language a project is
Go
1
star
71

devpod-provider-civo

DevPod on Civo
Go
1
star
72

devpod-pro-ecs-terraform

Terraform Script to deploy DevPod Pro on ECS with Terraform
HCL
1
star
73

sh.loft.devpod

Flatpak package for Devpod GUI
Makefile
1
star
74

vcluster-pro-azure-rbac

A little Demo that shows how to use vCluster.Pro and Azure RBAC together
1
star