@@ -54,7 +54,28 @@ $(document).ajaxStart(function () {
54
54
$ . blockUI ( { message : '<h3>Loading Executors Page...</h3>' } ) ;
55
55
} ) ;
56
56
57
+ function findKubernetesServiceBaseURI ( ) {
58
+ var k8sProxyPattern = '/api/v1/proxy/namespaces/' ;
59
+ var k8sProxyPatternPos = document . baseURI . indexOf ( k8sProxyPattern ) ;
60
+ if ( k8sProxyPatternPos > 0 ) {
61
+ // Spark is running in a kubernetes cluster, and the web ui is served
62
+ // through the kubectl proxy.
63
+ var remaining = document . baseURI . substr ( k8sProxyPatternPos + k8sProxyPattern . length ) ;
64
+ var urlSlashesCount = remaining . split ( '/' ) . length - 3 ;
65
+ var words = document . baseURI . split ( '/' ) ;
66
+ var baseURI = words . slice ( 0 , words . length - urlSlashesCount ) . join ( '/' ) ;
67
+ return baseURI ;
68
+ }
69
+
70
+ return null ;
71
+ }
72
+
57
73
function createTemplateURI ( appId ) {
74
+ var kubernetesBaseURI = findKubernetesServiceBaseURI ( ) ;
75
+ if ( kubernetesBaseURI ) {
76
+ return kubernetesBaseURI + '/static/executorspage-template.html' ;
77
+ }
78
+
58
79
var words = document . baseURI . split ( '/' ) ;
59
80
var ind = words . indexOf ( "proxy" ) ;
60
81
if ( ind > 0 ) {
@@ -70,6 +91,14 @@ function createTemplateURI(appId) {
70
91
}
71
92
72
93
function getStandAloneppId ( cb ) {
94
+ var kubernetesBaseURI = findKubernetesServiceBaseURI ( ) ;
95
+ if ( kubernetesBaseURI ) {
96
+ var appIdAndPort = kubernetesBaseURI . split ( '/' ) . slice ( - 1 ) [ 0 ] ;
97
+ var appId = appIdAndPort . split ( ':' ) [ 0 ] ;
98
+ cb ( appId ) ;
99
+ return ;
100
+ }
101
+
73
102
var words = document . baseURI . split ( '/' ) ;
74
103
var ind = words . indexOf ( "proxy" ) ;
75
104
if ( ind > 0 ) {
@@ -95,6 +124,11 @@ function getStandAloneppId(cb) {
95
124
}
96
125
97
126
function createRESTEndPoint ( appId ) {
127
+ var kubernetesBaseURI = findKubernetesServiceBaseURI ( ) ;
128
+ if ( kubernetesBaseURI ) {
129
+ return kubernetesBaseURI + "/api/v1/applications/" + appId + "/allexecutors" ;
130
+ }
131
+
98
132
var words = document . baseURI . split ( '/' ) ;
99
133
var ind = words . indexOf ( "proxy" ) ;
100
134
if ( ind > 0 ) {
0 commit comments