deploy

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package deploy is purposed to deploy an app. This concern encompasses creating the app CRD if it doesn't exist, possibly creating the app image from source code, and then creating a deployment that will the image in a k8s cluster.

Index

Constants

View Source
const (
	FlagApp                = "app"
	FlagImage              = "image"
	FlagKetchYaml          = "ketch-yaml"
	FlagStrict             = "strict"
	FlagSteps              = "steps"
	FlagStepInterval       = "step-interval"
	FlagWait               = "wait"
	FlagTimeout            = "timeout"
	FlagDescription        = "description"
	FlagEnvironment        = "env"
	FlagFramework          = "framework"
	FlagRegistrySecret     = "registry-secret"
	FlagBuilder            = "builder"
	FlagBuildPacks         = "build-packs"
	FlagVolume             = "volume"
	FlagVolumeMountPath    = "volume-mount-path"
	FlagVolumeMountOptions = "volume-mount-options"
	FlagFSGroup            = "fs-group"
	FlagRunAsUser          = "run-as-user"
	FlagUnits              = "units"
	FlagVersion            = "unit-version"
	FlagProcess            = "unit-process"

	FlagAppShort         = "a"
	FlagImageShort       = "i"
	FlagDescriptionShort = "d"
	FlagEnvironmentShort = "e"
	FlagFrameworkShort   = "k"
)

Command line flags

Variables

View Source
var (
	DefaultBuilder = "heroku/buildpacks:20"
)

Functions

func GetImageConfig

func GetImageConfig(ctx context.Context, args ImageConfigRequest) (*registryv1.ConfigFile, error)

func WaitForDeployment

func WaitForDeployment(ctx context.Context, svc *Services, app *ketchv1.App, timeout time.Duration) error

Types

type Application

type Application struct {
	Version        *string   `json:"version,omitempty"`
	Type           *string   `json:"type"`
	Name           *string   `json:"name"`
	Image          *string   `json:"image,omitempty"`
	Framework      *string   `json:"framework"`
	Description    *string   `json:"description,omitempty"`
	Environment    []string  `json:"environment,omitempty"`
	RegistrySecret *string   `json:"registrySecret,omitempty"`
	Builder        *string   `json:"builder,omitempty"`
	BuildPacks     []string  `json:"buildPacks,omitempty"`
	Processes      []Process `json:"processes,omitempty"`
	CName          *CName    `json:"cname,omitempty"`
}

Application represents the fields in an application.yaml file that will be transitioned to a ChangeSet.

func GetApplicationFromKetchApp

func GetApplicationFromKetchApp(app ketchv1.App) *Application

GetApplicationFromKetchApp takes an App parameter and returns a yaml-file friendly Application

type CName

type CName struct {
	DNSName string `json:"dnsName"`
	Secure  bool   `json:"secure"`
}

type ChangeSet

type ChangeSet struct {
	// contains filtered or unexported fields
}

type Client

type Client interface {
	Get(ctx context.Context, key client.ObjectKey, obj client.Object) error
	Create(ctx context.Context, obj client.Object, opts ...client.CreateOption) error
	Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error
}

Client represents go sdk k8s client operations that we need.

type GetImageConfigFn

type GetImageConfigFn func(ctx context.Context, args ImageConfigRequest) (*registryv1.ConfigFile, error)

type Hooks

type Hooks struct {
	Restart Restart `json:"restart"`
}

type ImageConfigRequest

type ImageConfigRequest struct {
	// contains filtered or unexported fields
}

type Options

type Options struct {
	AppName                 string
	Image                   string
	KetchYamlFileName       string
	StrictKetchYamlDecoding bool
	Steps                   int
	StepTimeInterval        string
	Wait                    bool
	Timeout                 string
	AppSourcePath           string
	SubPaths                []string

	Framework            string
	Description          string
	Envs                 []string
	DockerRegistrySecret string
	Builder              string
	BuildPacks           []string
	Volume               string
	VolumeMountPath      string
	VolumeMountOptions   map[string]string
	FSGroup              int64
	RunAsUser            int64

	Units   int
	Version int
	Process string
}

Options receive values set in flags. They are processed into a ChangeSet which describes the values that have been explicitly set by the end user. In this way we know if we will need to update an existing app CRD.

func (Options) GetChangeSet

func (o Options) GetChangeSet(flags *pflag.FlagSet) *ChangeSet

func (*Options) GetChangeSetFromYaml

func (o *Options) GetChangeSetFromYaml(filename string) (*ChangeSet, error)

GetChangeSetFromYaml reads an application.yaml file and returns a ChangeSet from the file's values.

type Port

type Port struct {
	Protocol   string `json:"protocol"`
	Port       int    `json:"port"`
	TargetPort int    `json:"targetPort"`
}

type Process

type Process struct {
	Name  string `json:"name"`  // required
	Units *int   `json:"units"` // default 1
}

type Restart

type Restart struct {
	Before string `json:"before"`
	After  string `json:"after"`
}

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner is concerned with managing and running the deployment.

func New

func New(params *ChangeSet) *Runner

New creates a Runner which will execute the deployment.

func (Runner) Run

func (r Runner) Run(ctx context.Context, svc *Services) error

Run executes the deployment. This includes creating the application CRD if it doesn't already exist, possibly building source code and creating an image and creating and applying a deployment CRD to the cluster.

type Services

type Services struct {
	// Client gets updates and creates ketch CRDs
	Client Client
	// Kubernetes client
	KubeClient kubernetes.Interface
	// Builder references source builder from internal/builder package
	Builder SourceBuilderFn
	// Function that retrieve image config
	GetImageConfig GetImageConfigFn
	// Wait is a function that will wait until it detects the a deployment is finished
	Wait WaitFn
	// Writer probably points to stdout or stderr, receives textual output
	Writer io.Writer
}

Services contains interfaces and function pointers to external services needed for deploy. The purpose of this structure is so that we can swap out implementations of these services for unit tests.

type WaitFn

type WaitFn func(ctx context.Context, svc *Services, app *ketchv1.App, timeout time.Duration) error

Jump to

Keyboard shortcuts

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