Documentation ¶
Overview ¶
Package resource contains helpers to generate Kubernetes API objects.
Index ¶
- func NewConfigMap(ns, name string, opts ...ObjectOption) *corev1.ConfigMap
- func NewContainer(name string, opts ...ObjectOption) *corev1.Container
- func NewDeployment(ns, name string, opts ...ObjectOption) *appsv1.Deployment
- func NewKnService(ns, name string, opts ...ObjectOption) *servingv1.Service
- func NewServiceAccount(ns, name string, opts ...ObjectOption) *corev1.ServiceAccount
- func TerminationErrorToLogs(object interface{})
- func VisibilityClusterLocal(object interface{})
- func VisibilityPublic(object interface{})
- type ObjectOption
- func Affinity(affinity corev1.Affinity) ObjectOption
- func Annotation(key, val string) ObjectOption
- func Container(c *corev1.Container) ObjectOption
- func Controller(obj kmeta.OwnerRefable) ObjectOption
- func Data(key, value string) ObjectOption
- func EntrypointCommand(cmdAndArgs ...string) ObjectOption
- func EnvVar(name, val string) ObjectOption
- func EnvVarFromSecret(name, secretName, secretKey string) ObjectOption
- func EnvVars(evs ...corev1.EnvVar) ObjectOption
- func Image(img string) ObjectOption
- func Label(key, val string) ObjectOption
- func Labels(ls labels.Set) ObjectOption
- func Limits(cpu, mem *resource.Quantity) ObjectOption
- func NodeSelector(selector map[string]string) ObjectOption
- func Owners(owners ...kmeta.OwnerRefable) ObjectOption
- func PodAnnotation(key, val string) ObjectOption
- func PodLabel(key, val string) ObjectOption
- func Port(name string, port int32) ObjectOption
- func Probe(path, port string) ObjectOption
- func Requests(cpu, mem *resource.Quantity) ObjectOption
- func Selector(key, val string) ObjectOption
- func ServiceAccount(sa *corev1.ServiceAccount) ObjectOption
- func StartupProbe(path, port string) ObjectOption
- func Toleration(t corev1.Toleration) ObjectOption
- func VolumeMounts(vms ...corev1.VolumeMount) ObjectOption
- func Volumes(vs ...corev1.Volume) ObjectOption
- type ServiceAccountOption
Constants ¶
This section is empty.
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, 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 NewServiceAccount ¶
func NewServiceAccount(ns, name string, opts ...ObjectOption) *corev1.ServiceAccount
NewServiceAccount creates a ServiceAccount object.
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 ObjectOption ¶
type ObjectOption func(interface{})
ObjectOption is a functional option for building Kubernetes API objects.
func Affinity ¶ added in v1.25.0
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 Container ¶
func Container(c *corev1.Container) ObjectOption
Container adds a container to a PodSpecable's Pod template.
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 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 Label ¶
func Label(key, val string) ObjectOption
Label sets the value of an API object's label.
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 ¶ added in v1.24.3
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 ¶ added in v1.25.0
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 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 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 ¶ added in v1.17.0
func VolumeMounts(vms ...corev1.VolumeMount) ObjectOption
VolumeMounts attaches VolumeMounts to a Container.
func Volumes ¶ added in v1.17.0
func Volumes(vs ...corev1.Volume) ObjectOption
Volumes attaches Volumes to a PodSpecable.
type ServiceAccountOption ¶
type ServiceAccountOption func(*corev1.ServiceAccount)
ServiceAccountOption is a functional option for a ServiceAccount.