Documentation ¶
Index ¶
Constants ¶
const ( MutationDone = "mutated" MutationDisabled = "disabled" )
Annotation values controlling injection.
const ( GroupName = "legion.planet.com" APIVersion = "v1alpha1" )
Group and version for this package.
Variables ¶
var ( MeasurePodsReviewed = stats.Int64("patch/pods_reviewed", "Number of pods reviewed.", stats.UnitDimensionless) TagKind, _ = tag.NewKey("kind") TagNamespace, _ = tag.NewKey("namespace") TagName, _ = tag.NewKey("name") TagResult, _ = tag.NewKey("result") )
Opencensus measurements.
var ( SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: APIVersion} SchemeBuilder = runtime.NewSchemeBuilder(func(s *runtime.Scheme) error { s.AddKnownTypes(SchemeGroupVersion, &PodMutation{}) return nil }) AddToScheme = SchemeBuilder.AddToScheme )
Registration utilities.
Functions ¶
func AdmissionReviewWebhook ¶
func AdmissionReviewWebhook(r Reviewer) http.HandlerFunc
AdmissionReviewWebhook returns a new admission review webhook. Admission requests are reviewed by the supplied Reviewer.
Types ¶
type IgnoreFunc ¶
IgnoreFunc returns true if a pod should be allowed without injection.
func IgnorePodsInHostNetwork ¶
func IgnorePodsInHostNetwork() IgnoreFunc
IgnorePodsInHostNetwork returns a function that ignores pods in the host network namespace.
func IgnorePodsWithAnnotation ¶
func IgnorePodsWithAnnotation(k, v string) IgnoreFunc
IgnorePodsWithAnnotation returns a function that ignores pods with the supplied annotation.
func IgnorePodsWithoutAnnotation ¶
func IgnorePodsWithoutAnnotation(k, v string) IgnoreFunc
IgnorePodsWithoutAnnotation returns a function that ignores pods without the supplied annotation.
type PodMutation ¶
type PodMutation struct { meta.TypeMeta `json:",inline"` meta.ObjectMeta `json:"metadata,omitempty"` Spec PodMutationSpec `json:"spec,omitempty"` }
A PodMutation specifies how a pod will be mutated. +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
func DecodePodMutation ¶
func DecodePodMutation(data []byte) (PodMutation, error)
DecodePodMutation decodes a PodMutation from the provided bytes. It uses k8s.io/apimachinery's UniversalDecoder in order to decode bytes encoded in any format supported by Kubernetes (i.e. YAML, JSON, etc).
func (*PodMutation) DeepCopy ¶
func (in *PodMutation) DeepCopy() *PodMutation
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodMutation.
func (*PodMutation) DeepCopyInto ¶
func (in *PodMutation) DeepCopyInto(out *PodMutation)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (*PodMutation) DeepCopyObject ¶
func (in *PodMutation) DeepCopyObject() runtime.Object
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
type PodMutationSpec ¶
type PodMutationSpec struct { Strategy PodMutationStrategy `json:"strategy,omitempty"` Template PodMutationTemplate `json:"template,omitempty"` }
A PodMutationSpec specifies the fields of a pod that will be updated. +k8s:deepcopy-gen=true
func (*PodMutationSpec) DeepCopy ¶
func (in *PodMutationSpec) DeepCopy() *PodMutationSpec
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodMutationSpec.
func (*PodMutationSpec) DeepCopyInto ¶
func (in *PodMutationSpec) DeepCopyInto(out *PodMutationSpec)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type PodMutationStrategy ¶
type PodMutationStrategy struct { // Overwrite keys that are already set in the original pod. Overwrite bool `json:"overwrite,omitempty"` // Append to, rather than replacing, arrays in the original pod. Append bool `json:"append,omitempty"` }
A PodMutationStrategy determines how pod configuration will be injected. +k8s:deepcopy-gen=true
func (*PodMutationStrategy) DeepCopy ¶
func (in *PodMutationStrategy) DeepCopy() *PodMutationStrategy
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodMutationStrategy.
func (*PodMutationStrategy) DeepCopyInto ¶
func (in *PodMutationStrategy) DeepCopyInto(out *PodMutationStrategy)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type PodMutationTemplate ¶
type PodMutationTemplate struct { meta.ObjectMeta `json:"metadata,omitempty"` Spec core.PodSpec `json:"spec,omitempty"` }
A PodMutationTemplate specifies the fields of a pod that will be updated. +k8s:deepcopy-gen=true
func (*PodMutationTemplate) DeepCopy ¶
func (in *PodMutationTemplate) DeepCopy() *PodMutationTemplate
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PodMutationTemplate.
func (*PodMutationTemplate) DeepCopyInto ¶
func (in *PodMutationTemplate) DeepCopyInto(out *PodMutationTemplate)
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
type PodMutator ¶
type PodMutator struct {
// contains filtered or unexported fields
}
PodMutator is a Reviewer that mutates pods.
func NewPodMutator ¶
func NewPodMutator(p Patcher, mo ...PodMutatorOption) *PodMutator
NewPodMutator returns a new NewPodMutator with the supplied options.
func (*PodMutator) Review ¶
func (m *PodMutator) Review(ar *admission.AdmissionRequest) *admission.AdmissionResponse
Review approves and patches pod admission requests.
type PodMutatorOption ¶
type PodMutatorOption func(d *PodMutator)
A PodMutatorOption configures an PodMutator.
func WithIgnoreFuncs ¶
func WithIgnoreFuncs(fn ...IgnoreFunc) PodMutatorOption
WithIgnoreFuncs configs a PodMutator with the supplied ignore functions.
func WithLogger ¶
func WithLogger(l *zap.Logger) PodMutatorOption
WithLogger configures a PodMutator to use the supplied logger.
type Reviewer ¶
type Reviewer interface {
Review(*admission.AdmissionRequest) *admission.AdmissionResponse
}
A Reviewer reviews admission requests.