Documentation
¶
Overview ¶
application.go manages an Application[1]
[1] https://github.com/kubernetes-sigs/application
The declarative package contains tools and a controller compatible with http://sigs.k8s.io/controller-runtime to manage a Kubernetes deployment based off of a instance of a CustomResource in the cluster.
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Variables
- func DefaultObjectOrder(ctx context.Context) func(o *manifest.Object) int
- func ExtractApplication(objects *manifest.Objects) (*manifest.Object, error)
- func WatchAll(config *rest.Config, ctrl controller.Controller, recnl Source, ...) (chan struct{}, error)
- func WithApplyPrune() reconcilerOption
- func WithGroupVersionKind(gvk schema.GroupVersionKind) reconcilerOption
- func WithLabels(labelMaker LabelMaker) reconcilerOption
- func WithManagedApplication(labelMaker LabelMaker) reconcilerOption
- func WithManifestController(mc ManifestController) reconcilerOption
- func WithObjectTransform(operations ...ObjectTransform) reconcilerOption
- func WithOwner(ownerFn OwnerSelector) reconcilerOption
- func WithPreserveNamespace() reconcilerOption
- func WithRawManifestOperation(operations ...ManifestOperation) reconcilerOption
- func WithStatus(status Status) reconcilerOption
- type DeclarativeObject
- type DynamicWatch
- type LabelMaker
- type ManifestController
- type ManifestLoaderFunc
- type ManifestOperation
- type ObjectTransform
- type OwnerSelector
- type Preflight
- type Reconciled
- type Reconciler
- func (r *Reconciler) BuildDeploymentObjects(ctx context.Context, name types.NamespacedName, instance DeclarativeObject) (*manifest.Objects, error)
- func (r *Reconciler) Init(mgr manager.Manager, prototype DeclarativeObject, opts ...reconcilerOption) error
- func (r *Reconciler) Reconcile(request reconcile.Request) (reconcile.Result, error)
- func (r *Reconciler) SetSink(sink Sink)
- type Sink
- type Source
- type Status
- type StatusBuilder
Constants ¶
This section is empty.
Variables ¶
var Options struct { // Begin options are applied before evaluating controller specific options Begin []reconcilerOption // End options are applied after evaluating controller specific options End []reconcilerOption }
Options are a set of reconcilerOptions applied to all controllers
Functions ¶
func ExtractApplication ¶
ExtractApplication extracts a single app.k8s.io/Application from objects.
- 0 Application: (nil, nil) - 1 Application: (*app, nil) - >1 Application: (nil, err)
func WatchAll ¶
func WatchAll(config *rest.Config, ctrl controller.Controller, recnl Source, labelMaker LabelMaker) (chan struct{}, error)
WatchAll creates a Watch on ctrl for all objects reconciled by recnl
func WithApplyPrune ¶
func WithApplyPrune() reconcilerOption
WithApplyPrune turns on the --prune behavior of kubectl apply. This behavior deletes any objects that exist in the API server that are not deployed by the current version of the manifest which match a label specific to the addon instance.
This option requires WithLabels to be used
func WithGroupVersionKind ¶
func WithGroupVersionKind(gvk schema.GroupVersionKind) reconcilerOption
WithGroupVersionKind specifies the GroupVersionKind of the managed custom resource This option is required.
func WithLabels ¶
func WithLabels(labelMaker LabelMaker) reconcilerOption
WithLabels sets a fixed set of labels configured provided by a LabelMaker to all deployment objecs for a given DeclarativeObject
func WithManagedApplication ¶
func WithManagedApplication(labelMaker LabelMaker) reconcilerOption
WithManagedApplication is a transform that will modify the Application object in the deployment to match the configuration of the rest of the deployment.
func WithManifestController ¶
func WithManifestController(mc ManifestController) reconcilerOption
WithManifestController overrides the default source for loading manifests
func WithObjectTransform ¶
func WithObjectTransform(operations ...ObjectTransform) reconcilerOption
WithObjectTransform adds the specified ObjectTransforms to the chain of manifest changes
func WithOwner ¶
func WithOwner(ownerFn OwnerSelector) reconcilerOption
WithOwner sets an owner ref on each deployed object by the OwnerSelector
func WithPreserveNamespace ¶
func WithPreserveNamespace() reconcilerOption
WithPreserveNamespace preserves the namespaces defined in the deployment manifest instead of matching the namespace of the DeclarativeObject
func WithRawManifestOperation ¶
func WithRawManifestOperation(operations ...ManifestOperation) reconcilerOption
WithRawManifestOperation adds the specific ManifestOperations to the chain of manifest changes
func WithStatus ¶
func WithStatus(status Status) reconcilerOption
WithStatus provides a Status interface that will be used during Reconcile
Types ¶
type DeclarativeObject ¶
func SourceAsOwner ¶
func SourceAsOwner(ctx context.Context, src DeclarativeObject, obj manifest.Object, objs manifest.Objects) (DeclarativeObject, error)
SourceAsOwner is a OwnerSelector that selects the source DeclarativeObject as the owner
type DynamicWatch ¶
type DynamicWatch interface { // Add registers a watch for changes to 'trigger' filtered by 'options' to raise an event on 'target' Add(trigger schema.GroupVersionKind, options metav1.ListOptions, target metav1.ObjectMeta) error }
type LabelMaker ¶
type LabelMaker = func(context.Context, DeclarativeObject) map[string]string
LabelMaker returns a fixed set of labels for a given DeclarativeObject
func SourceLabel ¶
func SourceLabel(scheme *runtime.Scheme) LabelMaker
SourceLabel returns a fixed label based on the type and name of the DeclarativeObject
type ManifestController ¶
type ManifestLoaderFunc ¶
type ManifestLoaderFunc func() ManifestController
var DefaultManifestLoader ManifestLoaderFunc
DefaultManifestLoader is the manifest loader we use when a manifest loader is not otherwise configured
type ManifestOperation ¶
ManifestOperation is an operation that transforms raw string manifests before applying it
type ObjectTransform ¶
ObjectTransform is an operation that transforms the manifest objects before applying it
func AddLabels ¶
func AddLabels(labels map[string]string) ObjectTransform
AddLabels returns an ObjectTransform that adds labels to all the objects
func ImageRegistryTransform ¶
func ImageRegistryTransform(registry, imagePullSecret string) ObjectTransform
ImageRegistryTransform modifies all Pods to use registry for the image source and adds the imagePullSecret
type OwnerSelector ¶
type OwnerSelector = func(context.Context, DeclarativeObject, manifest.Object, manifest.Objects) (DeclarativeObject, error)
OwnerSelector selects a runtime.Object to be the owner of a given manifest.Object
type Preflight ¶
type Preflight interface { // Preflight validates if the current state of the world is ready for reconciling. // Returning a non-nil error on this object will prevent Reconcile from running. // The caller is encouraged to surface the error status on the DeclarativeObject. Preflight(context.Context, DeclarativeObject) error }
type Reconciled ¶
type Reconciler ¶
type Reconciler struct {
// contains filtered or unexported fields
}
func (*Reconciler) BuildDeploymentObjects ¶
func (r *Reconciler) BuildDeploymentObjects(ctx context.Context, name types.NamespacedName, instance DeclarativeObject) (*manifest.Objects, error)
BuildDeploymentObjects performs all manifest operations to build a final set of objects for deployment
func (*Reconciler) Init ¶
func (r *Reconciler) Init(mgr manager.Manager, prototype DeclarativeObject, opts ...reconcilerOption) error
func (*Reconciler) Reconcile ¶
+rbac:groups=apps,resources=deployments,verbs=get;list;watch;create;update;patch;delete
func (*Reconciler) SetSink ¶
func (r *Reconciler) SetSink(sink Sink)
SetSink provides a Sink that will be notified for all deployments
type Status ¶
type Status interface { Reconciled Preflight }
Status provides health and readiness information for a given DeclarativeObject
type StatusBuilder ¶
type StatusBuilder struct { ReconciledImpl Reconciled PreflightImpl Preflight }
StatusBuilder provides a pluggable implementation of Status
func (*StatusBuilder) Preflight ¶
func (s *StatusBuilder) Preflight(ctx context.Context, src DeclarativeObject) error
func (*StatusBuilder) Reconciled ¶
func (s *StatusBuilder) Reconciled(ctx context.Context, src DeclarativeObject, objs *manifest.Objects) error