bpmconverter

package
v1.0.1-0...-b3ee44d Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package bpmconverter converts bpm configs + ig manifests into k8s resources (services, qjob, qsts)

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"
	// EnvDeploymentName is the name of the BOSH deployment
	EnvDeploymentName = "DEPLOYMENT_NAME"
	// EnvBOSHManifestPath is a key for the container Env pointing to the BOSH manifest (CLI)
	EnvBOSHManifestPath = "BOSH_MANIFEST_PATH"
	// PodIPEnvVar is the environment variable containing status.podIP used to render BOSH spec.ip. (CLI)
	PodIPEnvVar = "POD_IP"
	// EnvInitialRollout is set to "false" if this is not the first time the instance group has run
	EnvInitialRollout = "INITIAL_ROLLOUT"
	// EnvPodOrdinal is the environment variable which holds the pods ordinal index, quarks-job also sets this to 0
	EnvPodOrdinal = "POD_ORDINAL"

	// EnvReplicas is set to 1
	EnvReplicas = "REPLICAS"
	// EnvAzIndex is set by available zone index
	EnvAzIndex = "AZ_INDEX"
)
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"

	// 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

	// VolumeDrainStampsName is the volume name for the drain-stamps directory.
	VolumeDrainStampsName = "drain-stamps"
	// VolumeDrainStampsMountPath is the mount path for the drain-stamps directory.
	VolumeDrainStampsMountPath = "/mnt/drain-stamps"

	// 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"
)

Variables

This section is empty.

Functions

func FilterLabels

func FilterLabels(labels map[string]string) map[string]string

FilterLabels filters out labels, that are not suitable for StatefulSet updates

func JobSpecCopierContainer

func JobSpecCopierContainer(releaseName string, jobImage string, volumeMountName string) corev1.Container

JobSpecCopierContainer will return a corev1.Container{} with the populated field.

Types

type BPMConverter

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

BPMConverter converts BPM information to kubernetes resources

func NewConverter

func NewConverter(volumeFactory VolumeFactory, newContainerFactoryFunc NewContainerFactoryFunc) *BPMConverter

NewConverter returns a new converter

func (*BPMConverter) Resources

func (kc *BPMConverter) Resources(manifest bdm.Manifest, namespace string, deploymentName string, serviceIP string, qStsVersion string, instanceGroup *bdm.InstanceGroup, bpmConfigs bpm.Configs, igResolvedSecretVersion string) (*Resources, error)

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

type ContainerFactory

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

ContainerFactory builds Kubernetes containers from BOSH jobs.

func NewContainerFactory

func NewContainerFactory(igName string, errand bool, version string, disableLogSidecar bool, releaseImageProvider bdm.ReleaseImageProvider, bpmConfigs bpm.Configs) ContainerFactory

NewContainerFactory returns a concrete implementation of ContainerFactory.

type ContainerFactoryImpl

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

ContainerFactoryImpl is a concrete implementation of ContainerFactor.

func (*ContainerFactoryImpl) JobsToContainers

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

func (*ContainerFactoryImpl) JobsToInitContainers

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

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

type DNSSettings

type DNSSettings interface {
	// DNSSetting get the DNS settings for POD.
	DNSSetting(namespace string) (corev1.DNSPolicy, *corev1.PodDNSConfig, error)
}

DNSSettings is a limited interface for the funcs used in the bpm converter

type NewContainerFactoryFunc

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

NewContainerFactoryFunc returns ContainerFactory from single BOSH instance group.

type Resources

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

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

type VolumeFactory

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

VolumeFactory builds Kubernetes containers from BOSH jobs.

type VolumeFactoryImpl

type VolumeFactoryImpl struct {
}

VolumeFactoryImpl is a concrete implementation of VolumeFactory

func NewVolumeFactory

func NewVolumeFactory() *VolumeFactoryImpl

NewVolumeFactory returns a concrete implementation of VolumeFactory

func (*VolumeFactoryImpl) GenerateBPMDisks

func (f *VolumeFactoryImpl) GenerateBPMDisks(instanceGroup *bdm.InstanceGroup, bpmConfigs bpm.Configs, namespace string) (bdm.Disks, 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

func (f *VolumeFactoryImpl) GenerateDefaultDisks(instanceGroup *bdm.InstanceGroup, igResolvedSecretVersion string, namespace string) bdm.Disks

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 - shared empty dir for drain-stamps files

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