Skip to content

Commit

Permalink
Add volume mounts for httpd configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunne committed Aug 23, 2021
1 parent 1ad1f72 commit 2cc0538
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/models/miq_worker/service_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ def create_container_objects
container[:env] << {:name => "PORT", :value => container_port.to_s}
container[:env] << {:name => "BINDING_ADDRESS", :value => "0.0.0.0"}
add_readiness_probe(container)
container[:volumeMounts] ||= []
definition[:spec][:template][:spec][:volumes] ||= []

if kind_of?(MiqUiWorker)
container[:volumeMounts] << {:name => "ui-httpd-configs", :mountPath => "/etc/httpd/conf.d"}
definition[:spec][:template][:spec][:volumes] << {:name=>"ui-httpd-configs", :configMap=>{:name=>"ui-httpd-configs", :defaultMode=>420}}
end
end

scale_deployment
Expand Down
18 changes: 18 additions & 0 deletions spec/models/miq_worker/container_common_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ def deployment_name_for(name)

expect(test_deployment.dig(:spec, :template, :spec).keys).not_to include(:nodeSelector)
end

it "MiqUiWorker adds the ui_httpd_configs volume mount" do
container_orchestrator = ContainerOrchestrator.new
kubeclient = double("Kubeclient::Client")

expect(ContainerOrchestrator).to receive(:new).and_return(container_orchestrator)
expect(container_orchestrator).to receive(:my_namespace).and_return("my-namespace")
expect(container_orchestrator).to receive(:raw_connect).and_return(kubeclient)

expect(kubeclient).to receive(:create_deployment) do |deployment|
expect(deployment.fetch_path(:spec, :template, :spec, :containers, 0, :volumeMounts)).to match_array([{:name => "ui-httpd-configs", :mountPath => "/etc/httpd/conf.d"}])
expect(deployment.fetch_path(:spec, :template, :spec, :volumes)).to match_array([{:name=>"ui-httpd-configs", :configMap=>{:name=>"ui-httpd-configs", :defaultMode=>420}}])
end

ui_worker = MiqUiWorker.new
expect(ui_worker).to receive(:scale_deployment)
ui_worker.create_container_objects
end
end

describe "#zone_selector" do
Expand Down

0 comments on commit 2cc0538

Please sign in to comment.