Documentation
¶
Index ¶
- Constants
- func DeploymentTargetRuntimeClient(controlPlane runtimeclient.Client) (runtimeclient.Client, error)
- func LoadConfigFile(configFilePath string) (*api.Config, error)
- func NewClientConfig(options *ConfigOptions) (*rest.Config, error)
- func NewClientConfigForTargetCluster(kubeconfigPath string) (*rest.Config, error)
- func NewClientConfigFromLocal(options *ConfigOptions) (*rest.Config, error)
- func NewRuntimeClient(config *rest.Config) (runtimeclient.Client, error)
- func PatchNamespace(ctx context.Context, client runtime_client.Client, namespace string) error
- func TargetClusterDefaultNamespace() string
- type Clients
- type ConfigOptions
- type ObjectManifest
Constants ¶
const ( // DefaultServerBurst is the default number of queries per second for server. DefaultServerQPS float32 = 200.0 // DefaultServerBurst is the default number of queries k8sclient handles concurrently for server. DefaultServerBurst int = 200 // DefaultCLIQPS is the default number of queries per second for CLI. DefaultCLIQPS float32 = 50.0 // DefaultCLIBurst is the default number of queries k8sclient handles concurrently for CLI. DefaultCLIBurst int = 100 // TargetKubeconfigEnvVar is the environment variable that points at a kubeconfig // file for an external target cluster. When set, Radius deploys application // resources (both recipe-provisioned and directly-rendered output resources) to // that cluster instead of the control-plane cluster it runs on. This is the // multi-cluster v1 contract; the kubeconfig is supplied (and refreshed) out of // band by the workflow that mounts it. TargetKubeconfigEnvVar = "RADIUS_TARGET_KUBECONFIG" )
Variables ¶
This section is empty.
Functions ¶
func DeploymentTargetRuntimeClient ¶
func DeploymentTargetRuntimeClient(controlPlane runtimeclient.Client) (runtimeclient.Client, error)
DeploymentTargetRuntimeClient returns the controller-runtime client that application resources (including the application namespace) should be created with. It returns controlPlane unchanged unless RADIUS_TARGET_KUBECONFIG is set, in which case it builds a runtime client for the external cluster named by that kubeconfig. This keeps application namespaces on the same cluster the application's resources deploy to, so in multi-cluster mode the control-plane cluster is not populated with per-application namespaces.
func LoadConfigFile ¶
LoadConfigFile loads the Kubernetes config file from the given path, or will load the default config from the home directory if no path is provided.
func NewClientConfig ¶
func NewClientConfig(options *ConfigOptions) (*rest.Config, error)
NewClientConfig builds a Kubernetes client config from either in-cluster or local configuration, and sets the QPS and Burst values if provided. It returns an error if the config cannot be built.
func NewClientConfigForTargetCluster ¶
NewClientConfigForTargetCluster builds a Kubernetes client config from the kubeconfig file at kubeconfigPath, using its current context and the server QPS/Burst defaults. It is used to target an external cluster (for example an AKS or EKS cluster) when the Radius control plane runs on a separate cluster.
func NewClientConfigFromLocal ¶
func NewClientConfigFromLocal(options *ConfigOptions) (*rest.Config, error)
NewClientConfigFromLocal builds a Kubernetes client config from a ConfigOptions instance, loading the config file from the ConfigFilePath and setting the QPS and Burst values if specified. It returns an error if the config file cannot be loaded or the client config cannot be initialized.
func NewRuntimeClient ¶
func NewRuntimeClient(config *rest.Config) (runtimeclient.Client, error)
NewRuntimeClient creates a new runtime client using the given config and adds the required resource schemes to the client.
func PatchNamespace ¶
PatchNamespace creates a new namespace with the given name and labels it with the given label, then applies it to the cluster. It returns an error if the patch operation fails.
func TargetClusterDefaultNamespace ¶
func TargetClusterDefaultNamespace() string
TargetClusterDefaultNamespace returns the namespace that application resources should default to on the deployment-target cluster when the environment does not specify one. When RADIUS_TARGET_KUBECONFIG is set, it is the namespace pinned by that kubeconfig's current context (an operator may scope the target credential to a namespace); otherwise, or when the context pins no namespace or the kubeconfig cannot be read, it falls back to "default", which exists on every Kubernetes cluster.
Types ¶
type Clients ¶
type Clients struct {
// RuntimeClient is the Kubernetes controller runtime client.
RuntimeClient runtimeclient.Client
// ClientSet is the Kubernetes client-go strongly-typed client.
ClientSet *kubernetes.Clientset
// DiscoveryClient is the Kubernetes client-go discovery client.
DiscoveryClient *discovery.DiscoveryClient
// DynamicClient is the Kubernetes client-go dynamic client.
DynamicClient dynamic.Interface
}
Clients is a collection of Kubernetes clients.
type ConfigOptions ¶
ConfigOptions is custom options to configure kubernetes client config.
type ObjectManifest ¶
type ObjectManifest map[schema.GroupVersionKind][]runtime.Object
ObjectManifest is a map of runtime.Object slice where the key is GroupVersionKind for the resource.
func ParseManifest ¶
func ParseManifest(data []byte) (ObjectManifest, error)
ParseManifest parses the given manifest and returns a map of runtime.Object slice where the key is GroupVersionKind for the resource. It returns an error if the given manifest is invalid.
func (ObjectManifest) Get ¶
func (m ObjectManifest) Get(gvk schema.GroupVersionKind) []runtime.Object
Get returns a runtime.Object slice for the given key.
func (ObjectManifest) GetFirst ¶
func (m ObjectManifest) GetFirst(gvk schema.GroupVersionKind) runtime.Object
GetFirst returns the first runtime.Object for the given key.