spec

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2017 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BuildLabelKey = "build"
)

allLabelKey is the key that Kedge injects in every Kubernetes resource that it generates as an ObjectMeta label

Variables

This section is empty.

Functions

func CoreOperations added in v0.2.0

func CoreOperations(data []byte) ([]runtime.Object, []string, error)

The "core operations" is important to Kedge as it unmarshals, validates the artifacts as well as return the correct transformation of said artifact.

Returns the converted Kubernetes objects, extra resources and an error, if any.

func GetScheme added in v0.2.0

func GetScheme() (*runtime.Scheme, error)

GetScheme() returns runtime.Scheme with supported Kubernetes API resource definitions which Kedge supports right now. The core v1 scheme is first initialized and then other controllers' scheme is added to that scheme, e.g. batch/v1 scheme is added to add support for Jobs controller to the v1 Scheme. Also, (from upstream) Scheme defines methods for serializing and deserializing API objects, a type registry for converting group, version, and kind information to and from Go schemas, and mappings between Go schemas of different versions. A scheme is the foundation for a versioned API and versioned configuration over time.

func SetGVK added in v0.2.0

func SetGVK(runtimeObject runtime.Object, scheme *runtime.Scheme) error

SetGVK() sets Group, Version and Kind for the generated Kubernetes resources. This takes in a generated Kubernetes API resource's runtime object and runtime scheme based on which the GVK will be set.

Types

type BuildConfigSpecMod added in v0.5.0

type BuildConfigSpecMod struct {
	build_v1.BuildConfigSpec `json:",inline"`
	// k8s: io.k8s.kubernetes.pkg.apis.meta.v1.ObjectMeta
	meta_v1.ObjectMeta `json:",inline"`
}

BuildConfigSpecMod defines OpenShift BuildConfig object kedgeSpec: io.kedge.BuildConfigSpec

type ConfigMapMod

type ConfigMapMod struct {
	// k8s: io.k8s.kubernetes.pkg.api.v1.ConfigMap
	api_v1.ConfigMap `json:",inline"`
	// k8s: io.k8s.kubernetes.pkg.apis.meta.v1.ObjectMeta
	// We need ObjectMeta here, even though it is present in api.ConfigMap
	// because the one upstream has a JSON tag "metadata" due to which it
	// cannot be merged at ConfigMap's root level. The ObjectMeta here
	// overwrites the one in upstream and lets us merge ObjectMeta at
	// ConfigMap's root YAML syntax
	meta_v1.ObjectMeta `json:",inline"`
}

ConfigMapMod holds configuration data for pods to consume. kedgeSpec: io.kedge.ConfigMap

type Container

type Container struct {
	// One common definitions for 'livenessProbe' and 'readinessProbe'
	// this allows to have only one place to define both probes (if they are the same)
	// Periodic probe of container liveness and readiness. Container will be restarted
	// if the probe fails. Cannot be updated. More info:
	// https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes
	// ref: io.k8s.kubernetes.pkg.api.v1.Probe
	// +optional
	Health *api_v1.Probe `json:"health,omitempty"`
	// k8s: io.k8s.kubernetes.pkg.api.v1.Container
	api_v1.Container `json:",inline"`
}

Container defines a single application container that you want to run within a pod. kedgeSpec: io.kedge.ContainerSpec

type Controller

type Controller struct {
	Controller string `json:"controller,omitempty"`
}

type ControllerFields added in v0.2.0

type ControllerFields struct {
	// Field to specify the version of application
	// +optional
	Appversion string `json:"appversion,omitempty"`

	Controller string `json:"controller,omitempty"`
	// List of volume that should be mounted on the pod.
	// ref: io.kedge.VolumeClaim
	// +optional
	VolumeClaims []VolumeClaim `json:"volumeClaims,omitempty"`
	// List of configMaps
	// ref: io.kedge.ConfigMap
	// +optional
	ConfigMaps []ConfigMapMod `json:"configMaps,omitempty"`
	// List of Kubernetes Services
	// ref: io.kedge.ServiceSpec
	// +optional
	Services []ServiceSpecMod `json:"services,omitempty"`
	// List of Kubernetes Ingress
	// ref: io.kedge.IngressSpec
	// +optional
	Ingresses []IngressSpecMod `json:"ingresses,omitempty"`
	// List of OpenShift Routes
	// ref: io.kedge.RouteSpec
	// +optional
	Routes []RouteSpecMod `json:"routes,omitempty"`
	// List of Kubernetes Secrets
	// ref: io.kedge.SecretSpec
	// +optional
	Secrets []SecretMod `json:"secrets,omitempty"`
	// List of OpenShift ImageStreams
	// ref: io.kedge.ImageStreamSpec
	// +optional
	ImageStreams []ImageStreamSpecMod `json:"imageStreams,omitempty"`
	// List of OpenShift BuildConfigs
	// ref: io.kedge.BuildConfigSpec
	// +optional
	BuildConfigs []BuildConfigSpecMod `json:"buildConfigs,omitempty"`
	// List of Kubernetes resource files, that can be directly given to Kubernetes
	// +optional
	IncludeResources []string `json:"includeResources,omitempty"`

	// k8s: io.k8s.kubernetes.pkg.apis.meta.v1.ObjectMeta
	meta_v1.ObjectMeta `json:",inline"`
	PodSpecMod         `json:",inline"`
}

ControllerFields are the common fields in every controller Kedge supports

func (*ControllerFields) CreateK8sObjects added in v0.2.0

func (app *ControllerFields) CreateK8sObjects() ([]runtime.Object, []string, error)

CreateK8sObjects, if given object DeploymentSpecMod, this function reads them and returns kubernetes objects as list of runtime.Object If the deployment is using field 'includeResources' then it will also return file names mentioned there as list of string

type ControllerInterface added in v0.2.0

type ControllerInterface interface {
	// Unmarshals input YAML data to the corresponding Kedge controller spec
	Unmarshal(data []byte) error

	// Validates the unmarshalled data
	Validate() error

	// Fixes the unmarshalled data, e.g. auto population/generation of fields
	Fix() error

	// Transforms the data in Kedge spec to Kubernetes' resource objects
	Transform() ([]runtime.Object, []string, error)
}

Every controller that Kedge supports is required to implement this interface

func GetController added in v0.2.0

func GetController(data []byte) (ControllerInterface, error)

GetController takes in raw input data, and returns the intended controller defined in the Kedge definition. Returns an error if the controller is not supported by Kedge

type DeploymentConfigSpecMod added in v0.4.0

type DeploymentConfigSpecMod struct {
	ControllerFields                  `json:",inline"`
	os_deploy_v1.DeploymentConfigSpec `json:",inline"`

	// Replicas is the number of desired replicas.
	// We need to add this field here despite being in v1.DeploymentConfigSpec
	// because the one in v1.DeploymentConfigSpec has the type as int32, which
	// does not let us check if the set value is 0, is it set by the user or not
	// since this field's value with default to 0. We need the default value as
	// 1. Hence, we need to check if the user has set it or not.Making the type
	// *int32 helps us do it, followed by substitution later on.
	Replicas *int32 `json:"replicas,omitempty"`
}

Ochestrator: OpenShift DeploymentConfigSpecMod is Kedge's extension of OpenShift DeploymentConfig in order to define and allow a complete kedge app based on OpenShift kedgeSpec: io.kedge.DeploymentConfigSpecMod

func (*DeploymentConfigSpecMod) Fix added in v0.4.0

func (deploymentConfig *DeploymentConfigSpecMod) Fix() error

Fix all services / volume claims / configmaps that are applied TODO: abstract out this code when more controllers are added

func (*DeploymentConfigSpecMod) Transform added in v0.4.0

func (deploymentConfig *DeploymentConfigSpecMod) Transform() ([]runtime.Object, []string, error)

func (*DeploymentConfigSpecMod) Unmarshal added in v0.4.0

func (deploymentConfig *DeploymentConfigSpecMod) Unmarshal(data []byte) error

Unmarshal the Kedge YAML file

func (*DeploymentConfigSpecMod) Validate added in v0.4.0

func (deploymentConfig *DeploymentConfigSpecMod) Validate() error

Validate all portions of the file

type DeploymentSpecMod added in v0.2.0

type DeploymentSpecMod struct {
	ControllerFields `json:",inline"`
	// k8s: io.k8s.kubernetes.pkg.apis.apps.v1beta1.DeploymentSpec
	ext_v1beta1.DeploymentSpec `json:",inline"`
}

DeploymentSpecMod is Kedge's extension of Kubernetes DeploymentSpec and allows defining a complete kedge application kedgeSpec: io.kedge.DeploymentSpecMod

func (*DeploymentSpecMod) Fix added in v0.2.0

func (deployment *DeploymentSpecMod) Fix() error

func (*DeploymentSpecMod) Transform added in v0.2.0

func (deployment *DeploymentSpecMod) Transform() ([]runtime.Object, []string, error)

Transform function if given DeploymentSpecMod data creates the versioned kubernetes objects and returns them in list of runtime.Object And if the field in DeploymentSpecMod called 'includeResources' is used then it returns the filenames mentioned there as list of string

func (*DeploymentSpecMod) Unmarshal added in v0.2.0

func (deployment *DeploymentSpecMod) Unmarshal(data []byte) error

func (*DeploymentSpecMod) Validate added in v0.2.0

func (deployment *DeploymentSpecMod) Validate() error

type ImageStreamSpecMod added in v0.5.0

type ImageStreamSpecMod struct {
	image_v1.ImageStreamSpec `json:",inline"`
	// k8s: io.k8s.kubernetes.pkg.apis.meta.v1.ObjectMeta
	meta_v1.ObjectMeta `json:",inline"`
}

ImageStreamSpec defines OpenShift ImageStream Object kedgeSpec: io.kedge.ImageStreamSpec

type IngressSpecMod

type IngressSpecMod struct {
	// k8s: io.k8s.kubernetes.pkg.apis.extensions.v1beta1.IngressSpec
	ext_v1beta1.IngressSpec `json:",inline"`
	// k8s: io.k8s.kubernetes.pkg.apis.meta.v1.ObjectMeta
	meta_v1.ObjectMeta `json:",inline"`
}

IngressSpecMod defines Kubernetes Ingress object kedgeSpec: io.kedge.IngressSpec

type JobSpecMod added in v0.2.0

type JobSpecMod struct {
	ControllerFields `json:",inline"`
	// k8s: io.k8s.kubernetes.pkg.apis.batch.v1.JobSpec
	batch_v1.JobSpec `json:",inline"`
	// Optional duration in seconds relative to the startTime that the job may be active
	// before the system tries to terminate it; value must be positive integer
	// This only sets ActiveDeadlineSeconds in JobSpec, not PodSpec
	// +optional
	ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds,conflicting,omitempty"`
}

JobSpecMod is Kedge's extension of Kubernetes JobSpec and allows defining a complete kedge application kedgeSpec: io.kedge.JobSpecMod

func (*JobSpecMod) Fix added in v0.2.0

func (job *JobSpecMod) Fix() error

func (*JobSpecMod) Transform added in v0.2.0

func (job *JobSpecMod) Transform() ([]runtime.Object, []string, error)

func (*JobSpecMod) Unmarshal added in v0.2.0

func (job *JobSpecMod) Unmarshal(data []byte) error

func (*JobSpecMod) Validate added in v0.2.0

func (job *JobSpecMod) Validate() error

type PodSpecMod

type PodSpecMod struct {
	// List of containers belonging to the pod. Containers cannot currently be
	// added or removed. There must be at least one container in a Pod. Cannot be updated.
	// ref: io.kedge.ContainerSpec
	Containers []Container `json:"containers,conflicting,omitempty"`
	// List of initialization containers belonging to the pod. Init containers are
	// executed in order prior to containers being started. If any init container
	// fails, the pod is considered to have failed and is handled according to its
	// restartPolicy. The name for an init container or normal container must be
	// unique among all containers.
	// ref: io.kedge.ContainerSpec
	// +optional
	InitContainers []Container `json:"initContainers,conflicting,omitempty"`
	// k8s: io.k8s.kubernetes.pkg.api.v1.PodSpec
	api_v1.PodSpec `json:",inline"`
}

PodSpecMod is a description of a pod

type RouteSpecMod added in v0.4.0

type RouteSpecMod struct {
	os_route_v1.RouteSpec `json:",inline"`
	// k8s: io.k8s.kubernetes.pkg.apis.meta.v1.ObjectMeta
	meta_v1.ObjectMeta `json:",inline"`
}

type SecretMod

type SecretMod struct {
	// k8s: io.k8s.kubernetes.pkg.api.v1.Secret
	api_v1.Secret `json:",inline"`
	// k8s: io.k8s.kubernetes.pkg.apis.meta.v1.ObjectMeta
	// We need ObjectMeta here, even though it is present in api.Secret
	// because the one upstream has a JSON tag "metadata" due to which it
	// cannot be merged at Secret's root level. The ObjectMeta here
	// overwrites the one in upstream and lets us merge ObjectMeta at
	// Secret's root YAML syntax
	meta_v1.ObjectMeta `json:",inline"`
}

SecretMod defines secret that will be consumed by application kedgeSpec: io.kedge.SecretSpec

type ServicePortMod

type ServicePortMod struct {
	// k8s: io.k8s.kubernetes.pkg.api.v1.ServicePort
	api_v1.ServicePort `json:",inline"`
	// Host to create ingress automatically. Endpoint allows specifying an
	// ingress resource in the format '<Host>/<Path>'
	// +optional
	Endpoint string `json:"endpoint"`
}

ServicePortMod is used to define Kubernetes service's port kedgeSpec: io.kedge.ServicePort

type ServiceSpecMod

type ServiceSpecMod struct {
	// k8s: io.k8s.kubernetes.pkg.api.v1.ServiceSpec
	api_v1.ServiceSpec `json:",inline"`
	// The list of ports that are exposed by this service. More info:
	// https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
	// ref: io.kedge.ServicePort
	// +optional
	Ports []ServicePortMod `json:"ports,conflicting"`
	// The list of portMappings, where each portMapping allows specifying port,
	// targetPort and protocol in the format '<port>:<targetPort>/<protocol>'
	// +optional
	PortMappings []intstr.IntOrString `json:"portMappings,omitempty"`
	// k8s: io.k8s.kubernetes.pkg.apis.meta.v1.ObjectMeta
	meta_v1.ObjectMeta `json:",inline"`
}

ServiceSpecMod is used to define Kubernetes service kedgeSpec: io.kedge.ServiceSpec

type VolumeClaim

type VolumeClaim struct {
	// Data from the kubernetes persistent volume claim spec
	// k8s: io.k8s.kubernetes.pkg.api.v1.PersistentVolumeClaimSpec
	api_v1.PersistentVolumeClaimSpec `json:",inline"`
	// Size of persistent volume
	Size string `json:"size"`
	// k8s: io.k8s.kubernetes.pkg.apis.meta.v1.ObjectMeta
	meta_v1.ObjectMeta `json:",inline"`
}

VolumeClaim is used to define Persistent Volumes for app kedgeSpec: io.kedge.VolumeClaim

Jump to

Keyboard shortcuts

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