k8s

package
v0.0.0-...-ee44553 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnotationIngressService       = "qubling.cloud/ingress-service"
	AnnotationLegacyIngressService = "zostay-ingress-service"

	AnnotationHostAliases       = "qubling.cloud/host-aliases"
	AnnotationLegacyHostAliases = "zostay-host-aliases"

	AnnotationServiceName       = "qubling.cloud/service-name"
	AnnotationLegacyServiceName = "zostay-dns-srv/service-name"

	AnnotationDestination       = "qubling.cloud/destination"
	AnnotationLegacyDestination = "zostay-dns-srv/destination"

	AnnotationDeprecatedDNSNames = "qubling.cloud/deprecated-dns-names"

	LabelQublingEnabled = "qubling.cloud/infra-enabled"
)
View Source
const (
	AwsAccessKeyId  = "aws_access_key_id"
	SecretAccessKey = "secret_access_key"

	AnnotationManagedSecret = "qubling.cloud/managed-secret"
)
View Source
const (
	FieldManagerRestart = "qubling.cloud/restart"

	AnnotationRestartTrigger = "qubling.cloud/restart-trigger"
)
View Source
const (
	FieldManagerGenifest = "genifest" // k8s SSA field manager string used by this app
)

Variables

This section is empty.

Functions

func MakeAccessKeySecretResource

func MakeAccessKeySecretResource(
	ns,
	name,
	accessKey,
	secretKey string,
) (*bitnamiv1alpha1.SealedSecret, error)

MakeAccessKeySecretResource is syntactic sugar around MakeSecretResource() for use with access key information.

func MakeSealedSecretResource

func MakeSealedSecretResource(
	ns,
	name string,
	data map[string]string,
) (*bitnamiv1alpha1.SealedSecret, error)

MakeSealedSecretResource constructs a bitnami sealed secret object for the given namespace, name, and data to encrypt. It will perform the encryption of that data.

func MakeSecretApplyConfigResource

func MakeSecretApplyConfigResource(
	ns,
	name string,
	data map[string]string,
) *appcorev1.SecretApplyConfiguration

MakeSecretApplyConfigResource constructs and returns a secret object ready to be applied via the simple Apply() method.

Types

type Client

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

Client is a help tool for accessing Kubernetes information from the Kubernetes API.

func New

func New(context string) (*Client, error)

New returns a new kubernetes client from local configuration or returns an error.

func (*Client) ApplyResource

func (c *Client) ApplyResource(
	ctx context.Context,
	un *unstructured.Unstructured,
	force bool,
) error

ApplyResource serializes a resource and then applies.

func (*Client) ApplyResourceConfig

func (c *Client) ApplyResourceConfig(
	ctx context.Context,
	context,
	config string,
	force bool,
) error

ApplyResourceConfig performs server-side apply for the given resource configuration.

func (*Client) CurrentAccessKeyFromSecrets

func (c *Client) CurrentAccessKeyFromSecrets(ctx context.Context, ns, name string) (string, error)

CurrentAccessKeyFromSecrets will find and return the access key id stored in the identified secret or will return an error.

func (*Client) DeleteResource

func (c *Client) DeleteResource(
	ctx context.Context,
	un *unstructured.Unstructured,
) error

DeleteResource deletes a single resource given by name.

func (*Client) DeleteResourceConfig

func (c *Client) DeleteResourceConfig(
	ctx context.Context,
	config string,
) error

DeleteResourceConfig performs deletion of the resource described by the given configuration file contents.

func (*Client) GetSecret

func (c *Client) GetSecret(
	ctx context.Context,
	ns,
	name string,
) (map[string]string, error)

GetSecret will the secret data for the identified secret.

func (*Client) ListIngressesHosts

func (c *Client) ListIngressesHosts(
	ctx context.Context,
	ns string,
) ([]IngressHosts, error)

ListIngressesHosts returns a list of all IngressHosts objects for every kind of supported ingress. This includes Ingress objects as well as synthetic ingress in ConfigMaps marked for=ingress.

func (*Client) ListServiceDnsInfo

func (c *Client) ListServiceDnsInfo(ctx context.Context, ns string) ([]ServiceDnsInfo, error)

ListServiceDnsInfo returns all the DNS information for services in the given namespace. This uses the AnnotationServiceName and AnnotationLegacyServiceName as well as the AnnotationDestination and AnnotationLegacyDestination annotations to find the information and return it.

func (*Client) PrepareResource

func (c *Client) PrepareResource(
	config string,
) (*unstructured.Unstructured, dynamic.ResourceInterface, error)

PrepareResource parses a configuration string into an applicable parsed configuration.

func (*Client) Restart

func (c *Client) Restart(
	ctx context.Context,
	un *unstructured.Unstructured,
	force bool,
) error

Restart performs different tasks depending on the kind of record.

* Pod - no operation * ReplicaSet - delete pods * Deployment - modify the pod template to trigger a redeploy * Daemonset - modify the pod template to trigger a redeploy * Statefulset - modify the pod template to trigger a redeploy * CronJob - modify the job template to trigger restart, also delete jobs * Job - delete pods

As of this writing, only Deployment handling is implemented.

func (*Client) SerializeResource

func (c *Client) SerializeResource(
	un *unstructured.Unstructured,
) (*SerializedResource, error)

SerializeResource turns a resource into JSON bytes ready for application via ApplySerializedResource and returns those bytes along with the namespace into which the resource should be applied.

func (*Client) UpdateAccessKey

func (c *Client) UpdateAccessKey(ctx context.Context, ns, name, accessKey, secretKey string) error

UpdateAccessKey is syntactic sugar around UpdateSecret() for use with access key information.

func (*Client) UpdateSecret

func (c *Client) UpdateSecret(
	ctx context.Context,
	ns,
	name string,
	data map[string]string,
) error

UpdateSecret turns the given data map into the secret data in a secret object and applies the change immediately.

type IngressHosts

type IngressHosts struct {
	Name          string
	Namespace     string
	Kind          string
	Hosts         []string
	LoadBalancers []string
}

IngressHosts represent a collection of hosts that will need to be configured for DNS.

type SerializedResource

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

SerializedResource is a resource that has been fully prepared for application, but allows some introspection for detecting changes and other such details.

func (*SerializedResource) Apply

func (s *SerializedResource) Apply(
	ctx context.Context,
	force bool,
) error

Apply applies a SerializedResource to the cluster.

func (*SerializedResource) Bytes

func (s *SerializedResource) Bytes() []byte

Bytes returns the serialized resource as bytes.

func (*SerializedResource) ResourceID

func (s *SerializedResource) ResourceID() string

ResourceID returns a resource identifier consisting of "ns/group/version/kind/name" which provides a convenient naming scheme for comparing one revision of a resource to another.

type ServiceDnsInfo

type ServiceDnsInfo struct {
	ServiceName string
	Destination string
	Port        int
}

Jump to

Keyboard shortcuts

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