resource

package
v1.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package resource contains helpers to generate Kubernetes API objects.

Index

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 NewServiceAccount added in v1.12.0

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.

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 (main 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 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 added in v1.12.0

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 Owners added in v1.12.0

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

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

func PodLabel

func PodLabel(key, val string) ObjectOption

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

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 SecretMount added in v1.14.0

func SecretMount(name, target, secretName, secretKey string) ObjectOption

SecretMount adds a Secret volume and a corresponding mount to a PodSpecable.

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 string) 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.

type ServiceAccountOption added in v1.12.0

type ServiceAccountOption func(*corev1.ServiceAccount)

ServiceAccountOption is a functional option for a ServiceAccount.

Jump to

Keyboard shortcuts

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