Documentation ¶
Overview ¶
Package resource contains helpers to generate Kubernetes API objects.
Index ¶
- 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 TerminationErrorToLogs(object interface{})
- type ObjectOption
- func Container(c *corev1.Container) ObjectOption
- func Controller(obj kmeta.OwnerRefable) 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 Limits(cpu, mem resource.Quantity) 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 string) ObjectOption
- func StartupProbe(path, port string) ObjectOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 TerminationErrorToLogs ¶ added in v1.3.0
func TerminationErrorToLogs(object interface{})
TerminationErrorToLogs sets the TerminationMessagePolicy of a container to FallbackToLogsOnError.
Types ¶
type ObjectOption ¶
type ObjectOption func(interface{})
ObjectOption is a functional option for building Kubernetes API objects.
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 (owner) of an API object.
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 ¶ added in v1.2.0
func Limits(cpu, mem resource.Quantity) ObjectOption
Limits sets the CPU and memory limits of a Deployment's first container.
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 Deployment's first container.
func Requests ¶ added in v1.2.0
func Requests(cpu, mem resource.Quantity) ObjectOption
Requests sets the CPU and memory requests of a Deployment'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 ¶ added in v1.3.0
func ServiceAccount(sa string) ObjectOption
ServiceAccount sets the ServiceAccount name of a PodSpecable.
func StartupProbe ¶ added in v1.2.0
func StartupProbe(path, port string) ObjectOption
StartupProbe sets the HTTP startup probe of a Deployment's first container.