-
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.
- Loading branch information
Showing
16 changed files
with
436 additions
and
415 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:feature | ||
`Image` - Add new annotation `kimup.cloudavenue.io/failure-policy` to control the failure policy of the image tag mutation. The default value is `Fail`. The supported values are `Fail` and `Ignore`. | ||
``` |
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,80 @@ | ||
--- | ||
hide: | ||
- toc | ||
--- | ||
|
||
# Failure Policy | ||
|
||
## Overview | ||
|
||
Kimup operator allows you to manage the behavior of the operator when it fails to apply the tag on a pod. The failure policy is defined by the annotation `kimup.cloudavenue.io/failure-policy` on the **namespace** or the **pod**. The failure policy can be set to `fail` or `ignore`. The default value is `fail`. | ||
|
||
!!! warning | ||
The annotation `kimup.cloudavenue.io/enabled` must be set to `true` on the namespace or the pod to apply the failure policy. If the annotation is not set, the failure policy will be ignored. See [Scope](../getting-started/scope.md) for more information. | ||
|
||
## Logical | ||
|
||
![Logical pod creation schema](../getting-started/logical-pod-creation-light.png#only-light) | ||
![Logical pod creation schema](../getting-started/logical-pod-creation-dark.png#only-dark) | ||
|
||
## Apply the failure policy | ||
|
||
When the annotation `kimup.cloudavenue.io/failure-policy: "fail"` is set on a namespace, the operator will fail if it can't apply the tag on a pod created in this namespace. | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: your-env | ||
annotations: | ||
kimup.cloudavenue.io/enabled: "true" | ||
kimup.cloudavenue.io/failure-policy: "fail" | ||
``` | ||
When the annotation `kimup.cloudavenue.io/failure-policy: "ignore"` is set on a namespace, the operator will ignore the failure if it can't apply the tag on a pod created in this namespace. | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: your-env | ||
annotations: | ||
kimup.cloudavenue.io/enabled: "true" | ||
kimup.cloudavenue.io/failure-policy: "ignore" | ||
``` | ||
|
||
For a pod, the same logic applies. | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: your-pod | ||
namespace: your-env | ||
annotations: | ||
kimup.cloudavenue.io/enabled: "true" | ||
kimup.cloudavenue.io/failure-policy: "fail" | ||
``` | ||
|
||
## Override the failure policy for a pod | ||
|
||
When the annotation `kimup.cloudavenue.io/failure-policy` is set on a namespace, the operator will apply the failure policy on all pods created in this namespace. If the annotation is set on a pod, the operator will apply the failure policy defined on the pod, but i will be necessary to set the annotation `kimup.cloudavenue.io/enabled` to `true` on the pod. | ||
|
||
```yaml | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: your-env | ||
annotations: | ||
kimup.cloudavenue.io/enabled: "true" | ||
kimup.cloudavenue.io/failure-policy: "fail" | ||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: your-pod | ||
namespace: your-env | ||
annotations: | ||
kimup.cloudavenue.io/enabled: "true" | ||
kimup.cloudavenue.io/failure-policy: "ignore" | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,64 @@ | ||
package annotations | ||
|
||
import "strings" | ||
|
||
// * Action | ||
|
||
type ( | ||
Action struct { | ||
aChan aChan | ||
value string | ||
} | ||
|
||
AActionKey string | ||
) | ||
|
||
const ( | ||
// Action Refresh | ||
ActionRefresh AActionKey = "refresh" | ||
|
||
// Action Reload | ||
ActionReload AActionKey = "reload" | ||
|
||
// Action Delete | ||
ActionDelete AActionKey = "delete" | ||
) | ||
|
||
func (a *Annotation) Action() (ac *Action) { | ||
ac = &Action{ | ||
aChan: make(aChan), | ||
} | ||
|
||
if v, ok := a.annotations[string(KeyAction)]; ok { | ||
ac.value = v | ||
} | ||
|
||
go func() { | ||
for { | ||
select { | ||
case x := <-ac.aChan: | ||
a.annotations[string(x.key)] = x.value | ||
case <-a.ctx.Done(): | ||
return | ||
} | ||
} | ||
}() | ||
|
||
return ac | ||
} | ||
|
||
func (a *Action) Is(action AActionKey) bool { | ||
return strings.EqualFold(a.value, string(action)) | ||
} | ||
|
||
func (a *Action) IsNull() bool { | ||
return a.value == "" | ||
} | ||
|
||
func (a *Action) Get() AActionKey { | ||
return AActionKey(a.value) | ||
} | ||
|
||
func (a *Action) Set(action AActionKey) { | ||
a.aChan.Send(KeyAction, string(action)) | ||
} |
Oops, something went wrong.