Documentation ¶
Index ¶
- Constants
- Variables
- func MinifySvcK8sExtension(src map[string]interface{}) (map[string]interface{}, error)
- func MinifyVolK8sExtension(src map[string]interface{}) (map[string]interface{}, error)
- func ServiceTypesEqual(s, t ServiceType) bool
- func Version() string
- func WorkloadReplicasFromCompose(svc *composego.ServiceConfig) int
- func WorkloadRollingUpdateMaxSurgeFromCompose(svc *composego.ServiceConfig) int
- func WorkloadTypesEqual(s, t WorkloadType) bool
- type Autoscale
- type ExecProbe
- type Expose
- type HTTPProbe
- type ImagePull
- type K8sExtensionOption
- type LivenessProbe
- type PodSecurity
- type ProbeConfig
- type ProbeType
- type ReadinessProbe
- type Resource
- type RestartPolicy
- type Service
- type ServiceExtension
- type ServiceType
- type SvcK8sConfig
- type TCPProbe
- type VolK8sConfig
- type VolumeExtension
- type Workload
- type WorkloadType
Constants ¶
const ( // DefaultVolumeSize default value PV class DefaultVolumeSize = "1Gi" // DefaultVolumeStorageClass default PV storage class DefaultVolumeStorageClass = "" // DefaultService is a default service DefaultService = NoService // DefaultRestartPolicy is a default restart policy DefaultRestartPolicy = RestartPolicyAlways // DefaultWorkload is a default workload type DefaultWorkload = DeploymentWorkload // DefaultServiceAccountName is a default SA to be used DefaultServiceAccountName = "default" // DefaultImagePullPolicy default image pull policy DefaultImagePullPolicy = "IfNotPresent" // DefaultImagePullSecret default image pull credentials secret name DefaultImagePullSecret = "" // JobWorkload workload type JobWorkload = "Job" // DefaultReplicaNumber default number of replicas per workload DefaultReplicaNumber = 1 // DefaultAutoscaleMaxReplicaNumber default maximum number of replicas per workload (used in Horizontal Pod Autoscaler) DefaultAutoscaleMaxReplicaNumber = 0 // DefaultAutoscaleCPUThreshold default CPU utilization threshold (percentage) for the workload's Horizontal Pod Autoscaler DefaultAutoscaleCPUThreshold = 70 // DefaultAutoscaleMemoryThreshold default Memory utilization threshold (percentage) for the workload's Horizontal Pod Autoscaler DefaultAutoscaleMemoryThreshold = 70 // DefaultRollingUpdateMaxSurge default number of containers to be updated at a time DefaultRollingUpdateMaxSurge = 1 // DefaultResourceLimitMem default Memory resource limit // https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory DefaultResourceLimitMem = "500Mi" // DefaultResourceRequestMem default Memory resource request // https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory DefaultResourceRequestMem = "10Mi" // DefaultResourceLimitCPU default CPU Limit // Kubernetes notation details: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu // Default: 0.5, which is equivalent to 50% of CPU DefaultResourceLimitCPU = "0.5" // DefaultResourceRequestCPU default CPU resource request // This value follows docker compose resource notation // https://docs.docker.com/compose/compose-file/#resources // Kubernetes notation details: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu // Default: 0.1, which is equivalent to 10% of CPU DefaultResourceRequestCPU = "0.1" // DefaultProbeTimeout default 10s DefaultProbeTimeout = "10s" // DefaultProbeInterval default 1m (1 minute) DefaultProbeInterval = "1m" // DefaultProbeInitialDelay default 1m (1 minute) DefaultProbeInitialDelay = "1m" // DefaultProbeFailureThreshold default 3. Defines the failure threshold (number of retries) for the workload before giving up. DefaultProbeFailureThreshold = 3 // DefaultProbeSuccessThreshold default 1. Minimum consecutive successes for the probe to be considered successful DefaultProbeSuccessThreshold = 1 // DefaultProbeDisable default false. Enabled by default DefaultProbeDisable = false )
const ( PartIdentifier = "id" PartValue = "value" )
const (
K8SExtensionKey = "x-k8s"
)
Variables ¶
var ( // AppName is the app's name, can be overridden using ldflags. AppName = "kev" // Author is the prog author Author = "Appvia" // Email is the default email Email = "info@appvia.io" // Compiled in the time it was compiling Compiled = "0" // GitSHA is the sha this was built off GitSHA = "no gitsha provided" // GitBranch is the branch program was built off GitBranch = "no branch provided" // Release is the releasing version Release = "latest" // Tag is the release tag of the build Tag = "" )
var ( // DefaultSecurityContextRunAsUser default UID for pod security context DefaultSecurityContextRunAsUser *int64 = nil // DefaultSecurityContextRunAsGroup default GID for pod security context DefaultSecurityContextRunAsGroup *int64 = nil // DefaultSecurityContextFsGroup default fs Group for pod security context DefaultSecurityContextFsGroup *int64 = nil // DefaultLivenessProbeCommand default command DefaultLivenessProbeCommand = []string{"echo", "Define healthcheck command for service"} )
var ErrUnsupportedProbeType = errors.New("unsupported probe type")
ErrUnsupportedProbeType should be returned when an unsupported probe type is provided.
var SecretMatchers = []map[string]string{}/* 138 elements not displayed */
Functions ¶
func MinifySvcK8sExtension ¶ added in v0.5.0
MinifySvcK8sExtension creates a minimal service extension configuration using the supplied src.
func MinifyVolK8sExtension ¶ added in v0.5.0
MinifyVolK8sExtension creates a minimal volume extension configuration using the supplied src.
func ServiceTypesEqual ¶ added in v0.5.0
func ServiceTypesEqual(s, t ServiceType) bool
ServiceTypesEqual checks if the supplied ServiceTypes are equal
func WorkloadReplicasFromCompose ¶ added in v0.5.0
func WorkloadReplicasFromCompose(svc *composego.ServiceConfig) int
func WorkloadRollingUpdateMaxSurgeFromCompose ¶ added in v0.5.0
func WorkloadRollingUpdateMaxSurgeFromCompose(svc *composego.ServiceConfig) int
func WorkloadTypesEqual ¶ added in v0.5.0
func WorkloadTypesEqual(s, t WorkloadType) bool
WorkloadTypesEqual checks if the supplied WorkloadTypes are equal
Types ¶
type Autoscale ¶ added in v0.5.0
type Autoscale struct { MaxReplicas int `yaml:"maxReplicas,omitempty"` CPUThreshold int `yaml:"cpuThreshold,omitempty"` MemoryThreshold int `yaml:"memThreshold,omitempty"` }
func AutoscaleWithDefaults ¶ added in v0.5.0
func AutoscaleWithDefaults() Autoscale
type ExecProbe ¶ added in v0.5.0
type ExecProbe struct {
Command []string `yaml:"command"`
}
ExecProbe holds the necessary properties to define the exec check on the k8s probe.
type HTTPProbe ¶ added in v0.5.0
HTTPProbe holds the necessary properties to define the http check on the k8s probe.
type ImagePull ¶ added in v0.5.0
type ImagePull struct { Policy string `yaml:"policy,omitempty" validate:"oneof='' IfNotPresent Never Always"` Secret string `yaml:"secret,omitempty"` }
func ImagePullWithDefaults ¶ added in v0.5.0
func ImagePullWithDefaults() ImagePull
type K8sExtensionOption ¶ added in v0.5.0
type K8sExtensionOption func(*extensionOptions)
K8sExtensionOption will modify parsing behaviour of the k8s extension.
func SkipValidation ¶ added in v0.5.0
func SkipValidation() K8sExtensionOption
SkipValidation skips validation when parsing a k8s extension from a service.
type LivenessProbe ¶ added in v0.5.0
type LivenessProbe struct { // TODO: find a decent way of using ProbeType here that validates the content of the string Type string `yaml:"type" validate:"required,oneof=none exec tcp http"` ProbeConfig `yaml:",inline"` }
LivenessProbe holds all the settings for the same k8s probe.
func DefaultLivenessProbe ¶ added in v0.5.0
func DefaultLivenessProbe() LivenessProbe
DefaultLivenessProbe creates a default liveness probe. Defaults to exec.
func LivenessProbeFromCompose ¶ added in v0.5.0
func LivenessProbeFromCompose(svc *composego.ServiceConfig) LivenessProbe
type PodSecurity ¶ added in v0.5.0
type PodSecurity struct { RunAsUser *int64 `yaml:"runAsUser,omitempty"` RunAsGroup *int64 `yaml:"runAsGroup,omitempty"` FsGroup *int64 `yaml:"fsGroup,omitempty"` }
func PodSecurityWithDefaults ¶ added in v0.5.0
func PodSecurityWithDefaults() PodSecurity
type ProbeConfig ¶ added in v0.5.0
type ProbeConfig struct { HTTP HTTPProbe `yaml:"http,omitempty"` TCP TCPProbe `yaml:"tcp,omitempty"` Exec ExecProbe `yaml:"exec,omitempty"` InitialDelay time.Duration `yaml:"initialDelay,omitempty"` Period time.Duration `yaml:"period,omitempty"` FailureThreshold int `yaml:"failureThreshold,omitempty"` SuccessThreshold int `yaml:"successThreshold,omitempty"` Timeout time.Duration `yaml:"timeout,omitempty"` }
ProbeConfig holds all the shared properties between liveness and readiness probe.
type ProbeType ¶ added in v0.5.0
type ProbeType string
ProbeType defines all possible types of kubernetes probes
var ( // ProbeTypeNone disables probe checks. ProbeTypeNone ProbeType = "none" // ProbeTypeExec uses a shell command for probe checks. ProbeTypeExec ProbeType = "exec" // ProbeTypeHTTP defines an http request which is used by probe checks. ProbeTypeHTTP ProbeType = "http" // ProbeTypeTCP defines a tcp port which is used by probe checks. ProbeTypeTCP ProbeType = "tcp" )
func ProbeTypeFromString ¶ added in v0.5.0
ProbeTypeFromString finds the ProbeType from it's string representation or returns Disabled as a default.
type ReadinessProbe ¶ added in v0.5.0
type ReadinessProbe struct { // TODO: find a decent way of using ProbeType here that validates the content of the string Type string `yaml:"type,omitempty"` ProbeConfig `yaml:",inline,omitempty"` }
ReadinessProbe holds all the settings for the same k8s probe.
func DefaultReadinessProbe ¶ added in v0.5.0
func DefaultReadinessProbe() ReadinessProbe
DefaultReadinessProbe defines the default readiness probe. Defaults to none.
type Resource ¶ added in v0.5.0
type Resource struct { Memory string `yaml:"memory,omitempty"` MaxMemory string `yaml:"maxMemory,omitempty"` CPU string `yaml:"cpu,omitempty"` MaxCPU string `yaml:"maxCpu,omitempty"` Storage string `yaml:"storage,omitempty"` MaxStorage string `yaml:"maxStorage,omitempty"` }
func ResourceFromCompose ¶ added in v0.5.0
func ResourceFromCompose(svc *composego.ServiceConfig) (Resource, error)
type RestartPolicy ¶ added in v0.5.0
type RestartPolicy string
const ( // RestartPolicyAlways default value RestartPolicyAlways RestartPolicy = "Always" // RestartPolicyOnFailure restart policy RestartPolicyOnFailure RestartPolicy = "OnFailure" // RestartPolicyNever restart policy RestartPolicyNever RestartPolicy = "Never" )
func RestartPoliciesFromValue ¶ added in v0.5.0
func RestartPoliciesFromValue(s string) (RestartPolicy, bool)
RestartPoliciesFromValue returns a Restart Policy for a given case insensitive value. Returns a blank string and false for unknown values.
func WorkloadRestartPolicyFromCompose ¶ added in v0.5.0
func WorkloadRestartPolicyFromCompose(svc *composego.ServiceConfig) RestartPolicy
WorkloadRestartPolicyFromCompose infers a kev-valid restart policy from compose data.
func (RestartPolicy) String ¶ added in v0.5.0
func (p RestartPolicy) String() string
String converts a restart policy to a string value
type Service ¶ added in v0.5.0
type Service struct { Type ServiceType `yaml:"type" validate:"serviceType"` NodePort int `yaml:"nodeport,omitempty"` Expose Expose `yaml:"expose,omitempty"` }
Service will hold the service specific extensions in the future.
type ServiceExtension ¶ added in v0.5.0
type ServiceExtension struct {
K8S SvcK8sConfig `yaml:"x-k8s"`
}
ServiceExtension represents the root of the docker-compose extensions for a service
type ServiceType ¶ added in v0.5.0
type ServiceType string
const ( // NoService default value NoService ServiceType = "None" // NodePortService svc type NodePortService ServiceType = "NodePort" // LoadBalancerService svc type LoadBalancerService ServiceType = "LoadBalancer" // ClusterIPService svc type ClusterIPService ServiceType = "ClusterIP" // HeadlessService svc type HeadlessService ServiceType = "Headless" )
func ServiceTypeFromCompose ¶ added in v0.5.0
func ServiceTypeFromCompose(svc *composego.ServiceConfig) (ServiceType, error)
func ServiceTypeFromValue ¶ added in v0.5.0
func ServiceTypeFromValue(s string) (ServiceType, bool)
ServiceTypeFromValue returns a Service Type for a given case insensitive value. Returns a blank string and false for unknown values.
func (ServiceType) String ¶ added in v0.5.0
func (s ServiceType) String() string
String converts a service type to a string value
type SvcK8sConfig ¶ added in v0.5.0
type SvcK8sConfig struct { Disabled bool `yaml:"disabled,omitempty"` Workload Workload `yaml:"workload" validate:"required,dive"` Service Service `yaml:"service,omitempty"` }
SvcK8sConfig represents the root of the k8s specific fields supported by kev.
func DefaultSvcK8sConfig ¶ added in v0.5.0
func DefaultSvcK8sConfig() SvcK8sConfig
DefaultSvcK8sConfig returns a service's K8S Config with set defaults.
func ParseSvcK8sConfigFromMap ¶ added in v0.5.0
func ParseSvcK8sConfigFromMap(m map[string]interface{}, opts ...K8sExtensionOption) (SvcK8sConfig, error)
ParseSvcK8sConfigFromMap handles the extraction of the k8s-specific extension values from the top level map.
func SvcK8sConfigFromCompose ¶ added in v0.5.0
func SvcK8sConfigFromCompose(svc *composego.ServiceConfig) (SvcK8sConfig, error)
SvcK8sConfigFromCompose creates a K8s service extension from a compose-go service. It extracts and infers values based on rules applied to the compose-go service.
func (SvcK8sConfig) Map ¶ added in v0.5.0
func (skc SvcK8sConfig) Map() (map[string]interface{}, error)
func (SvcK8sConfig) Merge ¶ added in v0.5.0
func (skc SvcK8sConfig) Merge(other SvcK8sConfig) (SvcK8sConfig, error)
func (SvcK8sConfig) Validate ¶ added in v0.5.0
func (skc SvcK8sConfig) Validate() error
type TCPProbe ¶ added in v0.5.0
type TCPProbe struct {
Port int `yaml:"port"`
}
TCPProbe holds the necessary properties to define the tcp check on the k8s probe.
type VolK8sConfig ¶ added in v0.5.0
type VolK8sConfig struct { Size string `yaml:"size" validate:"required,quantity"` StorageClass string `yaml:"storageClass,omitempty"` Selector string `yaml:"selector,omitempty"` }
VolK8sConfig represents the root of the k8s specific fields supported by kev.
func DefaultVolK8sConfig ¶ added in v0.5.0
func DefaultVolK8sConfig() VolK8sConfig
DefaultVolK8sConfig returns a volume's K8s config with set defaults.
func ParseVolK8sConfigFromMap ¶ added in v0.5.0
func ParseVolK8sConfigFromMap(m map[string]interface{}, opts ...K8sExtensionOption) (VolK8sConfig, error)
ParseVolK8sConfigFromMap parses a volume extension from the related map
func VolK8sConfigFromCompose ¶ added in v0.5.0
func VolK8sConfigFromCompose(vol *composego.VolumeConfig) (VolK8sConfig, error)
VolK8sConfigFromCompose returns a VolK8sConfig from a compose-go VolumeConfig It extracts and infers values based on rules applied to the compose-go volume.
func (VolK8sConfig) Map ¶ added in v0.5.0
func (vkc VolK8sConfig) Map() (map[string]interface{}, error)
Map converts a VolK8sConfig config into a map
func (VolK8sConfig) Merge ¶ added in v0.5.0
func (vkc VolK8sConfig) Merge(src VolK8sConfig) (VolK8sConfig, error)
Merge merges in a src volume's K8s config
func (VolK8sConfig) Validate ¶ added in v0.5.0
func (vkc VolK8sConfig) Validate() error
Validate validates a volumes K8s config
type VolumeExtension ¶ added in v0.5.0
type VolumeExtension struct {
K8S VolK8sConfig `yaml:"x-k8s"`
}
VolumeExtension represents the root of the docker-compose extensions for a volume
type Workload ¶ added in v0.5.0
type Workload struct { Type WorkloadType `yaml:"type,omitempty" validate:"workloadType"` Replicas int `yaml:"replicas" validate:""` ServiceAccountName string `yaml:"serviceAccountName,omitempty" validate:"subdomainIfAny"` RollingUpdateMaxSurge int `yaml:"rollingUpdateMaxSurge,omitempty" validate:""` Annotations map[string]string `yaml:"annotations,omitempty"` LivenessProbe LivenessProbe `yaml:"livenessProbe,omitempty"` ReadinessProbe ReadinessProbe `yaml:"readinessProbe,omitempty"` RestartPolicy RestartPolicy `yaml:"restartPolicy,omitempty" validate:"restartPolicy"` ImagePull ImagePull `yaml:"imagePull,omitempty"` Resource Resource `yaml:"resource,omitempty"` Autoscale Autoscale `yaml:"autoscale,omitempty"` PodSecurity PodSecurity `yaml:"podSecurity,omitempty"` Command []string `yaml:"command,omitempty"` CommandArgs []string `yaml:"commandArgs,omitempty"` }
Workload holds all the workload-related k8s configurations.
type WorkloadType ¶ added in v0.5.0
type WorkloadType string
const ( // DeploymentWorkload workload type DeploymentWorkload WorkloadType = "Deployment" // DaemonSetWorkload workload type DaemonSetWorkload WorkloadType = "DaemonSet" // StatefulSetWorkload workload type StatefulSetWorkload WorkloadType = "StatefulSet" )
func WorkloadTypeFromCompose ¶ added in v0.5.0
func WorkloadTypeFromCompose(svc *composego.ServiceConfig) WorkloadType
func WorkloadTypeFromValue ¶ added in v0.5.0
func WorkloadTypeFromValue(s string) (WorkloadType, bool)
WorkloadTypeFromValue returns a Workload Type for a given case insensitive value. Returns a blank string and false for unknown values.
func (WorkloadType) String ¶ added in v0.5.0
func (w WorkloadType) String() string
String converts a workload type to a string value