config_kit 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d87686cf24927b1e2bfb70a50dfb58e2cde955e5
4
+ data.tar.gz: 1635b8f74554c97e702ec4261846cde10435a6c8
5
+ SHA512:
6
+ metadata.gz: f7965a88abcbbddaa6e0437f0fd7c61f371702c87b0beadf85074639548420d09132f1bff27a91a0a5be7570bd3a54b4169c4185d58ee7fb7bb8cccc0a39a55f
7
+ data.tar.gz: b51369d2c72f7c65c85b75eef778663a3c10794bcf1afb54ebc996e595f17403948f49563fcb392dfccbb2279b50324992527a732264e12babe14e0ce0aeda77
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+
20
+ # Vim
21
+ *.swp
22
+ *.swo
23
+
24
+ # ctags
25
+ tags
26
+
27
+ #Mac
28
+ .DS_Store
29
+ tmp/
30
+
31
+ .idea
32
+ reports/
33
+ target/
34
+ log
35
+ migrations/*.db
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'http://gems.sd.laxino.com'
2
+
3
+ gem 'diplomat', '1.4.1'
4
+ gem 'git', '1.3.0'
5
+ group :test do
6
+ gem 'simplecov', '0.12.0'
7
+ gem 'rspec'
8
+ gem 'faker'
9
+ gem 'as-duration'
10
+ gem 'factory_girl'
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,62 @@
1
+ GEM
2
+ remote: http://gems.sd.laxino.com/
3
+ specs:
4
+ activesupport (5.1.0)
5
+ concurrent-ruby (~> 1.0, >= 1.0.2)
6
+ i18n (~> 0.7)
7
+ minitest (~> 5.1)
8
+ tzinfo (~> 1.1)
9
+ as-duration (0.1.1)
10
+ concurrent-ruby (1.0.5)
11
+ diff-lcs (1.3)
12
+ diplomat (1.4.1)
13
+ faraday (~> 0.9)
14
+ json
15
+ docile (1.1.5)
16
+ factory_girl (4.8.0)
17
+ activesupport (>= 3.0.0)
18
+ faker (1.7.3)
19
+ i18n (~> 0.5)
20
+ faraday (0.12.1)
21
+ multipart-post (>= 1.2, < 3)
22
+ git (1.3.0)
23
+ i18n (0.8.1)
24
+ json (2.1.0)
25
+ minitest (5.10.2)
26
+ multipart-post (2.0.0)
27
+ rspec (3.6.0)
28
+ rspec-core (~> 3.6.0)
29
+ rspec-expectations (~> 3.6.0)
30
+ rspec-mocks (~> 3.6.0)
31
+ rspec-core (3.6.0)
32
+ rspec-support (~> 3.6.0)
33
+ rspec-expectations (3.6.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.6.0)
36
+ rspec-mocks (3.6.0)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.6.0)
39
+ rspec-support (3.6.0)
40
+ simplecov (0.12.0)
41
+ docile (~> 1.1.0)
42
+ json (>= 1.8, < 3)
43
+ simplecov-html (~> 0.10.0)
44
+ simplecov-html (0.10.0)
45
+ thread_safe (0.3.6)
46
+ tzinfo (1.2.3)
47
+ thread_safe (~> 0.1)
48
+
49
+ PLATFORMS
50
+ ruby
51
+
52
+ DEPENDENCIES
53
+ as-duration
54
+ diplomat (= 1.4.1)
55
+ factory_girl
56
+ faker
57
+ git (= 1.3.0)
58
+ rspec
59
+ simplecov (= 0.12.0)
60
+
61
+ BUNDLED WITH
62
+ 1.14.6
data/README.md ADDED
@@ -0,0 +1,146 @@
1
+ # Configuration Kit(config_kit)
2
+
3
+ ## Introduction
4
+
5
+ config_kit is a tool to manage the application configuration using consul as back service as configuration store, and support configuration versioning, rollout or rollback control.
6
+
7
+ ## How to Use
8
+
9
+ To understand config_kit, first we need to understand basic configuration management approaches using in config_kit. Next we will provide quick starting for you to experience config_kit functionalities.
10
+
11
+ ### Seven Types of Configuration Management
12
+
13
+ config_kit provides command line(ck) to init, bootstrap, deploy, rollout, rollback for appication configuration
14
+
15
+ * init: init is to initialize metadata for specific data center, which will including the informaction of data center name and entitled environment for the data center
16
+
17
+ * describe: retrieve inforamation about all configuration or app configuration
18
+
19
+ >describe all information of configuration
20
+
21
+ ```bash
22
+ ck describe
23
+ ```
24
+
25
+ >describe one application information of configuration
26
+
27
+ ```bash
28
+ ck describe --app axle
29
+ ```
30
+
31
+ >describe specified version of an application of configuration
32
+
33
+ ```bash
34
+ ck describe --app axle --version 1.0.0
35
+ ```
36
+
37
+
38
+ * get: get is to retrive the full contents of the configuration
39
+
40
+ >get current version full configuration information
41
+
42
+ ```bash
43
+ ck get
44
+ ```
45
+
46
+ >get current version full configuration information and output to yaml format
47
+
48
+ ```bash
49
+ ck get -o yaml
50
+ ```
51
+
52
+ >get current version full configuration of an application
53
+
54
+ ```bash
55
+ ck get --app axle -o yaml
56
+ ```
57
+
58
+ >get specify version configuration of an application
59
+
60
+ ```bash
61
+ ck get --app axle --version 1.0.0 -o yaml
62
+ ```
63
+
64
+ * bootstrap: bootstrap is to create a application configuration tied specified version, and will not take active after bootstrap.
65
+
66
+ >bootstrap from file
67
+
68
+ ```shell
69
+ ck bootstrap --from-file file:///config/int0 --app all --version 1.0.0
70
+ ```
71
+
72
+ >bootstrap from git
73
+
74
+ ```bash
75
+ ck bootstrap --from-git ssh://git_repository/config.git --app all --version=1.0.0
76
+ ```
77
+
78
+ * deploy: deploy is not only to creat a application configuration, but also set as default configuration for active after deploy
79
+
80
+ * rollout: rollout is to activate specified version.
81
+
82
+ * rollback: TBD
83
+
84
+ ### Setup Consul Storage
85
+
86
+ To setup consul, we using docker to run a testing consul server, if you need a consul server in production, pls using stack file in cluster folder.
87
+
88
+ ```
89
+ docker container run -d --name=consul -p 8400:8400 -p 8500:8500 -p 8600:53/udp consul
90
+ ```
91
+
92
+ You can open urs http://localhost:8500 to access UI of consul
93
+
94
+ ### Prepare the configuration data
95
+
96
+ To create configuration data, pls refere to README in config folder, and two configuration data for axle and infra is placed in same folder as well.
97
+
98
+ ### Default Setting of config_kit
99
+
100
+ In order to simplified process for new user, we have default settings in config_kit to shorten start step for new user.
101
+
102
+ In config_kit
103
+
104
+ * default consul server: http://localhost:8500
105
+ * default configuration data: ./config (where example configuration is ready for you)
106
+
107
+ ### Let's Go
108
+
109
+ Assume consul container is up and running, so we can use deploy command to deploy the first configuration in config folder
110
+
111
+ ```
112
+ ck bootstrap
113
+ ```
114
+
115
+ Then open http://localhost:8500 to check the configuration data.
116
+
117
+ ### How to manage configuration data
118
+
119
+ ### Todo
120
+
121
+ #### Cli
122
+ - [ ] provide deployment summary for deploy command;
123
+ - [ ] provide bootstrp summary for bootstrap command;
124
+ - [ ] provide rollback summary for rollback command;
125
+ - [ ] provide rollout summary fro rollout command;
126
+ - [ ] support --pretty options in get command for output formatting;
127
+ - [ ] enhance error output for all comamnds;
128
+
129
+ #### Configuration
130
+ - [X] support change configuration throught environment;
131
+
132
+ #### Data Loader
133
+ - [ ] support load configuration data from git repository;
134
+ - [ ] support checksum for loaded data;
135
+ - [ ] join all array elements with comma;
136
+
137
+ #### Doc
138
+ - [ ] provide writing configuration data file guideline;
139
+ - [ ] complete manage configuration data section;
140
+
141
+ #### Manager
142
+ - [ ] provide API to integrate with d13n, which can get configuration data from application;
143
+
144
+ ## Thank you!
145
+ Pls let me know if you have any problems.
146
+
data/bin/ck ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..','lib'))
4
+ require 'config_kit/cli/command'
5
+ begin
6
+ ConfigKit::Cli::Command.run
7
+ rescue ConfigKit::Cli::Command::CommandFailure => failure
8
+ STDERR.puts failure.message
9
+ STDERR.puts failure.options if failure.options
10
+ exit 1
11
+ end
@@ -0,0 +1,64 @@
1
+ version: '3.1'
2
+
3
+ #customise this with options from
4
+ #https://www.consul.io/docs/agent/options.html
5
+
6
+ services:
7
+
8
+ seed:
9
+ image: consul:latest
10
+ deploy:
11
+ restart_policy:
12
+ condition: none #we do not want this to be restarted on timeout (see entrypoint options below)
13
+ replicas: 1
14
+ placement:
15
+ constraints:
16
+ - 'node.role != manager'
17
+ environment:
18
+ - "CONSUL_BIND_INTERFACE=eth0"
19
+ entrypoint:
20
+ - timeout #this seed fires up the cluster after which it is no longer needed
21
+ - -sTERM #this is the same signal as docker would send on a scale down / stop
22
+ - -t300 #terminate after 5 mins
23
+ - consul
24
+ - agent
25
+ - -server
26
+ - -bootstrap-expect=3
27
+ - -data-dir=/tmp/consuldata
28
+ - -advertise={{ GetInterfaceIP "eth0" }}
29
+ networks:
30
+ - "consul"
31
+
32
+ cluster:
33
+ image: consul:latest
34
+ depends_on:
35
+ - "seed"
36
+ deploy:
37
+ mode: global ##this will deploy to all nodes that
38
+ placement:
39
+ constraints:
40
+ - 'node.role == manager'
41
+ environment:
42
+ - "CONSUL_LOCAL_CONFIG={\"disable_update_check\": true}"
43
+ - "CONSUL_BIND_INTERFACE=eth0"
44
+ - "CONSUL_HTTP_ADDR=0.0.0.0"
45
+ entrypoint:
46
+ - consul
47
+ - agent
48
+ - -server
49
+ - -data-dir=/tmp/consuldata
50
+ - -bind={{ GetInterfaceIP "eth0" }}
51
+ - -client=0.0.0.0
52
+ - -retry-join=seed:8301
53
+ - -disable-host-node-id=true
54
+ - -advertise={{ GetInterfaceIP "eth0" }}
55
+ - -ui ##assuming you want the UI on
56
+ networks:
57
+ - "consul"
58
+ ports:
59
+ - "8500:8500"
60
+ - "8600:8600"
61
+
62
+ networks:
63
+ consul:
64
+ driver: overlay
data/config/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # Configuration Kit(config_kit)
2
+
3
+ Configuration Kit is tool kit to handle application configuration which need to specified with deployment environment, so that all the configuration for the deployment environment can be isolated from application code phrase(which is including three phrase only, they are test, development and production). Finally, we can archive build once and run everywhere.
4
+
5
+ ## Design Detail
6
+
7
+ We are use consul as configration data store and reply on its high avaibility and reliabilty to maintain and provide robust configuration management service for all running docker container.
8
+
9
+ ### Configruation Data Source Structure
10
+
11
+ Config kit will support two type of data source, which are local file directory and git source repository structure
12
+
13
+ #### Local File Directory
14
+
15
+ Assum local file data source is located in current_path/config, under this config folder we will separate all config data per deployment environment and application, which will share one same infra configuration data within this deployment environment.
16
+
17
+ Here is an example
18
+
19
+ * file:///./config/int0/int0.infra.yml
20
+ * file:///./config/int0/int0.axle.yml
21
+ * file:///./config/int0/int0.belt.yml
22
+
23
+ Above is for integration0 environment. Similarily, for staging0 environment, we can have below configuration data file structure:
24
+
25
+ * file:///./config/stg0/stg0.infra.yml
26
+ * file:///./config/stg0/stg0.axle.yml
27
+ * file:///./config/stg0/stg0.belt.yml
28
+
29
+ #### Git source repository
30
+
31
+ Similary with local file, we will define the following structure in git repository
32
+
33
+ * git://git_repos/config_kit.git/int0/int0.infra.yml
34
+ * git://git_repos/config_kit.git/int0/int0.axle.yml
35
+ * git://git_repos/config_kit.git/int0/int0.belt.yml
36
+ * git://git_repos/config_kit.git/stg0/stg0.infra.yml
37
+ * git://git_repos/config_kit.git/stg0/stg0.axle.yml
38
+ * git://git_repos/config_kit.git/stg0/stg0.belt.yml
39
+
40
+ ### K/V Structure
41
+
42
+ Since consul is KV storage and we use this property to store all the configuration.
43
+
44
+ Application Configuration
45
+
46
+ * /v1/config_kit/axle/v1.0/database => 'mysql'
47
+
48
+ Deployment Configuration:
49
+
50
+ * /v1/config_kit/deploy/axle/default => v1.0
51
+ * /v1/config_kit/deploy/axle/v1.0/ts => 201705061235 # Timestamp
52
+ * /v1/config_kit/deploy/axle/v1.0/cm => b193bc91 # Checksum or git commit hash
53
+
54
+ ## Configuration List
55
+
56
+ ### Description
57
+
58
+ * key: reference key in Axle.config, which is symble. If key is dotted, you need to single quote to reference it as symble such as Axle.config[:
59
+ 'service.schedule.base_path'].
60
+ * default: it is default value of this configuration.
61
+ * type: Ruby data type of this configuration.
62
+ * allowed_from_server: It can be overwrited by config-kit from server side.
63
+ * description: describe the information of configuration.
64
+ * deprecated: indicate configuration is deprecated or not.
65
+
66
+ ### Axle
67
+
68
+ #### Configuration Catagory
69
+
70
+ * default: No prefix and including axle service host, port etc..
71
+ * service: containe the configuration of service host, port and endpoint path etc...
72
+ * database: containe the configuration of database host name, port, username and password etc...
73
+ * jackpot: containe the configuration about Jackpot such alert configuration...
74
+ * game: containe the configuration for game;
75
+ * alert: container the configuration for alert;
76
+
77
+ Pls follow the catagory mentioned above with proper prefix to named the configuration list below.
78
+
79
+ #### Config Data
80
+ | key | default | type | allowed_from_server | description | deprecated |
81
+ |---------|---------|------|---------------------|---------------------|-------------|
82
+ | port | 3000 | Integer | false | Define service port. | false |
83
+ | host | 'localhost' | String | false | Define Service host. | false |
84
+ | log_file_name | 'axle.log' | String | false | log file name | false |
85
+ | log_level | 'info' | String | false | Sets the level of logger. | false |
86
+ | log_file_path | 'stdout' | String | false | Define a path to the log file, excluding the filename. | false |
87
+ | config_path | DefaultSource.config_path | String | false | Path to <b>axle.yml</b>. If undefined, the agent checks the following directories (in order): <b>config/axle.yml</b>, <b>axle.yml</b>, <b>$HOME/.axle/axle.yml</b> and <b>$HOME/axle.yml</b>. | false |
88
+ | config_search_path | DefaultSource.config_search_paths | String | false | An array of candidate locations for the service\'s configuration file. | false |
89
+ | service.action.base_path | '/action' | String | false | Defines base path for action service endpoint. | false |
90
+ | service.schedule.base_path | '/schedule' | String | false | Defines base path for schedule service endpoint. | false |
91
+ | service.loopback.base_path | '/loopback' | String | false | Defines base path for loopback service endpoint. | false |
92
+ | service.operation.base_path | '/operation' | String | false | Defines base path for operation service endpoint. | false |
93
+ | database.adapter | 'mysql2' | String | true | database adapter for sequel | false |
94
+ | database.host | 'localhost' | String | true | database server hostname | false |
95
+ | database.port | 3306 | Integer | true | database server port | false |
96
+ | database.username | 'laxino' | String | true | database server username | false |
97
+ | database.passward | 'passord' | String | true | database password | false |
98
+ | database.database | 'g2_axle_production' | String | true | database name | false |
99
+ | jackpot.submit_status.#{property_id}.path | 'http://games.83suncity.local' | String | true | Jackpot Status Submission Path | false |
100
+ | jackpot.submit_status.#{property_id}.secret_access_key | 'akjlasdfasdfalas;sdkfajs' | String | true | Jackpot Status Submission Secret | false |
101
+ | jackpot.submit_status.#{property_id}.stats_postfix | 'jackpotstats' | String | true | Jackpot Status Submission Stats Postfix | false |
102
+ | jackpot.submit_status.#{property_id}.post_with_content_md5 | true | Boolean | true | Jackpot Status ON/OFF Context md5 Checksum | false |
103
+ | jackpot.allow_debug_mode | false | Boolean | false | 'Jackpot debug mode ON/OFF' | false |
104
+ | service.fams.host | 'fams' | String | true | 'FAMS host name' | false |
105
+ | service.fams.port | 80 | Integer | true | 'FAMS host name' | false |
106
+ | service.fams.bet_path | '/fund_adapter/bet' | String | false | 'FAMS result path.' | false |
107
+ | service.fams.cancel_bet_path | '/fund_adapter/cancel_bet' | String | false | 'FAMS cancel bet path.' | false |
108
+ | service.fams.query_balance_path | '/fund_adapter/query_player_balance' | String | false | 'FAMS query player balance path.' | false |
109
+ | service.fams.get_balance_path | '/get_player_balance_info' | String | false | 'FAMS get player balance info path.' | false |
110
+ | service.rap.host | 'rap' | String | true | 'RAP host name' | false |
111
+ | service.rap.port | 80 | Integer | true | 'RAP service port' | false |
112
+ | service.rap.get_token_path | '/get_third_party_token' | String | false | 'RAP service port' | false |
113
+ | service.sm.host | 'sm' | String | true | 'Station Management Service host name' | false |
114
+ | service.sm.port | 80 | Integer | true | 'Station Management Service port' | false |
115
+ | service.sm.message_path | '/messages/create.json' | String | false | 'Station Management Service message path' | false |
116
+ | service.sm.validate_machine_token_path | '/validate_machine_token.json' | String | false | 'Station Management Service validate machine token path' | false |
117
+ | service.anms.host | 'snms' | String | true | 'ANMS host name' | false |
118
+ | service.anms.port | 80 | Integer | true | 'ANMS port' | false |
119
+ | service.anms.request_send_alert_path | '/messages/request_send_alert.json' | String | false | 'ANMS message path' | false |
120
+ | service.js.host | 'job_scheduler.com' | String | true | 'Job Scheduler host name' | false |
121
+ | service.js.port | 80 | Integer | true | 'Job Scheduler Service Port' | false |
122
+ | service.js.message_path | '/messages/create.json' | String | false | 'Job Scheduler Service message path' | false |
123
+ | service.self_schedule_host | 'axle.com' | String | true | 'axle schedule url' | false |
124
+ | player.token_secret | 'secret' | String | false | 'Player token (JWT) secret key.' | false |
125
+ | alert.mail_server | 'moexc01.mo.laxino.com' | String | true | 'alert mail server.' | false |
126
+ | game.allow_test_mode | false | Boolean | false | 'Allow test mode player ON/OFF' | false |
127
+ | alert.big_win.property_ids | [20000] | Array | false | 'Properties that need to send big win alert mail' | false |
128
+ | alert.big_win.mail_context.serverity | 2 | Integer | false | 'Big win alert mail serverity' | false |
129
+ | alert.jackpot.win.mail_recipient | 'lm.cs@laxino.com' | String | true | Jackpot Win Alert Mail Recipient | false |
130
+ | alert.jackpot.win.mail_context.serverity | 2 | Integer | true | serverity of Jackpot Win Alert | false |
131
+ | alert.jackpot.win.anms_property_ids | [20000] | Array | false | 'Properties that need to send jackpot win alert mail by ANMS' | false |
132
+ | alert.jackpot.submit_status.exception.mail_recipient | 'lm.cs@laxino.com' | String | true | Jackpot Status Submision Exception Mail Recipient | false |
133
+ | alert.jackpot.submit_status.exception.mail_context.serverity | 2 | Integer | true | Serverity of Jackpot Status Submision Exception Mail | false |
134
+ | alert.jackpot.snapshot_report.mail_recipient | 'lm.cs@laxino.com' | String | true | Jackpot Snapshot Report Recipient | false |