Sha256: 5ca719cc11702ccd2d7bdb6bbfbeaa92ca7fba4752b239e0fe741661a6b81321

Contents?: true

Size: 1.93 KB

Versions: 16

Compression:

Stored size: 1.93 KB

Contents

module Pfab
  module Templates
    class Cron < Base
      def write_to(f)
        f << YAML.dump(job.deep_stringify_keys)
      end

      def job
        {
          apiVersion: "batch/v1beta1",
          kind: "CronJob",
          metadata: {
            name: "#{@data['deployed_name']}-#{@data['sha']}",
            namespace: @data['env'],
            labels: {
              application: @data['application'],
              "deployed-name" => @data['deployed_name'],
              "application-type" => "job",
            }
          },
          spec: {
            schedule: get("schedule"),
            successfulJobsHistoryLimit: 1,
            failedJobsHistoryLimit: 1,
            jobTemplate: {
              metadata: {
                name: "#{@data['deployed_name']}-#{@data['sha']}",
                namespace: @data['env'],
                labels: {
                  application: @data['application'],
                  "deployed-name" => @data['deployed_name'],
                  "application-type" => "cron",
                },
              },
              spec: {
                template: {
                  metadata: {
                    labels: {
                      application: @data['application'],
                      "deployed-name" => @data['deployed_name'],
                      "application-type" => "cron",
                    },
                  },
                  spec: {

                    containers: [
                      {
                        image: image_name,
                        name: @data['deployed_name'],
                        command: app_vars["command"].split(" "),
                        env: env_vars,
                        resources: resources,
                      },
                    ],
                    restartPolicy: "Never",
                  },
                },
                backoffLimit: 2,
              },
            },
          },
        }
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pfab-0.33.0 lib/pfab/templates/cron.rb
pfab-0.19.0 lib/pfab/templates/cron.rb
pfab-0.18.0 lib/pfab/templates/cron.rb
pfab-0.17.0 lib/pfab/templates/cron.rb
pfab-0.16.0 lib/pfab/templates/cron.rb
pfab-0.15.0 lib/pfab/templates/cron.rb
pfab-0.14.0 lib/pfab/templates/cron.rb
pfab-0.13.0 lib/pfab/templates/cron.rb
pfab-0.12.0 lib/pfab/templates/cron.rb
pfab-0.11.0 lib/pfab/templates/cron.rb
pfab-0.10.0 lib/pfab/templates/cron.rb
pfab-0.9.0 lib/pfab/templates/cron.rb
pfab-0.8.4 lib/pfab/templates/cron.rb
pfab-0.8.3 lib/pfab/templates/cron.rb
pfab-0.8.2 lib/pfab/templates/cron.rb
pfab-0.8.1 lib/pfab/templates/cron.rb