Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 5679742

Browse files
Aakash ShahSannidhi Jalukar
authored andcommitted
Fix Eirini being unable to communicate with CC on k8s
* When deployed on K8s, istio handles transparently applying mTLS to network traffic. [#172321999]
1 parent dda2574 commit 5679742

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

lib/cloud_controller/opi/stager_client.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,13 @@ def get_lifecycle(staging_details, staging_guid, action_builder)
117117
end
118118

119119
def staging_completion_callback(staging_details)
120-
port = config.get(:tls_port)
121-
scheme = 'https'
120+
if !!config.get(:kubernetes, :host_url)
121+
port = 80
122+
scheme = 'http'
123+
else
124+
port = config.get(:tls_port)
125+
scheme = 'https'
126+
end
122127

123128
auth = "#{config.get(:internal_api, :auth_user)}:#{CGI.escape(config.get(:internal_api, :auth_password))}"
124129
host_port = "#{config.get(:internal_service_hostname)}:#{port}"

spec/unit/lib/cloud_controller/opi/stager_client_spec.rb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
auth_user: 'internal_user',
1414
auth_password: 'internal_password'
1515
},
16-
internal_service_hostname: 'api.internal.cf'
16+
internal_service_hostname: 'api.internal.cf',
17+
kubernetes: kubernetes_config,
1718
)
1819
end
1920
let(:eirini_url) { 'http://eirini.loves.heimdall:777' }
2021
let(:staging_guid) { 'some_staging_guid' }
22+
let(:kubernetes_config) { {} }
2123

2224
let(:staging_details) { stub_staging_details(lifecycle_type) }
2325
let(:lifecycle_data) { stub_lifecycle_data }
@@ -186,6 +188,22 @@
186188
}.to_json
187189
)
188190
end
191+
192+
context 'when kubernetes is configured' do
193+
let(:kubernetes_config) do
194+
{
195+
host_url: 'https://master.default.svc.cluster-domain.example',
196+
}
197+
end
198+
199+
it 'configures the callback url with http and relies on Istio for mTLS' do
200+
stager_client.stage(staging_guid, staging_details)
201+
expect(WebMock).to have_requested(:post, "#{eirini_url}/stage/#{staging_guid}").with { |req|
202+
parsed_json = JSON.parse(req.body)
203+
parsed_json['completion_callback'] == 'http://internal_user:internal_password@api.internal.cf:80/internal/v3/staging//build_completed?start='
204+
}
205+
end
206+
end
189207
end
190208
end
191209

0 commit comments

Comments
 (0)