@@ -46,10 +46,15 @@ export interface AccountResponse {
4646
4747/**
4848 * Get management endpoint
49+ * For PRA instances, the Management API endpoint is shared (only deployed on primary instance)
4950 * @param subdomain - Subdomain
5051 * @returns Management endpoint
5152 */
5253export async function getManagementEndpoint ( subdomain : string = 'zenko.local' ) : Promise < string > {
54+ const managementInstance = process . env . MANAGEMENT_INSTANCE ;
55+ if ( managementInstance ) {
56+ logger . info ( `Using Management API from primary instance: ${ managementInstance } (target: ${ process . env . ZENKO_NAME } )` ) ;
57+ }
5358 return `http://management.${ subdomain } ` ;
5459}
5560
@@ -117,22 +122,29 @@ export async function getManagementToken(subdomain: string = 'zenko.local'): Pro
117122}
118123
119124/**
120- * Get instance ID
125+ * Get instance ID from the target Zenko CR
126+ * NOTE: This returns the TARGET instance's ID (e.g., PRA), which is used when creating locations
127+ * @param zenkoName - Optional Zenko CR name to override ZENKO_NAME env var
121128 * @returns Instance ID
122129 */
123- export async function getInstanceId ( ) : Promise < string | null > {
130+ export async function getInstanceId ( zenkoName ?: string ) : Promise < string | null > {
124131 if ( ! KubernetesHelper . customObject ) {
125132 throw new Error ( 'KubernetesHelper not initialized' ) ;
126133 }
134+ const targetZenkoName = zenkoName || process . env . ZENKO_NAME || 'end2end' ;
135+ logger . debug ( `Getting instanceId from Zenko CR: ${ targetZenkoName } ` ) ;
136+
127137 const instanceId = await KubernetesHelper . customObject . getNamespacedCustomObject ( {
128138 group : 'zenko.io' ,
129139 version : 'v1alpha2' ,
130140 namespace : process . env . NAMESPACE || 'default' ,
131141 plural : 'zenkos' ,
132- name : process . env . ZENKO_NAME || 'end2end' ,
142+ name : targetZenkoName ,
133143 } ) ;
134144
135- return instanceId . status ?. instanceID || process . env . INSTANCE_ID ;
145+ const id = instanceId . status ?. instanceID || process . env . INSTANCE_ID ;
146+ logger . info ( `Using instanceId: ${ id } from Zenko CR: ${ targetZenkoName } ` ) ;
147+ return id ;
136148}
137149
138150/**
0 commit comments