Class: Clusters::Applications::Ingress

Inherits:
ApplicationRecord show all
Includes:
AfterCommitQueue, Concerns::ApplicationCore, Concerns::ApplicationData, Concerns::ApplicationStatus, Concerns::ApplicationVersion, UsageStatistics
Defined in:
app/models/clusters/applications/ingress.rb

Constant Summary collapse

VERSION =
'1.40.2'
INGRESS_CONTAINER_NAME =
'nginx-ingress-controller'
MODSECURITY_LOG_CONTAINER_NAME =
'modsecurity-log'
MODSECURITY_MODE_LOGGING =
"DetectionOnly"
MODSECURITY_MODE_BLOCKING =
"On"
MODSECURITY_OWASP_RULES_FILE =
"/etc/nginx/owasp-modsecurity-crs/nginx-modsecurity.conf"
FETCH_IP_ADDRESS_DELAY =
30.seconds

Instance Method Summary collapse

Methods included from AfterCommitQueue

#run_after_commit, #run_after_commit_or_now

Methods included from Concerns::ApplicationData

#files, #repository, #uninstall_command

Methods included from Concerns::ApplicationVersion

#update_available?

Methods included from Concerns::ApplicationStatus

#available?, #status_states, #update_in_progress?, #updateable?

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Instance Method Details

#allowed_to_uninstall?Boolean

Returns:

  • (Boolean)

56
57
58
# File 'app/models/clusters/applications/ingress.rb', line 56

def allowed_to_uninstall?
  external_ip_or_hostname? && !application_jupyter_installed?
end

#chartObject


48
49
50
# File 'app/models/clusters/applications/ingress.rb', line 48

def chart
  'stable/nginx-ingress'
end

#external_ip_or_hostname?Boolean

Returns:

  • (Boolean)

70
71
72
# File 'app/models/clusters/applications/ingress.rb', line 70

def external_ip_or_hostname?
  external_ip.present? || external_hostname.present?
end

#ingress_serviceObject


82
83
84
# File 'app/models/clusters/applications/ingress.rb', line 82

def ingress_service
  cluster.kubeclient.get_service("ingress-#{INGRESS_CONTAINER_NAME}", Gitlab::Kubernetes::Helm::NAMESPACE)
end

#install_commandObject


60
61
62
63
64
65
66
67
68
# File 'app/models/clusters/applications/ingress.rb', line 60

def install_command
  Gitlab::Kubernetes::Helm::InstallCommand.new(
    name: name,
    version: VERSION,
    rbac: cluster.platform_kubernetes_rbac?,
    chart: chart,
    files: files
  )
end

#schedule_status_updateObject


74
75
76
77
78
79
80
# File 'app/models/clusters/applications/ingress.rb', line 74

def schedule_status_update
  return unless installed?
  return if external_ip
  return if external_hostname

  ClusterWaitForIngressIpAddressWorker.perform_async(name, id)
end

#valuesObject


52
53
54
# File 'app/models/clusters/applications/ingress.rb', line 52

def values
  content_values.to_yaml
end