2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Clusters
|
|
|
|
module Applications
|
2019-07-07 11:18:12 +05:30
|
|
|
class Ingress < ApplicationRecord
|
2019-03-02 22:35:43 +05:30
|
|
|
VERSION = '1.1.2'.freeze
|
2018-11-18 11:00:15 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
self.table_name = 'clusters_applications_ingress'
|
|
|
|
|
|
|
|
include ::Clusters::Concerns::ApplicationCore
|
|
|
|
include ::Clusters::Concerns::ApplicationStatus
|
2018-11-18 11:00:15 +05:30
|
|
|
include ::Clusters::Concerns::ApplicationVersion
|
2018-03-27 19:54:05 +05:30
|
|
|
include ::Clusters::Concerns::ApplicationData
|
|
|
|
include AfterCommitQueue
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
default_value_for :ingress_type, :nginx
|
2018-11-18 11:00:15 +05:30
|
|
|
default_value_for :version, VERSION
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
enum ingress_type: {
|
|
|
|
nginx: 1
|
|
|
|
}
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
FETCH_IP_ADDRESS_DELAY = 30.seconds
|
|
|
|
|
|
|
|
state_machine :status do
|
2019-02-15 15:39:39 +05:30
|
|
|
after_transition any => [:installed] do |application|
|
2018-03-27 19:54:05 +05:30
|
|
|
application.run_after_commit do
|
|
|
|
ClusterWaitForIngressIpAddressWorker.perform_in(
|
|
|
|
FETCH_IP_ADDRESS_DELAY, application.name, application.id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
def chart
|
|
|
|
'stable/nginx-ingress'
|
|
|
|
end
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
# We will implement this in future MRs.
|
|
|
|
# Basically we need to check all dependent applications are not installed
|
|
|
|
# first.
|
|
|
|
def allowed_to_uninstall?
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
def install_command
|
|
|
|
Gitlab::Kubernetes::Helm::InstallCommand.new(
|
2018-11-18 11:00:15 +05:30
|
|
|
name: name,
|
|
|
|
version: VERSION,
|
2018-11-20 20:47:30 +05:30
|
|
|
rbac: cluster.platform_kubernetes_rbac?,
|
2018-03-27 19:54:05 +05:30
|
|
|
chart: chart,
|
2018-11-18 11:00:15 +05:30
|
|
|
files: files
|
2018-03-27 19:54:05 +05:30
|
|
|
)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2018-03-27 19:54:05 +05:30
|
|
|
def schedule_status_update
|
|
|
|
return unless installed?
|
|
|
|
return if external_ip
|
2019-07-07 11:18:12 +05:30
|
|
|
return if external_hostname
|
2018-03-27 19:54:05 +05:30
|
|
|
|
|
|
|
ClusterWaitForIngressIpAddressWorker.perform_async(name, id)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
def ingress_service
|
|
|
|
cluster.kubeclient.get_service('ingress-nginx-ingress-controller', Gitlab::Kubernetes::Helm::NAMESPACE)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|