pidalio

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

README

pidalio

pidalio-logo

Build Status codecov Go Report Card Go doc

A transport middleware working in clientside for client-go to mutate any k8s resource via (Cluster)OverridePolicy.

If you want to use it in serverside as a webhook, please use https://github.com/k-cloud-labs/kinitiras.

Quick Start

Apply crd files to your cluster
kubectl apply -f https://raw.githubusercontent.com/k-cloud-labs/pkg/main/charts/_crds/bases/policy.kcloudlabs.io_overridepolicies.yaml
kubectl apply -f https://raw.githubusercontent.com/k-cloud-labs/pkg/main/charts/_crds/bases/policy.kcloudlabs.io_clusteroverridepolicies.yaml

OverridePolicy is used to mutate object in the same namespace.
ClusterOverridePolicy can mutate object in any namespace.

For cluster scoped resource:

  • Apply ClusterOverridePolicy by policies name in ascending;

For namespaced scoped resource, apply order is:

  • First apply ClusterOverridePolicy;
  • Then apply OverridePolicy;
Add transport middleware

What you need to do is just call RegisterPolicyTransport func after rest.Config initialized and before client to initialize.

import(
	"github.com/k-cloud-labs/pidalio"
)

// the black magic code
pidalio.RegisterPolicyTransport(config, make(chan struct{}))

Feature

  • Support mutate k8s resource by (Cluster)OverridePolicy via plaintext jsonpatch.
  • Support mutate k8s resource by (Cluster)OverridePolicy programmable via CUE.
  • Support render template to cue in transport(even policy is not created by others)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyOverridePolicy

func ApplyOverridePolicy(manager overridemanager.OverrideManager, unstructuredObj *unstructured.Unstructured, operation admissionv1.Operation) error

func NewForConfig added in v0.2.0

func NewForConfig(config *rest.Config) (client.Client, error)

NewForConfig creates a new client for the given config.

func RegisterPolicyTransport added in v0.2.0

func RegisterPolicyTransport(config *rest.Config, stopCh chan struct{})

RegisterPolicyTransport init transport and register to wrapper.

Types

This section is empty.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL