resource

package
v1.7.14 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Copyright 2021 The Cockroach Authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	RELATED_IMAGE_PREFIX         = "RELATED_IMAGE_COCKROACH_"
	NotSupportedVersion          = "not_supported_version"
	CrdbContainerImageAnnotation = "crdb.io/containerimage"
	CrdbVersionAnnotation        = "crdb.io/version"
	CrdbHistoryAnnotation        = "crdb.io/history"
	CrdbRestartAnnotation        = "crdb.io/restart"
	CrdbCertExpirationAnnotation = "crdb.io/certexpiration"
	CrdbRestartTypeAnnotation    = "crdb.io/restarttype"
)
View Source
const (
	// JobContainerName used on spec for the container
	JobContainerName     = "crdb"
	GetTagVersionCommand = "/cockroach/cockroach.sh version | grep 'Build Tag:'| awk '{print $3}'"
)
View Source
const (
	DataDirName      = "datadir"
	DataDirMountPath = "/cockroach/cockroach-data/"

	DbContainerName = "db"
)

Variables

View Source
var CRDB_PREFIX string = "CRDB_"

Functions

func ClusterPlaceholder

func ClusterPlaceholder(name string) *api.CrdbCluster

Types

type Builder

type Builder interface {
	Build(client.Object) error
	Placeholder() client.Object
}

Builder populates a given Kubernetes resource or creates its default instance (placeholder)

type Cluster

type Cluster struct {
	Fetcher
	// contains filtered or unexported fields
}

func NewCluster

func NewCluster(original *api.CrdbCluster) Cluster

func (Cluster) CASecretName

func (cluster Cluster) CASecretName() string

func (Cluster) ClientTLSSecretName

func (cluster Cluster) ClientTLSSecretName() string

func (Cluster) DeleteRestartTypeAnnotation

func (cluster Cluster) DeleteRestartTypeAnnotation()

func (Cluster) DiscoveryServiceName

func (cluster Cluster) DiscoveryServiceName() string

func (Cluster) Domain

func (cluster Cluster) Domain() string

func (Cluster) Failed

func (cluster Cluster) Failed(atype api.ActionType) bool

func (Cluster) GetAnnotationContainerImage

func (cluster Cluster) GetAnnotationContainerImage() string

func (Cluster) GetAnnotationHistory

func (cluster Cluster) GetAnnotationHistory() string

func (Cluster) GetAnnotationRestartType

func (cluster Cluster) GetAnnotationRestartType() string

func (Cluster) GetCockroachDBImageName

func (cluster Cluster) GetCockroachDBImageName() string

func (Cluster) GetVersionAnnotation

func (cluster Cluster) GetVersionAnnotation() string

GetVersionAnnotation gets the current version of the cluster retrieved by version checker action

func (Cluster) InitTime

func (cluster Cluster) InitTime() metav1.Time

func (Cluster) IsFresh

func (cluster Cluster) IsFresh(fetcher Fetcher) (bool, error)

func (Cluster) IsSupportedImage

func (cluster Cluster) IsSupportedImage() bool

func (Cluster) JobName

func (cluster Cluster) JobName() string

func (Cluster) LookupSupportedVersion

func (cluster Cluster) LookupSupportedVersion(version string) (string, bool)

func (Cluster) Name

func (cluster Cluster) Name() string

func (Cluster) Namespace

func (cluster Cluster) Namespace() string

func (Cluster) NodeTLSSecretName

func (cluster Cluster) NodeTLSSecretName() string

func (Cluster) ObjectKey

func (cluster Cluster) ObjectKey() types.NamespacedName

func (Cluster) PublicServiceName

func (cluster Cluster) PublicServiceName() string

func (Cluster) ResetActionType

func (cluster Cluster) ResetActionType(atype api.ActionType)

func (Cluster) SecureMode

func (cluster Cluster) SecureMode() string

func (Cluster) SetActionFailed

func (cluster Cluster) SetActionFailed(atype api.ActionType, errMsg string)

func (Cluster) SetActionFinished

func (cluster Cluster) SetActionFinished(atype api.ActionType)

func (Cluster) SetActionUnknown

func (cluster Cluster) SetActionUnknown(atype api.ActionType)

func (Cluster) SetAnnotationCertExpiration

func (cluster Cluster) SetAnnotationCertExpiration(certExpiration string)

func (Cluster) SetAnnotationContainerImage

func (cluster Cluster) SetAnnotationContainerImage(containerimage string)

func (Cluster) SetAnnotationVersion

func (cluster Cluster) SetAnnotationVersion(version string)

func (Cluster) SetClusterStatus

func (cluster Cluster) SetClusterStatus()

func (Cluster) SetClusterStatusOnFirstReconcile

func (cluster Cluster) SetClusterStatusOnFirstReconcile()

func (Cluster) SetClusterVersion

func (cluster Cluster) SetClusterVersion(version string)

func (Cluster) SetCrdbContainerImage

func (cluster Cluster) SetCrdbContainerImage(containerimage string)

func (Cluster) SetFalse

func (cluster Cluster) SetFalse(ctype api.ClusterConditionType)

func (Cluster) SetTrue

func (cluster Cluster) SetTrue(ctype api.ClusterConditionType)

func (Cluster) Spec

func (cluster Cluster) Spec() *api.CrdbClusterSpec

func (Cluster) StatefulSetName

func (cluster Cluster) StatefulSetName() string

func (Cluster) Status

func (cluster Cluster) Status() *api.CrdbClusterStatus

func (Cluster) True

func (cluster Cluster) True(ctype api.ClusterConditionType) bool

True checks if the api.ClusterConditionType is true

func (Cluster) Unwrap

func (cluster Cluster) Unwrap() *api.CrdbCluster

type DiscoveryServiceBuilder

type DiscoveryServiceBuilder struct {
	*Cluster

	Selector map[string]string
}

This service only exists to create DNS entries for each pod in the StatefulSet such that they can resolve each other's IP addresses. It does not create a load-balanced ClusterIP and should not be used directly by clients in most circumstances.

func (DiscoveryServiceBuilder) Build

func (DiscoveryServiceBuilder) Placeholder

func (b DiscoveryServiceBuilder) Placeholder() client.Object

type Fetcher

type Fetcher interface {
	Fetch(obj client.Object) error
}

Fetcher updates the object with its state from Kubernetes

type JobBuilder

type JobBuilder struct {
	*Cluster

	Selector labels.Labels
	JobName  string
}

func (JobBuilder) Build

func (b JobBuilder) Build(obj client.Object) error

func (JobBuilder) MakeContainers

func (b JobBuilder) MakeContainers() []corev1.Container

MakeContainers creates a slice of corev1.Containers which includes a single corev1.Container that is based on the CR.

func (JobBuilder) Placeholder

func (b JobBuilder) Placeholder() client.Object

type KubeFetcher

type KubeFetcher struct {
	client.Reader
	// contains filtered or unexported fields
}

KubeFetcher fetches Kubernetes results

func NewKubeFetcher

func NewKubeFetcher(ctx context.Context, namespace string, reader client.Reader) *KubeFetcher

func (KubeFetcher) Fetch

func (f KubeFetcher) Fetch(o client.Object) error

type KubePersister

type KubePersister struct {
	client.Client
	// contains filtered or unexported fields
}

KubePersister saves resources back into Kubernetes

func NewKubePersister

func NewKubePersister(ctx context.Context, namespace string, client client.Client, persistFn kube.PersistFn) *KubePersister

func (KubePersister) Persist

func (p KubePersister) Persist(obj client.Object, mutateFn func() error) (upserted bool, err error)

type ManagedResource

type ManagedResource struct {
	Resource

	labels.Labels
}

ManagedResource is a `Resource` with labels which can be reconciled by `Reconciler`

func NewManagedKubeResource

func NewManagedKubeResource(ctx context.Context, client client.Client, cluster *Cluster, persistFn kube.PersistFn) ManagedResource

type PdbBuilder

type PdbBuilder struct {
	*Cluster

	Selector map[string]string
}

PdbBuilder models the PodDistruptionBudget that the operator maintains.

func (PdbBuilder) Build

func (b PdbBuilder) Build(obj client.Object) error

Build creates a policy.PodDisruptionBudget for the StatefulSet.

func (PdbBuilder) Placeholder

func (b PdbBuilder) Placeholder() client.Object

type Persister

type Persister interface {
	Persist(obj client.Object, mutateFn func() error) (upserted bool, err error)
}

Persister creates or updates the object in Kubernetes after calling the mutation function.

type PublicServiceBuilder

type PublicServiceBuilder struct {
	*Cluster

	Selector map[string]string
}

func (PublicServiceBuilder) Build

func (b PublicServiceBuilder) Build(obj client.Object) error

func (PublicServiceBuilder) Placeholder

func (b PublicServiceBuilder) Placeholder() client.Object

type Reconciler

type Reconciler struct {
	ManagedResource

	Builder
	Owner  metav1.Object
	Scheme *runtime.Scheme
}

Reconciler reconciles managed Kubernetes resource with `Builder` results

func (Reconciler) Reconcile

func (r Reconciler) Reconcile() (upserted bool, err error)

type Resource

type Resource struct {
	Fetcher
	Persister
}

Resource represents a resource that can be fetched or saved

func NewKubeResource

func NewKubeResource(ctx context.Context, client client.Client, namespace string, persistFn kube.PersistFn) Resource

type StatefulSetBuilder

type StatefulSetBuilder struct {
	*Cluster

	Selector  labels.Labels
	Telemetry string
}

func (StatefulSetBuilder) Build

func (b StatefulSetBuilder) Build(obj client.Object) error

func (StatefulSetBuilder) MakeContainers

func (b StatefulSetBuilder) MakeContainers() []corev1.Container

MakeContainers creates a slice of corev1.Containers which includes a single corev1.Container that is based on the CR.

func (StatefulSetBuilder) MakeInitContainers added in v1.7.6

func (b StatefulSetBuilder) MakeInitContainers() []corev1.Container

MakeInitContainers creates a slice of corev1.Containers which includes a single corev1.Container that is based on the CR.

func (StatefulSetBuilder) Placeholder

func (b StatefulSetBuilder) Placeholder() client.Object

func (StatefulSetBuilder) SetAnnotations

func (b StatefulSetBuilder) SetAnnotations(obj client.Object) error

type TLSSecret

type TLSSecret struct {
	Resource
	// contains filtered or unexported fields
}

func CreateTLSSecret

func CreateTLSSecret(name string, r Resource) *TLSSecret

CreateTLSSecrete returns a TLSSecreat struct that is used to store the certs via secrets.

func LoadTLSSecret

func LoadTLSSecret(name string, r Resource) (*TLSSecret, error)

func (*TLSSecret) CA

func (s *TLSSecret) CA() []byte

func (*TLSSecret) CAKey

func (s *TLSSecret) CAKey() []byte

func (*TLSSecret) Key

func (s *TLSSecret) Key() []byte

func (*TLSSecret) PriveKey

func (s *TLSSecret) PriveKey() []byte

func (*TLSSecret) Ready

func (s *TLSSecret) Ready() bool

func (*TLSSecret) ReadyCA

func (s *TLSSecret) ReadyCA() bool

func (*TLSSecret) UpdateCAKey

func (s *TLSSecret) UpdateCAKey(cakey []byte, log logr.Logger) error

UpdateCAKey updates CA key

func (*TLSSecret) UpdateCertAndCA

func (s *TLSSecret) UpdateCertAndCA(cert, ca []byte, log logr.Logger) error

func (*TLSSecret) UpdateCertAndKeyAndCA

func (s *TLSSecret) UpdateCertAndKeyAndCA(cert, key []byte, ca []byte, log logr.Logger) error

UpdateCertAndKeyAndCA updates three different certificates at the same time. It save the TLSCertKey, the CA, and the TLSPrivateKey in a secret.

func (*TLSSecret) UpdateKey

func (s *TLSSecret) UpdateKey(key []byte) error

Jump to

Keyboard shortcuts

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