resource

package
v0.1.56 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package resource contains helpers to generate Kubernetes API objects.

Index

Constants

View Source
const (
	// appNameLabel is the name of the application.
	AppNameLabel = "app.kubernetes.io/name"
	// appInstanceLabel is a unique name identifying the instance of an application.
	AppInstanceLabel = "app.kubernetes.io/instance"
	// appComponentLabel is the component within the architecture.
	AppComponentLabel = "app.kubernetes.io/component"
	// appPartOfLabel is the name of a higher level application this one is part of.
	AppPartOfLabel = "app.kubernetes.io/part-of"
	// appManagedByLabel is the tool being used to manage the operation of an application.
	AppManagedByLabel = "app.kubernetes.io/managed-by"
)

Kubernetes recommended labels https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/

View Source
const (
	PartOf    = "typhoon"
	ManagedBy = "core-controller"
)

Common label values

Variables

This section is empty.

Functions

func NewConfigMap

func NewConfigMap(ns, name string, opts ...ObjectOption) *corev1.ConfigMap

NewConfigMap creates a ConfigMap object.

func NewContainer

func NewContainer(name string, image string, opts ...ObjectOption) *corev1.Container

NewContainer creates a Container object.

func NewDeployment

func NewDeployment(ns, name string, opts ...ObjectOption) *appsv1.Deployment

NewDeployment creates a Deployment object.

func NewKnService

func NewKnService(ns, name string, opts ...ObjectOption) *servingv1.Service

NewKnService creates a Knative Service object.

func NewMeta added in v0.1.8

func NewMeta(ns, name string, opts ...MetaOption) *metav1.ObjectMeta

func NewRoleBinding added in v0.1.8

func NewRoleBinding(namespace, name, roleName, subjectName string, opts ...RoleBindingOption) *rbacv1.RoleBinding

func NewSecret added in v0.1.8

func NewSecret(namespace, name string, opts ...SecretOption) *corev1.Secret

func NewService added in v0.1.8

func NewService(namespace, name string, opts ...ServiceOption) *corev1.Service

func NewServiceAccount

func NewServiceAccount(ns, name string, opts ...ObjectOption) *corev1.ServiceAccount

NewServiceAccount creates a ServiceAccount object.

func NewVolume added in v0.1.8

func NewVolume(name string, opts ...VolumeOption) *corev1.Volume

func NewVolumeMount added in v0.1.8

func NewVolumeMount(name, mountPath string, opts ...VolumeMountOption) *corev1.VolumeMount

func TerminationErrorToLogs

func TerminationErrorToLogs(object interface{})

TerminationErrorToLogs sets the TerminationMessagePolicy of a container to FallbackToLogsOnError.

func VisibilityClusterLocal

func VisibilityClusterLocal(object interface{})

VisibilityClusterLocal makes the Knative Service only available on the cluster's local network.

func VisibilityPublic

func VisibilityPublic(object interface{})

VisibilityPublic makes the Knative Service available on the public internet.

Types

type ConfigMapOption added in v0.1.8

type ConfigMapOption func(*corev1.ConfigMap)

type ContainerOption added in v0.1.8

type ContainerOption func(*corev1.Container)

type DeploymentOption added in v0.1.8

type DeploymentOption func(*appsv1.Deployment)

type MetaOption added in v0.1.8

type MetaOption func(*metav1.ObjectMeta)

func MetaAddLabel added in v0.1.8

func MetaAddLabel(key, value string) MetaOption

func MetaAddOwner added in v0.1.8

func MetaAddOwner(o metav1.Object, gvk schema.GroupVersionKind) MetaOption

func MetaSetDeletion added in v0.1.8

func MetaSetDeletion(t *metav1.Time) MetaOption

type ObjectOption

type ObjectOption func(interface{})

ObjectOption is a functional option for building Kubernetes API objects.

func Affinity

func Affinity(affinity corev1.Affinity) ObjectOption

Affinity sets an Affinity on a PodSpecable.

func Annotation

func Annotation(key, val string) ObjectOption

Annotation sets the value of an API object's annotation.

func ConfigMapWithMetaOptions added in v0.1.8

func ConfigMapWithMetaOptions(opts ...MetaOption) ObjectOption

func Container

func Container(c *corev1.Container) ObjectOption

Container adds a container to a PodSpecable's Pod template.

func ContainerAddArgs added in v0.1.8

func ContainerAddArgs(s string) ObjectOption

func ContainerAddEnvFromFieldRef added in v0.1.8

func ContainerAddEnvFromFieldRef(name, path string) ObjectOption

func ContainerAddEnvFromValue added in v0.1.8

func ContainerAddEnvFromValue(name, value string) ObjectOption

func ContainerAddEnvVarFromSecret added in v0.1.8

func ContainerAddEnvVarFromSecret(name, secretName, secretKey string) ObjectOption

func ContainerAddPort added in v0.1.8

func ContainerAddPort(name string, containerPort int32) ObjectOption

func ContainerWithImagePullPolicy added in v0.1.8

func ContainerWithImagePullPolicy(policy corev1.PullPolicy) ObjectOption

func Controller

func Controller(obj kmeta.OwnerRefable) ObjectOption

Controller sets the given object as the controller (main owner) of an API object.

func Data

func Data(key, value string) ObjectOption

Data sets one UTF-8 data entry in a ConfigMap.

func DeploymentAddSelectorForTemplate added in v0.1.8

func DeploymentAddSelectorForTemplate(key, value string) ObjectOption

func DeploymentSetReplicas added in v0.1.8

func DeploymentSetReplicas(replicas int32) ObjectOption

func DeploymentWithMetaOptions added in v0.1.8

func DeploymentWithMetaOptions(opts ...MetaOption) ObjectOption

func DeploymentWithTemplateSpecOptions added in v0.1.8

func DeploymentWithTemplateSpecOptions(opts ...ObjectOption) ObjectOption

func EntrypointCommand

func EntrypointCommand(cmdAndArgs ...string) ObjectOption

EntrypointCommand overrides the entrypoint command of a Container or PodSpecable's first container.

func EnvVar

func EnvVar(name, val string) ObjectOption

EnvVar sets the value of a Container's environment variable.

func EnvVarFromSecret

func EnvVarFromSecret(name, secretName, secretKey string) ObjectOption

EnvVarFromSecret sets the value of a Container's environment variable to a reference to a Kubernetes Secret.

func EnvVars

func EnvVars(evs ...corev1.EnvVar) ObjectOption

EnvVars sets the value of multiple environment variables.

func Image

func Image(img string) ObjectOption

Image sets a Container's image.

func Label

func Label(key, val string) ObjectOption

Label sets the value of an API object's label.

func Labels

func Labels(ls labels.Set) ObjectOption

Labels sets multiple labels on an API object.

func Limits

func Limits(cpu, mem *resource.Quantity) ObjectOption

Limits sets the CPU and memory limits of a Container or PodSpecable's first container.

func NodeSelector

func NodeSelector(selector map[string]string) ObjectOption

NodeSelector sets a NodeSelector on a PodSpecable.

func Owners

func Owners(owners ...kmeta.OwnerRefable) ObjectOption

Owners sets the given objects as regular owners of an API object.

func PodAnnotation

func PodAnnotation(key, val string) ObjectOption

PodAnnotation sets the value of a Annotation of a PodSpecable's Pod template.

func PodLabel

func PodLabel(key, val string) ObjectOption

PodLabel sets the value of a label of a PodSpecable's Pod template.

func PodSpecAddContainer added in v0.1.8

func PodSpecAddContainer(opt *corev1.Container) ObjectOption

func PodSpecWithServiceAccountName added in v0.1.8

func PodSpecWithServiceAccountName(saName string) ObjectOption

func PodTemplateSpecWithMetaOptions added in v0.1.8

func PodTemplateSpecWithMetaOptions(opts ...MetaOption) ObjectOption

func PodTemplateSpecWithPodSpecOptions added in v0.1.8

func PodTemplateSpecWithPodSpecOptions(opts ...ObjectOption) ObjectOption

func Port

func Port(name string, port int32) ObjectOption

Port adds a port to a Container.

func Probe

func Probe(path, port string) ObjectOption

Probe sets the HTTP readiness probe of a Container or PodSpecable's first container.

func Requests

func Requests(cpu, mem *resource.Quantity) ObjectOption

Requests sets the CPU and memory requests of a Container or PodSpecable's first container.

func Selector

func Selector(key, val string) ObjectOption

Selector adds a label selector to a Deployment's spec, ensuring a corresponding label exists in the Pod template.

func ServiceAccount

func ServiceAccount(sa *corev1.ServiceAccount) ObjectOption

ServiceAccount sets the ServiceAccount name of a PodSpecable.

func ServiceAccountWithMetaOptions added in v0.1.8

func ServiceAccountWithMetaOptions(opts ...MetaOption) ObjectOption

func StartupProbe

func StartupProbe(path, port string) ObjectOption

StartupProbe sets the HTTP startup probe of a Container or PodSpecable's first container.

func Toleration

func Toleration(t corev1.Toleration) ObjectOption

Toleration sets a Toleration on a PodSpecable.

func VolumeMounts

func VolumeMounts(vms ...corev1.VolumeMount) ObjectOption

VolumeMounts attaches VolumeMounts to a Container.

func Volumes

func Volumes(vs ...corev1.Volume) ObjectOption

Volumes attaches Volumes to a PodSpecable.

type PodSpecOption added in v0.1.8

type PodSpecOption func(*corev1.PodSpec)

type PodTemplateSpecOption added in v0.1.8

type PodTemplateSpecOption func(*corev1.PodTemplateSpec)

type RoleBindingOption added in v0.1.8

type RoleBindingOption func(*rbacv1.RoleBinding)

func RoleBindingWithMetaOptions added in v0.1.8

func RoleBindingWithMetaOptions(opts ...MetaOption) RoleBindingOption

type SecretOption added in v0.1.8

type SecretOption func(*corev1.Secret)

func SecretSetData added in v0.1.8

func SecretSetData(key string, value []byte) SecretOption

func SecretWithMetaOptions added in v0.1.8

func SecretWithMetaOptions(opts ...MetaOption) SecretOption

type ServiceAccountOption

type ServiceAccountOption func(*corev1.ServiceAccount)

ServiceAccountOption is a functional option for a ServiceAccount.

type ServiceOption added in v0.1.8

type ServiceOption func(*corev1.Service)

func ServiceAddPort added in v0.1.8

func ServiceAddPort(name string, port int32, targetPort int32) ServiceOption

func ServiceAddSelectorLabel added in v0.1.8

func ServiceAddSelectorLabel(key, value string) ServiceOption

func ServiceSetType added in v0.1.8

func ServiceSetType(st corev1.ServiceType) ServiceOption

func ServiceWithMetaOptions added in v0.1.8

func ServiceWithMetaOptions(opts ...MetaOption) ServiceOption

type VolumeMountOption added in v0.1.8

type VolumeMountOption func(*corev1.VolumeMount)

func VolumeMountWithReadOnlyOption added in v0.1.8

func VolumeMountWithReadOnlyOption(b bool) VolumeMountOption

type VolumeOption added in v0.1.8

type VolumeOption func(*corev1.Volume)

func VolumeFromSecretOption added in v0.1.8

func VolumeFromSecretOption(secretName, secretKey, mountFile string) VolumeOption

Jump to

Keyboard shortcuts

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