Provides access to gcloud
, the command line client of Google Cloud to manage cloud resources.
Add this library to the classpath:
buildscript {
dependencies {
...
classpath 'gradle.plugin.com.github.rmee:gcloud:<VERSION>'
}
}
A setup of Kubernetes with Google Cloud can looks as follows:
apply plugin: 'kubectl'
apply plugin: 'gcloud'
kubectl {
url = 'https://35.198.168.245'
namespace = 'default'
insecureSkipTlsVerify = false
}
gcloud {
keyFile = file("$projectDir/src/main/config/gcloud.key")
zone = 'europe-west3-c'
project = '...'
gke {
clusterName = 'sb4bdemo'
}
client{
imageName = 'google/cloud-sdk'
version = '159.0.0'
}
}
gcloud.key
stores the service account credentials of Google Cloud.- the
gcloud
plugin will reconfigure thekubectl
plugin to share the same docker image in order to work together to perform authentication withglcoud
.
To setup a service account use:
https://medium.com/google-cloud/using-googles-private-container-registry-with-docker-1b470cf3f50a
Make sure the service account also has the proper Kubernetes credentials, like:
./kubectl create clusterrolebinding your-user-cluster-admin-binding --clusterrole=cluster-admin [email protected]
gcloud
offers three Gradle tasks:
gcloudActivateServiceAccount
to perform the login.gcloudGetKubernetesCredentials
to get the .kubeconfig to start working thekubectl
plugin.gcloudSetProject
called implicitly as dependency to set the current project.
A wrapper cloud
will be generated into the project root to allow easy access from the command line next to Gradle tasks.