oci-logging-analytics-kubernetes-discovery 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/bin/oci-loganalytics-kubernetes-discovery +32 -2
- data/lib/discover/infrastructure.rb +2 -2
- data/lib/enum/auth_type_enum.rb +1 -0
- data/lib/oci_loganalytics_resources_discovery.rb +4 -25
- data/lib/util/helper.rb +15 -0
- data/lib/util/oci_clients.rb +138 -78
- data/lib/version.rb +1 -1
- data/oci-logging-analytics-kubernetes-discovery.gemspec +8 -3
- metadata +18 -6
- data/Gemfile.lock +0 -145
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1460fe2976e56c6f9ff763614d151ff90b96d2edd5662c135592a34885f2f512
|
4
|
+
data.tar.gz: 11e3c57a184df35f61ff7b61829a6ce9a78f818a8c2373a930052d7a311e00e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a2babc9026d6ed886ab3f0527dad557ff43796737a517c04aac2485f04a32b00b3918f445a736f2123a0740f43ab15dbf12ae2c96c939e7394d2a1bb45522a1
|
7
|
+
data.tar.gz: 9f4bed331119bca930922675bcf156e1825afafce7d6f53215f2fb2bb81dffce15d27071efbc771e8200252d96bf570592e139308916de8993f667cfa9434d4d
|
data/.gitignore
CHANGED
@@ -8,6 +8,7 @@ require 'optparse'
|
|
8
8
|
require_relative '../lib/oci_loganalytics_resources_discovery'
|
9
9
|
require_relative '../lib/util/logging'
|
10
10
|
require_relative '../lib/util/string_utils'
|
11
|
+
require_relative '../lib/util/helper'
|
11
12
|
|
12
13
|
extend Util::Logging
|
13
14
|
extend Util::StringUtils
|
@@ -34,11 +35,17 @@ optparse = OptionParser.new do |param|
|
|
34
35
|
param.on('--kubernetes_resourcename_prefix PREFIX', 'Kubernetes cluster resourcename prefix. Defaults to oci-onm') { |o| cluster_config[:kubernetes_resourcename_prefix] = o }
|
35
36
|
param.on('--kubernetes_cluster_id KUBERNETES_CLUSTER_ID', 'Unique identifier for Kubernetes cluster') { |o| cluster_config[:kubernetes_cluster_id] = o }
|
36
37
|
|
38
|
+
# OCI Auth Type
|
39
|
+
param.on('--auth_type AUTH_TYPE', "OCI Authentication type - #{Util::Helper.enum_values(Enum::AuthTypeEnum)}") { |o| auth_config[:auth_type] = o }
|
40
|
+
param.on('--oci_domain DOMAIN', 'OCI domain, ex - us-ashburn-1.oci.oraclecloud.com') { |o| auth_config[:oci_domain] = o }
|
41
|
+
|
37
42
|
# OCI Config-based Auth
|
38
|
-
param.on('--endpoint ENDPOINT', 'Logging Analytics Ingestion API endpoint to ingest your application logs') { |o| auth_config[:endpoint] = o }
|
39
43
|
param.on('--profile_name PROFILE_NAME', 'OCI Config Profile Name to be used from the configuration file') { |o| auth_config[:profile_name] = o }
|
40
44
|
param.on('--config_file_location CONFIG_FILE_LOCATION', 'The location of the configuration file containing OCI authentication details') { |o| auth_config[:config_file_location] = o }
|
41
45
|
|
46
|
+
# OCI Logging Analytics custom endpoints
|
47
|
+
param.on('--endpoint ENDPOINT', 'Logging Analytics Ingestion API endpoint to ingest your application logs') { |o| auth_config[:endpoint] = o }
|
48
|
+
|
42
49
|
# Kubernetes Cluster
|
43
50
|
# For AuthNAuth when the job is outside the cluster.
|
44
51
|
param.on('--kube_config_location KUBE_CONFIG_LOCATION', 'Path to the kubernetes configuration (kubeconfig) file') { |o| kube_config[:kube_config_location] = o }
|
@@ -96,6 +103,17 @@ begin
|
|
96
103
|
end
|
97
104
|
end
|
98
105
|
|
106
|
+
# Valid auth input check.
|
107
|
+
unless auth_config[:auth_type].nil?
|
108
|
+
unless Util::Helper.enum_value_defined?(Enum::AuthTypeEnum, auth_config[:auth_type])
|
109
|
+
raise OptionParser::InvalidOption, "--auth_type #{auth_config[:auth_type]} | valid inputs - #{Util::Helper.enum_values(Enum::AuthTypeEnum)}"
|
110
|
+
end
|
111
|
+
|
112
|
+
if auth_config[:auth_type] == Enum::AuthTypeEnum::CONFIG
|
113
|
+
raise OptionParser::MissingArgument, '--config_file_location' if auth_config[:config_file_location].nil?
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
99
117
|
# If threads are enabled, thread count and queue size should be provided as arguments.
|
100
118
|
if app_config[:enable_threading] && app_config[:thread_count].nil?
|
101
119
|
raise OptionParser::MissingArgument, '--thread_count'
|
@@ -116,11 +134,23 @@ cluster_config[:kubernetes_cluster_id] = cluster_config[:kubernetes_cluster_id]
|
|
116
134
|
cluster_config[:oci_la_cluster_entity_id] = cluster_config[:oci_la_cluster_entity_id] ||= nil
|
117
135
|
cluster_config[:kubernetes_resourcename_prefix] = cluster_config[:kubernetes_resourcename_prefix] ||= 'oci-onm'
|
118
136
|
|
137
|
+
# OCI Auth Type
|
138
|
+
if !auth_config[:config_file_location].nil?
|
139
|
+
auth_config[:auth_type] = auth_config[:auth_type] ||= Enum::AuthTypeEnum::CONFIG
|
140
|
+
else
|
141
|
+
auth_config[:auth_type] = auth_config[:auth_type] ||= Enum::AuthTypeEnum::INSTANCE_PRINCIPAL
|
142
|
+
end
|
143
|
+
|
144
|
+
# OCI Domain
|
145
|
+
auth_config[:oci_domain] = auth_config[:oci_domain] ||= nil
|
146
|
+
|
119
147
|
# Config based auth
|
120
|
-
auth_config[:endpoint] = auth_config[:endpoint] ||= nil
|
121
148
|
auth_config[:profile_name] = auth_config[:profile_name] ||= 'DEFAULT'
|
122
149
|
auth_config[:config_file_location] = auth_config[:config_file_location] ||= nil
|
123
150
|
|
151
|
+
# OCI Logging Analytics custom endpoints
|
152
|
+
auth_config[:endpoint] = auth_config[:endpoint] ||= nil
|
153
|
+
|
124
154
|
# Kubernetes cluster related
|
125
155
|
kube_config[:kube_config_location] = kube_config[:kube_config_location] ||= nil
|
126
156
|
kube_config[:kubernetes_url] = kube_config[:kubernetes_url] ||= nil
|
@@ -93,7 +93,7 @@ module Discover
|
|
93
93
|
def fetch_vcn_response(_auth_object, vcn_id)
|
94
94
|
client = nil
|
95
95
|
begin
|
96
|
-
client = Util::OCIClients.get_clients[:
|
96
|
+
client = Util::OCIClients.get_clients[:vcn_client]
|
97
97
|
response = client.get_vcn(vcn_id)
|
98
98
|
|
99
99
|
@vnc_response = response.data
|
@@ -108,7 +108,7 @@ module Discover
|
|
108
108
|
client = nil
|
109
109
|
begin
|
110
110
|
opts = { vcn_id: vcn_id }
|
111
|
-
client = Util::OCIClients.get_clients[:
|
111
|
+
client = Util::OCIClients.get_clients[:vcn_client]
|
112
112
|
response = client.list_subnets(compartment_id, opts)
|
113
113
|
|
114
114
|
@subnet_response = response.data
|
data/lib/enum/auth_type_enum.rb
CHANGED
@@ -52,10 +52,11 @@ module OciLogAnalyticsResourcesDiscovery
|
|
52
52
|
|
53
53
|
# OCI.logger = Util::Logging.logger
|
54
54
|
|
55
|
-
get_auth_object
|
56
|
-
|
57
55
|
options = { mode: app_config_hash[:mode] }
|
58
|
-
|
56
|
+
Util::OCIClients.initialize(@auth_config_hash, options)
|
57
|
+
|
58
|
+
@auth_object = Util::OCIClients.get_auth_config_object
|
59
|
+
@oci_clients = Util::OCIClients.get_clients
|
59
60
|
|
60
61
|
if @app_config_hash[:mode] == 'object'
|
61
62
|
@snapshot_id = Time.now.to_i
|
@@ -147,17 +148,6 @@ module OciLogAnalyticsResourcesDiscovery
|
|
147
148
|
end
|
148
149
|
end
|
149
150
|
|
150
|
-
def get_auth_object
|
151
|
-
begin
|
152
|
-
Util::OCIClients.initialize_auth_config(@auth_config_hash)
|
153
|
-
rescue StandardError => e
|
154
|
-
logger.error("Error occurred in creating authentication object - #{e}")
|
155
|
-
raise e
|
156
|
-
end
|
157
|
-
@auth_object = Util::OCIClients.get_auth_config_object
|
158
|
-
logger.debug('Successfully loaded the OCI auth config.')
|
159
|
-
end
|
160
|
-
|
161
151
|
def get_kube_clients
|
162
152
|
begin
|
163
153
|
Util::KubeClient.create_clients(@kube_config_hash)
|
@@ -169,17 +159,6 @@ module OciLogAnalyticsResourcesDiscovery
|
|
169
159
|
logger.debug('Kubeclients created successfully.')
|
170
160
|
end
|
171
161
|
|
172
|
-
def get_oci_clients(options)
|
173
|
-
begin
|
174
|
-
Util::OCIClients.create_clients(@auth_object, options)
|
175
|
-
rescue StandardError => e
|
176
|
-
logger.error("Error occurred in creating OCI clients - #{e}")
|
177
|
-
raise e
|
178
|
-
end
|
179
|
-
@oci_clients = Util::OCIClients.get_clients
|
180
|
-
logger.debug('OCI clients created successfully.')
|
181
|
-
end
|
182
|
-
|
183
162
|
def get_infra_resources_payload
|
184
163
|
logger.debug('Discovering Infrastructure Resources')
|
185
164
|
infra_resources_payload = nil
|
data/lib/util/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Util
|
2
|
+
module Helper
|
3
|
+
module_function
|
4
|
+
# Function to check if a value is defined in the enum
|
5
|
+
def enum_value_defined?(enum_module, value)
|
6
|
+
enum_module.constants(false).any? { |const| enum_module.const_get(const) == value }
|
7
|
+
end
|
8
|
+
|
9
|
+
# Function to get enum values as list
|
10
|
+
def enum_values(enum_module)
|
11
|
+
enum_module.constants(false).map { |const| enum_module.const_get(const) }
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
data/lib/util/oci_clients.rb
CHANGED
@@ -13,43 +13,67 @@ module Util
|
|
13
13
|
|
14
14
|
module_function
|
15
15
|
|
16
|
-
attr_accessor :oci_clients, :ce_client, :id_client, :lb_client, :la_client, :rs_client,
|
17
|
-
:
|
16
|
+
attr_accessor :oci_clients, :ce_client, :id_client, :lb_client, :la_client, :rs_client,
|
17
|
+
:vcn_client, :oci_config, :instance_principals_signer, :la_endpoint,
|
18
|
+
:auth_type, :auth_config_object, :oci_domain
|
18
19
|
|
19
|
-
|
20
|
+
# This must be the first method called before any other method
|
21
|
+
def initialize(auth_config_hash, options)
|
20
22
|
begin
|
21
|
-
|
23
|
+
initialize_auth_config(auth_config_hash)
|
24
|
+
rescue StandardError => e
|
25
|
+
logger.error("Error occurred in creating authentication object - #{e}")
|
26
|
+
raise e
|
27
|
+
end
|
28
|
+
logger.debug('Successfully loaded the OCI auth config.')
|
22
29
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
30
|
+
begin
|
31
|
+
create_clients(options)
|
32
|
+
rescue StandardError => e
|
33
|
+
logger.error("Error occurred in creating OCI clients - #{e}")
|
34
|
+
raise e
|
35
|
+
end
|
36
|
+
logger.debug('OCI clients created successfully.')
|
37
|
+
|
38
|
+
set_clients
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_clients(options)
|
42
|
+
begin
|
43
|
+
@la_client = initialize_la_client(nil)
|
44
|
+
|
45
|
+
return if options[:mode] == 'object'
|
46
|
+
|
47
|
+
@ce_client = initialize_ce_client
|
48
|
+
@id_client = initialize_id_client
|
49
|
+
@lb_client = initialize_lb_client
|
50
|
+
@rs_client = initialize_rs_client
|
51
|
+
@vcn_client = initialize_vcn_client
|
27
52
|
|
28
|
-
@ce_client = initialize_ce_client(auth_object)
|
29
|
-
@id_client = initialize_id_client(auth_object)
|
30
|
-
@lb_client = initialize_lb_client(auth_object)
|
31
|
-
@rs_client = initialize_rs_client(auth_object)
|
32
|
-
@vnc_client = initialize_vnc_client(auth_object)
|
33
53
|
rescue StandardError => e
|
34
54
|
logger.error("Error while creating OCI clients. Error: #{e}")
|
35
55
|
raise e
|
36
56
|
end
|
37
|
-
set_clients
|
38
|
-
nil
|
39
57
|
end
|
40
58
|
|
41
|
-
def initialize_ce_client(
|
59
|
+
def initialize_ce_client()
|
42
60
|
client = nil
|
43
|
-
|
61
|
+
endpoint = nil
|
62
|
+
unless @oci_domain.nil?
|
63
|
+
endpoint = "https://containerengine.#{@oci_domain}"
|
64
|
+
logger.info("CE Client endpoint: #{endpoint}")
|
65
|
+
end
|
66
|
+
logger.debug("Creating container engine client with auth_type: #{@auth_type}")
|
44
67
|
begin
|
45
|
-
case
|
68
|
+
case @auth_type
|
46
69
|
when Enum::AuthTypeEnum::CONFIG
|
47
|
-
client = OCI::ContainerEngine::ContainerEngineClient.new(config:
|
70
|
+
client = OCI::ContainerEngine::ContainerEngineClient.new(config: @oci_config, endpoint: endpoint)
|
48
71
|
when Enum::AuthTypeEnum::INSTANCE_PRINCIPAL
|
49
|
-
client = OCI::ContainerEngine::ContainerEngineClient.new(config:
|
72
|
+
client = OCI::ContainerEngine::ContainerEngineClient.new(config: @oci_config, endpoint: endpoint, signer: @instance_principals_signer)
|
50
73
|
else
|
51
|
-
logger.warn("Unknown auth_type '#{
|
74
|
+
logger.warn("Unknown auth_type '#{@auth_type}' provided for container engine client.")
|
52
75
|
end
|
76
|
+
logger.info("CE Client created.")
|
53
77
|
@ce_client = client
|
54
78
|
rescue StandardError => e
|
55
79
|
logger.error("Error while creating container engine client: #{e}")
|
@@ -58,20 +82,24 @@ module Util
|
|
58
82
|
client
|
59
83
|
end
|
60
84
|
|
61
|
-
def initialize_id_client(
|
85
|
+
def initialize_id_client()
|
62
86
|
client = nil
|
63
|
-
|
87
|
+
endpoint = nil
|
88
|
+
unless @oci_domain.nil?
|
89
|
+
endpoint = "https://identity.#{@oci_domain}"
|
90
|
+
logger.info("ID Client endpoint: #{endpoint}")
|
91
|
+
end
|
92
|
+
logger.debug("Creating identity client with auth_type: #{@auth_type}")
|
64
93
|
begin
|
65
|
-
case
|
94
|
+
case @auth_type
|
66
95
|
when Enum::AuthTypeEnum::CONFIG
|
67
|
-
client = OCI::Identity::IdentityClient.new(config:
|
68
|
-
when Enum::AuthTypeEnum::ENDPOINT
|
69
|
-
client = OCI::Identity::IdentityClient.new(config: auth_object[:oci_config], endpoint: auth_object[:endpoint])
|
96
|
+
client = OCI::Identity::IdentityClient.new(config: @oci_config, endpoint: endpoint)
|
70
97
|
when Enum::AuthTypeEnum::PRINCIPAL
|
71
|
-
client = OCI::Identity::IdentityClient.new(config:
|
98
|
+
client = OCI::Identity::IdentityClient.new(config: @oci_config, endpoint: endpoint, signer: @instance_principals_signer)
|
72
99
|
else
|
73
|
-
logger.warn("Unknown auth_type '#{
|
100
|
+
logger.warn("Unknown auth_type '#{@auth_type}' provided for identity client.")
|
74
101
|
end
|
102
|
+
logger.info("ID Client created.")
|
75
103
|
@id_client = client
|
76
104
|
rescue StandardError => e
|
77
105
|
logger.error("Error while creating identity client: #{e}")
|
@@ -80,20 +108,24 @@ module Util
|
|
80
108
|
@id_client
|
81
109
|
end
|
82
110
|
|
83
|
-
def initialize_lb_client(
|
111
|
+
def initialize_lb_client()
|
84
112
|
client = nil
|
85
|
-
|
113
|
+
endpoint = nil
|
114
|
+
unless @oci_domain.nil?
|
115
|
+
endpoint = "https://iaas.#{@oci_domain}"
|
116
|
+
logger.info("LB Client endpoint: #{endpoint}")
|
117
|
+
end
|
118
|
+
logger.debug("Creating load balancer client with auth_type: #{@auth_type}")
|
86
119
|
begin
|
87
|
-
case
|
120
|
+
case @auth_type
|
88
121
|
when Enum::AuthTypeEnum::CONFIG
|
89
|
-
client = OCI::LoadBalancer::LoadBalancerClient.new(config:
|
90
|
-
when Enum::AuthTypeEnum::ENDPOINT
|
91
|
-
client = OCI::LoadBalancer::LoadBalancerClient.new(config: auth_object[:oci_config], endpoint: auth_object[:endpoint])
|
122
|
+
client = OCI::LoadBalancer::LoadBalancerClient.new(config: @oci_config, endpoint: endpoint)
|
92
123
|
when Enum::AuthTypeEnum::PRINCIPAL
|
93
|
-
client = OCI::LoadBalancer::LoadBalancerClient.new(config:
|
124
|
+
client = OCI::LoadBalancer::LoadBalancerClient.new(config: @oci_config, endpoint: endpoint, signer: @instance_principals_signer)
|
94
125
|
else
|
95
|
-
logger.warn("Unknown auth_type '#{
|
126
|
+
logger.warn("Unknown auth_type '#{@auth_type}' provided for load balancer client.")
|
96
127
|
end
|
128
|
+
logger.info("LB Client created.")
|
97
129
|
@lb_client = client
|
98
130
|
rescue StandardError => e
|
99
131
|
logger.error("Error while creating load balancer client: #{e}")
|
@@ -102,26 +134,35 @@ module Util
|
|
102
134
|
@lb_client
|
103
135
|
end
|
104
136
|
|
105
|
-
def initialize_la_client(
|
106
|
-
client
|
107
|
-
|
137
|
+
def initialize_la_client(custom_retry_config)
|
138
|
+
logger.debug("Creating log analytics client with auth_type: #{@auth_type}")
|
139
|
+
|
108
140
|
Config::OCIClientRetryConfig.set_custom_retry_config(custom_retry_config) unless custom_retry_config.nil?
|
109
141
|
|
142
|
+
endpoint = @la_endpoint
|
143
|
+
if endpoint.nil? && !@oci_domain.nil?
|
144
|
+
endpoint = "https://loganalytics.#{@oci_domain}"
|
145
|
+
logger.info("LA Client endpoint: #{endpoint}")
|
146
|
+
end
|
147
|
+
|
148
|
+
client = nil
|
149
|
+
|
110
150
|
begin
|
111
|
-
case
|
151
|
+
case @auth_type
|
112
152
|
when Enum::AuthTypeEnum::CONFIG
|
113
|
-
client = OCI::LogAnalytics::LogAnalyticsClient.new(config:
|
114
|
-
endpoint:
|
153
|
+
client = OCI::LogAnalytics::LogAnalyticsClient.new(config: @oci_config,
|
154
|
+
endpoint: endpoint,
|
115
155
|
retry_config: Config::OCIClientRetryConfig.get_retry_config)
|
116
156
|
when Enum::AuthTypeEnum::INSTANCE_PRINCIPAL
|
117
|
-
client = OCI::LogAnalytics::LogAnalyticsClient.new(config:
|
118
|
-
endpoint:
|
119
|
-
signer:
|
157
|
+
client = OCI::LogAnalytics::LogAnalyticsClient.new(config: @oci_config,
|
158
|
+
endpoint: endpoint,
|
159
|
+
signer: @instance_principals_signer,
|
120
160
|
retry_config: Config::OCIClientRetryConfig.get_retry_config)
|
121
161
|
else
|
122
|
-
logger.warn("Unknown auth_type while creating log analytics client: #{
|
162
|
+
logger.warn("Unknown auth_type while creating log analytics client: #{@auth_type}")
|
123
163
|
raise StandardError, 'Unknown auth_type for log analytics client.'
|
124
164
|
end
|
165
|
+
logger.info("LA Client created.")
|
125
166
|
@la_client = client
|
126
167
|
rescue StandardError => e
|
127
168
|
logger.error("Error while creating log analytics client: #{e}")
|
@@ -130,20 +171,24 @@ module Util
|
|
130
171
|
@la_client
|
131
172
|
end
|
132
173
|
|
133
|
-
def initialize_rs_client(
|
174
|
+
def initialize_rs_client()
|
134
175
|
client = nil
|
135
|
-
|
176
|
+
endpoint = nil
|
177
|
+
unless @oci_domain.nil?
|
178
|
+
endpoint = "https://query.#{@oci_domain}"
|
179
|
+
logger.info("RS Client endpoint: #{endpoint}")
|
180
|
+
end
|
181
|
+
logger.debug("Creating resource search client with auth_type: #{@auth_type}")
|
136
182
|
begin
|
137
|
-
case
|
183
|
+
case @auth_type
|
138
184
|
when Enum::AuthTypeEnum::CONFIG
|
139
|
-
client = OCI::ResourceSearch::ResourceSearchClient.new(config:
|
140
|
-
when Enum::AuthTypeEnum::ENDPOINT
|
141
|
-
client = OCI::ResourceSearch::ResourceSearchClient.new(config: auth_object[:oci_config], endpoint: auth_object[:endpoint])
|
185
|
+
client = OCI::ResourceSearch::ResourceSearchClient.new(config: @oci_config, endpoint: endpoint)
|
142
186
|
when Enum::AuthTypeEnum::PRINCIPAL
|
143
|
-
client = OCI::ResourceSearch::ResourceSearchClient.new(config:
|
187
|
+
client = OCI::ResourceSearch::ResourceSearchClient.new(config: @oci_config, endpoint: endpoint, signer: @instance_principals_signer)
|
144
188
|
else
|
145
|
-
logger.warn("Unknown auth_type '#{
|
189
|
+
logger.warn("Unknown auth_type '#{@auth_type}' provided for resource search client.")
|
146
190
|
end
|
191
|
+
logger.info("RS Client created.")
|
147
192
|
@rs_client = client
|
148
193
|
rescue StandardError => e
|
149
194
|
logger.error("Error while creating resource search client: #{e}")
|
@@ -152,43 +197,56 @@ module Util
|
|
152
197
|
@rs_client
|
153
198
|
end
|
154
199
|
|
155
|
-
def
|
200
|
+
def initialize_vcn_client()
|
156
201
|
client = nil
|
157
|
-
|
202
|
+
endpoint = nil
|
203
|
+
unless @oci_domain.nil?
|
204
|
+
endpoint = "https://iass.#{@oci_domain}"
|
205
|
+
logger.info("VCN Client endpoint: #{endpoint}")
|
206
|
+
end
|
207
|
+
logger.debug("Creating virtual network client with auth_type: #{@auth_type}")
|
158
208
|
begin
|
159
|
-
case
|
209
|
+
case @auth_type
|
160
210
|
when Enum::AuthTypeEnum::CONFIG
|
161
|
-
client = OCI::Core::VirtualNetworkClient.new(config:
|
162
|
-
when Enum::AuthTypeEnum::ENDPOINT
|
163
|
-
client = OCI::Core::VirtualNetworkClient.new(config: auth_object[:oci_config], endpoint: auth_object[:endpoint])
|
211
|
+
client = OCI::Core::VirtualNetworkClient.new(config: @oci_config, endpoint: endpoint)
|
164
212
|
when Enum::AuthTypeEnum::PRINCIPAL
|
165
|
-
client = OCI::Core::VirtualNetworkClient.new(config:
|
213
|
+
client = OCI::Core::VirtualNetworkClient.new(config: @oci_config, endpoint: endpoint, signer: @instance_principals_signer)
|
166
214
|
else
|
167
|
-
logger.warn("Unknown auth_type '#{
|
215
|
+
logger.warn("Unknown auth_type '#{@auth_type}' provided for virtual network client.")
|
168
216
|
end
|
169
|
-
|
217
|
+
logger.info("VCN Client created.")
|
218
|
+
@vcn_client = client
|
170
219
|
rescue StandardError => e
|
171
220
|
logger.error("Error while creating virtual network client: #{e}")
|
172
221
|
raise e
|
173
222
|
end
|
174
|
-
@
|
223
|
+
@vcn_client
|
175
224
|
end
|
176
225
|
|
177
226
|
def initialize_auth_config(auth_config_hash)
|
178
|
-
@
|
227
|
+
@auth_type = auth_config_hash[:auth_type]
|
228
|
+
@oci_domain = auth_config_hash[:oci_domain]
|
229
|
+
@la_endpoint = auth_config_hash[:endpoint]
|
179
230
|
|
180
231
|
begin
|
181
|
-
if
|
232
|
+
if @auth_type == Enum::AuthTypeEnum::INSTANCE_PRINCIPAL
|
233
|
+
@oci_config = OCI::Config.new
|
234
|
+
if @oci_domain.nil?
|
235
|
+
@instance_principals_signer = OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner.new
|
236
|
+
else
|
237
|
+
fedration_endpoint = "https://auth.#{@oci_domain}/v1/x509"
|
238
|
+
logger.info("Federation Endpoint: #{fedration_endpoint}")
|
239
|
+
@instance_principals_signer = OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner.new(
|
240
|
+
federation_endpoint: fedration_endpoint
|
241
|
+
)
|
242
|
+
end
|
243
|
+
# elsif @auth_type == Enum::AuthTypeEnum::OKE_WORKLOAD_IDENTITY
|
244
|
+
# @workload_identity_signer = OCI::Auth::Signers::oke_workload_resource_principal_signer
|
245
|
+
elsif @auth_type == Enum::AuthTypeEnum::CONFIG
|
182
246
|
@oci_config = OCI::ConfigFileLoader.load_config(config_file_location: auth_config_hash[:config_file_location],
|
183
|
-
|
184
|
-
end
|
185
|
-
|
186
|
-
if !@oci_config.nil?
|
187
|
-
@auth_type = Enum::AuthTypeEnum::CONFIG
|
247
|
+
profile_name: auth_config_hash[:profile_name])
|
188
248
|
else
|
189
|
-
|
190
|
-
@instance_principals_signer = instance_principals_signer = OCI::Auth::Signers::InstancePrincipalsSecurityTokenSigner.new
|
191
|
-
@auth_type = Enum::AuthTypeEnum::INSTANCE_PRINCIPAL
|
249
|
+
raise Exception::InvalidOption, "#{@auth_type}"
|
192
250
|
end
|
193
251
|
rescue StandardError => e
|
194
252
|
logger.error("Error occurred while initializing OCI authentication configuration. Error: #{e}")
|
@@ -208,7 +266,7 @@ module Util
|
|
208
266
|
lb_client: @lb_client,
|
209
267
|
la_client: @la_client,
|
210
268
|
rs_client: @rs_client,
|
211
|
-
|
269
|
+
vcn_client: @vcn_client
|
212
270
|
}
|
213
271
|
end
|
214
272
|
|
@@ -219,9 +277,11 @@ module Util
|
|
219
277
|
def set_auth_config_object
|
220
278
|
@auth_object = {
|
221
279
|
oci_config: @oci_config,
|
222
|
-
|
280
|
+
la_endpoint: @la_endpoint,
|
223
281
|
instance_principals_signer: @instance_principals_signer,
|
224
|
-
|
282
|
+
# workload_identity_signer: @workload_identity_signer,
|
283
|
+
auth_type: @auth_type,
|
284
|
+
oci_domain: @oci_domain
|
225
285
|
}.compact
|
226
286
|
end
|
227
287
|
end
|
data/lib/version.rb
CHANGED
@@ -19,6 +19,11 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
20
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
21
|
end
|
22
|
+
|
23
|
+
# Specify which files should not be added to the gem when it is released.
|
24
|
+
build_ignore = ['Gemfile.lock']
|
25
|
+
spec.files -= build_ignore
|
26
|
+
|
22
27
|
spec.bindir = 'bin'
|
23
28
|
spec.executables << 'oci-loganalytics-kubernetes-discovery'
|
24
29
|
spec.require_paths = ['lib']
|
@@ -37,9 +42,9 @@ Gem::Specification.new do |spec|
|
|
37
42
|
spec.add_development_dependency 'test-unit', '~> 3.0'
|
38
43
|
spec.add_development_dependency 'webmock', '~> 3.0'
|
39
44
|
|
40
|
-
spec.add_runtime_dependency 'concurrent-ruby', '~> 1.2.2'
|
41
|
-
spec.add_runtime_dependency 'kubeclient', '~> 4.9.3'
|
42
|
-
spec.add_runtime_dependency 'oci', '~> 2.
|
45
|
+
spec.add_runtime_dependency 'concurrent-ruby', '~> 1.2', '>= 1.2.2'
|
46
|
+
spec.add_runtime_dependency 'kubeclient', '~> 4.9', '>= 4.9.3'
|
47
|
+
spec.add_runtime_dependency 'oci', '~> 2.21'
|
43
48
|
spec.add_runtime_dependency 'rubyzip', '~> 2.3.2'
|
44
49
|
spec.add_runtime_dependency 'yajl-ruby', '~> 1.0'
|
45
50
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oci-logging-analytics-kubernetes-discovery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oracle
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-11-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -184,6 +184,9 @@ dependencies:
|
|
184
184
|
requirement: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
186
|
- - "~>"
|
187
|
+
- !ruby/object:Gem::Version
|
188
|
+
version: '1.2'
|
189
|
+
- - ">="
|
187
190
|
- !ruby/object:Gem::Version
|
188
191
|
version: 1.2.2
|
189
192
|
type: :runtime
|
@@ -191,6 +194,9 @@ dependencies:
|
|
191
194
|
version_requirements: !ruby/object:Gem::Requirement
|
192
195
|
requirements:
|
193
196
|
- - "~>"
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '1.2'
|
199
|
+
- - ">="
|
194
200
|
- !ruby/object:Gem::Version
|
195
201
|
version: 1.2.2
|
196
202
|
- !ruby/object:Gem::Dependency
|
@@ -198,6 +204,9 @@ dependencies:
|
|
198
204
|
requirement: !ruby/object:Gem::Requirement
|
199
205
|
requirements:
|
200
206
|
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '4.9'
|
209
|
+
- - ">="
|
201
210
|
- !ruby/object:Gem::Version
|
202
211
|
version: 4.9.3
|
203
212
|
type: :runtime
|
@@ -205,6 +214,9 @@ dependencies:
|
|
205
214
|
version_requirements: !ruby/object:Gem::Requirement
|
206
215
|
requirements:
|
207
216
|
- - "~>"
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '4.9'
|
219
|
+
- - ">="
|
208
220
|
- !ruby/object:Gem::Version
|
209
221
|
version: 4.9.3
|
210
222
|
- !ruby/object:Gem::Dependency
|
@@ -213,14 +225,14 @@ dependencies:
|
|
213
225
|
requirements:
|
214
226
|
- - "~>"
|
215
227
|
- !ruby/object:Gem::Version
|
216
|
-
version: '2.
|
228
|
+
version: '2.21'
|
217
229
|
type: :runtime
|
218
230
|
prerelease: false
|
219
231
|
version_requirements: !ruby/object:Gem::Requirement
|
220
232
|
requirements:
|
221
233
|
- - "~>"
|
222
234
|
- !ruby/object:Gem::Version
|
223
|
-
version: '2.
|
235
|
+
version: '2.21'
|
224
236
|
- !ruby/object:Gem::Dependency
|
225
237
|
name: rubyzip
|
226
238
|
requirement: !ruby/object:Gem::Requirement
|
@@ -261,7 +273,6 @@ files:
|
|
261
273
|
- ".gitignore"
|
262
274
|
- ".travis.yml"
|
263
275
|
- Gemfile
|
264
|
-
- Gemfile.lock
|
265
276
|
- LICENSE.txt
|
266
277
|
- README.md
|
267
278
|
- Rakefile
|
@@ -288,6 +299,7 @@ files:
|
|
288
299
|
- lib/infra_resources.rb
|
289
300
|
- lib/objects_resources.rb
|
290
301
|
- lib/oci_loganalytics_resources_discovery.rb
|
302
|
+
- lib/util/helper.rb
|
291
303
|
- lib/util/kube_client.rb
|
292
304
|
- lib/util/kubectl_ops.rb
|
293
305
|
- lib/util/log_analytics.rb
|
@@ -316,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
328
|
- !ruby/object:Gem::Version
|
317
329
|
version: '0'
|
318
330
|
requirements: []
|
319
|
-
rubygems_version: 3.3.
|
331
|
+
rubygems_version: 3.3.27
|
320
332
|
signing_key:
|
321
333
|
specification_version: 4
|
322
334
|
summary: A rubygem for discovering Kubernetes resources and send it to OCI Logging
|
data/Gemfile.lock
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
oci-logging-analytics-kubernetes-discovery (1.0.1)
|
5
|
-
concurrent-ruby (~> 1.2.2)
|
6
|
-
kubeclient (~> 4.9.3)
|
7
|
-
oci (~> 2.20)
|
8
|
-
rubyzip (~> 2.3.2)
|
9
|
-
yajl-ruby (~> 1.0)
|
10
|
-
|
11
|
-
GEM
|
12
|
-
remote: https://rubygems.org/
|
13
|
-
specs:
|
14
|
-
addressable (2.8.5)
|
15
|
-
public_suffix (>= 2.0.2, < 6.0)
|
16
|
-
ast (2.4.2)
|
17
|
-
base64 (0.2.0)
|
18
|
-
coderay (1.1.3)
|
19
|
-
concurrent-ruby (1.2.3)
|
20
|
-
crack (0.4.5)
|
21
|
-
rexml
|
22
|
-
docile (1.4.0)
|
23
|
-
domain_name (0.6.20240107)
|
24
|
-
ffi (1.16.3)
|
25
|
-
ffi-compiler (1.0.1)
|
26
|
-
ffi (>= 1.0.0)
|
27
|
-
rake
|
28
|
-
forking_test_runner (1.13.0)
|
29
|
-
parallel_tests (>= 1.3.7)
|
30
|
-
hashdiff (1.0.1)
|
31
|
-
http (4.4.1)
|
32
|
-
addressable (~> 2.3)
|
33
|
-
http-cookie (~> 1.0)
|
34
|
-
http-form_data (~> 2.2)
|
35
|
-
http-parser (~> 1.2.0)
|
36
|
-
http-accept (1.7.0)
|
37
|
-
http-cookie (1.0.5)
|
38
|
-
domain_name (~> 0.5)
|
39
|
-
http-form_data (2.3.0)
|
40
|
-
http-parser (1.2.3)
|
41
|
-
ffi-compiler (>= 1.0, < 2.0)
|
42
|
-
httplog (1.6.2)
|
43
|
-
rack (>= 2.0)
|
44
|
-
rainbow (>= 2.0.0)
|
45
|
-
inifile (3.0.0)
|
46
|
-
json (2.7.2)
|
47
|
-
jsonpath (1.1.5)
|
48
|
-
multi_json
|
49
|
-
jwt (2.8.1)
|
50
|
-
base64
|
51
|
-
kubeclient (4.9.3)
|
52
|
-
http (>= 3.0, < 5.0)
|
53
|
-
jsonpath (~> 1.0)
|
54
|
-
recursive-open-struct (~> 1.1, >= 1.1.1)
|
55
|
-
rest-client (~> 2.0)
|
56
|
-
method_source (1.0.0)
|
57
|
-
mime-types (3.5.2)
|
58
|
-
mime-types-data (~> 3.2015)
|
59
|
-
mime-types-data (3.2023.1205)
|
60
|
-
minitest (5.15.0)
|
61
|
-
minitest-rg (5.3.0)
|
62
|
-
minitest (~> 5.0)
|
63
|
-
mocha (1.16.1)
|
64
|
-
multi_json (1.15.0)
|
65
|
-
netrc (0.11.0)
|
66
|
-
oci (2.20.0)
|
67
|
-
inifile (~> 3.0, >= 3.0.0)
|
68
|
-
json (>= 1.4.6, < 3.0.0)
|
69
|
-
jwt (~> 2.1)
|
70
|
-
psych (>= 3.1.0, < 5.0.0)
|
71
|
-
parallel (1.23.0)
|
72
|
-
parallel_tests (4.3.0)
|
73
|
-
parallel
|
74
|
-
parser (3.2.2.4)
|
75
|
-
ast (~> 2.4.1)
|
76
|
-
racc
|
77
|
-
power_assert (2.0.3)
|
78
|
-
pry (0.14.2)
|
79
|
-
coderay (~> 1.1)
|
80
|
-
method_source (~> 1.0)
|
81
|
-
psych (4.0.6)
|
82
|
-
stringio
|
83
|
-
public_suffix (5.0.4)
|
84
|
-
racc (1.7.3)
|
85
|
-
rack (3.0.8)
|
86
|
-
rainbow (3.1.1)
|
87
|
-
rake (13.1.0)
|
88
|
-
recursive-open-struct (1.1.3)
|
89
|
-
regexp_parser (2.8.2)
|
90
|
-
rest-client (2.1.0)
|
91
|
-
http-accept (>= 1.7.0, < 2.0)
|
92
|
-
http-cookie (>= 1.0.2, < 2.0)
|
93
|
-
mime-types (>= 1.16, < 4.0)
|
94
|
-
netrc (~> 0.8)
|
95
|
-
rexml (3.2.6)
|
96
|
-
rubocop (1.3.1)
|
97
|
-
parallel (~> 1.10)
|
98
|
-
parser (>= 2.7.1.5)
|
99
|
-
rainbow (>= 2.2.2, < 4.0)
|
100
|
-
regexp_parser (>= 1.8)
|
101
|
-
rexml
|
102
|
-
rubocop-ast (>= 1.1.1)
|
103
|
-
ruby-progressbar (~> 1.7)
|
104
|
-
unicode-display_width (>= 1.4.0, < 2.0)
|
105
|
-
rubocop-ast (1.30.0)
|
106
|
-
parser (>= 3.2.1.0)
|
107
|
-
ruby-progressbar (1.13.0)
|
108
|
-
rubyzip (2.3.2)
|
109
|
-
simplecov (0.22.0)
|
110
|
-
docile (~> 1.1)
|
111
|
-
simplecov-html (~> 0.11)
|
112
|
-
simplecov_json_formatter (~> 0.1)
|
113
|
-
simplecov-html (0.12.3)
|
114
|
-
simplecov_json_formatter (0.1.4)
|
115
|
-
stringio (3.1.0)
|
116
|
-
test-unit (3.6.1)
|
117
|
-
power_assert
|
118
|
-
unicode-display_width (1.8.0)
|
119
|
-
webmock (3.19.1)
|
120
|
-
addressable (>= 2.8.0)
|
121
|
-
crack (>= 0.3.2)
|
122
|
-
hashdiff (>= 0.4.0, < 2.0.0)
|
123
|
-
yajl-ruby (1.4.3)
|
124
|
-
|
125
|
-
PLATFORMS
|
126
|
-
ruby
|
127
|
-
x86_64-linux
|
128
|
-
|
129
|
-
DEPENDENCIES
|
130
|
-
bundler (~> 2.3.3)
|
131
|
-
forking_test_runner (~> 1.13.0)
|
132
|
-
httplog (~> 1.6.2)
|
133
|
-
minitest (~> 5.15.0)
|
134
|
-
minitest-rg (~> 5.3.0)
|
135
|
-
mocha (~> 1.5)
|
136
|
-
oci-logging-analytics-kubernetes-discovery!
|
137
|
-
pry (~> 0.14.2)
|
138
|
-
rake (~> 13.1.0)
|
139
|
-
rubocop (~> 1.3.0)
|
140
|
-
simplecov (~> 0.22.0)
|
141
|
-
test-unit (~> 3.0)
|
142
|
-
webmock (~> 3.0)
|
143
|
-
|
144
|
-
BUNDLED WITH
|
145
|
-
2.3.3
|