Documentation ¶
Overview ¶
Package util contains deployment types, middlewares, constants,
Index ¶
- Constants
- Variables
- func SetDeploymentDefaults(deployImageRequest *DeployImageRequest, appConfig *config.CommonConfiguration)
- type Base64JSONBytes
- type ConfigContainer
- type ContainerConfig
- type DeployImageRequest
- type DeployImageResponse
- type DeployVersionResponse
- type HealthCheckConfig
- type ImportContainer
- type InitContainer
- type InstanceConfig
- type Markers
- type Metrics
- type Probe
- type ResourceConfig
- type Resources
- type RuntimeConfigType
- type UploadFileData
- type VersionData
- type Volume
- type VolumeLink
- type VolumeType
Constants ¶
const (
DotnetAppSettingsJSON = "dotnet-appsettings"
)
Variables ¶
var ValidSize validator.Func = func(fl validator.FieldLevel) bool { size := fl.Field().String() _, err := resource.ParseQuantity(size) return err == nil }
Functions ¶
func SetDeploymentDefaults ¶
func SetDeploymentDefaults( deployImageRequest *DeployImageRequest, appConfig *config.CommonConfiguration, )
setting known defaults from constants
Types ¶
type Base64JSONBytes ¶
type Base64JSONBytes []byte
func (*Base64JSONBytes) UnmarshalJSON ¶
func (jsonConfig *Base64JSONBytes) UnmarshalJSON(b []byte) error
custom struct unmarshal JSON interface implementation
type ConfigContainer ¶
type ContainerConfig ¶
type ContainerConfig struct { // ContainerPreName identifies namespace to be used ContainerPreName string `json:"containerPreName"` // name of the container used for service, configmap names, various component names Container string `json:"container" binding:"required"` // portbinding list contains external/interal ports Ports []builder.PortBinding `json:"port" binding:"dive"` // Port ranges to be exposed ! no native range support in k8s PortRanges []builder.PortRangeBinding `json:"portRanges" binding:"dive"` // mount list, if a name starts with @ it can be used by multiple components eg @data|/target/mount/path Mounts []string `json:"mount"` // volumes Volumes []Volume `json:"volumes,omitempty" binding:"dive"` // environment variables list Environment []string `json:"environment"` // Secrets Secrets map[string]string `json:"secrets,omitempty"` // the type of the runtime text provided eg. dotnet-appsettings RuntimeConfigType RuntimeConfigType `json:"runtimeConfigType"` // create an ingress object or not Expose bool `json:"expose"` // use nginx tls configuration ExposeTLS bool `json:"exposeTls"` // ingress prefix before hostname, `containerName.containerPrefix.<ingress root>` by default, this replaces both before root IngressName string `json:"ingressName"` // ingress hostname, env value used by default, can be overridden here IngressHost string `json:"ingressHost"` // Set endpoint upload limit, default value is: 1m // for docker hosts, this is needs to be bytes: 1000000 ~1m IngressUploadLimit string `json:"ingressUploadLimit"` Shared bool `json:"shared"` // config container is spawned as an initcontainer copying files to a shared volume ConfigContainer *ConfigContainer `json:"configContainer,omitempty"` // import container uses rclone to copy over files before container startup ImportContainer *ImportContainer `json:"importContainer,omitempty"` // standard initContainers InitContainers []InitContainer `json:"initContainers,omitempty" binding:"dive"` // container user id User *int64 `json:"user"` // the initial command of a container have mixed terms // docker --> k8s: entrypoint => command, cmd => args // we use the k8s term here // command is the active process of the container Command []string `json:"command"` // args are added to the command Args []string `json:"args"` // if we need to spawn a pseudo-terminal TTY bool `json:"tty"` // dagent only LogConfig *container.LogConfig `json:"logConfig"` RestartPolicy builder.RestartPolicyName `json:"restartPolicy"` // bridge(container, default) host, none or network name NetworkMode string `json:"networkMode"` // extra networks Networks []string `json:"networks"` // docker only labels DockerLabels map[string]string `json:"dockerLabels"` // k8s-only-section // Deployments strategy, on deployment how to restart underlying pods // Values: Recreate (all-at-once), Rolling(one-by-one only if succeeds) DeploymentStrategy string `json:"deploymentStrategy"` // health check configuration HealthCheckConfig HealthCheckConfig `json:"healthCheck"` // custom header configuration CustomHeaders []string `json:"customHeaders,omitempty"` // resource management ResourceConfig ResourceConfig `json:"resourceConfig"` // add proxy and cors headers ProxyHeaders bool `json:"proxyHeaders"` // Expose service using external IP // also sets the externalTrafficPolcy to "local" UseLoadBalancer bool `json:"useLoadBalancer"` // ExtraLBAnnotations, this is legacy // Annotations.Service does the same, keeping it for compat // lots of cloud provider specific configs can be put into annotations // they vary enough to have it exposed like this ExtraLBAnnotations map[string]string `json:"extraLBAnnotations,omitempty"` // Annotations Annotations Markers `json:"annotations"` // k8s labels Labels Markers `json:"labels"` // Metrics Metrics *Metrics `json:"metrics,omitempty"` }
func (*ContainerConfig) Strings ¶
func (c *ContainerConfig) Strings(appConfig *config.CommonConfiguration) []string
type DeployImageRequest ¶
type DeployImageRequest struct { RequestID string `json:"RequestId" binding:"required"` RegistryAuth *imageHelper.RegistryAuth `json:"RegistryAuth,omitempty"` InstanceConfig InstanceConfig `json:"InstanceConfig" binding:"required"` ContainerConfig ContainerConfig `json:"ContainerConfig" binding:"required"` RuntimeConfig Base64JSONBytes `json:"RuntimeConfig,omitempty"` Registry *string `json:"Registry,omitempty"` ImageName string `json:"ImageName" binding:"required"` Tag string `json:"Tag" binding:"required"` Issuer string `json:"Issuer"` }
func (*DeployImageRequest) Strings ¶
func (d *DeployImageRequest) Strings(appConfig *config.CommonConfiguration) []string
type DeployImageResponse ¶
type DeployVersionResponse ¶
type DeployVersionResponse []DeployImageResponse
type HealthCheckConfig ¶
type ImportContainer ¶
type ImportContainer struct { // environment used to pass down secrets to the container // for Azure refer to rclone docs: https://rclone.org/azureblob/ // one way to go either RCLONE_AZUREBLOB_ACCOUNT with RCLONE_AZUREBLOB_KEY // or using RCLONE_AZUREBLOB_SAS_URL list, read privileges needed Environments map[string]string `json:"environments" binding:"required"` // target volume name, volume name that is present on the deployment Volume string `json:"volume" binding:"required"` // for azureblob storage use `sync :azuresync:<container>/<product-guid>/<version-guid>/<component>/<volume>` Command string `json:"command" binding:"required"` }
Import container builds on rclone container https://rclone.org/ refer to docs Idea: shift this one level up, this should not be visible in container configs Reason: it is not user configured data Update: 2022-03-16, it can be, loading anything into a container before starting it can be useful Note:
Use environment variables to set auth credentials Use command field to define instruction ~30 remote storage is supported
type InitContainer ¶
type InitContainer struct { // name of the init container, they must be unique within a pod Name string `json:"name"` // image to use Image string `json:"image"` // Reference(s) to already existing volume(s) Volumes []VolumeLink `json:"volumes"` // command to run, expecting exit code 0 Command []string `json:"command"` // arguments added to the command Args []string `json:"args"` // use env/secrets from the parent container UseParent bool `json:"useParent"` // envs directly defined Envs map[string]string `json:"envs"` }
classic initContainer, also mimicked on docker TODO(nandor-magyar): extend docs here
type InstanceConfig ¶
type InstanceConfig struct { // prefix of the container, identifies namespace ContainerPreName string `json:"containerPreName" binding:"required"` // not-in-use MountPath string `json:"mountPath"` // name of the instance eg. configmaps Name string `json:"name"` // variables for instance; configmaps: name-common, name must be defined Environment []string `json:"environment,omitempty"` // not-in-use/unimplemented; registry is taken from containerConfig Registry string `json:"registry"` // not-in-use/unimplemented; git repository prefix RepositoryPreName string `json:"repositoryPreName"` SharedEnvironment []string `json:"sharedEnvironment,omitempty"` UseSharedEnvs bool `json:"useSharedEnvs" validate:"excluded_with=SharedEnvironment"` }
func (*InstanceConfig) Strings ¶
func (i *InstanceConfig) Strings() []string
type Markers ¶
type Markers struct { // Deployment used in both cases Deployment map[string]string `json:"deployment"` // k8s-only, service annonations Service map[string]string `json:"service"` // k8s-only ingress annotations Ingress map[string]string `json:"ingress"` }
key-value pairs passed to workload
type ResourceConfig ¶
type RuntimeConfigType ¶
type RuntimeConfigType string
type UploadFileData ¶
type VersionData ¶
type Volume ¶
type Volume struct { // name of the volume, the prefix will be the pod using it Name string `json:"name"` // mount path of the given deployment Path string `json:"path" binding:"required"` // required size, not guaranteed that the provisioned size will match // some PVCs support dynamic expansion/shrink, others not Size string `json:"size" binding:"validSize"` // type of the volume: RO,RWO,RWX,mem,tmp // RO: readonly // RWO: readwrite once normal (default) // RWX: readwrite many, shared volume within the instance // mem: use inmemory tmpfs // tmp: use tmpfs, with disk Type string `json:"type"` // kubernetes only // storage classes depend on the cloud providers // `kubectl get storageclasses.storage.k8s.io` // usable values could be returned to the UI letting the user change Class string `json:"class"` }
Verbose volume definitions with support of size and type parameters
Example JSON defining a temporal volume:
"volumes": [{ "name": "app-import", "path": "/path/in/container", "size": "10Gi", "type": "tmp", "class": "" }]
Note: dagent maps these back into the old "name|/some/path" format, ingoring type and size constraints
type VolumeLink ¶
type VolumeType ¶
type VolumeType string
const ( ReadOnlyVolumeType VolumeType = "RO" ReadWriteOnceVolumeType VolumeType = "RWO" // same as empty string ReadWriteManyVolumeType VolumeType = "RWX" MemoryVolumeType VolumeType = "mem" EmptyDirVolumeType VolumeType = "tmp" )
func (*VolumeType) UnmarshalJSON ¶
func (vt *VolumeType) UnmarshalJSON(b []byte) error