osdCloud

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RhSreCcsAccessRolename        = "RH-SRE-CCS-Access"
	RhTechnicalSupportAccess      = "RH-Technical-Support-Access"
	OrganizationAccountAccessRole = "OrganizationAccountAccessRole"
	ProdJumproleConfigKey         = "prod_jumprole_account_id"
	StageJumproleConfigKey        = "stage_jumprole_account_id"
)

Variables

This section is empty.

Functions

func CreateAWSV2Config added in v0.13.5

func CreateAWSV2Config(conn *sdk.Connection, cluster *cmv1.Cluster) (awsSdk.Config, error)

CreateAWSV2Config creates an aws-sdk-go-v2 config via Backplane given an internal cluster id

func GenerateAWSClientForCluster

func GenerateAWSClientForCluster(awsProfile string, clusterID string) (aws.Client, error)

GenerateAWSClientForCluster generates an AWS client given an OCM cluster id and AWS profile name. If an AWS profile name is not specified, this function will also read the AWS_PROFILE environment variable or use the default AWS profile.

func GenerateCCSClusterAWSClient

func GenerateCCSClusterAWSClient(ocmClient *sdk.Connection, awsClient aws.Client, clusterID string, clusterRegion string, partition string, sessionName string) (aws.Client, error)

func GenerateGCPComputeInstancesClient added in v0.14.1

func GenerateGCPComputeInstancesClient() (*compute.InstancesClient, error)

func GenerateJumpRoleCredentials

func GenerateJumpRoleCredentials(client aws.Client, region, sessionName string) (*stsTypes.Credentials, error)

GenerateJumpRoleCredentials performs the Assume Role chain from IAM User to the Jump role This sequence stays within the Red Hat account boundary, so a failure here indicates an internal misconfiguration

func GenerateNonCCSClusterAWSClient

func GenerateNonCCSClusterAWSClient(ocmClient *sdk.Connection, awsClient aws.Client, clusterID string, clusterRegion string, partition string, sessionName string) (aws.Client, error)

func GenerateOrganizationAccountAccessCredentials

func GenerateOrganizationAccountAccessCredentials(client aws.Client, accountId, sessionName, partition string) (*stsTypes.Credentials, error)

GenerateOrganizationAccountAccessCredentials Uses the provided IAM Client to try and assume OrganizationAccountAccessRole for the given AWS Account This only works when the provided client is a user from the root account of an organization and the AWS account provided is a linked accounts within that organization

func GenerateRoleSessionName

func GenerateRoleSessionName(client aws.Client) (string, error)

GenerateRoleSessionName Uses the current IAM ARN to generate a role name. This should end up being RH-SRE-$kerberosID

func GenerateSupportRoleCredentials

func GenerateSupportRoleCredentials(client aws.Client, region, sessionName, targetRole string) (*stsTypes.Credentials, error)

GenerateSupportRoleCredentials Uses the provided IAM Client to perform the Assume Role chain needed to get to a cluster's Support Role

func ListInstances added in v0.14.1

func ListInstances(client *compute.InstancesClient, projectID, zone string) *compute.InstanceIterator

Types

type AwsCluster added in v0.14.3

type AwsCluster struct {
	*BaseClient
	AZs        []string
	AwsProfile string
	AwsClient  aws.Client
}

AwsCluster Concrete struct with fields required only for interacting with the AWS cloud.

func (*AwsCluster) Close added in v0.14.3

func (a *AwsCluster) Close()

func (*AwsCluster) GetAZs added in v0.14.3

func (a *AwsCluster) GetAZs() []string

func (*AwsCluster) GetAllVirtualMachines added in v0.14.3

func (a *AwsCluster) GetAllVirtualMachines(string) ([]VirtualMachine, error)

func (*AwsCluster) Login added in v0.14.3

func (a *AwsCluster) Login() error

type BaseClient added in v0.14.3

type BaseClient struct {
	ClusterId string
	OcmClient *sdk.Connection
	Cluster   *ocmv1.Cluster
}

BaseClient A common struct used to not repeat fields used in the sub'classes' for AWS and GCP.

func (*BaseClient) GetCluster added in v0.14.3

func (b *BaseClient) GetCluster() *ocmv1.Cluster

type ClusterHealthClient added in v0.14.3

type ClusterHealthClient interface {
	Login() error
	GetCluster() *ocmv1.Cluster
	GetAZs() []string
	GetAllVirtualMachines(region string) ([]VirtualMachine, error)
	Close()
}

ClusterHealthClient This client is used to interface with AWS & GCP and provide common abstractions that are generated from the cloud-specific resources. Right now the client is only used by the `osdctl cluster health` command and only provides functions used in that command. It can and should be extended as seen fit if it seems useful.

func NewAwsCluster added in v0.14.3

func NewAwsCluster(ocmClient *sdk.Connection, clusterId string, awsProfile string) (ClusterHealthClient, error)

func NewGcpCluster added in v0.14.3

func NewGcpCluster(ocmClient *sdk.Connection, clusterId string) (ClusterHealthClient, error)

type GcpCluster added in v0.14.3

type GcpCluster struct {
	*BaseClient
	ComputeClient *compute.InstancesClient
	ProjectId     string
	Zones         []string
}

Concrete struct with fields required only for interacting with the GCP cloud.

func (*GcpCluster) Close added in v0.14.3

func (g *GcpCluster) Close()

func (*GcpCluster) GetAZs added in v0.14.3

func (g *GcpCluster) GetAZs() []string

func (*GcpCluster) GetAllVirtualMachines added in v0.14.3

func (g *GcpCluster) GetAllVirtualMachines(region string) ([]VirtualMachine, error)

func (*GcpCluster) Login added in v0.14.3

func (g *GcpCluster) Login() error

type GcpProjectClaim added in v0.14.1

type GcpProjectClaim struct {
	Spec GcpProjectClaimSpec `json:"spec"`
}

func ParseGcpProjectClaim added in v0.14.1

func ParseGcpProjectClaim(raw string) (*GcpProjectClaim, error)

type GcpProjectClaimSpec added in v0.14.1

type GcpProjectClaimSpec struct {
	GcpProjectID string `json:"gcpProjectID"`
}

type VirtualMachine added in v0.14.3

type VirtualMachine struct {
	Original interface{}
	Name     string
	Size     string
	State    string
	Labels   map[string]string
}

VirtualMachine Abstract the AWS instances and GCP instances into a common type. The Original field should store the data returned by the cloud directly, so it can be accessed via casting if needed.

Jump to

Keyboard shortcuts

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