Class: Kube::Cluster::Standard::CronJobWithServiceAccount
- Inherits:
-
Manifest
- Object
- Schema::Manifest
- Manifest
- Kube::Cluster::Standard::CronJobWithServiceAccount
- Defined in:
- lib/kube/cluster/standard/cron_job_with_service_account.rb
Overview
A CronJob plus the ServiceAccount/Role/RoleBinding it runs as, bundled into one Manifest. The RBAC rules use the Role shorthand; the CronJob’s serviceAccountName is wired to the generated ServiceAccount. Everything is named after name.
CronJobWithServiceAccount.new(
name: "glauth-config-builder",
image: "nixery.dev/shell/ruby/kubectl/cacert",
schedule: "*/5 * * * *",
rules: [
"secrets" => %w[get list],
"batch/jobs" => %w[create],
],
command: RubyScript(<<~'BUILD'),
...
BUILD
)
Instance Attribute Summary
Attributes inherited from Manifest
Instance Method Summary collapse
-
#initialize(name:, image:, schedule:, rules:, env: {}, command: nil, backoff_limit: 3, ttl: 300, concurrency_policy: "Forbid", &block) ⇒ CronJobWithServiceAccount
constructor
A new instance of CronJobWithServiceAccount.
Methods inherited from Manifest
Constructor Details
#initialize(name:, image:, schedule:, rules:, env: {}, command: nil, backoff_limit: 3, ttl: 300, concurrency_policy: "Forbid", &block) ⇒ CronJobWithServiceAccount
Returns a new instance of CronJobWithServiceAccount.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/kube/cluster/standard/cron_job_with_service_account.rb', line 28 def initialize(name:, image:, schedule:, rules:, env: {}, command: nil, backoff_limit: 3, ttl: 300, concurrency_policy: "Forbid", &block) service_account_with_role = Kube::Cluster::Standard::ServiceAccountWithRole.new( service_account: Kube::Cluster::Standard::ServiceAccount.new(name: name), role: Kube::Cluster::Standard::Role.new(rules: rules), ) cron_job = Kube::Cluster::Standard::CronJob.new( name: name, image: image, schedule: schedule, env: env, command: command, backoff_limit: backoff_limit, ttl: ttl, concurrency_policy: concurrency_policy, ) do spec.jobTemplate.spec.template.spec.serviceAccountName = name end super(*service_account_with_role.to_a, cron_job) instance_exec(&block) if block end |