Skip to content

RhysJackson/googleKubernetesR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

googleKubernetesR

An R package for the Google Kubernetes Engine API. Note: This package is in a very early stage of development and not recommended for use in production.

Thanks

A big thank you to Mark Edmondson for the googleAuthR package which is used extensively in this project.

Currently implemented

Installation

devtools::install_github("RhysJackson/googleKubernetesR")
library(googleKubernetesR)

Authentication

Authenticate with JSON file

# Create and download your OAuth 2.0 credentials from the Google Cloud Platform
k8s_auth(json = "client_secret.json")

Authenticate with client ID and client secret

# If making many API calls, create your own OAuth client credentials from the Google Cloud console and provide them here as options to googleAuthR
options(googleAuthR.client_id = "YOUR-CLIENT-ID",
        googleAuthR.client_secret = "YOUR-CLIENT-SECRET")

# Authenticate
k8s_auth()

Examples

Create a cluster

# Create a 3 node, n1-standard-1, 100Gb disk, cluster with the default name 'r-cluster'
# Cluster comes configured with recommended scopes https://www.googleapis.com/auth/compute and https://www.googleapis.com/auth/devstorage.read_only
createCluster(projectId = "myProject", "europe-west1-d")
# Create 5 node, n1-highmem-2, 500Gb disk, cluster with read/write access to Google Cloud Storage

# Define the cluster spec
clusterSpec <- list(
  name = "my-cluster",
  initialNodeCount = 5,
  nodeConfig = list(
    machineType = "n1-highmem-2",
    diskSizeGb = 500,
    oauthScopes = c("https://www.googleapis.com/auth/compute",
    				"https://www.googleapis.com/auth/devstorage.read_write")
  )
)

# Create the cluster
createCluster(projectId = "myProject",
	zone = "europe-west1-d",
	clusterSpec = clusterSpec)

List Clusters

# List all clusters in a project
listClusters(projectId = "myProject")
# List all clusters in a specific zone
listClusters(projectId = "myProject", zone = "europe-west1-d")

Set addons for an existing cluster

See the AddonsConfig documentation for details on how to specify the addonsConfig argument

# Define the addons configuration
addonsConfig <- list(
	httpLoadBalancing = list(disabled = TRUE)
)

# Disable the HTTP Load Balancing addon
setAddons(projectId = "myProject",
		  projectLocation = "europe-west1-d",
		  clusterId = "my-cluster",
		  addonsConfig = addonsConfig)

Delete Cluster

deleteCluster(projectId = "myProject", zone = "europe-west1-d", clusterId = "my-cluster")

About

An R package for the Google Kubernetes Engine API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages