in pkg/controller/kibana/driver.go [98:206]
func (d *driver) Reconcile(
ctx context.Context,
state *State,
kb *kbv1.Kibana,
params operator.Parameters,
) *reconciler.Results {
results := reconciler.NewResult(ctx)
isEsAssocConfigured, err := association.IsConfiguredIfSet(ctx, kb.EsAssociation(), d.recorder)
if err != nil {
return results.WithError(err)
}
if !isEsAssocConfigured {
return results
}
isEntAssocConfigured, err := association.IsConfiguredIfSet(ctx, kb.EntAssociation(), d.recorder)
if err != nil {
return results.WithError(err)
}
if !isEntAssocConfigured {
return results
}
svc, err := common.ReconcileService(ctx, d.client, NewService(*kb), kb)
if err != nil {
// TODO: consider updating some status here?
return results.WithError(err)
}
_, results = certificates.Reconciler{
K8sClient: d.K8sClient(),
DynamicWatches: d.DynamicWatches(),
Owner: kb,
TLSOptions: kb.Spec.HTTP.TLS,
Namer: kbv1.KBNamer,
Labels: kb.GetIdentityLabels(),
Services: []corev1.Service{*svc},
GlobalCA: params.GlobalCA,
CACertRotation: params.CACertRotation,
CertRotation: params.CertRotation,
GarbageCollectSecrets: true,
}.ReconcileCAAndHTTPCerts(ctx)
if results.HasError() {
_, err := results.Aggregate()
k8s.MaybeEmitErrorEvent(d.Recorder(), err, kb, events.EventReconciliationError, "Certificate reconciliation error: %v", err)
return results
}
logger := ulog.FromContext(ctx)
assocAllowed, err := association.AllowVersion(d.version, kb, logger, d.Recorder())
if err != nil {
return results.WithError(err)
}
if !assocAllowed {
return results // will eventually retry
}
kibanaPolicyCfg, err := getPolicyConfig(ctx, d.client, *kb)
if err != nil {
return results.WithError(err)
}
kbSettings, err := NewConfigSettings(ctx, d.client, *kb, d.version, d.ipFamily, kibanaPolicyCfg.KibanaConfig)
if err != nil {
return results.WithError(err)
}
if err = ReconcileConfigSecret(ctx, d.client, *kb, kbSettings); err != nil {
return results.WithError(err)
}
basePath, err := GetKibanaBasePath(*kb)
if err != nil {
return results.WithError(err)
}
if err = stackmon.ReconcileConfigSecrets(ctx, d.client, *kb, basePath); err != nil {
return results.WithError(err)
}
if err = initcontainer.ReconcileScriptsConfigMap(ctx, d.client, *kb); err != nil {
return results.WithError(err)
}
span, _ := apm.StartSpan(ctx, "reconcile_deployment", tracing.SpanTypeApp)
defer span.End()
deploymentParams, err := d.deploymentParams(ctx, kb, kibanaPolicyCfg.PodAnnotations, basePath, params.SetDefaultSecurityContext)
if err != nil {
return results.WithError(err)
}
expectedDp := deployment.New(deploymentParams)
reconciledDp, err := deployment.Reconcile(ctx, d.client, expectedDp, kb)
if err != nil {
return results.WithError(err)
}
existingPods, err := k8s.PodsMatchingLabels(d.K8sClient(), kb.Namespace, map[string]string{kblabel.KibanaNameLabelName: kb.Name})
if err != nil {
return results.WithError(err)
}
deploymentStatus, err := common.DeploymentStatus(ctx, state.Kibana.Status.DeploymentStatus, reconciledDp, existingPods, kblabel.KibanaVersionLabelName)
if err != nil {
return results.WithError(err)
}
state.Kibana.Status.DeploymentStatus = deploymentStatus
return results
}