Skip to content

Commit

Permalink
Configure minio load balancer
Browse files Browse the repository at this point in the history
  • Loading branch information
malvads committed Jun 3, 2024
1 parent 832ddb4 commit 0e5d307
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
4 changes: 4 additions & 0 deletions resources/attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
default['minio']['user'] = 'minio'
default['minio']['group'] = 'minio'
default['minio']['port'] = 9000
default['minio']['access_key_id'] = 'redborder'
default['minio']['secret_key_id'] = 'redborder'
default['minio']['s3_hosts'] = ['localhost:9000']


# Flags
default['minio']['registered'] = false
44 changes: 42 additions & 2 deletions resources/providers/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
begin

user = new_resource.user

s3_user = new_resource.access_key_id
s3_password = new_resource.secret_key_id

dnf_package 'minio' do
action :upgrade
flush_cache [:before]
Expand Down Expand Up @@ -30,12 +32,49 @@
action [:start, :enable]
end

template '/etc/default/minio' do
source 'minio.erb'
variables(
s3_user: s3_user,
s3_password: s3_password
)
notifies :restart, 'service[minio]', :delayed
end

Chef::Log.info('Minio cookbook has been processed')
rescue => e
Chef::Log.error(e.message)
end
end

action :add_s3_conf_nginx do

service 'nginx' do
service_name 'nginx'
ignore_failure true
supports status: true, reload: true, restart: true, enable: true
action [:nothing]
end

s3_hosts = new_resource.s3_hosts
template '/etc/nginx/conf.d/s3.conf' do
source 's3.conf.erb'
owner 'nginx'
group 'nginx'
mode '0644'
cookbook 'nginx'
variables(s3_hosts: s3_hosts)
notifies :restart, 'service[nginx]', :delayed
notifies :run, 'execute[rb_sync_minio_cluster]', :delayed
end

execute 'rb_sync_minio_cluster' do
command '/usr/lib/redborder/bin/rb_sync_minio_cluster.sh'
action :nothing
end

end

action :remove do
begin

Expand All @@ -51,6 +90,7 @@
Chef::Log.error(e.message)
end
end

action :register do
ipaddress = new_resource.ipaddress

Expand All @@ -63,7 +103,7 @@
query['Address'] = ipaddress
query['Port'] = node['minio']['port']
json_query = Chef::JSONCompat.to_json(query)

puts "test"
execute 'Register service in consul' do
command "curl -X PUT http://localhost:8500/v1/agent/service/register -d '#{json_query}' &>/dev/null"
retries 3
Expand Down
5 changes: 4 additions & 1 deletion resources/resources/config.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
actions :add, :remove, :register, :deregister
actions :add, :remove, :register, :deregister, :add_s3_conf_nginx
default_action :add

attribute :user, kind_of: String, default: 'minio'
attribute :group, kind_of: String, default: 'minio'
attribute :port, kind_of: Integer, default: 9000
attribute :access_key_id, kind_of: String, default: 'redborder'
attribute :secret_key_id, kind_of: String, default: 'redborder'

attribute :ipaddress, kind_of: String, default: '127.0.0.1'
attribute :s3_hosts, kind_of: Array, default: ['localhost:9000']

0 comments on commit 0e5d307

Please sign in to comment.