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 =
'1.1.1'.freeze
DEFAULT_PROVIDER =
'cloud'.freeze
NAMESPACE =
'ingress-nginx'.freeze
SERVICE_NAME =
'ingress-nginx-controller'.freeze
SETUP_RESOURCES =
[
  "https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v#{VERSION}/deploy/static/provider/%{provider}/deploy.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, dependencies, depends_on, #docker_images, #initialize, #remove, #resources, task_dirs

Constructor Details

This class inherits a constructor from Kuby::Plugin

Instance Method Details

#configure(&block) ⇒ Object



25
26
27
# File 'lib/kuby/plugins/nginx_ingress.rb', line 25

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

#namespaceObject



48
49
50
# File 'lib/kuby/plugins/nginx_ingress.rb', line 48

def namespace
  NAMESPACE
end

#service_nameObject



52
53
54
# File 'lib/kuby/plugins/nginx_ingress.rb', line 52

def service_name
  SERVICE_NAME
end

#setupObject



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

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