template

package
v0.0.0-...-3e7746c Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2024 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppLabel       = "app.kubernetes.io/name"
	ComponentLabel = "app.kubernetes.io/component"
	InstanceLabel  = "app.kubernetes.io/instance"
)
View Source
const (
	AppliedHashAnnotation = "openstack.ospk8s.com/applied-hash"
)
View Source
const Finalizer = "openstack.ospk8s.com/finalizer"

Variables

This section is empty.

Functions

func AddDeploymentReadyCheck

func AddDeploymentReadyCheck(cw *ConditionWaiter, instance *appsv1.Deployment)

func AddStatefulSetReadyCheck

func AddStatefulSetReadyCheck(cw *ConditionWaiter, instance *appsv1.StatefulSet)

func AppLabels

func AppLabels(instance, app string) map[string]string

func AppliedHash

func AppliedHash(obj metav1.Object) string

func BidirectionalVolumeMount

func BidirectionalVolumeMount(name, mountPath string) corev1.VolumeMount

func Combine

func Combine(parts ...string) string

func ConfigMapEnvVar

func ConfigMapEnvVar(name, cmName, cmKey string) corev1.EnvVar

func ConfigMapVolume

func ConfigMapVolume(name, configMapName string, defaultMode *int32) corev1.Volume

func CreateJob

func CreateJob(ctx context.Context, c client.Client, instance *batchv1.Job, log logr.Logger) error

func CreateSecret

func CreateSecret(ctx context.Context, c client.Client, instance *corev1.Secret, log logr.Logger) error

func DecodeManifest

func DecodeManifest(encoded string) (*unstructured.Unstructured, error)

func DeleteJob

func DeleteJob(ctx context.Context, c client.Client, instance *batchv1.Job, log logr.Logger) error

func EmptyDirVolume

func EmptyDirVolume(name string) corev1.Volume

func Ensure

func Ensure[T CopyableObject[T]](ctx context.Context, c client.Client, instance T, log logr.Logger, update func(T)) error

func EnsureConfigMap

func EnsureConfigMap(ctx context.Context, c client.Client, instance *corev1.ConfigMap, log logr.Logger) error

func EnsureDaemonSet

func EnsureDaemonSet(ctx context.Context, c client.Client, instance *appsv1.DaemonSet, log logr.Logger) error

func EnsureDeployment

func EnsureDeployment(ctx context.Context, c client.Client, instance *appsv1.Deployment, log logr.Logger) error

func EnsureIngress

func EnsureIngress(ctx context.Context, c client.Client, instance *netv1.Ingress, log logr.Logger) error

func EnsurePersistentVolumeClaim

func EnsurePersistentVolumeClaim(ctx context.Context, c client.Client, instance *corev1.PersistentVolumeClaim, log logr.Logger) error

func EnsureResource

func EnsureResource(ctx context.Context, c client.Client, instance *unstructured.Unstructured, log logr.Logger) error

func EnsureRole

func EnsureRole(ctx context.Context, c client.Client, instance *rbacv1.Role, log logr.Logger) error

func EnsureRoleBinding

func EnsureRoleBinding(ctx context.Context, c client.Client, instance *rbacv1.RoleBinding, log logr.Logger) error

func EnsureSecret

func EnsureSecret(ctx context.Context, c client.Client, instance *corev1.Secret, log logr.Logger) error

func EnsureService

func EnsureService(ctx context.Context, c client.Client, instance *corev1.Service, log logr.Logger) error

func EnsureServiceAccount

func EnsureServiceAccount(ctx context.Context, c client.Client, instance *corev1.ServiceAccount, log logr.Logger) error

func EnsureStatefulSet

func EnsureStatefulSet(ctx context.Context, c client.Client, instance *appsv1.StatefulSet, log logr.Logger) error

func EnvFromConfigMap

func EnvFromConfigMap(name string) corev1.EnvFromSource

func EnvFromSecret

func EnvFromSecret(name string) corev1.EnvFromSource

func EnvFromSecretPrefixed

func EnvFromSecretPrefixed(name, prefix string) corev1.EnvFromSource

func EnvVar

func EnvVar(name, value string) corev1.EnvVar

func FieldEnvVar

func FieldEnvVar(name, fieldPath string) corev1.EnvVar

func GenericConfigMap

func GenericConfigMap(name, namespace string, labels map[string]string) *corev1.ConfigMap

func GenericDaemonSet

func GenericDaemonSet(component Component) *appsv1.DaemonSet

func GenericDeployment

func GenericDeployment(component Component) *appsv1.Deployment

func GenericIngress

func GenericIngress(name, namespace string, spec *openstackv1beta1.IngressSpec, labels map[string]string) *netv1.Ingress

func GenericIngressWithTLS

func GenericIngressWithTLS(name, namespace string, spec *openstackv1beta1.IngressSpec, tlsSpec openstackv1beta1.TLSServerSpec, labels map[string]string) *netv1.Ingress

func GenericJob

func GenericJob(component Component) *batchv1.Job

func GenericRole

func GenericRole(name, namespace string, labels map[string]string, rules []rbacv1.PolicyRule) *rbacv1.Role

func GenericRoleBinding

func GenericRoleBinding(name, namespace string, labels map[string]string) *rbacv1.RoleBinding

func GenericSecret

func GenericSecret(name, namespace string, labels map[string]string) *corev1.Secret

func GenericService

func GenericService(name, namespace string, labels map[string]string) *corev1.Service

func GenericServiceAccount

func GenericServiceAccount(name, namespace string, labels map[string]string) *corev1.ServiceAccount

func GenericStatefulSet

func GenericStatefulSet(component Component) *appsv1.StatefulSet

func HeadlessServiceName

func HeadlessServiceName(name string) string

func HostPathVolume

func HostPathVolume(name, path string) corev1.Volume

func IngressServiceBackend

func IngressServiceBackend(svcName, portName string) netv1.IngressBackend

func Labels

func Labels(instance, app, component string) map[string]string

func MatchesAppliedHash

func MatchesAppliedHash(obj metav1.Object, expected string) bool

func MergeINI

func MergeINI(cfg *ini.File, extraCfg openstackv1beta1.ExtraConfig)

func MergeStringMaps

func MergeStringMaps(maps ...map[string]string) map[string]string

func MustDecodeManifest

func MustDecodeManifest(encoded string) *unstructured.Unstructured

func MustEncodeYAML

func MustEncodeYAML(in interface{}) []byte

func MustGenerateFernetKey

func MustGenerateFernetKey() string

func MustGeneratePassword

func MustGeneratePassword() string

func MustLoadINI

func MustLoadINI(app, filename string) *ini.File

func MustLoadINITemplate

func MustLoadINITemplate(app, filename string, values interface{}) *ini.File

func MustOutputINI

func MustOutputINI(file *ini.File) *bytes.Buffer

func MustParseINI

func MustParseINI(encoded string) *ini.File

func MustReadFile

func MustReadFile(app, filename string) string

func MustRenderFile

func MustRenderFile(app, filename string, values interface{}) string

func NodePodAntiAffinity

func NodePodAntiAffinity(labels map[string]string) *corev1.PodAntiAffinity

func ObjectHash

func ObjectHash(i interface{}) (string, error)

ObjectHash creates a deep object hash and return it as a safe encoded string

func PersistentVolume

func PersistentVolume(name, claimName string) corev1.Volume

func PersistentVolumeClaim

func PersistentVolumeClaim(name string, labels map[string]string, spec openstackv1beta1.VolumeSpec) corev1.PersistentVolumeClaim

func ReadFile

func ReadFile(app, filename string) (string, error)

func ReadOnlyVolumeMount

func ReadOnlyVolumeMount(name, mountPath string) corev1.VolumeMount

func RenderFile

func RenderFile(app, filename string, values interface{}) (string, error)

func RoleRef

func RoleRef(name string) rbacv1.RoleRef

func SSHKeypairSecret

func SSHKeypairSecret(name, namespace string, labels map[string]string) (*corev1.Secret, error)

func SecretEnvVar

func SecretEnvVar(name, secretName, secretKey string) corev1.EnvVar

func SecretVolume

func SecretVolume(name, secretName string, defaultMode *int32) corev1.Volume

func SetAppliedHash

func SetAppliedHash(obj metav1.Object, hash string)

func SetAppliedHashUnstructured

func SetAppliedHashUnstructured(instance *unstructured.Unstructured, hash string)

func StorageResources

func StorageResources(capacity string) corev1.VolumeResourceRequirements

func SubPathVolumeMount

func SubPathVolumeMount(name, mountPath, subPath string) corev1.VolumeMount

func VolumeMount

func VolumeMount(name, mountPath string) corev1.VolumeMount

Types

type Component

type Component struct {
	Namespace            string
	Labels               map[string]string
	Replicas             int32
	Affinity             *corev1.Affinity
	NodeSelector         map[string]string
	InitContainers       []corev1.Container
	Containers           []corev1.Container
	SecurityContext      *corev1.PodSecurityContext
	Volumes              []corev1.Volume
	VolumeClaimTemplates []corev1.PersistentVolumeClaim
}

type ConditionWaiter

type ConditionWaiter struct {
	// contains filtered or unexported fields
}

func NewConditionWaiter

func NewConditionWaiter(scheme *runtime.Scheme, log logr.Logger) *ConditionWaiter

func (*ConditionWaiter) AddCheck

func (cw *ConditionWaiter) AddCheck(instance client.Object, conditionType string, ready bool) *ConditionWaiter

func (*ConditionWaiter) AddReadyCheck

func (cw *ConditionWaiter) AddReadyCheck(instance client.Object, conditions []metav1.Condition) *ConditionWaiter

func (*ConditionWaiter) Wait

func (cw *ConditionWaiter) Wait(ctx context.Context, report ReportFunc) (ctrl.Result, error)

type CopyableObject

type CopyableObject[T client.Object] interface {
	client.Object
	DeepCopy() T
}

type JobRunner

type JobRunner struct {
	// contains filtered or unexported fields
}

func NewJobRunner

func NewJobRunner(ctx context.Context, c client.Client, instance client.Object, log logr.Logger) *JobRunner

func (*JobRunner) Add

func (r *JobRunner) Add(hashField *string, job *batchv1.Job)

func (*JobRunner) Run

func (r *JobRunner) Run(ctx context.Context, report ReportFunc) (ctrl.Result, error)

type ReportFunc

type ReportFunc func(ctx context.Context, message string, args ...any) error

type Reporter

type Reporter struct {
	// contains filtered or unexported fields
}

Reporter provides a generic way to report the status of a resource.

func NewReporter

func NewReporter(instance client.Object, conditions *[]metav1.Condition, k8sClient client.Client, recorder record.EventRecorder) *Reporter

func (*Reporter) UpdateCompletedCondition

func (r *Reporter) UpdateCompletedCondition(ctx context.Context, status metav1.ConditionStatus, reason, message string, args ...any) error

func (*Reporter) UpdateCondition

func (r *Reporter) UpdateCondition(ctx context.Context, conditionType string, status metav1.ConditionStatus, reason, message string, args ...any) error

func (*Reporter) UpdateReadyCondition

func (r *Reporter) UpdateReadyCondition(ctx context.Context, status metav1.ConditionStatus, reason, message string, args ...any) error

Jump to

Keyboard shortcuts

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