jx: github.com/jenkins-x/jx/pkg/cloud/gke Index | Files | Directories

package gke

import "github.com/jenkins-x/jx/pkg/cloud/gke"

Index

Package Files

gcloud.go helper.go images.go interface.go naming.go

Constants

const KmsLocation = "global"

KmsLocation indicates the location used by the Google KMS service

Variables

var (
    // RequiredServiceAccountRoles the roles required to create a cluster with terraform
    RequiredServiceAccountRoles = []string{"roles/owner"}

    // KanikoServiceAccountRoles the roles required to run kaniko with GCS
    KanikoServiceAccountRoles = []string{"roles/storage.admin",
        "roles/storage.objectAdmin",
        "roles/storage.objectCreator"}

    // VeleroServiceAccountRoles the roles required to run velero with GCS
    VeleroServiceAccountRoles = []string{

        "roles/storage.admin",
        "roles/storage.objectAdmin",
        "roles/storage.objectCreator"}
)
var PROJECT_LIST_HEADER = "PROJECT_ID"

func BucketName Uses

func BucketName(serviceName string) string

BucketName creates a Bucket name for a given service name

func FindLatestImageTag Uses

func FindLatestImageTag(output string) (string, error)

FindLatestImageTag returns the latest image tag from the JSON output of the command ` gcloud container images list-tags gcr.io/jenkinsxio/builder-maven --format jsonhig`

func GcpServiceAccountSecretName Uses

func GcpServiceAccountSecretName(serviceName string) string

GcpServiceAccountSecretName builds the secret name where the GCP service account is stored

func GetCurrentProject Uses

func GetCurrentProject() (string, error)

func GetGoogleMachineTypes Uses

func GetGoogleMachineTypes() []string

func GetGoogleProjects Uses

func GetGoogleProjects() ([]string, error)

func GetGoogleRegions Uses

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

func GetGoogleZones Uses

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

func GetRegionFromZone Uses

func GetRegionFromZone(zone string) string

GetRegionFromZone parses the region from a GCP zone name. TODO: Return an error if the format of the zone is not correct

func KeyName Uses

func KeyName(serviceName string) string

KeyName creates a key name for a given service and cluster name

func KeyringName Uses

func KeyringName(serviceName string) string

KeyringName creates a keyring name for a given service and cluster name

func ParseContext Uses

func ParseContext(context string) (string, string, string, error)

ParseContext parses the context string for GKE and gets the GKE project, GKE zone and cluster name

func ServiceAccountName Uses

func ServiceAccountName(clusterName, serviceAbbreviation string) string

ServiceAccountName creates a service account name for a given service and cluster name

func StreamTransferFileFromBucket Uses

func StreamTransferFileFromBucket(fullBucketURL string) (*bufio.Scanner, error)

StreamTransferFileFromBucket will perform a stream transfer from the GCS bucket to stdout and return a scanner with the piped result

func UploadFileToBucket Uses

func UploadFileToBucket(data []byte, key string, fullBucketURL string) (string, error)

UploadFileToBucket will perform a stream transfer with the provided bytes to the GCS bucket with the target key name

type Cluster Uses

type Cluster struct {
    Name           string            `json:"name,omitempty"`
    ResourceLabels map[string]string `json:"resourceLabels,omitempty"`
    Status         string            `json:"status,omitempty"`
    Location       string            `json:"location,omitempty"`
}

Cluster struct to represent a cluster on gcloud

type GCloud Uses

type GCloud struct {
}

GCloud real implementation of the gcloud helper

func (*GCloud) AddBucketLabel Uses

func (g *GCloud) AddBucketLabel(bucketName string, label string)

AddBucketLabel adds a label to a Google Storage bucket

func (*GCloud) BucketExists Uses

func (g *GCloud) BucketExists(projectID string, bucketName string) (bool, error)

BucketExists checks if a Google Storage bucket exists

func (*GCloud) CheckPermission Uses

func (g *GCloud) CheckPermission(perm string, projectID string) (bool, error)

CheckPermission checks permission on the given project

func (*GCloud) CleanupServiceAccountKeys Uses

func (g *GCloud) CleanupServiceAccountKeys(serviceAccount string, projectID string) error

CleanupServiceAccountKeys remove all keys from given service account

func (*GCloud) ClusterZone Uses

func (g *GCloud) ClusterZone(cluster string) (string, error)

ClusterZone retrives the zone of GKE cluster description

func (*GCloud) ConfigureBucketRoles Uses

func (g *GCloud) ConfigureBucketRoles(projectID string, serviceAccount string, bucketURL string, roles []string) error

ConfigureBucketRoles gives the given roles to the given service account

func (*GCloud) ConnectToCluster Uses

func (g *GCloud) ConnectToCluster(projectID, zone, clusterName string) error

ConnectToCluster connects to the specified cluster

func (*GCloud) ConnectToRegionCluster Uses

func (g *GCloud) ConnectToRegionCluster(projectID, region, clusterName string) error

ConnectToRegionCluster connects to the specified regional cluster

func (*GCloud) CreateBucket Uses

func (g *GCloud) CreateBucket(projectID string, bucketName string, location string) error

CreateBucket creates a new Google Storage bucket

func (*GCloud) CreateDNSZone Uses

func (g *GCloud) CreateDNSZone(projectID string, domain string) (string, []string, error)

CreateDNSZone creates the tenants DNS zone if it doesn't exist and returns the list of name servers for the given domain and project

func (*GCloud) CreateGCPServiceAccount Uses

func (g *GCloud) CreateGCPServiceAccount(kubeClient kubernetes.Interface, serviceName, serviceAbbreviation, namespace, clusterName, projectID string, serviceAccountRoles []string, serviceAccountSecretKey string) (string, error)

CreateGCPServiceAccount creates a service account in GCP for a service using the account roles specified

func (*GCloud) CreateKmsKey Uses

func (g *GCloud) CreateKmsKey(keyName string, keyringName string, projectID string) error

CreateKmsKey creates a new KMS key in the given keyring

func (*GCloud) CreateKmsKeyring Uses

func (g *GCloud) CreateKmsKeyring(keyringName string, projectID string) error

CreateKmsKeyring creates a new KMS keyring

func (*GCloud) CreateManagedZone Uses

func (g *GCloud) CreateManagedZone(projectID string, domain string) error

CreateManagedZone creates a managed zone for the given domain in the specified project

func (*GCloud) CreateServiceAccountKey Uses

func (g *GCloud) CreateServiceAccountKey(serviceAccount string, projectID string, keyPath string) error

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

func (*GCloud) CurrentProject Uses

func (g *GCloud) CurrentProject() (string, error)

CurrentProject returns the current GKE project name if it can be detected

func (*GCloud) DeleteAllObjectsInBucket Uses

func (g *GCloud) DeleteAllObjectsInBucket(bucketName string) error

DeleteAllObjectsInBucket deletes all objects in a Google Storage bucket

func (*GCloud) DeleteBucket Uses

func (g *GCloud) DeleteBucket(bucketName string) error

DeleteBucket deletes a Google storage bucket

func (*GCloud) DeleteServiceAccount Uses

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

DeleteServiceAccount deletes a service account and its role bindings

func (*GCloud) DeleteServiceAccountKey Uses

func (g *GCloud) DeleteServiceAccountKey(serviceAccount string, projectID string, key string) error

DeleteServiceAccountKey deletes a service account key

func (*GCloud) EnableAPIs Uses

func (g *GCloud) EnableAPIs(projectID string, apis ...string) error

EnableAPIs enables APIs for the given services

func (*GCloud) FindBucket Uses

func (g *GCloud) FindBucket(bucketName string) bool

FindBucket finds a Google Storage bucket

func (*GCloud) FindServiceAccount Uses

func (g *GCloud) FindServiceAccount(serviceAccount string, projectID string) bool

FindServiceAccount checks if a service account exists

func (*GCloud) GetEnabledApis Uses

func (g *GCloud) GetEnabledApis(projectID string) ([]string, error)

GetEnabledApis returns which services have the API enabled

func (*GCloud) GetManagedZoneNameServers Uses

func (g *GCloud) GetManagedZoneNameServers(projectID string, domain string) (string, []string, error)

GetManagedZoneNameServers retrieves a list of name servers associated with a zone

func (*GCloud) GetOrCreateServiceAccount Uses

func (g *GCloud) 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 (*GCloud) GetProjectNumber Uses

func (g *GCloud) GetProjectNumber(projectID string) (string, error)

func (*GCloud) GetServiceAccountKeys Uses

func (g *GCloud) GetServiceAccountKeys(serviceAccount string, projectID string) ([]string, error)

GetServiceAccountKeys returns all keys of a service account

func (*GCloud) IsGCSWriteRoleEnabled Uses

func (g *GCloud) IsGCSWriteRoleEnabled(cluster string, zone string) (bool, error)

IsGCSWriteRoleEnabled will check if the devstorage.full_control scope is enabled in the cluster in order to use GCS

func (*GCloud) IsKmsKeyAvailable Uses

func (g *GCloud) IsKmsKeyAvailable(keyName string, keyringName string, projectID string) bool

IsKmsKeyAvailable checks if the KMS key is already available

func (*GCloud) IsKmsKeyringAvailable Uses

func (g *GCloud) IsKmsKeyringAvailable(keyringName string, projectID string) bool

IsKmsKeyringAvailable checks if the KMS keyring is already available

func (*GCloud) ListClusters Uses

func (g *GCloud) ListClusters(region string, projectID string) ([]Cluster, error)

ListClusters returns the clusters in a GKE project

func (*GCloud) ListObjects Uses

func (g *GCloud) ListObjects(bucketName string, path string) ([]string, error)

ListObjects checks if a Google Storage bucket exists

func (*GCloud) LoadGkeCluster Uses

func (g *GCloud) LoadGkeCluster(region string, projectID string, clusterName string) (*Cluster, error)

LoadGkeCluster load a gke cluster from a GKE project

func (*GCloud) Login Uses

func (g *GCloud) 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 (*GCloud) UpdateGkeClusterLabels Uses

func (g *GCloud) UpdateGkeClusterLabels(region string, projectID string, clusterName string, labels []string) error

UpdateGkeClusterLabels updates labesl for a gke cluster

func (*GCloud) UserLabel Uses

func (g *GCloud) UserLabel() string

UserLabel returns a string identifying current user that can be used as a label

type GClouder Uses

type GClouder interface {
    CreateManagedZone(projectID string, domain string) error
    CreateDNSZone(projectID string, domain string) (string, []string, error)
    GetManagedZoneNameServers(projectID string, domain string) (string, []string, error)
    ClusterZone(cluster string) (string, error)
    BucketExists(projectID string, bucketName string) (bool, error)
    CreateBucket(projectID string, bucketName string, location string) error
    AddBucketLabel(bucketName string, label string)
    FindBucket(bucketName string) bool
    DeleteAllObjectsInBucket(bucketName string) error
    DeleteBucket(bucketName string) error
    FindServiceAccount(serviceAccount string, projectID string) bool
    GetOrCreateServiceAccount(serviceAccount string, projectID string, clusterConfigDir string, roles []string) (string, error)
    CreateServiceAccountKey(serviceAccount string, projectID string, keyPath string) error
    GetServiceAccountKeys(serviceAccount string, projectID string) ([]string, error)
    ListClusters(region string, projectID string) ([]Cluster, error)
    LoadGkeCluster(region string, projectID string, clusterName string) (*Cluster, error)
    UpdateGkeClusterLabels(region string, projectID string, clusterName string, labels []string) error
    DeleteServiceAccountKey(serviceAccount string, projectID string, key string) error
    CleanupServiceAccountKeys(serviceAccount string, projectID string) error
    DeleteServiceAccount(serviceAccount string, projectID string, roles []string) error
    GetEnabledApis(projectID string) ([]string, error)
    EnableAPIs(projectID string, apis ...string) error
    Login(serviceAccountKeyPath string, skipLogin bool) error
    CheckPermission(perm string, projectID string) (bool, error)
    CreateKmsKeyring(keyringName string, projectID string) error
    IsKmsKeyringAvailable(keyringName string, projectID string) bool
    CreateKmsKey(keyName string, keyringName string, projectID string) error
    IsKmsKeyAvailable(keyName string, keyringName string, projectID string) bool
    IsGCSWriteRoleEnabled(cluster string, zone string) (bool, error)
    UserLabel() string
    CreateGCPServiceAccount(kubeClient kubernetes.Interface, serviceName, serviceAbbreviation, namespace, clusterName, projectID string, serviceAccountRoles []string, serviceAccountSecretKey string) (string, error)
    ConnectToCluster(projectID, zone, clusterName string) error
    ConnectToRegionCluster(projectID, region, clusterName string) error
    ConfigureBucketRoles(projectID string, serviceAccount string, bucketURL string, roles []string) error
    GetProjectNumber(projectID string) (string, error)
}

GClouder interface to define interactions with the gcloud command go:generate pegomock generate github.com/jenkins-x/jx/pkg/cloud/gke GClouder -o mocks/gclouder.go

type ImageTagInfo Uses

type ImageTagInfo struct {
    Digest string   `json: "digest"`
    Tags   []string `json: "tags"`
}

ImageTagInfo contains tag information for container images

Directories

PathSynopsis
externaldns
mocks
storage
vault

Package gke imports 19 packages (graph) and is imported by 17 packages. Updated 2019-11-02. Refresh now. Tools for package owners.