Documentation
¶
Overview ¶
Package state manages references to a logical zarf deployment in k8s.
Index ¶
- Constants
- func DebugPrint(ctx context.Context, state *State)
- func LocalhostRegistryAddress(ipFamily IPFamily, nodePort int) string
- type ArtifactServerInfo
- type ChartStatus
- type ComponentStatus
- type ConnectString
- type ConnectStrings
- type DeployedComponent
- type DeployedPackage
- type DeployedPackageOptions
- type GitServerInfo
- type IPFamily
- type InjectorInfo
- type InstalledChart
- type MergeOptions
- type RegistryInfo
- type RegistryMode
- type State
Constants ¶
const ( ZarfManagedByLabel = "app.kubernetes.io/managed-by" ZarfNamespaceName = "zarf" ZarfStateSecretName = "zarf-state" ZarfStateDataKey = "state" ZarfPackageInfoLabel = "package-deploy-info" )
Declares secrets and metadata keys and values. TODO(mkcp): Remove Zarf prefix, that's the project name. TODO(mkcp): Provide semantic doccomments for how these are used.
const ( RegistryKey = "registry" RegistryReadKey = "registry-readonly" GitKey = "git" GitReadKey = "git-readonly" ArtifactKey = "artifact" AgentKey = "agent" )
Credential keys TODO(mkcp): Provide semantic doccomments for how these are used.
const ( ZarfGeneratedPasswordLen = 24 ZarfGeneratedSecretLen = 48 ZarfInClusterContainerRegistryNodePort = 31999 ZarfInjectorDefaultHostPort = 5001 ZarfRegistryHostPort = 5000 ZarfRegistryPushUser = "zarf-push" ZarfRegistryPullUser = "zarf-pull" ZarfGitPushUser = "zarf-git-user" ZarfGitReadUser = "zarf-git-read-user" ZarfAgentHost = "agent-hook.zarf.svc" ZarfInClusterGitServiceURL = "http://zarf-gitea-http.zarf.svc.cluster.local:3000" ZarfInClusterArtifactServiceURL = ZarfInClusterGitServiceURL + "/api/packages/" + ZarfGitPushUser )
Values during setup of the initial zarf state
const IPV6Localhost = "::1"
IPV6Localhost is the IP of localhost in IPv6 (TODO: move to helpers next to IPV4Localhost)
Variables ¶
This section is empty.
Functions ¶
func DebugPrint ¶
DebugPrint takes a State struct, sanitizes sensitive fields, and prints them.
func LocalhostRegistryAddress ¶ added in v0.65.0
LocalhostRegistryAddress builds the IPv4 or IPv6 local address of the Zarf deployed registry.
Types ¶
type ArtifactServerInfo ¶ added in v0.56.0
type ArtifactServerInfo struct {
// Username of a user with push access to the artifact registry
PushUsername string `json:"pushUsername"`
// Password of a user with push access to the artifact registry
PushToken string `json:"pushPassword"`
// URL address of the artifact registry
Address string `json:"address"`
}
ArtifactServerInfo contains information Zarf uses to communicate with a artifact registry to push/pull repositories to.
func (*ArtifactServerInfo) FillInEmptyValues ¶ added in v0.56.0
func (as *ArtifactServerInfo) FillInEmptyValues()
FillInEmptyValues sets every necessary value that's currently empty to a reasonable default
func (ArtifactServerInfo) IsInternal ¶ added in v0.56.0
func (as ArtifactServerInfo) IsInternal() bool
IsInternal returns true if the artifact server URL is equivalent to the artifact server deployed through the default init package
type ChartStatus ¶ added in v0.63.0
type ChartStatus string
ChartStatus is the status of a Helm Chart release
const ( ChartStatusSucceeded ChartStatus = "Succeeded" ChartStatusFailed ChartStatus = "Failed" )
All status options for a Zarf component chart
type ComponentStatus ¶ added in v0.57.0
type ComponentStatus string
ComponentStatus defines the deployment status of a Zarf component within a package.
const ( ComponentStatusSucceeded ComponentStatus = "Succeeded" ComponentStatusFailed ComponentStatus = "Failed" ComponentStatusDeploying ComponentStatus = "Deploying" ComponentStatusRemoving ComponentStatus = "Removing" )
All the different status options for a Zarf Component
type ConnectString ¶ added in v0.57.0
type ConnectString struct {
// Descriptive text that explains what the resource you would be connecting to is used for
Description string `json:"description"`
// URL path that gets appended to the k8s port-forward result
URL string `json:"url"`
}
ConnectString contains information about a connection made with Zarf connect.
type ConnectStrings ¶ added in v0.57.0
type ConnectStrings map[string]ConnectString
ConnectStrings is a map of connect names to connection information.
type DeployedComponent ¶ added in v0.57.0
type DeployedComponent struct {
Name string `json:"name"`
InstalledCharts []InstalledChart `json:"installedCharts"`
Status ComponentStatus `json:"status"`
ObservedGeneration int `json:"observedGeneration"`
}
DeployedComponent contains information about a Zarf Package Component that has been deployed to a cluster.
type DeployedPackage ¶ added in v0.57.0
type DeployedPackage struct {
Name string `json:"name"`
Data v1alpha1.ZarfPackage `json:"data"`
CLIVersion string `json:"cliVersion"`
Generation int `json:"generation"`
DeployedComponents []DeployedComponent `json:"deployedComponents"`
ConnectStrings ConnectStrings `json:"connectStrings,omitempty"`
// [ALPHA] Optional namespace override - exported/json-tag for storage in deployed package state secret
NamespaceOverride string `json:"namespaceOverride,omitempty"`
}
DeployedPackage contains information about a Zarf Package that has been deployed to a cluster This object is saved as the data of a k8s secret within the 'Zarf' namespace (not as part of the ZarfState secret).
func (*DeployedPackage) GetSecretName ¶ added in v0.57.0
func (d *DeployedPackage) GetSecretName() string
GetSecretName returns the k8s secret name for the deployed package
type DeployedPackageOptions ¶ added in v0.57.0
type DeployedPackageOptions func(*DeployedPackage)
DeployedPackageOptions are options for the DeployedPackage function
func WithPackageNamespaceOverride ¶ added in v0.57.0
func WithPackageNamespaceOverride(namespaceOverride string) DeployedPackageOptions
WithPackageNamespaceOverride sets the [ALPHA] optional namespace override for a package during deployment
type GitServerInfo ¶ added in v0.56.0
type GitServerInfo struct {
// Username of a user with push access to the git repository
PushUsername string `json:"pushUsername"`
// Password of a user with push access to the git repository
PushPassword string `json:"pushPassword"`
// Username of a user with pull-only access to the git repository. If not provided for an external repository then the push-user is used
PullUsername string `json:"pullUsername"`
// Password of a user with pull-only access to the git repository. If not provided for an external repository then the push-user is used
PullPassword string `json:"pullPassword"`
// URL address of the git server
Address string `json:"address"`
}
GitServerInfo contains information Zarf uses to communicate with a git repository to push/pull repositories to.
func (*GitServerInfo) FillInEmptyValues ¶ added in v0.56.0
func (gs *GitServerInfo) FillInEmptyValues() error
FillInEmptyValues sets every necessary value that's currently empty to a reasonable default
func (GitServerInfo) IsInternal ¶ added in v0.56.0
func (gs GitServerInfo) IsInternal() bool
IsInternal returns true if the git server URL is equivalent to a git server deployed through the default init package
type IPFamily ¶ added in v0.65.0
type IPFamily string
IPFamily defines the different possible IPfamilies that can be used in Kubernetes clusters
type InjectorInfo ¶ added in v0.65.0
type InjectorInfo struct {
// The image to be used for the long lived injector
Image string `json:"injectorImage"`
// The number of payload configmaps required
PayLoadConfigMapAmount int `json:"payLoadConfigMapAmount"`
// The PayLoadShaSum for the payload ConfigMaps
PayLoadShaSum string `json:"payLoadShaSum"`
// The port that the injector is exposed through, either hostPort or nodePort
Port int `json:"port"`
}
InjectorInfo contains information on how to run the long lived Daemonset Injector
type InstalledChart ¶ added in v0.57.0
type InstalledChart struct {
Namespace string `json:"namespace"`
ChartName string `json:"chartName"`
ConnectStrings ConnectStrings `json:"connectStrings,omitempty"`
Status ChartStatus `json:"status"`
}
InstalledChart contains information about a Helm Chart that has been deployed to a cluster.
func MergeInstalledChartsForComponent ¶ added in v0.63.0
func MergeInstalledChartsForComponent(existingCharts, installedCharts []InstalledChart, partial bool) []InstalledChart
MergeInstalledChartsForComponent merges the provided existing charts with the provided installed charts.
type MergeOptions ¶
type MergeOptions struct {
GitServer GitServerInfo
RegistryInfo RegistryInfo
ArtifactServer ArtifactServerInfo
Services []string
}
MergeOptions tracks the user-defined options during cluster initialization. TODO(mkcp): Provide semantic doccomments for how exported fields are used.
type RegistryInfo ¶ added in v0.56.0
type RegistryInfo struct {
// Username of a user with push access to the registry
PushUsername string `json:"pushUsername"`
// Password of a user with push access to the registry
PushPassword string `json:"pushPassword"`
// Username of a user with pull-only access to the registry. If not provided for an external registry than the push-user is used
PullUsername string `json:"pullUsername"`
// Password of a user with pull-only access to the registry. If not provided for an external registry than the push-user is used
PullPassword string `json:"pullPassword"`
// URL address of the registry
Address string `json:"address"`
// Nodeport of the registry. Only needed if the internal Zarf registry is used and connected with over a nodeport service.
NodePort int `json:"nodePort"`
// Secret value that the registry was seeded with
Secret string `json:"secret"`
// RegistryMode defines how the registry is accessed (nodeport, proxy, or external)
RegistryMode RegistryMode `json:"registryMode"`
}
RegistryInfo contains information Zarf uses to communicate with a container registry to push/pull images.
func (*RegistryInfo) FillInEmptyValues ¶ added in v0.56.0
func (ri *RegistryInfo) FillInEmptyValues(ipFamily IPFamily) error
FillInEmptyValues sets every necessary value not already set to a reasonable default
func (RegistryInfo) IsInternal ¶ added in v0.56.0
func (ri RegistryInfo) IsInternal() bool
IsInternal returns true if the registry URL is equivalent to the registry deployed through the default init package
type RegistryMode ¶ added in v0.65.0
type RegistryMode string
RegistryMode defines how the registry is accessed
const ( // RegistryModeNodePort accesses the registry via NodePort service RegistryModeNodePort RegistryMode = "nodeport" // RegistryModeProxy accesses the registry via DaemonSet proxy RegistryModeProxy RegistryMode = "proxy" // RegistryModeExternal is used when the user has an external registry RegistryModeExternal RegistryMode = "external" )
type State ¶
type State struct {
// Indicates if Zarf was initialized while deploying its own k8s cluster
ZarfAppliance bool `json:"zarfAppliance"`
// K8s distribution of the cluster Zarf was deployed to
Distro string `json:"distro"`
// Machine architecture of the k8s node(s)
Architecture string `json:"architecture"`
// Default StorageClass value Zarf uses for variable templating
StorageClass string `json:"storageClass"`
// The IP family of the cluster, can be ipv4, ipv6, or dual
IPFamily IPFamily `json:"ipFamily,omitempty"`
// PKI certificate information for the agent pods Zarf manages
AgentTLS pki.GeneratedPKI `json:"agentTLS"`
InjectorInfo InjectorInfo `json:"injectorInfo"`
// Information about the repository Zarf is configured to use
GitServer GitServerInfo `json:"gitServer"`
// Information about the container registry Zarf is configured to use
RegistryInfo RegistryInfo `json:"registryInfo"`
// Information about the artifact registry Zarf is configured to use
ArtifactServer ArtifactServerInfo `json:"artifactServer"`
}
State is maintained as a secret in the Zarf namespace to track Zarf init data.