hosted

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// AnnotationTenantNameFmt with a CR `singular` name applied provides the
	// annotation key used to identify tenant resources by name on the host side
	// Example: tenant.crossplane.io/packageinstall-name
	AnnotationTenantNameFmt = "tenant.crossplane.io/%s-name"

	// AnnotationTenantNamespaceFmt with a CR `singular` name applied provides
	// the annotation key used to identify tenant resources by namespace on the
	// host side
	// Example: tenant.crossplane.io/package-namespace
	AnnotationTenantNamespaceFmt = "tenant.crossplane.io/%s-namespace"
)

Variables

This section is empty.

Functions

func GetClients

func GetClients() (client.Client, *kubernetes.Clientset, error)

GetClients is the function to get Host Kubernetes (where install and controller pods scheduled) clients with in cluster config. This function is called regardless of hosted mode being enabled: Hosted Mode Off (Standard Installation): - resource (tenant) kube client => in cluster config - host kube clients => in cluster config Hosted Mode On: - resource (tenant) kube client => via EnvTenantKubeconfig - host kube clients => in cluster config

func ImagePullSecretPrefixOnHost

func ImagePullSecretPrefixOnHost(tenantNS string, name string) string

ImagePullSecretPrefixOnHost returns the prefix of a host secret given the tenant secret name and namespace

func ImagePullSecretPrefixesOnHost

func ImagePullSecretPrefixesOnHost(tenantNS string, imagePullSecrets []corev1.LocalObjectReference) []corev1.LocalObjectReference

ImagePullSecretPrefixesOnHost takes a tenant namespace and list of tenant secret names and returns a list of secrets names prefixed with the namespace, potentially truncated, for use as secret name prefixes on the host

func ImagePullSecretsOnHost

func ImagePullSecretsOnHost(tenantNS string, imagePullSecrets []corev1.LocalObjectReference) ([]corev1.LocalObjectReference, error)

ImagePullSecretsOnHost takes a tenant namespace and list of image pull secrets and returns a list of UUID suffixed secret names for use on the host. The names of these secrets are prefixed by ImagePullSecretPrefixesOnHost

func ObjectReferenceAnnotationsOnHost

func ObjectReferenceAnnotationsOnHost(singular, name, namespace string) map[string]string

ObjectReferenceAnnotationsOnHost returns a map for use as annotations on the host to identify the named tenant resource. This annotation is used for reference purposes to define a relationship to a single resource of a specific kind. For example, this could be used to declare the tenant packageinstall resource that is related to a host install job.

On a host the original tenant resource name may be truncated away. Annotations provide a way to store the original name without truncation.

func SyncImagePullSecrets

func SyncImagePullSecrets(ctx context.Context, tenantKube, hostKube client.Client, tenantNS string, tenantSecretRefs []corev1.LocalObjectReference, hostSecretRefs []corev1.LocalObjectReference, hostObj packages.KindlyIdentifier) error

SyncImagePullSecrets copies imagePullSecrets from the tenant to the host using the supplied secret names and returns the name of the secrets on the host.

The secrets are searched on the host using a name prefix based on the tenant secret name. If the secrets are not present they are created with a host owner resource reference for garbage collection.

Types

type Config

type Config struct {
	// HostControllerNamespace is the namespace on Host Cluster where install and controller jobs/deployments will be
	// deployed.
	HostControllerNamespace string
	// TenantAPIServiceHost is Kubernetes Apiserver Host for custom resources (a.k.a Tenant Kubernetes)
	TenantAPIServiceHost string
	// TenantAPIServicePort is Kubernetes Apiserver Port for custom resources (a.k.a Tenant Kubernetes)
	TenantAPIServicePort string
}

Config is the configuration for Host Aware Mode where different Kubernetes API's are used for pod scheduling and custom resources.

func NewConfig

func NewConfig(hostControllerNamespace, tenantAPIServiceHost, tenantAPIServicePort string) (*Config, error)

NewConfig returns a new host aware config based on the input parameters.

func NewConfigForHost

func NewConfigForHost(hostControllerNamespace, host string) (*Config, error)

NewConfigForHost returns a host aware config given a controller namespace and a Host string, assumed to be in the format accepted by rest.Config. It returns a nil Config if either the supplied namespace or host are empty. https://pkg.go.dev/k8s.io/client-go/rest?tab=doc#Config

func (*Config) ObjectReferenceOnHost

func (c *Config) ObjectReferenceOnHost(name, namespace string) corev1.ObjectReference

ObjectReferenceOnHost maps objects with a given name and namespace into a single controller namespace on the Host Cluster.

The resource name on the host cluster may be truncated from the original tenant name to fit label value length. The resource name may be used as a label, as is the case for jobs and deployments where the admission controller generates labels based on the resource name.

Jump to

Keyboard shortcuts

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