Class: Kuby::Redis::Instance
- Inherits:
-
Object
- Object
- Kuby::Redis::Instance
- Extended by:
- KubeDSL::ValueFields
- Defined in:
- lib/kuby/redis/instance.rb
Constant Summary collapse
- PORT =
26379
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#connection_params ⇒ Object
github.com/spotahome/redis-operator#connection-to-the-created-redis-failovers The return value of this method is suitable for passing into ‘Redis.new` from the redis-rb gem.
- #custom_config(*args) ⇒ Object
-
#initialize(name, environment) ⇒ Instance
constructor
A new instance of Instance.
- #kubernetes ⇒ Object
- #redis(&block) ⇒ Object
- #resources ⇒ Object
- #service_name ⇒ Object
- #service_port ⇒ Object
Constructor Details
#initialize(name, environment) ⇒ Instance
Returns a new instance of Instance.
23 24 25 26 |
# File 'lib/kuby/redis/instance.rb', line 23 def initialize(name, environment) @name = "#{environment.kubernetes.selector_app}-#{name}" @environment = environment end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
10 11 12 |
# File 'lib/kuby/redis/instance.rb', line 10 def environment @environment end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/kuby/redis/instance.rb', line 10 def name @name end |
Instance Method Details
#connection_params ⇒ Object
github.com/spotahome/redis-operator#connection-to-the-created-redis-failovers The return value of this method is suitable for passing into ‘Redis.new` from the redis-rb gem.
43 44 45 46 47 48 |
# File 'lib/kuby/redis/instance.rb', line 43 def connection_params { sentinels: [{ host: service_name, port: service_port }], url: 'redis://mymaster' } end |
#custom_config(*args) ⇒ Object
50 51 52 |
# File 'lib/kuby/redis/instance.rb', line 50 def custom_config(*args) redis.spec.redis.custom_config(*args) end |
#kubernetes ⇒ Object
122 123 124 |
# File 'lib/kuby/redis/instance.rb', line 122 def kubernetes environment.kubernetes end |
#redis(&block) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/kuby/redis/instance.rb', line 54 def redis(&block) context = self @redis ||= Kuby::Redis.redis_failover do api_version 'databases.spotahome.com/v1' do name context.name namespace context.kubernetes.namespace..name end spec do sentinel do replicas context.sentinel_replicas resources do requests do add :cpu, '100m' end limits do add :memory, '100Mi' end end end redis do replicas context.redis_replicas storage do keep_after_deletion true persistent_volume_claim do do name "#{context.name}-pvc" end spec do access_modes context.storage_access_modes resources do requests do add :storage, context.storage end end end end end resources do requests do add :cpu, context.cpu_request add :memory, context.memory_request end limits do add :cpu, context.cpu_limit add :memory, context.memory_limit end end end end end @redis.instance_eval(&block) if block @redis end |
#resources ⇒ Object
28 29 30 |
# File 'lib/kuby/redis/instance.rb', line 28 def resources @resources ||= [redis] end |
#service_name ⇒ Object
32 33 34 |
# File 'lib/kuby/redis/instance.rb', line 32 def service_name @service_name ||= "rfs-#{name}" end |
#service_port ⇒ Object
36 37 38 |
# File 'lib/kuby/redis/instance.rb', line 36 def service_port PORT end |