Documentation ¶
Index ¶
- Variables
- func FullName(typ, namespace, name string) string
- func MetaConfigFromConfigMap(cm *v1.ConfigMap) interfaces.MetaConfig
- func MetaConfigFromSecret(s *v1.Secret) interfaces.MetaConfig
- func MetaDeploymentFromDeployment(deployment *appsv1.Deployment) interfaces.MetaDeployment
- func MetaDeploymentFromStatefulSet(statefulSet *appsv1.StatefulSet) interfaces.MetaDeployment
- func NewConfigAgent(k8sClient kubernetes.Interface, ...) interfaces.ConfigAgent
- type Change
- type Config
- type Deployment
- type DeploymentConfigController
- type RealConfigAgent
Constants ¶
This section is empty.
Variables ¶
var ( // ResourceVersionsTotal exposes the total number of resource versions observed ResourceVersionsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: "deployment_restart_controller", Name: "resource_versions_total", Help: "The total number of distinct resource versions observed.", }, []string{}) // ConfigsTotal exposes the total number of tracked configs ConfigsTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: "deployment_restart_controller", Name: "configs_total", Help: "The total number of tracked configs.", }, []string{}) // DeploymentsTotal exposes the total number of tracked deployments DeploymentsTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: "deployment_restart_controller", Name: "deployments_total", Help: "The total number of tracked deployments.", }, []string{}) // DeploymentAnnotationUpdatesTotal exposes the total number of deployment annotation updates DeploymentAnnotationUpdatesTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: "deployment_restart_controller", Name: "deployment_annotation_updates_total", Help: "The total number of deployment annotation updates.", }, []string{}) // DeploymentRestartsTotal exposes the total number of deployment restarts triggered DeploymentRestartsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: "deployment_restart_controller", Name: "deployment_restarts_total", Help: "The total number of deployment restarts triggered.", }, []string{}) // ChangesProcessedTotal exposes the total number of resource changes processed ChangesProcessedTotal = prometheus.NewCounterVec(prometheus.CounterOpts{ Namespace: "deployment_restart_controller", Name: "changes_processed_total", Help: "The total number of resource changes processed.", }, []string{}) // ChangesWaitingTotal exposes the total number of changes waiting to be processed ChangesWaitingTotal = prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: "deployment_restart_controller", Name: "changes_waiting_total", Help: "The total number of changes waiting to be processed.", }, []string{}) )
Functions ¶
func MetaConfigFromConfigMap ¶
func MetaConfigFromConfigMap(cm *v1.ConfigMap) interfaces.MetaConfig
MetaConfigFromConfigMap converts a ConfigMap into MetaConfig
func MetaConfigFromSecret ¶
func MetaConfigFromSecret(s *v1.Secret) interfaces.MetaConfig
MetaConfigFromSecret converts a Secret into MetaConfig
func MetaDeploymentFromDeployment ¶
func MetaDeploymentFromDeployment(deployment *appsv1.Deployment) interfaces.MetaDeployment
MetaDeploymentFromDeployment instantiates a meta deployment from a k8s Deployment
func MetaDeploymentFromStatefulSet ¶
func MetaDeploymentFromStatefulSet(statefulSet *appsv1.StatefulSet) interfaces.MetaDeployment
MetaDeploymentFromStatefulSet instantiates a meta deployment from a k8s StatefulSet
func NewConfigAgent ¶
func NewConfigAgent(k8sClient kubernetes.Interface, restartCheckPeriod, restartGracePeriod time.Duration, ignoredErrors []string) interfaces.ConfigAgent
NewConfigAgent creates a new real instance of interfaces.ConfigAgent
Types ¶
type Change ¶
type Change struct { Observations int // contains filtered or unexported fields }
Change stores a timestamp when the change was observed and the number of observations
type Config ¶
type Config struct { Deployments map[string]*Deployment // contains filtered or unexported fields }
Config represents a config instance and a map of deployments referencing it
func NewConfig ¶
func NewConfig(meta interfaces.MetaConfig) *Config
NewConfig returns a Config with an initialized checksum and empty deployments map
func NewPendingConfig ¶
func NewPendingConfig() *Config
NewPendingConfig returns a pending config with empty deployments map
func (*Config) Checksum ¶
Checksum returns the checksum or an empty string if the checksum is not set
func (*Config) Unused ¶
Unused returns true if the config is not used by any deployment and does not have a checksum
func (*Config) UpdateFromMeta ¶
func (c *Config) UpdateFromMeta(meta interfaces.MetaConfig) bool
UpdateFromMeta copies the checksum from a given MetaConfig. Returns true if the new checksum if different from the old one
type Deployment ¶
type Deployment struct { Configs map[string]*Config AppliedChecksums map[string]string // contains filtered or unexported fields }
Deployment stores a MetaDeployment instance and a map of configs referenced by it
func NewDeployment ¶
func NewDeployment(meta interfaces.MetaDeployment) *Deployment
NewDeployment creates a new deployment with a bound MetaDeployment object
func (*Deployment) NeedsUpdate ¶
func (d *Deployment) NeedsUpdate() bool
NeedsUpdate returns true if underlying k8s resource needs an update according to the current known state of config checksums and related configs
func (*Deployment) SaveChecksums ¶
func (d *Deployment) SaveChecksums(c interfaces.K8sClient, restart bool) error
SaveChecksums saves config checksums stored in the deployment instance as annotations on the k8s resource, optionally triggering a restart
func (*Deployment) UpdateFromMeta ¶
func (d *Deployment) UpdateFromMeta(meta interfaces.MetaDeployment) bool
UpdateFromMeta replaces the underlying MetaDeployment object and populates AppliedChecksums. Returns true if referenced configs or config checksums changed, otherwise returns false
type DeploymentConfigController ¶
type DeploymentConfigController struct { Stop chan struct{} // contains filtered or unexported fields }
DeploymentConfigController updates an annotation on Deployment-like resources once related ConfigMap-like objects change. This causes the Deployment to restart its Pods.
func NewDeploymentConfigController ¶
func NewDeploymentConfigController(restartCheckPeriod time.Duration, restartGracePeriod time.Duration, ignoredErrors []string) *DeploymentConfigController
NewDeploymentConfigController creates a new instance of DeploymentConfigController
func (*DeploymentConfigController) Run ¶
func (c *DeploymentConfigController) Run() (err error)
Run starts the controller loop
type RealConfigAgent ¶
type RealConfigAgent struct {
// contains filtered or unexported fields
}
RealConfigAgent implements interfaces.ConfigAgent
func (*RealConfigAgent) ResourceDeleted ¶
func (c *RealConfigAgent) ResourceDeleted(res interfaces.MetaResource)
ResourceDeleted tracks k8s resource deletions to allow cleanups of internal state
func (*RealConfigAgent) ResourceUpdated ¶
func (c *RealConfigAgent) ResourceUpdated(res interfaces.MetaResource)
ResourceUpdated tracks k8s resource updates and additions
func (*RealConfigAgent) Start ¶
func (c *RealConfigAgent) Start(stopWithErrorCh chan struct{})
Start the agent as a goroutine