lib/mkit/app/model/service.rb in mkit-0.2.0 vs lib/mkit/app/model/service.rb in mkit-0.3.0
- old
+ new
@@ -44,17 +44,10 @@
image: config.image,
command: config.command,
status: MKIt::Status::CREATING
)
- # docker network
- if config.network.nil? || config.network.empty?
- srv.pods_network="mkit"
- else
- srv.pods_network=config.network
- end
-
# reserve pool ip
srv.lease = Pool.find_by_name(MKIt::Utils.me).reserve_for(srv)
srv.dns_host = DnsHost.new(
service: srv,
@@ -89,10 +82,18 @@
self.min_replicas = 1
self.max_replicas = 1
end
self.max_replicas = self.min_replicas if self.min_replicas > self.max_replicas
+ # docker network
+ if config.network.nil? || config.network.empty?
+ self.pods_network="mkit"
+ else
+ self.pods_network=config.network
+ end
+ self.create_pods_network
+
# haproxy ports
self.service_port = []
config.ports&.each do |p|
port = ServicePort.create(service: self, config: p)
self.service_port << port
@@ -128,19 +129,16 @@
}
self.save
end
def create_pods_network
- netw = inspect_network(self.pods_network)
- create_network(self.pods_network) if netw.nil?
+ create_network(self.pods_network) if !network_exists?(self.pods_network)
end
def deploy_network
# create service interface...
self.lease.confirm
self.lease.up
- # ...and pods network
- self.create_pods_network
end
def add_volume(volume_config)
v = Volume.create(self, volume_config)
self.volume << v