forked from kubernetes-sigs/kubebuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix kustomize syntax during conversion to patches
This commit fixes the syntax error introduced in kubernetes-sigs#3374 where pathcesStrategicMerge was replaced with patches, which now requires that every patch additionally have a "path" key when multiple patches are specified in a file. Signed-off-by: Michael Shen <[email protected]>
- Loading branch information
Showing
10 changed files
with
98 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Creating Events | ||
|
||
`Events` can be useful alongside a Custom Resource's status information as they can | ||
show users or administrators a record of previous states or occurrences of events in | ||
addition to the current state. In general, events should only be generated when it | ||
would be useful for a user or administrator to know about it - it is not generally | ||
good practice to emit events for all operations. | ||
|
||
Refer to [Kubernetes API Conventions](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#events) | ||
for more best practices and details about events. | ||
|
||
|
||
## Implementing Events | ||
|
||
First, add an event recorder to your reconciler struct: | ||
|
||
```go | ||
import "k8s.io/client-go/tools/record" | ||
|
||
type CronJobReconciler struct { | ||
client.Client | ||
Scheme *runtime.Scheme | ||
Recorder record.EventRecorder | ||
} | ||
``` | ||
|
||
Setup in main.go with | ||
|
||
```go | ||
if *ctrlConfig.EnableVpcEndpointController { | ||
setupLog.Info("starting controller", "controller", vpcendpoint.ControllerName) | ||
if err = (&vpcendpoint.VpcEndpointReconciler{ | ||
Client: mgr.GetClient(), | ||
Scheme: mgr.GetScheme(), | ||
Recorder: mgr.GetEventRecorderFor(vpcendpoint.ControllerName), | ||
}).SetupWithManager(mgr); err != nil { | ||
setupLog.Error(err, "unable to create controller", "controller", vpcendpoint.ControllerName) | ||
os.Exit(1) | ||
} | ||
} | ||
``` | ||
|
||
Highlights: | ||
- If the object is not being deleted and does not have the finalizer registered, | ||
then add the finalizer and update the object in Kubernetes. | ||
- If object is being deleted and the finalizer is still present in finalizers list, | ||
then execute the pre-delete logic and remove the finalizer and update the | ||
object. | ||
- Ensure that the pre-delete logic is idempotent. | ||
|
||
{{#literatego ../cronjob-tutorial/testdata/finalizer_example.go}} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters