Class: Kuby::Plugins::NginxIngress

Inherits:
Kuby::Plugin show all
Defined in:
lib/kuby/plugins/nginx_ingress.rb

Defined Under Namespace

Classes: Config

Constant Summary collapse

VERSION =
'0.27.1'.freeze
DEFAULT_PROVIDER =
'cloud-generic'.freeze
NAMESPACE =
'ingress-nginx'.freeze
SERVICE_NAME =
'ingress-nginx'.freeze
SETUP_RESOURCES =
[
  "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-#{VERSION}/deploy/static/mandatory.yaml",
  "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-#{VERSION}/deploy/static/provider/%{provider}.yaml"
].freeze

Instance Attribute Summary

Attributes inherited from Kuby::Plugin

#environment

Instance Method Summary collapse

Methods inherited from Kuby::Plugin

#after_configuration, #after_deploy, #after_setup, #before_deploy, #before_setup, #docker_images, #initialize, #resources

Constructor Details

This class inherits a constructor from Kuby::Plugin

Instance Method Details

#configure(&block) ⇒ Object



23
24
25
# File 'lib/kuby/plugins/nginx_ingress.rb', line 23

def configure(&block)
  @config.instance_eval(&block) if block
end

#namespaceObject



46
47
48
# File 'lib/kuby/plugins/nginx_ingress.rb', line 46

def namespace
  NAMESPACE
end

#service_nameObject



50
51
52
# File 'lib/kuby/plugins/nginx_ingress.rb', line 50

def service_name
  SERVICE_NAME
end

#setupObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/kuby/plugins/nginx_ingress.rb', line 27

def setup
  Kuby.logger.info('Deploying nginx ingress resources')

  if already_deployed?
    Kuby.logger.info('Nginx ingress already deployed, skipping')
    return
  end

  SETUP_RESOURCES.each do |uri|
    uri = uri % { provider: @config.provider || DEFAULT_PROVIDER }
    kubernetes_cli.apply_uri(uri)
  end

  Kuby.logger.info('Nginx ingress resources deployed!')
rescue => e
  Kuby.logger.fatal(e.message)
  raise
end