-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Stefan Prodan <[email protected]>
- Loading branch information
1 parent
c87bb6b
commit fe24b7e
Showing
7 changed files
with
117 additions
and
5 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
examples/minimal/cue.mod/pkg/timoni.sh/core/v1alpha1/action.cue
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,24 @@ | ||
// Copyright 2023 Stefan Prodan | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package v1alpha1 | ||
|
||
// Action holds a list of annotations for controlling | ||
// Timoni's apply behaviour of Kubernetes resources. | ||
action: { | ||
// Force annotation for recreating immutable resources such as Kubernetes Jobs. | ||
force: { | ||
"action.timoni.sh/force": enabled | ||
} | ||
// One-off annotation for appling resources only if they don't exist on the cluster. | ||
oneoff: { | ||
"action.timoni.sh/one-off": enabled | ||
} | ||
// Keep annotation for preventing Timoni's garbage collector from deleting resources. | ||
keep: { | ||
"action.timoni.sh/prune": disabled | ||
} | ||
} | ||
|
||
enabled: "enabled" | ||
disabled: "disabled" |
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,58 @@ | ||
package templates | ||
|
||
import ( | ||
"encoding/yaml" | ||
"uuid" | ||
|
||
corev1 "k8s.io/api/core/v1" | ||
batchv1 "k8s.io/api/batch/v1" | ||
timoniv1 "timoni.sh/core/v1alpha1" | ||
) | ||
|
||
#TestJob: batchv1.#Job & { | ||
_config: #Config | ||
apiVersion: "batch/v1" | ||
kind: "Job" | ||
metadata: name: "\(_config.metadata.name)-test" | ||
metadata: namespace: _config.metadata.namespace | ||
metadata: labels: _config.metadata.labels | ||
metadata: annotations: timoniv1.action.force | ||
spec: batchv1.#JobSpec & { | ||
template: corev1.#PodTemplateSpec & { | ||
metadata: labels: _config.metadata.labels | ||
let _checksum = uuid.SHA1(uuid.ns.DNS, yaml.Marshal(_config)) | ||
metadata: annotations: "timoni.sh/checksum": "\(_checksum)" | ||
spec: { | ||
containers: [{ | ||
name: "curl" | ||
image: _config.test.image.reference | ||
imagePullPolicy: _config.imagePullPolicy | ||
command: [ | ||
"curl", | ||
"-v", | ||
"-m", | ||
"5", | ||
"\(_config.metadata.name):\(_config.service.port)", | ||
] | ||
}] | ||
restartPolicy: "Never" | ||
} | ||
} | ||
backoffLimit: 1 | ||
if _config.podSecurityContext != _|_ { | ||
securityContext: _config.podSecurityContext | ||
} | ||
if _config.topologySpreadConstraints != _|_ { | ||
topologySpreadConstraints: _config.topologySpreadConstraints | ||
} | ||
if _config.affinity != _|_ { | ||
affinity: _config.affinity | ||
} | ||
if _config.tolerations != _|_ { | ||
tolerations: _config.tolerations | ||
} | ||
if _config.imagePullSecrets != _|_ { | ||
imagePullSecrets: _config.imagePullSecrets | ||
} | ||
} | ||
} |
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