converter

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvJobsDir is a key for the container Env used to lookup the jobs dir.
	EnvJobsDir = "JOBS_DIR"

	// EnvLogsDir is the path from where to tail file logs.
	EnvLogsDir = "LOGS_DIR"
)
View Source
const (
	// EnvInstanceGroupName is a key for the container Env identifying the
	// instance group that container is started for (CLI)
	EnvInstanceGroupName = "INSTANCE_GROUP_NAME"
	// EnvBOSHManifestPath is a key for the container Env pointing to the BOSH manifest (CLI)
	EnvBOSHManifestPath = "BOSH_MANIFEST_PATH"
	// EnvCFONamespace is a key for the container Env used to lookup the
	// namespace CF operator is running in (CLI)
	EnvCFONamespace = "CF_OPERATOR_NAMESPACE"
	// EnvBaseDir is a key for the container Env used to lookup the base dir (CLI)
	EnvBaseDir = "BASE_DIR"
	// EnvVariablesDir is a key for the container Env used to lookup the variables dir (CLI)
	EnvVariablesDir = "VARIABLES_DIR"
	// EnvOutputFilePath is path where json output is to be redirected (CLI)
	EnvOutputFilePath = "OUTPUT_FILE_PATH"
	// EnvOutputFilePathValue is the value of filepath of JSON output dir
	EnvOutputFilePathValue = "/mnt/quarks"

	// InstanceGroupOutputFilename i s the file name of the JSON output file, which quarks job will look for
	InstanceGroupOutputFilename = "ig.json"
	// BPMOutputFilename i s the file name of the JSON output file, which quarks job will look for
	BPMOutputFilename = "bpm.json"

	// VarInterpolationContainerName is the name of the container that
	// performs variable interpolation for a manifest. It's also part of
	// the output secret's name
	VarInterpolationContainerName = "desired-manifest"
	// PodNameEnvVar is the environment variable containing metadata.name used to render BOSH spec.id. (CLI)
	PodNameEnvVar = "POD_NAME"
	// PodIPEnvVar is the environment variable containing status.podIP used to render BOSH spec.ip. (CLI)
	PodIPEnvVar = "POD_IP"
)
View Source
const (
	// VolumeRenderingDataName is the volume name for the rendering data.
	VolumeRenderingDataName = "rendering-data"
	// VolumeRenderingDataMountPath is the mount path for the rendering data.
	VolumeRenderingDataMountPath = "/var/vcap/all-releases"

	// VolumeJobsDirName is the volume name for the jobs directory.
	VolumeJobsDirName = "jobs-dir"
	// VolumeJobsDirMountPath is the mount path for the jobs directory.
	VolumeJobsDirMountPath = "/var/vcap/jobs"

	// VolumeJobsSrcDirName is the volume name for the jobs-src directory.
	VolumeJobsSrcDirName = "jobs-src-dir"
	// VolumeJobsSrcDirMountPath is the mount path for the jobs-src directory.
	VolumeJobsSrcDirMountPath = "/var/vcap/jobs-src"

	// VolumeDataDirName is the volume name for the data directory.
	VolumeDataDirName = "data-dir"
	// VolumeDataDirMountPath is the mount path for the ephemeral (data) directory.
	VolumeDataDirMountPath = bdm.DataDir

	// VolumeSysDirName is the volume name for the sys directory.
	VolumeSysDirName = "sys-dir"
	// VolumeSysDirMountPath is the mount path for the sys directory.
	VolumeSysDirMountPath = bdm.SysDir

	// VolumeStoreDirMountPath is the mount path for the store directory.
	VolumeStoreDirMountPath = "/var/vcap/store"

	// AdditionalVolumeBaseName helps in building an additional volume name together with
	// the index under the additional_volumes bpm list inside the bpm process schema.
	AdditionalVolumeBaseName = "bpm-additional-volume"

	// AdditionalVolumesRegex ensures only a valid path is defined
	// under the additional_volumes bpm list inside the bpm process schema.
	AdditionalVolumesRegex = "((/var/vcap/data/.+)|(/var/vcap/store/.+)|(/var/vcap/sys/run/.+))"

	// AdditionalVolumesVcapStoreRegex ensures that the path is of the form
	// /var/vcap/store.
	AdditionalVolumesVcapStoreRegex = "(/var/vcap/store/.+)"

	// UnrestrictedVolumeBaseName is the volume name for the unrestricted ones.
	UnrestrictedVolumeBaseName = "bpm-unrestricted-volume"
)
View Source
const (
	// VolumeLinksPath is the mount path for the links data.
	VolumeLinksPath = "/var/run/secrets/links/"
)

Variables

This section is empty.

Functions

func GetOperatorDockerImage

func GetOperatorDockerImage() string

GetOperatorDockerImage returns the image name of the operator docker image

func GetOperatorImagePullPolicy added in v1.0.0

func GetOperatorImagePullPolicy() corev1.PullPolicy

GetOperatorImagePullPolicy returns the image pull policy to be used for generated pods

func SetupOperatorDockerImage

func SetupOperatorDockerImage(org, repo, tag string, pullPolicy corev1.PullPolicy) error

SetupOperatorDockerImage initializes the package scoped variable

Types

type BPMResources

type BPMResources struct {
	InstanceGroups         []qstsv1a1.QuarksStatefulSet
	Errands                []qjv1a1.QuarksJob
	Services               []corev1.Service
	PersistentVolumeClaims []corev1.PersistentVolumeClaim
}

BPMResources contains BPM related k8s resources, which were converted from BOSH objects

type ContainerFactory

type ContainerFactory interface {
	JobsToInitContainers(jobs []bdm.Job, defaultVolumeMounts []corev1.VolumeMount, bpmDisks disk.BPMResourceDisks, requiredService *string) ([]corev1.Container, error)
	JobsToContainers(jobs []bdm.Job, defaultVolumeMounts []corev1.VolumeMount, bpmDisks disk.BPMResourceDisks) ([]corev1.Container, error)
}

ContainerFactory builds Kubernetes containers from BOSH jobs.

type ContainerFactoryImpl added in v0.4.1

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

ContainerFactoryImpl is a concrete implementation of ContainerFactor.

func NewContainerFactory

func NewContainerFactory(manifestName string, instanceGroupName string, version string, disableLogSidecar bool, releaseImageProvider ReleaseImageProvider, bpmConfigs bpm.Configs) *ContainerFactoryImpl

NewContainerFactory returns a concrete implementation of ContainerFactory.

func (*ContainerFactoryImpl) JobsToContainers added in v0.4.1

func (c *ContainerFactoryImpl) JobsToContainers(
	jobs []bdm.Job,
	defaultVolumeMounts []corev1.VolumeMount,
	bpmDisks disk.BPMResourceDisks,
) ([]corev1.Container, error)

JobsToContainers creates a list of Containers for corev1.PodSpec Containers field.

func (*ContainerFactoryImpl) JobsToInitContainers added in v0.4.1

func (c *ContainerFactoryImpl) JobsToInitContainers(
	jobs []bdm.Job,
	defaultVolumeMounts []corev1.VolumeMount,
	bpmDisks disk.BPMResourceDisks,
	requiredService *string,
) ([]corev1.Container, error)

JobsToInitContainers creates a list of Containers for corev1.PodSpec InitContainers field.

type DesiredManifest added in v1.0.0

type DesiredManifest interface {
	DesiredManifest(ctx context.Context, boshDeploymentName, namespace string) (*bdm.Manifest, error)
}

DesiredManifest unmarshals desired manifest from the manifest secret

func NewDesiredManifest added in v1.0.0

func NewDesiredManifest(client client.Client) DesiredManifest

NewDesiredManifest constructs a resolver

type Interpolator

type Interpolator interface {
	BuildOps(opsBytes []byte) error
	Interpolate(manifestBytes []byte) ([]byte, error)
}

Interpolator renders BOSH manifests by operations files

type InterpolatorImpl

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

InterpolatorImpl applies desired changes from BOSH operations files to to BOSH manifest

func NewInterpolator

func NewInterpolator() *InterpolatorImpl

NewInterpolator constructs an interpolator

func (*InterpolatorImpl) BuildOps

func (i *InterpolatorImpl) BuildOps(opsBytes []byte) error

BuildOps unmarshals ops definitions, processes them and holds them in memory

func (*InterpolatorImpl) Interpolate

func (i *InterpolatorImpl) Interpolate(manifestBytes []byte) ([]byte, error)

Interpolate returns manifest which is rendered by operations files

type JobFactory

type JobFactory struct {
	Namespace string
}

JobFactory is a concrete implementation of JobFactory

func NewJobFactory

func NewJobFactory(namespace string) *JobFactory

NewJobFactory returns a concrete implementation of JobFactory

func (*JobFactory) InstanceGroupManifestJob

func (f *JobFactory) InstanceGroupManifestJob(manifest bdm.Manifest, linkInfos LinkInfos, initialRollout bool) (*qjv1a1.QuarksJob, error)

InstanceGroupManifestJob generates the job to create an instance group manifest

func (*JobFactory) VariableInterpolationJob

func (f *JobFactory) VariableInterpolationJob(manifest bdm.Manifest) (*qjv1a1.QuarksJob, error)

VariableInterpolationJob returns an quarks job to create the desired manifest The desired manifest is a BOSH manifest with all variables interpolated. It's sometimes referred to as the 'with-vars' manifest.

type KubeConverter

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

KubeConverter represents a Manifest in kube resources

func NewKubeConverter

func NewKubeConverter(namespace string, volumeFactory VolumeFactory, newContainerFactoryFunc NewContainerFactoryFunc) *KubeConverter

NewKubeConverter converts a Manifest into kube resources

func (*KubeConverter) BPMResources

func (kc *KubeConverter) BPMResources(manifestName string, dns manifest.DomainNameService, qStsVersion string, instanceGroup *bdm.InstanceGroup, releaseImageProvider ReleaseImageProvider, bpmConfigs bpm.Configs, igResolvedSecretVersion string) (*BPMResources, error)

BPMResources uses BOSH Process Manager information to create k8s container specs from single BOSH instance group. It returns quarks stateful sets, services and quarks jobs.

func (*KubeConverter) Variables

func (kc *KubeConverter) Variables(manifestName string, variables []bdm.Variable) ([]qsv1a1.QuarksSecret, error)

Variables returns quarks secrets for a list of BOSH variables

type LinkInfo added in v1.0.0

type LinkInfo struct {
	SecretName   string
	ProviderName string
}

LinkInfo specifies the link provider and its secret name from Kube native components

type LinkInfos added in v1.0.0

type LinkInfos []LinkInfo

LinkInfos is a list of LinkInfo

func (*LinkInfos) VolumeMounts added in v1.0.0

func (q *LinkInfos) VolumeMounts() []corev1.VolumeMount

VolumeMounts returns a list of volumeMounts from LinkInfos

func (*LinkInfos) Volumes added in v1.0.0

func (q *LinkInfos) Volumes() []corev1.Volume

Volumes returns a list of volumes from LinkInfos

type NewContainerFactoryFunc added in v0.4.1

type NewContainerFactoryFunc func(manifestName string, instanceGroupName string, version string, disableLogSidecar bool, releaseImageProvider ReleaseImageProvider, bpmConfigs bpm.Configs) ContainerFactory

NewContainerFactoryFunc returns ContainerFactory from single BOSH instance group.

type NewInterpolatorFunc

type NewInterpolatorFunc func() Interpolator

NewInterpolatorFunc returns a fresh Interpolator

type ReleaseImageProvider

type ReleaseImageProvider interface {
	// GetReleaseImage returns the release image for an job in an instance group
	GetReleaseImage(instanceGroupName, jobName string) (string, error)
}

ReleaseImageProvider interface to provide the docker release image for a BOSH job This lookup is currently implemented by the manifest model.

type Resolver

type Resolver interface {
	WithOpsManifest(ctx context.Context, instance *bdv1.BOSHDeployment, namespace string) (*bdm.Manifest, []string, error)
	WithOpsManifestDetailed(ctx context.Context, instance *bdv1.BOSHDeployment, namespace string) (*bdm.Manifest, []string, error)
}

Resolver interface to provide a BOSH manifest resolved references from bdpl CRD

func NewResolver

func NewResolver(client client.Client, f NewInterpolatorFunc) Resolver

NewResolver constructs a resolver

type ResolverImpl

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

ResolverImpl resolves references from bdpl CRD to a BOSH manifest

func (*ResolverImpl) DesiredManifest

func (r *ResolverImpl) DesiredManifest(ctx context.Context, boshDeploymentName, namespace string) (*bdm.Manifest, error)

DesiredManifest reads the versioned secret created by the variable interpolation job and unmarshals it into a Manifest object

func (*ResolverImpl) WithOpsManifest

func (r *ResolverImpl) WithOpsManifest(ctx context.Context, instance *bdv1.BOSHDeployment, namespace string) (*bdm.Manifest, []string, error)

WithOpsManifest returns manifest and a list of implicit variables referenced by our bdpl CRD The resulting manifest has variables interpolated and ops files applied. It is the 'with-ops' manifest.

func (*ResolverImpl) WithOpsManifestDetailed

func (r *ResolverImpl) WithOpsManifestDetailed(ctx context.Context, instance *bdv1.BOSHDeployment, namespace string) (*bdm.Manifest, []string, error)

WithOpsManifestDetailed returns manifest and a list of implicit variables referenced by our bdpl CRD The resulting manifest has variables interpolated and ops files applied. It is the 'with-ops' manifest. This variant processes each ops file individually, so it's more debuggable - but slower.

type VolumeFactory added in v0.4.1

type VolumeFactory interface {
	GenerateDefaultDisks(manifestName string, instanceGroupName string, igResolvedSecretVersion string, namespace string) disk.BPMResourceDisks
	GenerateBPMDisks(manifestName string, instanceGroup *bdm.InstanceGroup, bpmConfigs bpm.Configs, namespace string) (disk.BPMResourceDisks, error)
}

VolumeFactory builds Kubernetes containers from BOSH jobs.

type VolumeFactoryImpl added in v0.4.1

type VolumeFactoryImpl struct {
}

VolumeFactoryImpl is a concrete implementation of VolumeFactoryImpl

func NewVolumeFactory added in v0.4.1

func NewVolumeFactory() *VolumeFactoryImpl

NewVolumeFactory returns a concrete implementation of VolumeFactory

func (*VolumeFactoryImpl) GenerateBPMDisks added in v0.4.1

func (f *VolumeFactoryImpl) GenerateBPMDisks(manifestName string, instanceGroup *bdm.InstanceGroup, bpmConfigs bpm.Configs, namespace string) (disk.BPMResourceDisks, error)

GenerateBPMDisks defines any other volumes required to be mounted, based on the bpm process schema definition. This looks for: - ephemeral_disk (boolean) - persistent_disk (boolean) - additional_volumes (list of volumes) - unrestricted_volumes (list of volumes)

func (*VolumeFactoryImpl) GenerateDefaultDisks added in v0.4.1

func (f *VolumeFactoryImpl) GenerateDefaultDisks(manifestName string, instanceGroupName string, igResolvedSecretVersion string, namespace string) disk.BPMResourceDisks

GenerateDefaultDisks defines default disks. This looks for: - the rendering data volume - the the jobs volume - the ephemeral (data) volume - the sys volume - the "not interpolated" manifest volume - resolved properties data volume

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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