-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsetup-kube.R
More file actions
17 lines (15 loc) · 733 Bytes
/
setup-kube.R
File metadata and controls
17 lines (15 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
## Used by the helm chart to configure R in the scheduler and worker pods. Not intended for use by users.
local({
setup_kube <- function() {
## EXTRA_R_PACKAGES in set in values.yaml in the helm chart.
install.packages(strsplit(Sys.getenv('EXTRA_R_PACKAGES'), ' ')[[1]])
}
## Allow users to get worker names, e.g.,
## plan(cluster, workers = get_kube_workers(), revtunnel = FALSE)
## This will only work if access to kubectl is enabled from within the pods.
get_kube_workers <- function() {
workers_string <- system("kubectl get pod --namespace default -o jsonpath='{.items[?(@.metadata.labels.component==\"worker\")].metadata.name}'", intern = TRUE)
return(strsplit(workers_string, ' ')[[1]])
}
}, envir = globalenv()
)