cloudinstall

package
v0.0.0-...-7d3c339 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 65 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDatabaseComputeTier   = armpostgresqlflexibleservers.SKUTierBurstable
	DefaultDatabaseVMSize        = "Standard_B1ms"
	DefaultPostgresMajorVersion  = 16
	DefaultInitialDatabaseSizeGb = 32
	DefaultBackupRetentionDays   = 7
)
View Source
const (
	TygerNamespace          = "tyger"
	DefaultTygerReleaseName = TygerNamespace
)
View Source
const DefaultKubernetesVersion = "1.27" // LTS
View Source
const (
	EnvironmentKindCloud = "azureCloud"
)
View Source
const (
	TagKey = "tyger-environment"
)

Variables

View Source
var (
	ResourceNameRegex       = regexp.MustCompile(`^[a-z][a-z\-0-9]{1,23}$`)
	StorageAccountNameRegex = regexp.MustCompile(`^[a-z0-9]{3,24}$`)
	SubdomainRegex          = regexp.MustCompile(`^[a-zA-Z]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?$`)
	DatabaseServerNameRegex = regexp.MustCompile(`^([a-z0-9](?:[a-z0-9\-]{1,61}[a-z0-9])?)?$`)
)
View Source
var (
	ErrNotLoggedIn = errors.New("you must run `az login` before running this command")
)

Functions

func CreateOrUpdateAppByUri

func CreateOrUpdateAppByUri(ctx context.Context, cred azcore.TokenCredential, app aadApp) (objectId string, err error)

func CreateServicePrincipal

func CreateServicePrincipal(ctx context.Context, cred azcore.TokenCredential, appId string) (string, error)

func GetAppByUri

func GetAppByUri(ctx context.Context, cred azcore.TokenCredential, uri string) (aadApp, error)

func GetChartSpec

func GetChartSpec(
	helmChartConfig *HelmChartConfig,
	helmClient helmclient.Client,
	overrideHelmChartConfig *HelmChartConfig,
	customizeSpec ...func(*helmclient.ChartSpec, helmclient.Client) error,
) (helmclient.ChartSpec, error)

func GetDefaultApiVersionForResource

func GetDefaultApiVersionForResource(ctx context.Context, resourceId string, providersClient *armresources.ProvidersClient) (string, error)

func GetDomainNameRegex

func GetDomainNameRegex(location string) *regexp.Regexp

func GetDomainNameSuffix

func GetDomainNameSuffix(location string) string

func GetGraphToken

func GetGraphToken(ctx context.Context, cred azcore.TokenCredential) (azcore.AccessToken, error)

func GetServicePrincipalByAppId

func GetServicePrincipalByAppId(ctx context.Context, cred azcore.TokenCredential, appId string) (string, error)

func GetServicePrincipalDisplayName

func GetServicePrincipalDisplayName(ctx context.Context, cred azcore.TokenCredential, objectId string) (string, error)

func GetSubscriptionId

func GetSubscriptionId(ctx context.Context, subName string, cred azcore.TokenCredential) (string, error)

func GetUserPrincipalName

func GetUserPrincipalName(ctx context.Context, cred azcore.TokenCredential, objectId string) (string, error)

func NewMiAwareAzureCLICredential

func NewMiAwareAzureCLICredential(options *azidentity.AzureCLICredentialOptions) (azcore.TokenCredential, error)

az account get-access-token fails if --tenant is provided and the user is logged in with a managed identity This creates a TokenProvider that works around this case

func Ptr

func Ptr[T any](t T) *T

func RandomAlphanumString

func RandomAlphanumString(n int) string

func RenderConfig

func RenderConfig(templateValues ConfigTemplateValues, writer io.Writer) error

Types

type ApiConfig

type ApiConfig struct {
	DomainName string      `json:"domainName"`
	Auth       *AuthConfig `json:"auth"`
	Helm       *HelmConfig `json:"helm"`
}

type AuthConfig

type AuthConfig struct {
	TenantID  string `json:"tenantId"`
	ApiAppUri string `json:"apiAppUri"`
	CliAppUri string `json:"cliAppUri"`
}

type CloudConfig

type CloudConfig struct {
	TenantID              string              `json:"tenantId"`
	SubscriptionID        string              `json:"subscriptionId"`
	DefaultLocation       string              `json:"defaultLocation"`
	ResourceGroup         string              `json:"resourceGroup"`
	Compute               *ComputeConfig      `json:"compute"`
	Storage               *StorageConfig      `json:"storage"`
	DatabaseConfig        *DatabaseConfig     `json:"database"`
	LogAnalyticsWorkspace *NamedAzureResource `json:"logAnalyticsWorkspace"`
}

type CloudEnvironmentConfig

type CloudEnvironmentConfig struct {
	Kind            string       `json:"kind"`
	EnvironmentName string       `json:"environmentName"`
	Cloud           *CloudConfig `json:"cloud"`
	Api             *ApiConfig   `json:"api"`
}

type ClusterConfig

type ClusterConfig struct {
	Name              string            `json:"name"`
	ApiHost           bool              `json:"apiHost"`
	Location          string            `json:"location"`
	KubernetesVersion string            `json:"kubernetesVersion,omitempty"`
	UserNodePools     []*NodePoolConfig `json:"userNodePools"`
}

type ComputeConfig

type ComputeConfig struct {
	Clusters                   []*ClusterConfig `json:"clusters"`
	ManagementPrincipals       []Principal      `json:"managementPrincipals"`
	PrivateContainerRegistries []string         `json:"privateContainerRegistries"`
}

func (*ComputeConfig) GetApiHostCluster

func (c *ComputeConfig) GetApiHostCluster() *ClusterConfig

func (*ComputeConfig) GetManagementPrincipalIds

func (c *ComputeConfig) GetManagementPrincipalIds() []string

type ConfigTemplateValues

type ConfigTemplateValues struct {
	EnvironmentName          string
	ResourceGroup            string
	TenantId                 string
	SubscriptionId           string
	DefaultLocation          string
	KubernetesVersion        string
	Principal                Principal
	DatabaseServerName       string
	PostgresMajorVersion     int
	BufferStorageAccountName string
	LogsStorageAccountName   string
	DomainName               string
	ApiTenantId              string
	CurrentIpAddress         string
	CpuNodePoolMinCount      int
	GpuNodePoolMinCount      int
}

type DatabaseConfig

type DatabaseConfig struct {
	ServerName           string          `json:"serverName"`
	Location             string          `json:"location"`
	ComputeTier          string          `json:"computeTier"`
	VMSize               string          `json:"vmSize"`
	FirewallRules        []*FirewallRule `json:"firewallRules,omitempty"`
	PostgresMajorVersion int             `json:"postgresMajorVersion"`
	StorageSizeGB        int             `json:"storageSizeGB"`
	BackupRetentionDays  int             `json:"backupRetentionDays"`
	BackupGeoRedundancy  bool            `json:"backupGeoRedundancy"`
}

type FirewallRule

type FirewallRule struct {
	Name           string `json:"name"`
	StartIpAddress string `json:"startIpAddress"`
	EndIpAddress   string `json:"endIpAddress"`
}

type HelmChartConfig

type HelmChartConfig struct {
	Namespace   string         `json:"namespace"`
	ReleaseName string         `json:"releaseName"`
	RepoName    string         `json:"repoName"`
	RepoUrl     string         `json:"repoUrl"`
	Version     string         `json:"version"`
	ChartRef    string         `json:"chartRef"`
	Values      map[string]any `json:"values"`
}

type HelmConfig

type HelmConfig struct {
	Tyger              *HelmChartConfig `json:"tyger"`
	Traefik            *HelmChartConfig `json:"traefik"`
	CertManager        *HelmChartConfig `json:"certManager"`
	NvidiaDevicePlugin *HelmChartConfig `json:"nvidiaDevicePlugin"`
}

type Installer

type Installer struct {
	Config     *CloudEnvironmentConfig
	Credential azcore.TokenCredential
}

func (*Installer) ApplyMigrations

func (inst *Installer) ApplyMigrations(ctx context.Context, targetVersion int, latest, offline, waitForCompletion bool) error

func (*Installer) CreateStorageAccount

func (inst *Installer) CreateStorageAccount(ctx context.Context,
	storageAccountConfig *StorageAccountConfig,
	restConfigPromise *install.Promise[*rest.Config],
	managedIdentityPromise *install.Promise[*armmsi.Identity],
) (any, error)

func (*Installer) GetMigrationLogs

func (inst *Installer) GetMigrationLogs(ctx context.Context, id int, destination io.Writer) error

func (*Installer) GetUserRESTConfig

func (inst *Installer) GetUserRESTConfig(ctx context.Context) (*rest.Config, error)

func (*Installer) InstallCloud

func (inst *Installer) InstallCloud(ctx context.Context) (err error)

func (*Installer) InstallIdentities

func (inst *Installer) InstallIdentities(ctx context.Context, cred azcore.TokenCredential) error

func (*Installer) InstallTyger

func (inst *Installer) InstallTyger(ctx context.Context) error

func (*Installer) InstallTygerHelmChart

func (inst *Installer) InstallTygerHelmChart(ctx context.Context, restConfig *rest.Config, dryRun bool) (manifest string, valuesYaml string, err error)

func (*Installer) ListDatabaseVersions

func (inst *Installer) ListDatabaseVersions(ctx context.Context, allVersions bool) ([]install.DatabaseVersion, error)

func (*Installer) PodExec

func (inst *Installer) PodExec(ctx context.Context, podName string, command ...string) (stdout *bytes.Buffer, stderr *bytes.Buffer, err error)

func (*Installer) QuickValidateConfig

func (inst *Installer) QuickValidateConfig() bool

func (*Installer) UninstallCloud

func (inst *Installer) UninstallCloud(ctx context.Context) (err error)

func (*Installer) UninstallTyger

func (inst *Installer) UninstallTyger(ctx context.Context, _ bool) error

type NamedAzureResource

type NamedAzureResource struct {
	ResourceGroup string `json:"resourceGroup"`
	Name          string `json:"name"`
}

type NodePoolConfig

type NodePoolConfig struct {
	Name     string `json:"name"`
	VMSize   string `json:"vmSize"`
	MinCount int32  `json:"minCount"`
	MaxCount int32  `json:"maxCount"`
}

type Principal

type Principal struct {
	ObjectId          string        `json:"objectId"`
	UserPrincipalName string        `json:"userPrincipalName"`
	Kind              PrincipalKind `json:"kind"`

	// Deprecated: Id is deprecated. Use ObjectId instead
	Id string `json:"id"`
}

func ObjectsIdToPrincipals

func ObjectsIdToPrincipals(ctx context.Context, cred azcore.TokenCredential, objectIds []string) ([]Principal, error)

type PrincipalKind

type PrincipalKind string
const (
	PrincipalKindUser             PrincipalKind = "User"
	PrincipalKindGroup            PrincipalKind = "Group"
	PrincipalKindServicePrincipal PrincipalKind = "ServicePrincipal"
)

type StorageAccountConfig

type StorageAccountConfig struct {
	Name     string `json:"name"`
	Location string `json:"location"`
	Sku      string `json:"sku"`
}

type StorageConfig

type StorageConfig struct {
	Buffers []*StorageAccountConfig `json:"buffers"`
	Logs    *StorageAccountConfig   `json:"logs"`
}

Jump to

Keyboard shortcuts

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