Skip to content

Commit

Permalink
Set the service account for the automation worker
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunne authored and agrare committed Sep 27, 2023
1 parent 6c8e7a6 commit 5d1816b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/automation_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ class AutomationWorker < MiqQueueWorkerBase
def self.kill_priority
MiqWorkerType::KILL_PRIORITY_GENERIC_WORKERS
end

def configure_worker_deployment(definition, replicas = 0)
super

definition[:spec][:template][:spec][:serviceAccountName] = "manageiq-automation"
end
end
35 changes: 35 additions & 0 deletions spec/models/automation_worker_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
RSpec.describe AutomationWorker do
describe "kubernetes worker deployment" do
let(:test_deployment) do
{
:metadata => {
:name => "test",
:labels => {:app => "manageiq"},
:namespace => "manageiq",
},
:spec => {
:selector => {:matchLabels => {:name => "test"}},
:template => {
:metadata => {:name => "test", :labels => {:name => "test", :app => "manageiq"}},
:spec => {
:containers => [{
:name => "test",
:env => []
}]
}
}
}
}
end

it "#configure_worker_deplyoment adds a node selector based on the zone name" do
EvmSpecHelper.local_miq_server

worker = described_class.new
worker.configure_worker_deployment(test_deployment)

expect(test_deployment.dig(:spec, :template, :spec, :nodeSelector)).to eq("manageiq/zone-#{MiqServer.my_zone}".gsub(" ", "-") => "true")
expect(test_deployment.dig(:spec, :template, :spec, :serviceAccountName)).to eq("manageiq-automation")
end
end
end

0 comments on commit 5d1816b

Please sign in to comment.