gke

package
v1.3.822 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2019 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const KmsLocation = "global"

KmsLocation indicates the location used by the Google KMS service

Variables

View Source
var PROJECT_LIST_HEADER = "PROJECT_ID"
View Source
var (
	REQUIRED_SERVICE_ACCOUNT_ROLES = []string{"roles/compute.instanceAdmin.v1",
		"roles/iam.serviceAccountActor",
		"roles/container.clusterAdmin",
		"roles/container.admin",
		"roles/container.developer",
		"roles/storage.objectAdmin",
		"roles/editor"}
)

Functions

func BucketExists

func BucketExists(projectID string, bucketName string) (bool, error)

BucketExists checks if a Google Storage bucket exists

func CheckPermission

func CheckPermission(perm string, projectID string) (bool, error)

CheckPermission checks permission on the given project

func CleanupServiceAccountKeys

func CleanupServiceAccountKeys(serviceAccount string, projectID string) error

CleanupServiceAccountKeys remove all keys from given service account

func ClusterName

func ClusterName(kuber kube.Kuber) (string, error)

ClusterName gets the cluster name from the current context Note that this just reads the ClusterName from the local kube config, which can be renamed (but is unlikely to happen)

func ClusterZone

func ClusterZone(cluster string) (string, error)

ClusterZone retrives the zone of GKE cluster description

func CreateBucket

func CreateBucket(projectID string, bucketName string, location string) error

CreateBucket creates a new Google Storage bucket

func CreateKmsKey

func CreateKmsKey(keyName string, keyringName string, projectID string) error

CreateKmsKey creates a new KMS key in the given keyring

func CreateKmsKeyring

func CreateKmsKeyring(keyringName string, projectID string) error

CreateKmsKeyring creates a new KMS keyring

func CreateServiceAccountKey

func CreateServiceAccountKey(serviceAccount string, projectID string, keyPath string) error

CreateServiceAccountKey creates a new service account key and downloads into the given file

func DeleteAllObjectsInBucket

func DeleteAllObjectsInBucket(bucketName string) error

DeleteAllObjectsInBucket deletes all objects in a Google Storage bucket

func DeleteBucket

func DeleteBucket(bucketName string) error

DeleteBucket deletes a Google storage bucket

func DeleteServiceAccount

func DeleteServiceAccount(serviceAccount string, projectID string, roles []string) error

DeleteServiceAccount deletes a service account and its role bindings

func DeleteServiceAccountKey

func DeleteServiceAccountKey(serviceAccount string, projectID string, key string) error

DeleteServiceAccountKey deletes a service account key

func EnableAPIs

func EnableAPIs(projectID string, apis ...string) error

EnableAPIs enables APIs for the given services

func FindBucket

func FindBucket(bucketName string) bool

FindBucket finds a Google Storage bucket

func FindServiceAccount

func FindServiceAccount(serviceAccount string, projectID string) bool

FindServiceAccount checks if a service account exists

func GetCurrentProject

func GetCurrentProject() (string, error)

func GetEnabledApis

func GetEnabledApis(projectID string) ([]string, error)

GetEnabledApis returns which services have the API enabled

func GetGoogleMachineTypes

func GetGoogleMachineTypes() []string

func GetGoogleProjects

func GetGoogleProjects() ([]string, error)

func GetGoogleZones

func GetGoogleZones(project string) ([]string, error)

func GetOrCreateServiceAccount

func GetOrCreateServiceAccount(serviceAccount string, projectID string, clusterConfigDir string, roles []string) (string, error)

GetOrCreateServiceAccount retrieves or creates a GCP service account. It will return the path to the file where the service account token is stored

func GetRegionFromZone

func GetRegionFromZone(zone string) string

GetRegionFromZone parses the region from a GCP zone name

func GetServiceAccountKeys

func GetServiceAccountKeys(serviceAccount string, projectID string) ([]string, error)

GetServiceAccountKeys returns all keys of a service account

func GetSimplifiedClusterName

func GetSimplifiedClusterName(complexClusterName string) string

GetSimplifiedClusterName get the simplified cluster name from the long-winded context cluster name that gets generated GKE cluster names as defined in the kube config are of the form gke_<projectname>_<region>_<clustername> This method will return <clustername> in the above

func IsKmsKeyAvailable

func IsKmsKeyAvailable(keyName string, keyringName string, projectID string) bool

IsKmsKeyAvailable checks if the KMS key is already available

func IsKmsKeyringAvailable

func IsKmsKeyringAvailable(keyringName string, projectID string) bool

IsKmsKeyringAvailable checks if the KMS keyring is already available

func Login

func Login(serviceAccountKeyPath string, skipLogin bool) error

Login login an user into Google account. It skips the interactive login using the browser when the skipLogin flag is active

func ShortClusterName

func ShortClusterName(kuber kube.Kuber) (string, error)

ShortClusterName returns a short clusters name. Eg, if ClusterName would return tweetypie-jenkinsx-dev, ShortClusterName would return tweetypie. This is needed because GCP has character limits on things like service accounts (6-30 chars) and combining a long cluster name and a long vault name exceeds this limit

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL