I have a Kubernetes operator that creates a new Deployment based upon the custom resource configuration. There are some error conditions that will cause a failure and the Deployment creation step is skipped. Is it possible to have the error text displayed on the command line?
At the moment I have:
err := validateSettings()
if err != nil {
// Log the error
logger.Error(err, "The Deployment settings are invalid")
// I also record the event in the custom object
r.recorder.Event(object, "Warning", "Failed", err.Error())
return reconcile.Result{}, err
}
When a user creates the custom object, the deployment is not created but the command line says that the custom object was created successfully.
# kubectl apply -f myobject.yaml
test.com/my-object created
The logs for the operator show the error and the a describe of the custom object show the event. I was hoping to have the event text displayed after the kubectl apply command.