Documentation ¶
Index ¶
- Constants
- type Container
- func (c *Container) AddEnv(name, value string)
- func (c *Container) AddPort(name string, port int, protocol ProtocolType)
- func (c *Container) AddVolumeMountPoint(volume *Volume, mountPath string, readOnly bool)
- func (c *Container) SetArgs(args ...string)
- func (c *Container) SetCommand(command ...string)
- type ContainerPort
- type EmptyDirVolume
- type EnvVar
- type HostPathVolume
- type Job
- func (j *Job) AddAnnotations(name, value string)
- func (j *Job) AddLabels(name, value string)
- func (j *Job) AddMetadata(name string, value interface{})
- func (j *Job) AddPodContainer(name, image string) *Container
- func (j *Job) AddPodVolume(name, path string) *Volume
- func (j *Job) AddSelectorMatchLabel(name, value string)
- type JobSelector
- type JobSpec
- type JobSpecTemplate
- type KubeClient
- type PodSpec
- type ProtocolType
- type RestartPolicyType
- type Secret
- type Volume
- type VolumeMount
Constants ¶
const ( // RestartOnFailure is a Job Restart Policy that restarts the pods on failure RestartOnFailure RestartPolicyType = "OnFailure" // NeverRestart is a Job Restart Policy that will never restart a failed job NeverRestart RestartPolicyType = "Never" // UDP is a ProtocolType that defines a "udp" protocol UDP ProtocolType = "UDP" // TCP is a ProtocolType that defines a "tcp" protocol TCP ProtocolType = "TCP" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct { Name string `json:"name,omitempty"` Image string `json:"image,omitempty"` ImagePullPolicy string `json:"imagePullPolicy,omitempty"` WorkingDir string `json:"workingDir,omitempty"` Command []string `json:"command,omitempty"` Args []string `json:"args,omitempty"` Ports []*ContainerPort `json:"ports,omitempty"` Env []*EnvVar `json:"env,omitempty"` VolumeMounts []*VolumeMount `json:"volumeMounts,omitempty"` }
Container defines a container in a kubernetes pod
func (*Container) AddPort ¶
func (c *Container) AddPort(name string, port int, protocol ProtocolType)
AddPort adds a new port to the container
func (*Container) AddVolumeMountPoint ¶
AddVolumeMountPoint adds a mount point to the container for the given volume
func (*Container) SetCommand ¶
SetCommand sets the command for the container
type ContainerPort ¶
type ContainerPort struct { Name string `json:"name,omitempty"` ContainerPort int `json:"containerPort,omitempty"` Protocol ProtocolType `json:"protocol,omitempty"` }
ContainerPort defines a port exposed by a container
type EmptyDirVolume ¶
type EmptyDirVolume struct {
Medium string `json:"medium,omitempty"`
}
EmptyDirVolume is a empty directory used as a volume
type HostPathVolume ¶
type HostPathVolume struct {
Path string `json:"path,omitempty"`
}
HostPathVolume is a volume that is located on the host path
type Job ¶
type Job struct { APIVersion string `json:"apiVersion,omitempty"` Kind string `json:"kind,omitempty"` Metadata map[string]interface{} `json:"metadata,omitempty"` Spec *JobSpec `json:"spec,omitempty"` Status *struct { Active int `json:"active,omitempty"` Succeeded int `json:"succeeded,omitempty"` Failed int `json:"failed,omitempty"` Conditions []struct { Status string `json:"status,omitempty"` Type string `json:"type,omitempty"` } `json:"conditions,omitempty"` } `json:"status,omitempty"` }
Job respresents a kubenertes Job
func (*Job) AddAnnotations ¶
AddAnnotations adds annotations to the job
func (*Job) AddMetadata ¶
AddMetadata adds a metadata to the job
func (*Job) AddPodContainer ¶
AddPodContainer adds a new container to the pod. Reference to the created pod is returned
func (*Job) AddPodVolume ¶
AddPodVolume adds a new volume to the pod. Reference to the created volume is returned
func (*Job) AddSelectorMatchLabel ¶
AddSelectorMatchLabel adds key=value labels to the selector and the job metadata
type JobSelector ¶
JobSelector defines a map of labels to select the pods for the job
type JobSpec ¶
type JobSpec struct { Selector *JobSelector `json:"selector,omitempty"` Template *JobSpecTemplate `json:"template,omitempty"` }
JobSpec defines the job selector and template
type JobSpecTemplate ¶
type JobSpecTemplate struct { Metadata map[string]interface{} `json:"metadata,omitempty"` Spec *PodSpec `json:"spec,omitempty"` }
JobSpecTemplate defines the metadata and pod template
type KubeClient ¶
type KubeClient interface { CreateJob(job *Job) error GetSecret(namespace string, secretName string) (map[string]string, error) GetLog(namespace, pod, container string) (string, error) GetPodNameBySelector(namespace string, selector map[string]string) (string, error) GetPodContainers(namespace, podName string) ([]string, error) }
KubeClient is the interface to access the kubernetes job API
func NewClient ¶
func NewClient(address string) (KubeClient, error)
NewClient returns a new KubeClient connecting to the address. This uses the service account credentials
type PodSpec ¶
type PodSpec struct { Volumes []*Volume `json:"volumes,omitempty"` Containers []*Container `json:"containers,omitempty"` RestartPolicy RestartPolicyType `json:"restartPolicy,omitempty"` }
PodSpec defines the specs of the pod
type ProtocolType ¶
type ProtocolType string
ProtocolType is a custom string type defining supported protocols for the pod's exposed ports. Currently supports "udp" and "tcp"
type RestartPolicyType ¶
type RestartPolicyType string
RestartPolicyType is a cumstom string type that defines Restart Policy for the Kuberentes job. Currently supported for Jobs are "OnFailure" and "Never"
type Volume ¶
type Volume struct { Name string `json:"name,omitempty"` HostPath *HostPathVolume `json:"hostPath,omitempty"` EmptyDir *EmptyDirVolume `json:"emptyDir,omitempty"` }
Volume defines a kubernetes volume for the pod
type VolumeMount ¶
type VolumeMount struct { Name string `json:"name,omitempty"` MountPath string `json:"mountPath,omitempty"` ReadOnly bool `json:"readOnly,omitempty"` }
VolumeMount defines where a volume will be mounted in a container