Documentation ¶
Overview ¶
Package cluster contains Zarf-specific cluster management functions.
Package cluster contains Zarf-specific cluster management functions.
Package cluster contains Zarf-specific cluster management functions.
Package cluster contains Zarf-specific cluster management functions.
Package cluster contains Zarf-specific cluster management functions.
Package cluster contains Zarf-specific cluster management functions.
Package cluster contains Zarf-specific cluster management functions.
Package cluster contains Zarf-specific cluster management functions.
Package cluster contains Zarf-specific cluster management functions.
Index ¶
- Constants
- func AdoptZarfManagedLabels(labels map[string]string) map[string]string
- func MergeZarfState(oldState *types.ZarfState, initOptions types.ZarfInitOptions, ...) (*types.ZarfState, error)
- func NewZarfManagedNamespace(name string) *corev1.Namespace
- type Cluster
- func (c *Cluster) Connect(ctx context.Context, target string) (*Tunnel, error)
- func (c *Cluster) ConnectToZarfRegistryEndpoint(ctx context.Context, registryInfo types.RegistryInfo) (string, *Tunnel, error)
- func (c *Cluster) ConnectTunnelInfo(ctx context.Context, zt TunnelInfo) (*Tunnel, error)
- func (c *Cluster) DeleteZarfNamespace(ctx context.Context) error
- func (c *Cluster) DisableRegHPAScaleDown(ctx context.Context) error
- func (c *Cluster) EnableRegHPAScaleDown(ctx context.Context) error
- func (c *Cluster) GenerateGitPullCreds(namespace, name string, gitServerInfo types.GitServerInfo) *corev1.Secret
- func (c *Cluster) GenerateRegistryPullCreds(ctx context.Context, namespace, name string, registryInfo types.RegistryInfo) (*corev1.Secret, error)
- func (c *Cluster) GetDeployedPackage(ctx context.Context, packageName string) (*types.DeployedPackage, error)
- func (c *Cluster) GetDeployedZarfPackages(ctx context.Context) ([]types.DeployedPackage, error)
- func (c *Cluster) GetInstalledChartsForComponent(ctx context.Context, packageName string, component v1alpha1.ZarfComponent) (installedCharts []types.InstalledChart, err error)
- func (c *Cluster) GetServiceInfoFromRegistryAddress(ctx context.Context, stateRegistryAddress string) (string, error)
- func (c *Cluster) HandleDataInjection(ctx context.Context, data v1alpha1.ZarfDataInjection, ...) error
- func (c *Cluster) InitZarfState(ctx context.Context, initOptions types.ZarfInitOptions) error
- func (c *Cluster) ListConnections(ctx context.Context) (types.ConnectStrings, error)
- func (c *Cluster) LoadZarfState(ctx context.Context) (state *types.ZarfState, err error)
- func (c *Cluster) NewTargetTunnelInfo(ctx context.Context, target string) (TunnelInfo, error)
- func (c *Cluster) NewTunnel(namespace, resourceType, resourceName, urlSuffix string, local, remote int) (*Tunnel, error)
- func (c *Cluster) PackageSecretNeedsWait(deployedPackage *types.DeployedPackage, component v1alpha1.ZarfComponent, ...) (needsWait bool, waitSeconds int, hookName string)
- func (c *Cluster) RecordPackageDeployment(ctx context.Context, pkg v1alpha1.ZarfPackage, ...) (deployedPackage *types.DeployedPackage, err error)
- func (c *Cluster) RecordPackageDeploymentAndWait(ctx context.Context, pkg v1alpha1.ZarfPackage, ...) (*types.DeployedPackage, error)
- func (c *Cluster) SaveZarfState(ctx context.Context, state *types.ZarfState) error
- func (c *Cluster) StartInjection(ctx context.Context, tmpDir, imagesDir string, injectorSeedSrcs []string) error
- func (c *Cluster) StopInjection(ctx context.Context) error
- func (c *Cluster) StripZarfLabelsAndSecretsFromNamespaces(ctx context.Context)
- func (c *Cluster) UpdateGiteaPVC(ctx context.Context, pvcName string, shouldRollBack bool) (string, error)
- func (c *Cluster) UpdateZarfManagedGitSecrets(ctx context.Context, state *types.ZarfState)
- func (c *Cluster) UpdateZarfManagedImageSecrets(ctx context.Context, state *types.ZarfState)
- type DockerConfig
- type DockerConfigEntry
- type DockerConfigEntryWithAuth
- type Tunnel
- func (tunnel *Tunnel) Close()
- func (tunnel *Tunnel) Connect(ctx context.Context) (string, error)
- func (tunnel *Tunnel) Endpoint() string
- func (tunnel *Tunnel) ErrChan() chan error
- func (tunnel *Tunnel) FullURL() string
- func (tunnel *Tunnel) HTTPEndpoint() string
- func (tunnel *Tunnel) Wrap(function func() error) error
- type TunnelInfo
Constants ¶
const ( // DefaultTimeout is the default time to wait for a cluster to be ready. DefaultTimeout = 30 * time.Second // AgentLabel is used to give instructions to the Zarf agent AgentLabel = "zarf.dev/agent" )
const ( DistroIsUnknown = "unknown" DistroIsK3s = "k3s" DistroIsK3d = "k3d" DistroIsKind = "kind" DistroIsMicroK8s = "microk8s" DistroIsEKS = "eks" DistroIsEKSAnywhere = "eksanywhere" DistroIsDockerDesktop = "dockerdesktop" DistroIsGKE = "gke" DistroIsAKS = "aks" DistroIsRKE2 = "rke2" DistroIsTKG = "tkg" )
List of supported distros via distro detection.
const ( ZarfManagedByLabel = "app.kubernetes.io/managed-by" ZarfNamespaceName = "zarf" ZarfStateSecretName = "zarf-state" ZarfStateDataKey = "state" ZarfPackageInfoLabel = "package-deploy-info" )
Zarf Cluster Constants.
const ( ZarfConnectLabelName = "zarf.dev/connect-name" ZarfConnectAnnotationDescription = "zarf.dev/connect-description" ZarfConnectAnnotationURL = "zarf.dev/connect-url" ZarfRegistry = "REGISTRY" ZarfGit = "GIT" ZarfInjector = "INJECTOR" ZarfInjectorName = "zarf-injector" ZarfInjectorPort = 5000 ZarfRegistryName = "zarf-docker-registry" ZarfRegistryPort = 5000 ZarfGitServerName = "zarf-gitea-http" ZarfGitServerPort = 3000 )
Zarf specific connect strings
const ( PodResource = "pod" SvcResource = "svc" )
Zarf Tunnel Configuration Constants.
Variables ¶
This section is empty.
Functions ¶
func AdoptZarfManagedLabels ¶
AdoptZarfManagedLabels adds & deletes the necessary labels that signal to Zarf it should manage a namespace
func MergeZarfState ¶
func MergeZarfState(oldState *types.ZarfState, initOptions types.ZarfInitOptions, services []string) (*types.ZarfState, error)
MergeZarfState merges init options for provided services into the provided state to create a new state struct
func NewZarfManagedNamespace ¶
NewZarfManagedNamespace returns a corev1.Namespace with Zarf-managed labels
Types ¶
type Cluster ¶
type Cluster struct { Clientset kubernetes.Interface RestConfig *rest.Config Watcher watcher.StatusWatcher }
Cluster Zarf specific cluster management functions.
func NewCluster ¶
NewCluster creates a new Cluster instance and validates connection to the cluster by fetching the Kubernetes version.
func NewClusterWithWait ¶
NewClusterWithWait creates a new Cluster instance and waits for the given timeout for the cluster to be ready.
func (*Cluster) ConnectToZarfRegistryEndpoint ¶
func (c *Cluster) ConnectToZarfRegistryEndpoint(ctx context.Context, registryInfo types.RegistryInfo) (string, *Tunnel, error)
ConnectToZarfRegistryEndpoint determines if a registry endpoint is in cluster, and if so opens a tunnel to connect to it
func (*Cluster) ConnectTunnelInfo ¶
ConnectTunnelInfo connects to the cluster with the provided TunnelInfo
func (*Cluster) DeleteZarfNamespace ¶
DeleteZarfNamespace deletes the Zarf namespace from the connected cluster.
func (*Cluster) DisableRegHPAScaleDown ¶
DisableRegHPAScaleDown disables the HPA scale down for the Zarf Registry.
func (*Cluster) EnableRegHPAScaleDown ¶
EnableRegHPAScaleDown enables the HPA scale down for the Zarf Registry.
func (*Cluster) GenerateGitPullCreds ¶
func (c *Cluster) GenerateGitPullCreds(namespace, name string, gitServerInfo types.GitServerInfo) *corev1.Secret
GenerateGitPullCreds generates a secret containing the git credentials.
func (*Cluster) GenerateRegistryPullCreds ¶
func (c *Cluster) GenerateRegistryPullCreds(ctx context.Context, namespace, name string, registryInfo types.RegistryInfo) (*corev1.Secret, error)
GenerateRegistryPullCreds generates a secret containing the registry credentials.
func (*Cluster) GetDeployedPackage ¶
func (c *Cluster) GetDeployedPackage(ctx context.Context, packageName string) (*types.DeployedPackage, error)
GetDeployedPackage gets the metadata information about the package name provided (if it exists in the cluster). We determine what packages have been deployed to the cluster by looking for specific secrets in the Zarf namespace.
func (*Cluster) GetDeployedZarfPackages ¶
GetDeployedZarfPackages gets metadata information about packages that have been deployed to the cluster. We determine what packages have been deployed to the cluster by looking for specific secrets in the Zarf namespace. Returns a list of DeployedPackage structs and a list of errors.
func (*Cluster) GetInstalledChartsForComponent ¶
func (c *Cluster) GetInstalledChartsForComponent(ctx context.Context, packageName string, component v1alpha1.ZarfComponent) (installedCharts []types.InstalledChart, err error)
GetInstalledChartsForComponent returns any installed Helm Charts for the provided package component.
func (*Cluster) GetServiceInfoFromRegistryAddress ¶
func (c *Cluster) GetServiceInfoFromRegistryAddress(ctx context.Context, stateRegistryAddress string) (string, error)
GetServiceInfoFromRegistryAddress gets the service info for a registry address if it is a NodePort
func (*Cluster) HandleDataInjection ¶
func (c *Cluster) HandleDataInjection(ctx context.Context, data v1alpha1.ZarfDataInjection, componentPath *layout.ComponentPaths, dataIdx int) error
HandleDataInjection waits for the target pod(s) to come up and inject the data into them todo: this currently requires kubectl but we should have enough k8s work to make this native now.
func (*Cluster) InitZarfState ¶
InitZarfState initializes the Zarf state with the given temporary directory and init configs.
func (*Cluster) ListConnections ¶
ListConnections will return a list of all Zarf connect matches found in the cluster.
func (*Cluster) LoadZarfState ¶
LoadZarfState returns the current zarf/zarf-state secret data or an empty ZarfState.
func (*Cluster) NewTargetTunnelInfo ¶ added in v0.38.0
NewTargetTunnelInfo returns a new TunnelInfo object for the specified target.
func (*Cluster) NewTunnel ¶
func (c *Cluster) NewTunnel(namespace, resourceType, resourceName, urlSuffix string, local, remote int) (*Tunnel, error)
NewTunnel will create a new Tunnel struct. Note that if you use 0 for the local port, an open port on the host system will be selected automatically, and the Tunnel struct will be updated with the selected port.
func (*Cluster) PackageSecretNeedsWait ¶
func (c *Cluster) PackageSecretNeedsWait(deployedPackage *types.DeployedPackage, component v1alpha1.ZarfComponent, skipWebhooks bool) (needsWait bool, waitSeconds int, hookName string)
PackageSecretNeedsWait checks if a package component has a running webhook that needs to be waited on.
func (*Cluster) RecordPackageDeployment ¶
func (c *Cluster) RecordPackageDeployment(ctx context.Context, pkg v1alpha1.ZarfPackage, components []types.DeployedComponent, connectStrings types.ConnectStrings, generation int) (deployedPackage *types.DeployedPackage, err error)
RecordPackageDeployment saves metadata about a package that has been deployed to the cluster.
func (*Cluster) RecordPackageDeploymentAndWait ¶
func (c *Cluster) RecordPackageDeploymentAndWait(ctx context.Context, pkg v1alpha1.ZarfPackage, components []types.DeployedComponent, connectStrings types.ConnectStrings, generation int, component v1alpha1.ZarfComponent, skipWebhooks bool) (*types.DeployedPackage, error)
RecordPackageDeploymentAndWait records the deployment of a package to the cluster and waits for any webhooks to complete.
func (*Cluster) SaveZarfState ¶
SaveZarfState takes a given state and persists it to the Zarf/zarf-state secret.
func (*Cluster) StartInjection ¶
func (c *Cluster) StartInjection(ctx context.Context, tmpDir, imagesDir string, injectorSeedSrcs []string) error
StartInjection initializes a Zarf injection into the cluster.
func (*Cluster) StopInjection ¶
StopInjection handles cleanup once the seed registry is up.
func (*Cluster) StripZarfLabelsAndSecretsFromNamespaces ¶
StripZarfLabelsAndSecretsFromNamespaces removes metadata and secrets from existing namespaces no longer manged by Zarf.
func (*Cluster) UpdateGiteaPVC ¶ added in v0.38.0
func (c *Cluster) UpdateGiteaPVC(ctx context.Context, pvcName string, shouldRollBack bool) (string, error)
UpdateGiteaPVC updates the existing Gitea persistent volume claim and tells Gitea whether to create or not.
func (*Cluster) UpdateZarfManagedGitSecrets ¶
UpdateZarfManagedGitSecrets updates all Zarf-managed git secrets in all namespaces based on state TODO: Refactor to return errors properly.
type DockerConfig ¶
type DockerConfig struct {
Auths DockerConfigEntry `json:"auths"`
}
DockerConfig contains the authentication information from the machine's docker config.
type DockerConfigEntry ¶
type DockerConfigEntry map[string]DockerConfigEntryWithAuth
DockerConfigEntry contains a map of DockerConfigEntryWithAuth for a registry.
type DockerConfigEntryWithAuth ¶
type DockerConfigEntryWithAuth struct {
Auth string `json:"auth"`
}
DockerConfigEntryWithAuth contains a docker config authentication string.
type Tunnel ¶
type Tunnel struct {
// contains filtered or unexported fields
}
Tunnel is the main struct that configures and manages port forwarding tunnels to Kubernetes resources.
func (*Tunnel) Close ¶
func (tunnel *Tunnel) Close()
Close disconnects a tunnel connection by closing the StopChan, thereby stopping the goroutine.
func (*Tunnel) Endpoint ¶
Endpoint returns the tunnel ip address and port (i.e. for docker registries)
func (*Tunnel) FullURL ¶
FullURL returns the tunnel endpoint as a HTTP URL string with the urlSuffix appended.
func (*Tunnel) HTTPEndpoint ¶
HTTPEndpoint returns the tunnel endpoint as a HTTP URL string.