Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Active job meets kubernetes

Active job meets kubernetes

Kubernetes Meetup Osaka #1でのLT資料です

Yasutomo Uemori

September 24, 2019
Tweet

More Decks by Yasutomo Uemori

Other Decks in Programming

Transcript

  1. me.inspect => { “HN”: "wakaba260", “name”: "Yasutomo Uemori", “company”: "株式会社Aiming",

    “twitter”: "https://twitter.com/wakaba260yen", “github”: "https://github.com/yuemori", “skills”: ["rails api", "docker", "kubernetes", "GCP"] }
  2. ActiveJobの使用例 class GuestsCleanupJob < ApplicationJob queue_as :default def perform(*args) #

    後で実行したい作業をここに書く end end # 「キューイングシステムが空いたらジョブを実行する」とキューに登録する guest = Guest.find(guest_id) GuestsCleanupJob.perform_later(guest)
  3. # app/jobs/print_message_job.rb class PrintMessageJob < ApplicationJob include KubeQueue::Worker worker_name 'print-message-job'

    image "your-registry/your-image" container_name 'your-container-name' def perform(payload) logger.info payload[:message] end end PrintMessageJob.perform_later(message: ‘hello!’)
  4. class ComputePiJob < ApplicationJob include KubeQueue::Worker worker_name 'pi' image 'perl'

    container_name 'pi' command "perl","-Mbignum=bpi","-wle","print bpi(2000)" cpu_limit '0.3' cpu_request '0.2' memory_limit '100m' memory_request '50m' end