oci-logging-analytics-kubernetes-discovery 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- 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 +1 -1
- metadata +6 -5
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
@@ -44,7 +44,7 @@ Gem::Specification.new do |spec|
|
|
44
44
|
|
45
45
|
spec.add_runtime_dependency 'concurrent-ruby', '~> 1.2', '>= 1.2.2'
|
46
46
|
spec.add_runtime_dependency 'kubeclient', '~> 4.9', '>= 4.9.3'
|
47
|
-
spec.add_runtime_dependency 'oci', '~> 2.
|
47
|
+
spec.add_runtime_dependency 'oci', '~> 2.21'
|
48
48
|
spec.add_runtime_dependency 'rubyzip', '~> 2.3.2'
|
49
49
|
spec.add_runtime_dependency 'yajl-ruby', '~> 1.0'
|
50
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
|
@@ -225,14 +225,14 @@ dependencies:
|
|
225
225
|
requirements:
|
226
226
|
- - "~>"
|
227
227
|
- !ruby/object:Gem::Version
|
228
|
-
version: '2.
|
228
|
+
version: '2.21'
|
229
229
|
type: :runtime
|
230
230
|
prerelease: false
|
231
231
|
version_requirements: !ruby/object:Gem::Requirement
|
232
232
|
requirements:
|
233
233
|
- - "~>"
|
234
234
|
- !ruby/object:Gem::Version
|
235
|
-
version: '2.
|
235
|
+
version: '2.21'
|
236
236
|
- !ruby/object:Gem::Dependency
|
237
237
|
name: rubyzip
|
238
238
|
requirement: !ruby/object:Gem::Requirement
|
@@ -299,6 +299,7 @@ files:
|
|
299
299
|
- lib/infra_resources.rb
|
300
300
|
- lib/objects_resources.rb
|
301
301
|
- lib/oci_loganalytics_resources_discovery.rb
|
302
|
+
- lib/util/helper.rb
|
302
303
|
- lib/util/kube_client.rb
|
303
304
|
- lib/util/kubectl_ops.rb
|
304
305
|
- lib/util/log_analytics.rb
|
@@ -327,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
327
328
|
- !ruby/object:Gem::Version
|
328
329
|
version: '0'
|
329
330
|
requirements: []
|
330
|
-
rubygems_version: 3.3.
|
331
|
+
rubygems_version: 3.3.27
|
331
332
|
signing_key:
|
332
333
|
specification_version: 4
|
333
334
|
summary: A rubygem for discovering Kubernetes resources and send it to OCI Logging
|