rigging

package module
v0.0.0-...-f519c37 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: Apache-2.0 Imports: 44 Imported by: 31

README

Rig

The Rig tool adds changeset semantics to Kubernetes operations. For example:

# upsert a daemon set (changeset is created automatically)
rig upsert -c change1 -f daemonset.yaml
# delete a service
rig delete -c change1 svc/service1
# update config map
rig delete -c change1 configmaps/cf1
# check status
rig status -c change1
# revert everything
rig revert -c change1
# or freeze changeset, so it can no longer be updated
rig freeze -c change1

Usage

You can view changesets to see what happened:

View all changesets

rig get

Get detailed operations log for a changeset

rig get change1
rig get change1 -o yaml

Delete a changeset

rig cs delete change1

Environment variables can be used to bind rig to particular changeset:

export RIG_CHANGESET=cs1
rig upsert -f daemonset.yaml

Supported Resources

The following resources are supported:

  • ConfigMap
  • DaemonSet
  • ReplicationController
  • Service
  • Secret
  • Deployment

Rolling Updates

Only Deployment updates are rolling, updating of daemon sets or replication controllers simply deletes all the pods

Status checks

As a precondition to declaring Deployment, DaemonSet or ReplicatonController as ready, rig requires all pods must be in Running state.

Contributing

Rig is developed by Teleport. If you'd like to contribute to Rig, check out our contributing guidelines and Code of Conduct.

Documentation

Index

Constants

View Source
const (
	ChangesetResourceName              = "changesets.changeset.gravitational.io"
	ChangesetGroup                     = "changeset.gravitational.io"
	ChangesetVersion                   = "v1"
	ChangesetCollection                = "changesets"
	ChangesetPlural                    = "changesets"
	ChangesetSingular                  = "changeset"
	ChangesetScope                     = "Namespaced"
	DefaultNamespace                   = "default"
	KindDaemonSet                      = "DaemonSet"
	KindStatefulSet                    = "StatefulSet"
	KindChangeset                      = "Changeset"
	KindConfigMap                      = "ConfigMap"
	KindDeployment                     = "Deployment"
	KindReplicaSet                     = "ReplicaSet"
	KindReplicationController          = "ReplicationController"
	KindService                        = "Service"
	KindServiceAccount                 = "ServiceAccount"
	KindSecret                         = "Secret"
	KindJob                            = "Job"
	KindRole                           = "Role"
	KindClusterRole                    = "ClusterRole"
	KindRoleBinding                    = "RoleBinding"
	KindClusterRoleBinding             = "ClusterRoleBinding"
	KindPodSecurityPolicy              = "PodSecurityPolicy"
	KindCustomResourceDefinition       = "CustomResourceDefinition"
	KindNamespace                      = "Namespace"
	KindPriorityClass                  = "PriorityClass"
	KindAPIService                     = "APIService"
	KindServiceMonitor                 = monitoringv1.ServiceMonitorsKind
	KindAlertmanager                   = monitoringv1.AlertmanagersKind
	KindPrometheus                     = monitoringv1.PrometheusesKind
	KindPrometheusRule                 = monitoringv1.PrometheusRuleKind
	KindValidatingWebhookConfiguration = "ValidatingWebhookConfiguration"
	KindMutatingWebhookConfiguration   = "MutatingWebhookConfiguration"
	ControllerUIDLabel                 = "controller-uid"
	OpStatusCreated                    = "created"
	OpStatusCompleted                  = "completed"
	OpStatusReverted                   = "reverted"
	ChangesetStatusReverted            = "reverted"
	ChangesetStatusInProgress          = "in-progress"
	ChangesetStatusCommitted           = "committed"
	// DefaultRetryAttempts specifies amount of retry attempts for checks
	DefaultRetryAttempts = 60
	// RetryPeriod is a period between Retries
	DefaultRetryPeriod = time.Second
	DefaultBufferSize  = 1024

	ChangesetAPIVersion = "changeset.gravitational.io/v1"

	// CustomerManagedAnnotation specifies an annotation that a customer can use to take control of a kubernetes object
	// that is normally managed via gravity/rigging. If rigging sees this annotation on an object, it will no longer
	// update the object to the current desired state. Insert / Delete operations will still proceed however. This
	// is mainly so that a customer can take over and customize configuration built into gravity.
	CustomerManagedAnnotation = "gravitational.io/customer-managed"
)
View Source
const (
	ActionCreate  action = "create"
	ActionDelete  action = "delete"
	ActionReplace action = "replace"
	ActionApply   action = "apply"
)

Variables

This section is empty.

Functions

func CollectPods

func CollectPods(ctx context.Context, namespace string, matchLabels map[string]string, logger log.FieldLogger, client *kubernetes.Clientset,
	fn func(metav1.OwnerReference) bool) (map[string]v1.Pod, error)

CollectPods collects pods matched by fn

func ConvertError

func ConvertError(err error) error

func ConvertErrorWithContext

func ConvertErrorWithContext(err error, format string, args ...interface{}) error

func FromFile

func FromFile(act action, path string) ([]byte, error)

FromFile performs action on the Kubernetes resources specified in the path supplied as an argument.

func FromStdIn

func FromStdIn(act action, data string) ([]byte, error)

FromStdin performs action on the Kubernetes resources specified in the string supplied as an argument.

func GenerateConfigMap

func GenerateConfigMap(name string, namespace string, fromFile []string, fromLiteral []string) (*v1.ConfigMap, error)

GenerateConfigMap returns a configMap using the specified parameters.

func KubeCommand

func KubeCommand(args ...string) *exec.Cmd

KubeCommand returns an exec.Command for kubectl with the supplied arguments.

func LabelNode

func LabelNode(name string, label string) ([]byte, error)

func Namespace

func Namespace(namespace string) string

Namespace returns a default namespace if the specified namespace is empty

func ParseAPIService

func ParseAPIService(r io.Reader) (*apiregistrationv1.APIService, error)

ParseAPIService parses a APIService resource from the provided data

func ParseAlertmanager

func ParseAlertmanager(r io.Reader) (*monitoringv1.Alertmanager, error)

ParseAlertmanager parses a Alertmanager resource from the provided data

func ParseClusterRole

func ParseClusterRole(r io.Reader) (*rbacv1.ClusterRole, error)

ParseClusterRole parses an rbac cluster role from the specified stream

func ParseClusterRoleBinding

func ParseClusterRoleBinding(r io.Reader) (*rbacv1.ClusterRoleBinding, error)

ParseClusterRoleBinding parses an rbac cluster role binding from the specified stream

func ParseConfigMap

func ParseConfigMap(r io.Reader) (*v1.ConfigMap, error)

ParseConfigMap parses Config Map

func ParseCustomResourceDefinition

func ParseCustomResourceDefinition(r io.Reader) (*extensionsv1.CustomResourceDefinition, error)

ParseCustomResourceDefinition parses a Custom Resource Definition

func ParseDaemonSet

func ParseDaemonSet(r io.Reader) (*appsv1.DaemonSet, error)

ParseDaemonSet parses daemon set from reader

func ParseDeployment

func ParseDeployment(r io.Reader) (*appsv1.Deployment, error)

ParseDeployment parses deployment

func ParseJob

func ParseJob(r io.Reader) (*batchv1.Job, error)

ParseJob parses the specified reader as a Job resource

func ParseMutatingWebhookConfiguration

func ParseMutatingWebhookConfiguration(r io.Reader) (*admissionregistrationv1.MutatingWebhookConfiguration, error)

ParseMutatingWebhookConfiguration parses a MutatingWebhookConfiguration resources from the provided data stream.

func ParseNamespace

func ParseNamespace(r io.Reader) (*v1.Namespace, error)

ParseNamespace parses a namespace object from the specified stream

func ParsePodSecurityPolicy

func ParsePodSecurityPolicy(r io.Reader) (*v1beta1.PodSecurityPolicy, error)

ParsePodSecurityPolicy parses a pod security policy from the specified stream

func ParsePriorityClass

func ParsePriorityClass(r io.Reader) (*schedulingv1beta1.PriorityClass, error)

ParsePriorityClass parses a PriorityClass object from the specified stream

func ParsePrometheus

func ParsePrometheus(r io.Reader) (*monitoringv1.Prometheus, error)

ParsePrometheus parses a Prometheus resource from the provided data

func ParsePrometheusRule

func ParsePrometheusRule(r io.Reader) (*monitoringv1.PrometheusRule, error)

ParsePrometheusRule parses a PrometheusRule resource from the provided data

func ParseReplicationController

func ParseReplicationController(r io.Reader) (*v1.ReplicationController, error)

ParseReplicationController parses replication controller

func ParseRole

func ParseRole(r io.Reader) (*rbacv1.Role, error)

ParseRole parses an rbac role from the specified stream

func ParseRoleBinding

func ParseRoleBinding(r io.Reader) (*rbacv1.RoleBinding, error)

ParseRoleBinding parses an rbac role binding from the specified stream

func ParseSecret

func ParseSecret(r io.Reader) (*v1.Secret, error)

ParseSecret parses a secret from the specified stream

func ParseService

func ParseService(r io.Reader) (*v1.Service, error)

ParseService parses service

func ParseServiceAccount

func ParseServiceAccount(r io.Reader) (*v1.ServiceAccount, error)

ParseServiceAccount parses a service account from the specified stream

func ParseServiceMonitor

func ParseServiceMonitor(r io.Reader) (*monitoringv1.ServiceMonitor, error)

ParseServiceMonitor parses a ServiceMonitor resource from the provided data

func ParseShortcut

func ParseShortcut(in, defaultVal string) (string, error)

func ParseStatefulSet

func ParseStatefulSet(r io.Reader) (*appsv1.StatefulSet, error)

ParseStatefulSet parses statefulset resource from reader

func ParseValidatingWebhookConfiguration

func ParseValidatingWebhookConfiguration(r io.Reader) (*admissionregistrationv1.ValidatingWebhookConfiguration, error)

ParseValidatingWebhookConfiguration parses a ValidatingWebhookConfiguration resources from the provided data stream.

func PollStatus

func PollStatus(ctx context.Context, retryAttempts int, retryPeriod time.Duration, reporter StatusReporter) error

PollStatus polls status periodically

func ScaleReplicationController

func ScaleReplicationController(name string, replicas int, tries int) error

func WaitForRCPods

func WaitForRCPods(rcName string, desired int, delay time.Duration, tries int) error

Types

type APIServiceConfig

type APIServiceConfig struct {
	// APIService is the parsed APIService resource
	*v1.APIService
	// Client is Kube aggregator clientset
	Client *apiregistration.Clientset
}

APIServiceConfig is a APIService control configuration

func (*APIServiceConfig) CheckAndSetDefaults

func (c *APIServiceConfig) CheckAndSetDefaults() error

CheckAndSetDefaults validates the config

type APIServiceControl

type APIServiceControl struct {
	APIServiceConfig
	log.FieldLogger
}

APIServiceControl a controller for APIService resources

func NewAPIServiceControl

func NewAPIServiceControl(config APIServiceConfig) (*APIServiceControl, error)

NewAPIServiceControl returns new instance of APIService updater

func (*APIServiceControl) Delete

func (c *APIServiceControl) Delete(ctx context.Context, cascade bool) error

func (*APIServiceControl) Status

func (c *APIServiceControl) Status(ctx context.Context) error

func (*APIServiceControl) Upsert

func (c *APIServiceControl) Upsert(ctx context.Context) error

type AlertmanagerConfig

type AlertmanagerConfig struct {
	// Alertmanager is the parsed Alertmanager resource
	*monitoringv1.Alertmanager
	// Client is monitoring API client
	Client *monitoring.Clientset
}

AlertmanagerConfig is a Alertmanager control configuration

func (*AlertmanagerConfig) CheckAndSetDefaults

func (c *AlertmanagerConfig) CheckAndSetDefaults() error

CheckAndSetDefaults validates the config

type AlertmanagerControl

type AlertmanagerControl struct {
	AlertmanagerConfig
	log.FieldLogger
}

AlertmanagerControl a controller for Alertmanager resources

func NewAlertmanagerControl

func NewAlertmanagerControl(config AlertmanagerConfig) (*AlertmanagerControl, error)

NewAlertmanagerControl returns new instance of Alertmanager updater

func (*AlertmanagerControl) Delete

func (c *AlertmanagerControl) Delete(ctx context.Context, cascade bool) error

func (*AlertmanagerControl) Status

func (c *AlertmanagerControl) Status(ctx context.Context) error

func (*AlertmanagerControl) Upsert

func (c *AlertmanagerControl) Upsert(ctx context.Context) error

type Changeset

type Changeset struct {
	ChangesetConfig

	// APIExtensionsClient is a client for the extensions server
	APIExtensionsClient *apiextensionsclientset.Clientset
	// APIRegistrationClient is Kube aggregator clientset
	APIRegistrationClient *apiregistration.Clientset
	// MonitoringClient is Prometheus operator client
	MonitoringClient *monitoring.Clientset
	// contains filtered or unexported fields
}

Changeset is a is a collection changeset log that can revert a series of changes to the system

func NewChangeset

func NewChangeset(ctx context.Context, config ChangesetConfig) (*Changeset, error)

func (*Changeset) Create

func (cs *Changeset) Create(ctx context.Context, namespace, name string) (*ChangesetResource, error)

Create creates a new one given the name and namespace. The new changeset is created with status in-progress. If there's already a changeset with this name in this namespace, AlreadyExists error is returned.

func (*Changeset) Delete

func (cs *Changeset) Delete(ctx context.Context, namespace, name string) error

func (*Changeset) DeleteResource

func (cs *Changeset) DeleteResource(ctx context.Context, changesetNamespace, changesetName string, resourceNamespace string, resource Ref, cascade bool) error

DeleteResource deletes a resources in the context of a given changeset

func (*Changeset) Freeze

func (cs *Changeset) Freeze(ctx context.Context, changesetNamespace, changesetName string) error

Freeze "freezes" changeset, prohibits adding or removing any changes to it

func (*Changeset) Get

func (cs *Changeset) Get(ctx context.Context, namespace, name string) (*ChangesetResource, error)

func (*Changeset) Init

func (cs *Changeset) Init(ctx context.Context) error

func (*Changeset) List

func (cs *Changeset) List(ctx context.Context, namespace string) (*ChangesetList, error)

func (*Changeset) Revert

func (cs *Changeset) Revert(ctx context.Context, changesetNamespace, changesetName string) error

Revert rolls back all the operations in reverse order they were applied

func (*Changeset) Status

func (cs *Changeset) Status(ctx context.Context, changesetNamespace, changesetName string, retryAttempts int, retryPeriod time.Duration) error

Status checks all statuses for all resources updated or added in the context of a given changeset

func (*Changeset) Upsert

func (cs *Changeset) Upsert(ctx context.Context, changesetNamespace, changesetName string, data []byte) error

Upsert upserts resource in a context of a changeset

type ChangesetConfig

type ChangesetConfig struct {
	// Client is k8s client
	Client *kubernetes.Clientset
	// Config is rest client config
	Config *rest.Config
}

func (*ChangesetConfig) CheckAndSetDefaults

func (c *ChangesetConfig) CheckAndSetDefaults() error

type ChangesetItem

type ChangesetItem struct {
	From              string    `json:"from"`
	To                string    `json:"to"`
	UID               string    `json:"uid"`
	Status            string    `json:"status"`
	CreationTimestamp time.Time `json:"time"`
}

type ChangesetList

type ChangesetList struct {
	metav1.TypeMeta `json:",inline"`
	// Standard list metadata
	// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
	metav1.ListMeta `json:"metadata,omitempty"`
	// Items is a list of third party objects
	Items []ChangesetResource `json:"items"`
}

func (*ChangesetList) GetObjectKind

func (tr *ChangesetList) GetObjectKind() schema.ObjectKind

type ChangesetResource

type ChangesetResource struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Spec              ChangesetSpec `json:"spec"`
}

func (*ChangesetResource) GetObjectKind

func (tr *ChangesetResource) GetObjectKind() schema.ObjectKind

func (*ChangesetResource) String

func (tr *ChangesetResource) String() string

type ChangesetSpec

type ChangesetSpec struct {
	Status string          `json:"status"`
	Items  []ChangesetItem `json:"items"`
}

type ClusterRoleBindingConfig

type ClusterRoleBindingConfig struct {
	// Binding is the existing cluster role binding
	*v1.ClusterRoleBinding
	// Client is k8s client
	Client *kubernetes.Clientset
}

ClusterRoleBindingConfig defines controller configuration

type ClusterRoleBindingControl

type ClusterRoleBindingControl struct {
	ClusterRoleBindingConfig
	log.FieldLogger
}

ClusterRoleBindingControl is a cluster role bindings controller, adds various operations, like delete, status check and update

func NewClusterRoleBindingControl

func NewClusterRoleBindingControl(config ClusterRoleBindingConfig) (*ClusterRoleBindingControl, error)

NewClusterRoleBindingControl returns a new instance of the ClusterRoleBinding controller

func (*ClusterRoleBindingControl) Delete

func (c *ClusterRoleBindingControl) Delete(ctx context.Context, cascade bool) error

func (*ClusterRoleBindingControl) Status

func (*ClusterRoleBindingControl) Upsert

type ClusterRoleConfig

type ClusterRoleConfig struct {
	// Role is the existing cluster role
	*v1.ClusterRole
	// Client is k8s client
	Client *kubernetes.Clientset
}

ClusterRoleConfig defines controller configuration

type ClusterRoleControl

type ClusterRoleControl struct {
	ClusterRoleConfig
	log.FieldLogger
}

ClusterRoleControl is a cluster roles controller, adds various operations, like delete, status check and update

func NewClusterRoleControl

func NewClusterRoleControl(config ClusterRoleConfig) (*ClusterRoleControl, error)

NewClusterRoleControl returns a new instance of the ClusterRole controller

func (*ClusterRoleControl) Delete

func (c *ClusterRoleControl) Delete(ctx context.Context, cascade bool) error

func (*ClusterRoleControl) Status

func (c *ClusterRoleControl) Status(ctx context.Context) error

func (*ClusterRoleControl) Upsert

func (c *ClusterRoleControl) Upsert(ctx context.Context) error

type ConfigMapConfig

type ConfigMapConfig struct {
	// ConfigMap is already parsed daemon set, will be used if present
	*v1.ConfigMap
	// Client is k8s client
	Client *kubernetes.Clientset
}

ConfigMapConfig is a ConfigMap control configuration

type ConfigMapControl

type ConfigMapControl struct {
	ConfigMapConfig
	*log.Entry
}

ConfigMapControl is a daemon set controller, adds various operations, like delete, status check and update

func NewConfigMapControl

func NewConfigMapControl(config ConfigMapConfig) (*ConfigMapControl, error)

NewConfigMapControl returns new instance of ConfigMap updater

func (*ConfigMapControl) Delete

func (c *ConfigMapControl) Delete(ctx context.Context, cascade bool) error

func (*ConfigMapControl) Status

func (c *ConfigMapControl) Status(ctx context.Context) error

func (*ConfigMapControl) Upsert

func (c *ConfigMapControl) Upsert(ctx context.Context) error

type CustomResourceDefinitionConfig

type CustomResourceDefinitionConfig struct {
	// CustomResourceDefinition is already parsed daemon set, will be used if present
	*apiextensions.CustomResourceDefinition
	// Client is k8s client
	Client *apiextensionsclientset.Clientset
}

CustomResourceDefinitionConfig is a CustomResourceDefinition control configuration

type CustomResourceDefinitionControl

type CustomResourceDefinitionControl struct {
	CustomResourceDefinitionConfig
	*log.Entry
}

CustomResourceDefinitionControl is a daemon set controller, adds various operations, like delete, status check and update

func NewCustomResourceDefinitionControl

func NewCustomResourceDefinitionControl(
	config CustomResourceDefinitionConfig) (*CustomResourceDefinitionControl, error)

NewCustomResourceDefinitionControl returns new instance of CustomResourceDefinition updater

func (*CustomResourceDefinitionControl) Delete

func (c *CustomResourceDefinitionControl) Delete(ctx context.Context, cascade bool) error

func (*CustomResourceDefinitionControl) Status

func (*CustomResourceDefinitionControl) Upsert

type DSConfig

type DSConfig struct {
	// DaemonSet specifies the existing resource
	*appsv1.DaemonSet
	// Client is k8s client
	Client *kubernetes.Clientset
}

DSConfig is a DaemonSet control configuration

type DSControl

type DSControl struct {
	DSConfig
	log.FieldLogger
}

DSControl is a daemon set controller, adds various operations, like delete, status check and update

func NewDaemonSetControl

func NewDaemonSetControl(config DSConfig) (*DSControl, error)

NewDaemonSetControl returns new instance of DaemonSet controller

func (*DSControl) Delete

func (c *DSControl) Delete(ctx context.Context, cascade bool) error

func (*DSControl) Status

func (c *DSControl) Status(ctx context.Context) error

func (*DSControl) Upsert

func (c *DSControl) Upsert(ctx context.Context) error

type DeploymentConfig

type DeploymentConfig struct {
	// Deployment specifies the existing deployment
	*appsv1.Deployment
	// Client is k8s client
	Client *kubernetes.Clientset
}

DeploymentConfig is a Deployment control configuration

type DeploymentControl

type DeploymentControl struct {
	DeploymentConfig
	log.FieldLogger
}

DeploymentControl is a deployment controller, adds various operations, like delete, status check and update

func NewDeploymentControl

func NewDeploymentControl(config DeploymentConfig) (*DeploymentControl, error)

NewDeploymentControl returns new instance of Deployment updater

func (*DeploymentControl) Delete

func (c *DeploymentControl) Delete(ctx context.Context, cascade bool) error

func (*DeploymentControl) Status

func (c *DeploymentControl) Status(ctx context.Context) error

func (*DeploymentControl) Upsert

func (c *DeploymentControl) Upsert(ctx context.Context) error

type Job

type Job struct {
	Status JobStatus
}

type JobConfig

type JobConfig struct {
	*batchv1.Job
	*kubernetes.Clientset
}

type JobControl

type JobControl struct {
	JobConfig
	log.FieldLogger
}

func NewJobControl

func NewJobControl(config JobConfig) (*JobControl, error)

func (*JobControl) Delete

func (c *JobControl) Delete(ctx context.Context, cascade bool) error

func (*JobControl) Status

func (c *JobControl) Status(ctx context.Context) error

func (*JobControl) Upsert

func (c *JobControl) Upsert(ctx context.Context) error

type JobStatus

type JobStatus struct {
	Succeeded int
	Active    int
}

type Metadata

type Metadata struct {
	Name   string
	Labels map[string]string
}

type MutatingWebhookConfigurationConfig

type MutatingWebhookConfigurationConfig struct {
	*admissionregistrationv1.MutatingWebhookConfiguration
	Client *kubernetes.Clientset
}

MutatingWebhookConfigurationConfig is the control configuration.

func (*MutatingWebhookConfigurationConfig) CheckAndSetDefaults

func (c *MutatingWebhookConfigurationConfig) CheckAndSetDefaults() error

CheckAndSetDefauls validates the config and sets defaults.

type MutatingWebhookConfigurationControl

type MutatingWebhookConfigurationControl struct {
	MutatingWebhookConfigurationConfig
	log.FieldLogger
}

MutatingWebhookConfigurationControl is the control service for MutatingWebhookConfiguration resources.

func NewMutatingWebhookConfigurationControl

func NewMutatingWebhookConfigurationControl(config MutatingWebhookConfigurationConfig) (*MutatingWebhookConfigurationControl, error)

NewMutatingWebhookConfigurationControl creates control service for MutatingWebhookConfiguration resouces.

func (*MutatingWebhookConfigurationControl) Delete

Delete deletes the resource.

func (*MutatingWebhookConfigurationControl) Status

Status checks whether the resource exists.

func (*MutatingWebhookConfigurationControl) Upsert

Upsert creates or updates the resource.

type NamespaceConfig

type NamespaceConfig struct {
	// Namespace is already parsed daemon set, will be used if present
	*v1.Namespace
	// Client is k8s client
	Client *kubernetes.Clientset
}

NamespaceConfig is a Namespace control configuration

type NamespaceControl

type NamespaceControl struct {
	NamespaceConfig
	*log.Entry
}

NamespaceControl is a daemon set controller, adds various operations, like delete, status check and update

func NewNamespaceControl

func NewNamespaceControl(
	config NamespaceConfig) (*NamespaceControl, error)

NewNamespaceControl returns new instance of Namespace updater

func (*NamespaceControl) Delete

func (c *NamespaceControl) Delete(ctx context.Context, cascade bool) error

func (*NamespaceControl) Status

func (c *NamespaceControl) Status(ctx context.Context) error

func (*NamespaceControl) Upsert

func (c *NamespaceControl) Upsert(ctx context.Context) error

type Node

type Node struct {
	Metadata Metadata
}

type NodeList

type NodeList struct {
	Items []Node
}

func GetAllNodes

func GetAllNodes() (*NodeList, error)

func NodesMatchingLabel

func NodesMatchingLabel(labelQuery string) (*NodeList, error)

type OperationInfo

type OperationInfo struct {
	From *ResourceHeader
	To   *ResourceHeader
}

func GetOperationInfo

func GetOperationInfo(item ChangesetItem) (*OperationInfo, error)

GetOperationInfo returns operation information

func (*OperationInfo) Kind

func (o *OperationInfo) Kind() string

func (*OperationInfo) String

func (o *OperationInfo) String() string

type Pod

type Pod struct {
	Status PodStatus
}

type PodCondition

type PodCondition struct {
	Type   string
	Status string
}

type PodList

type PodList struct {
	Items []Pod
}

func GetRCPods

func GetRCPods(name string) (*PodList, error)

type PodSecurityPolicyConfig

type PodSecurityPolicyConfig struct {
	// PodSecurityPolicy is the existing pod security policy
	*v1beta1.PodSecurityPolicy
	// Client is k8s client
	Client *kubernetes.Clientset
}

PodSecurityPolicyConfig defines controller configuration

func (*PodSecurityPolicyConfig) CheckAndSetDefaults

func (c *PodSecurityPolicyConfig) CheckAndSetDefaults() error

type PodSecurityPolicyControl

type PodSecurityPolicyControl struct {
	PodSecurityPolicyConfig
	log.FieldLogger
}

PodSecurityPolicyControl is a pod security policy controller, adds various operations, like delete, status check and update

func NewPodSecurityPolicyControl

func NewPodSecurityPolicyControl(config PodSecurityPolicyConfig) (*PodSecurityPolicyControl, error)

NewPodSecurityPolicyControl returns a new instance of the PodSecurityPolicy controller

func (*PodSecurityPolicyControl) Delete

func (c *PodSecurityPolicyControl) Delete(ctx context.Context, cascade bool) error

func (*PodSecurityPolicyControl) Status

func (*PodSecurityPolicyControl) Upsert

type PodStatus

type PodStatus struct {
	Phase      string
	Conditions []PodCondition
}

type PriorityClassConfig

type PriorityClassConfig struct {
	// PriorityClass is already parsed daemon set, will be used if present
	*v1beta1.PriorityClass
	// Client is k8s client
	Client *kubernetes.Clientset
}

PriorityClassConfig is a PriorityClass control configuration

type PriorityClassControl

type PriorityClassControl struct {
	PriorityClassConfig
	*log.Entry
}

PriorityClassControl is a daemon set controller, adds various operations, like delete, status check and update

func NewPriorityClassControl

func NewPriorityClassControl(
	config PriorityClassConfig) (*PriorityClassControl, error)

NewPriorityClassControl returns new instance of PriorityClass updater

func (*PriorityClassControl) Delete

func (c *PriorityClassControl) Delete(ctx context.Context, cascade bool) error

func (*PriorityClassControl) Status

func (c *PriorityClassControl) Status(ctx context.Context) error

func (*PriorityClassControl) Upsert

func (c *PriorityClassControl) Upsert(ctx context.Context) error

type PrometheusConfig

type PrometheusConfig struct {
	// Prometheus is the parsed Prometheus resource
	*monitoringv1.Prometheus
	// Client is monitoring API client
	Client *monitoring.Clientset
}

PrometheusConfig is a Prometheus control configuration

func (*PrometheusConfig) CheckAndSetDefaults

func (c *PrometheusConfig) CheckAndSetDefaults() error

CheckAndSetDefaults validates the config

type PrometheusControl

type PrometheusControl struct {
	PrometheusConfig
	log.FieldLogger
}

PrometheusControl a controller for Prometheus resources

func NewPrometheusControl

func NewPrometheusControl(config PrometheusConfig) (*PrometheusControl, error)

NewPrometheusControl returns new instance of Prometheus updater

func (*PrometheusControl) Delete

func (c *PrometheusControl) Delete(ctx context.Context, cascade bool) error

func (*PrometheusControl) Status

func (c *PrometheusControl) Status(ctx context.Context) error

func (*PrometheusControl) Upsert

func (c *PrometheusControl) Upsert(ctx context.Context) error

type PrometheusRuleConfig

type PrometheusRuleConfig struct {
	// PrometheusRule is the parsed PrometheusRule resource
	*monitoringv1.PrometheusRule
	// Client is monitoring API client
	Client *monitoring.Clientset
}

PrometheusRuleConfig is a PrometheusRule control configuration

func (*PrometheusRuleConfig) CheckAndSetDefaults

func (c *PrometheusRuleConfig) CheckAndSetDefaults() error

CheckAndSetDefaults validates the config

type PrometheusRuleControl

type PrometheusRuleControl struct {
	PrometheusRuleConfig
	log.FieldLogger
}

PrometheusRuleControl a controller for PrometheusRule resources

func NewPrometheusRuleControl

func NewPrometheusRuleControl(config PrometheusRuleConfig) (*PrometheusRuleControl, error)

NewPrometheusRuleControl returns new instance of PrometheusRule updater

func (*PrometheusRuleControl) Delete

func (c *PrometheusRuleControl) Delete(ctx context.Context, cascade bool) error

func (*PrometheusRuleControl) Status

func (c *PrometheusRuleControl) Status(ctx context.Context) error

func (*PrometheusRuleControl) Upsert

func (c *PrometheusRuleControl) Upsert(ctx context.Context) error

type RCConfig

type RCConfig struct {
	// ReplicationController specifies the existing ReplicationController
	*v1.ReplicationController
	// Client is k8s client
	Client *kubernetes.Clientset
}

RCConfig is a ReplicationController control configuration

type RCControl

type RCControl struct {
	RCConfig
	log.FieldLogger
}

RCControl is a daemon set controller, adds various operations, like delete, status check and update

func NewReplicationControllerControl

func NewReplicationControllerControl(config RCConfig) (*RCControl, error)

NewReplicationControllerControl returns new instance of ReplicationController control

func (*RCControl) Delete

func (c *RCControl) Delete(ctx context.Context, cascade bool) error

func (*RCControl) Status

func (c *RCControl) Status(ctx context.Context) error

func (*RCControl) Upsert

func (c *RCControl) Upsert(ctx context.Context) error

type Ref

type Ref struct {
	Kind string
	Name string
}

Ref is a resource refernece

func ParseRef

func ParseRef(ref string) (*Ref, error)

ParseRef parses resource reference eg daemonsets/ds1

func (*Ref) IsEmtpy

func (r *Ref) IsEmtpy() bool

func (*Ref) Set

func (r *Ref) Set(v string) error

func (*Ref) String

func (r *Ref) String() string

type ReplicationController

type ReplicationController struct {
	Status ReplicationControllerStatus
}

func GetReplicationController

func GetReplicationController(name string) (*ReplicationController, error)

type ReplicationControllerStatus

type ReplicationControllerStatus struct {
	Replicas             int
	FullyLabeledReplicas int
	ObservedGeneration   int
}

type ResourceHeader

type ResourceHeader struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`
}

func ParseResourceHeader

func ParseResourceHeader(reader io.Reader) (*ResourceHeader, error)

ParseResourceHeader parses resource header information

type RoleBindingConfig

type RoleBindingConfig struct {
	// RoleBinding is the existing role binding
	*v1.RoleBinding
	// Client is k8s client
	Client *kubernetes.Clientset
}

RoleBindingConfig defines controller configuration

type RoleBindingControl

type RoleBindingControl struct {
	RoleBindingConfig
	log.FieldLogger
}

RoleBindingControl is a role bindings controller, adds various operations, like delete, status check and update

func NewRoleBindingControl

func NewRoleBindingControl(config RoleBindingConfig) (*RoleBindingControl, error)

NewRoleBindingControl returns a new instance of the RoleBinding controller

func (*RoleBindingControl) Delete

func (c *RoleBindingControl) Delete(ctx context.Context, cascade bool) error

func (*RoleBindingControl) Status

func (c *RoleBindingControl) Status(ctx context.Context) error

func (*RoleBindingControl) Upsert

func (c *RoleBindingControl) Upsert(ctx context.Context) error

type RoleConfig

type RoleConfig struct {
	// Role is the existing role
	*v1.Role
	// Client is k8s client
	Client *kubernetes.Clientset
}

RoleConfig defines controller configuration

type RoleControl

type RoleControl struct {
	RoleConfig
	log.FieldLogger
}

RoleControl is a roles controller, adds various operations, like delete, status check and update

func NewRoleControl

func NewRoleControl(config RoleConfig) (*RoleControl, error)

NewRoleControl returns a new instance of the Role controller

func (*RoleControl) Delete

func (c *RoleControl) Delete(ctx context.Context, cascade bool) error

func (*RoleControl) Status

func (c *RoleControl) Status(ctx context.Context) error

func (*RoleControl) Upsert

func (c *RoleControl) Upsert(ctx context.Context) error

type SecretConfig

type SecretConfig struct {
	// Secret specifies the existing secret
	*v1.Secret
	// Client is k8s client
	Client *kubernetes.Clientset
}

SecretConfig is a Secret control configuration

type SecretControl

type SecretControl struct {
	SecretConfig
	log.FieldLogger
}

SecretControl is a daemon set controller, adds various operations, like delete, status check and update

func NewSecretControl

func NewSecretControl(config SecretConfig) (*SecretControl, error)

NewSecretControl returns new instance of Secret updater

func (*SecretControl) Delete

func (c *SecretControl) Delete(ctx context.Context, cascade bool) error

func (*SecretControl) Status

func (c *SecretControl) Status(ctx context.Context) error

func (*SecretControl) Upsert

func (c *SecretControl) Upsert(ctx context.Context) error

type ServiceAccountConfig

type ServiceAccountConfig struct {
	// ServiceAccount is the existing service account
	*v1.ServiceAccount
	// Client is k8s client
	Client *kubernetes.Clientset
}

ServiceAccountConfig defines controller configuration

type ServiceAccountControl

type ServiceAccountControl struct {
	ServiceAccountConfig
	log.FieldLogger
}

ServiceAccountControl is a service accounts controller, adds various operations, like delete, status check and update

func NewServiceAccountControl

func NewServiceAccountControl(config ServiceAccountConfig) (*ServiceAccountControl, error)

NewServiceAccountControl returns a new instance of the ServiceAccount controller

func (*ServiceAccountControl) Delete

func (c *ServiceAccountControl) Delete(ctx context.Context, cascade bool) error

func (*ServiceAccountControl) Status

func (c *ServiceAccountControl) Status(ctx context.Context) error

func (*ServiceAccountControl) Upsert

func (c *ServiceAccountControl) Upsert(ctx context.Context) error

type ServiceConfig

type ServiceConfig struct {
	// Service specifies the existing service
	*v1.Service
	// Client is k8s client
	Client *kubernetes.Clientset
}

ServiceConfig is a Service control configuration

func (*ServiceConfig) CheckAndSetDefaults

func (c *ServiceConfig) CheckAndSetDefaults() error

type ServiceControl

type ServiceControl struct {
	ServiceConfig
	log.FieldLogger
}

ServiceControl is a daemon set controller, adds various operations, like delete, status check and update

func NewServiceControl

func NewServiceControl(config ServiceConfig) (*ServiceControl, error)

NewServiceControl returns new instance of Service updater

func (*ServiceControl) Delete

func (c *ServiceControl) Delete(ctx context.Context, cascade bool) error

func (*ServiceControl) Status

func (c *ServiceControl) Status(ctx context.Context) error

func (*ServiceControl) Upsert

func (c *ServiceControl) Upsert(ctx context.Context) error

type ServiceMonitorConfig

type ServiceMonitorConfig struct {
	// ServiceMonitor is the parsed ServiceMonitor resource
	*monitoringv1.ServiceMonitor
	// Client is monitoring API client
	Client *monitoring.Clientset
}

ServiceMonitorConfig is a ServiceMonitor control configuration

func (*ServiceMonitorConfig) CheckAndSetDefaults

func (c *ServiceMonitorConfig) CheckAndSetDefaults() error

CheckAndSetDefaults validates the config

type ServiceMonitorControl

type ServiceMonitorControl struct {
	ServiceMonitorConfig
	log.FieldLogger
}

ServiceMonitorControl a controller for ServiceMonitor resources

func NewServiceMonitorControl

func NewServiceMonitorControl(config ServiceMonitorConfig) (*ServiceMonitorControl, error)

NewServiceMonitorControl returns new instance of ServiceMonitor updater

func (*ServiceMonitorControl) Delete

func (c *ServiceMonitorControl) Delete(ctx context.Context, cascade bool) error

func (*ServiceMonitorControl) Status

func (c *ServiceMonitorControl) Status(ctx context.Context) error

func (*ServiceMonitorControl) Upsert

func (c *ServiceMonitorControl) Upsert(ctx context.Context) error

type StatefulSetConfig

type StatefulSetConfig struct {
	// StatefulSet is already parsed statefulset
	*appsv1.StatefulSet
	// Client is k8s client
	Client *kubernetes.Clientset
}

StatefulSetConfig is a StatefulSet control configuration

type StatefulSetControl

type StatefulSetControl struct {
	StatefulSetConfig
	log.FieldLogger
}

StatefulSetControl is a statefulset controller, adds various operations, like delete, status check and update

func NewStatefulSetControl

func NewStatefulSetControl(config StatefulSetConfig) (*StatefulSetControl, error)

NewStatefulSetControl returns new instance of the StatefulSet controller

func (*StatefulSetControl) Delete

func (c *StatefulSetControl) Delete(ctx context.Context, cascade bool) error

Delete deletes this statefulset resource

func (*StatefulSetControl) Status

func (c *StatefulSetControl) Status(ctx context.Context) error

Status returns status of pods for this resource

func (*StatefulSetControl) Upsert

func (c *StatefulSetControl) Upsert(ctx context.Context) error

Upsert creates or updates a statefulset resource

type StatusReporter

type StatusReporter interface {
	// Status returns the state of the resource.
	// Returns nil if successful (created/deleted/updated), otherwise an error
	Status(ctx context.Context) error
	// Infof logs the specified message and arguments in context of this resource
	Infof(message string, args ...interface{})
}

StatusReporter reports the status of the resource.

type ValidatingWebhookConfigurationConfig

type ValidatingWebhookConfigurationConfig struct {
	*admissionregistrationv1.ValidatingWebhookConfiguration
	Client *kubernetes.Clientset
}

ValidatingWebhookConfigurationConfig is the control configuration.

func (*ValidatingWebhookConfigurationConfig) CheckAndSetDefaults

func (c *ValidatingWebhookConfigurationConfig) CheckAndSetDefaults() error

CheckAndSetDefauls validates the config and sets defaults.

type ValidatingWebhookConfigurationControl

type ValidatingWebhookConfigurationControl struct {
	ValidatingWebhookConfigurationConfig
	log.FieldLogger
}

ValidatingWebhookConfigurationControl is the control service for ValidatingWebhookConfiguration resources.

func NewValidatingWebhookConfigurationControl

func NewValidatingWebhookConfigurationControl(config ValidatingWebhookConfigurationConfig) (*ValidatingWebhookConfigurationControl, error)

NewValidatingWebhookConfigurationControl creates control service for ValidatingWebhookConfiguration resouces.

func (*ValidatingWebhookConfigurationControl) Delete

Delete deletes the resource.

func (*ValidatingWebhookConfigurationControl) Status

Status checks whether the resource exists.

func (*ValidatingWebhookConfigurationControl) Upsert

Upsert creates or updates the resource.

Directories

Path Synopsis
tool
rig

Jump to

Keyboard shortcuts

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