komponents

package
v0.0.0-...-2dfab7d Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClusterRoleBinding

type ClusterRoleBinding struct {
	Name        string
	RoleRefName string
	Subjects    []*Subject
}

func (*ClusterRoleBinding) ToManifest

func (crb *ClusterRoleBinding) ToManifest() (any, error)

type ConfigMap

type ConfigMap struct {
	Name      string
	Namespace string
}

func (*ConfigMap) ToManifest

func (ns *ConfigMap) ToManifest() (any, error)

ToManifest is only structured for reading. For creating configMaps more work needs to be done.

type ConfigRef

type ConfigRef struct {
	ConfigMapRef string
	SecretsRef   string
}

ConfigRef implements EnvConfig and can provide configMap and Secrets based configuration based on refs

func (*ConfigRef) ToEnvFrom

func (c *ConfigRef) ToEnvFrom() []map[string]any

func (*ConfigRef) ToVolumeMounts

func (c *ConfigRef) ToVolumeMounts() []map[string]any

func (*ConfigRef) ToVolumes

func (c *ConfigRef) ToVolumes() []map[string]any

type CronJob

type CronJob struct {
	Name           string
	Namespace      string
	Labels         map[string]string
	ContainerImage string
	Schedule       string // the crontab string
	Command        []string
	EnvConfig      EnvConfig
	PodMetadata    map[string]any
}

func (*CronJob) ToManifest

func (j *CronJob) ToManifest() (any, error)

type CronJobWithSpec

type CronJobWithSpec struct {
	Name        string
	Namespace   string
	Labels      map[string]string
	Schedule    string
	Command     []string
	PodMetadata map[string]any
	PodSpec     map[string]any
}

CronJobWithSpec represents a CronJob which is created using an existing Pod's spec as its base. This means it will re-use the image and environment information from the existing pod (via its spec). This komponent is analogous to JobWithSpec.

func (*CronJobWithSpec) ToManifest

func (j *CronJobWithSpec) ToManifest() (any, error)

type Deployment

type Deployment struct {
	Name      string
	Namespace string
	Labels    map[string]string
	Spec      DeploymentSpec
}

func (*Deployment) ToManifest

func (d *Deployment) ToManifest() (any, error)

type DeploymentSpec

type DeploymentSpec struct {
	Selector Selector `json:"selector"`
	Template Template `json:"template"`
}

type EmptyEnvConfig

type EmptyEnvConfig struct{}

func (*EmptyEnvConfig) ToEnvFrom

func (*EmptyEnvConfig) ToEnvFrom() []map[string]any

func (*EmptyEnvConfig) ToVolumeMounts

func (*EmptyEnvConfig) ToVolumeMounts() []map[string]any

func (*EmptyEnvConfig) ToVolumes

func (*EmptyEnvConfig) ToVolumes() []map[string]any

type EnvConfig

type EnvConfig interface {
	ToEnvFrom() []map[string]any
	ToVolumes() []map[string]any
	ToVolumeMounts() []map[string]any
}

type HorizontalPodAutoscaler

type HorizontalPodAutoscaler struct {
	Name           string
	Namespace      string
	Labels         map[string]string
	ScaleTargetRef ScaleTargetRef
	MinReplicas    int
	MaxReplicas    int
	Metrics        []Metric
}

func (*HorizontalPodAutoscaler) ToManifest

func (hpa *HorizontalPodAutoscaler) ToManifest() (any, error)

type Host

type Host struct {
	Hostname  string
	Namespace string
}

func HostInDefaultNamespace

func HostInDefaultNamespace(h string) *Host

func (*Host) ToManifest

func (ns *Host) ToManifest() (any, error)

ToManifest is only structured for reading. For creating secrets more work needs to be done.

type Job

type Job struct {
	// TODO: have a way to validate arguments
	Name                    string // TODO: ensure it's a valid k8s name
	Namespace               string
	Labels                  map[string]string
	ContainerImage          string
	Command                 []string
	EnvConfig               EnvConfig
	PodMetadata             map[string]any
	BackoffLimit            int
	TTLSecondsAfterFinished int
	// contains filtered or unexported fields
}

func (*Job) PatchForTest

func (j *Job) PatchForTest(patchMapper map[string]any)

PatchForTest is an api for tests. It is too fast-and-loose to use in production. Please use more structured APIs for prod.

patchMapper patchMapper make me a patch find me a find catch me a catch

func (*Job) ToManifest

func (j *Job) ToManifest() (any, error)

type JobWithSpec

type JobWithSpec struct {
	Command                 []string
	Name                    string
	Namespace               string
	Labels                  map[string]string
	PodMetadata             map[string]any
	PodSpec                 map[string]any
	BackoffLimit            int
	TTLSecondsAfterFinished int
	// contains filtered or unexported fields
}

func (*JobWithSpec) ToManifest

func (j *JobWithSpec) ToManifest() (any, error)

type Metric

type Metric struct {
	Type     string
	Resource MetricResource
}

type MetricResource

type MetricResource struct {
	Name   string
	Target map[string]any
}

type Namespace

type Namespace struct {
	Name   string
	Labels map[string]string
}

func (*Namespace) ToManifest

func (ns *Namespace) ToManifest() (any, error)

type NetworkPolicy

type NetworkPolicy struct {
	Name              string
	Namespace         string
	AllowedNamespaces []string
}

NetworkPolicy is a simplified version of k8s NetworkPolicy resource For now, we only support limiting ingress based on namespaces. We can make this more complicated if needed

func (*NetworkPolicy) ToManifest

func (np *NetworkPolicy) ToManifest() (any, error)

ToManifest is only structured for reading. For creating secrets more work needs to be done.

type Passthru

type Passthru struct {
	JsonManifest []byte // json
}

func (*Passthru) ToManifest

func (p *Passthru) ToManifest() (any, error)

type Pod

type Pod struct {
	Labels    map[string]any
	Namespace string
	Spec      map[string]any
}

func (*Pod) ToManifest

func (p *Pod) ToManifest() (any, error)

type Port

type Port struct {
	Name       string
	Port       int
	Protocol   string
	TargetPort string
}

type Quota

type Quota struct {
	Pods string
}

type ResourceQuota

type ResourceQuota struct {
	Name      string
	Namespace string
	Quota     *Quota
}

func (*ResourceQuota) ToManifest

func (rb *ResourceQuota) ToManifest() (any, error)

type RoleBinding

type RoleBinding struct {
	Name      string
	Namespace string
	RoleRef   *RoleRef
	Subjects  []*Subject
}

func (*RoleBinding) ToManifest

func (rb *RoleBinding) ToManifest() (any, error)

type RoleRef

type RoleRef struct {
	Kind string
	Name string
}

type ScaleTargetRef

type ScaleTargetRef struct {
	ApiVersion string
	Kind       string
	Name       string
}

type Secret

type Secret struct {
	Name      string
	Namespace string
	Type      string
	Data      map[string]any
}

func SecretFromUnstructured

func SecretFromUnstructured(u *unstructured.Unstructured) *Secret

func (*Secret) ToManifest

func (ns *Secret) ToManifest() (any, error)

ToManifest is only structured for reading. For creating secrets more work needs to be done.

type Selector

type Selector struct {
	MatchLabels map[string]string `json:"matchLabels"`
}

type Service

type Service struct {
	Name           string
	Namespace      string
	Labels         map[string]string
	Ports          []Port
	SelectorLabels map[string]string
	Type           string // TODO make enum: ClusterIP, NodePort, LoadBalancer, ExternalName
}

func (*Service) ToManifest

func (svc *Service) ToManifest() (any, error)

type ServiceAccount

type ServiceAccount struct {
	Name      string
	Namespace string
}

func (*ServiceAccount) ToManifest

func (sa *ServiceAccount) ToManifest() (any, error)

type Subject

type Subject struct {
	Kind      string
	Name      string
	Namespace string
}

type Template

type Template struct {
	Metadata map[string]any `json:"metadata"`
	Spec     map[string]any `json:"spec"`
}

type TypedJob

type TypedJob struct {
	// TODO: have a way to validate arguments
	Name           string // TODO: ensure it's a valid k8s name
	Namespace      string
	ContainerImage string
	Command        []string
}

Experiment to see if we prefer to used the typed objects from the typed K8s APIs. So far: Pros: It's typed, so you get compile time checking, completion, docs in IDE Cons: Feels slow to translate. With the untyped case I can easily look at

a YAML and write the corresponding struct very quickly. With the
typed API I find myself trying to figure out in which go package
a given type is defined, and making sure we're importing it

func (*TypedJob) ToManifest

func (j *TypedJob) ToManifest() (any, error)

Jump to

Keyboard shortcuts

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