Documentation
¶
Index ¶
- func DefaultDurationRound() func(duration interface{}) string
- func Run(f util.Factory, streams genericiooptions.IOStreams, args []string) error
- func SetDurationRound(f func(duration interface{}) string) (revertFunc func())
- func SetNowFunc(f func() time.Time) (revertFunc func())
- func SetStartedAfterClause(f func(createdKubeDate, startedKubeDate string) string) (revertFunc func())
- type OwnersResult
- type RenderableObject
- func (r RenderableObject) Annotations() (annotations map[string]interface{})
- func (r RenderableObject) Include(templateName string, data interface{}) (string, error)
- func (r RenderableObject) IncludeRenderableObject(obj RenderableObject) (output string)
- func (r RenderableObject) KStatus() *kstatus.Result
- func (r RenderableObject) Kind() (kind string)
- func (r RenderableObject) KubeGet(namespace string, args ...string) (out []RenderableObject)
- func (r RenderableObject) KubeGetByLabelsMap(namespace, resourceType string, labels map[string]interface{}) (out []RenderableObject)
- func (r RenderableObject) KubeGetCalicoGlobalNetworkPoliciesMatchingPod(namespace string, podLabels map[string]interface{}) (out []RenderableObject)
- func (r RenderableObject) KubeGetCalicoNetworkPoliciesMatchingPod(namespace string, podLabels map[string]interface{}) (out []RenderableObject)
- func (r RenderableObject) KubeGetCiliumClusterwideNetworkPoliciesMatchingPod(podLabels map[string]interface{}) (out []RenderableObject)
- func (r RenderableObject) KubeGetCiliumNetworkPoliciesMatchingPod(namespace string, podLabels map[string]interface{}) (out []RenderableObject)
- func (r RenderableObject) KubeGetContainerLogs(namespace, podName, containerName string, previous bool, tailLines int) string
- func (r RenderableObject) KubeGetEndpointSlicesForService(namespace, serviceName string) (out []RenderableObject)
- func (r RenderableObject) KubeGetEvents() RenderableObject
- func (r RenderableObject) KubeGetFirst(namespace string, args ...string) RenderableObject
- func (r RenderableObject) KubeGetIngressesMatchingService(namespace, svcName string) (out []RenderableObject)
- func (r RenderableObject) KubeGetNetworkPoliciesMatchingPod(namespace string, podLabels map[string]interface{}) (out []RenderableObject)
- func (r RenderableObject) KubeGetNodeMetrics(name string) RenderableObject
- func (r RenderableObject) KubeGetNodeStatsSummary(nodeName string) map[string]interface{}
- func (r RenderableObject) KubeGetNonTerminatedPodsOnNode(nodeName string) (podList []RenderableObject)
- func (r RenderableObject) KubeGetOwners() (out OwnersResult)
- func (r RenderableObject) KubeGetPodDisruptionBudgetsMatchingLabels(namespace string, labels_ map[string]interface{}) (out []RenderableObject)
- func (r RenderableObject) KubeGetPodMetrics(namespace, name string) RenderableObject
- func (r RenderableObject) KubeGetRoutesMatchingService(namespace, svcName string) (out []RenderableObject)
- func (r RenderableObject) KubeGetServicesMatchingLabels(namespace string, labels map[string]interface{}) (out []RenderableObject)
- func (r RenderableObject) KubeGetServicesMatchingPod(namespace, podName string) (out []RenderableObject)
- func (r RenderableObject) KubeGetUnifiedDiffString(resourceOrKind, namespace, nameA, nameB string) string
- func (r RenderableObject) KubeMetricsUnavailableReason() string
- func (r RenderableObject) Labels() (labels map[string]interface{})
- func (r RenderableObject) Metadata() (metadata map[string]interface{})
- func (r RenderableObject) Name() string
- func (r RenderableObject) Namespace() string
- func (r RenderableObject) RolloutStatus(obj RenderableObject) map[string]interface{}
- func (r RenderableObject) Spec() (spec map[string]interface{})
- func (r RenderableObject) Status() (status map[string]interface{})
- func (r RenderableObject) StatusConditions() (conditions []interface{})
- func (r RenderableObject) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultDurationRound ¶ added in v0.7.14
func DefaultDurationRound() func(duration interface{}) string
func SetDurationRound ¶ added in v0.7.14
func SetDurationRound(f func(duration interface{}) string) (revertFunc func())
SetDurationRound is a helper method for tests
func SetNowFunc ¶ added in v0.7.17
SetNowFunc is a helper method for tests
func SetStartedAfterClause ¶ added in v0.7.19
func SetStartedAfterClause(f func(createdKubeDate, startedKubeDate string) string) (revertFunc func())
SetStartedAfterClause is a helper method for tests
Types ¶
type OwnersResult ¶ added in v0.7.19
type OwnersResult struct {
Owners []RenderableObject
Orphans []metav1.OwnerReference
}
OwnersResult is the result of resolving an object's ownerReferences: the owner objects that could be found, plus any ownerReferences whose owner no longer exists (orphans).
type RenderableObject ¶ added in v0.7.0
type RenderableObject struct {
unstructured.Unstructured
Config *viper.Viper
// contains filtered or unexported fields
}
RenderableObject is the object passed to the templates, also provides methods to run queries against Kubernetes API. It is an unstructured.Unstructured (so it has the Object field that keeps the Object) but there a numerous helper methods that already helps with the templates.
func (RenderableObject) Annotations ¶ added in v0.7.0
func (r RenderableObject) Annotations() (annotations map[string]interface{})
func (RenderableObject) Include ¶ added in v0.7.0
func (r RenderableObject) Include(templateName string, data interface{}) (string, error)
func (RenderableObject) IncludeRenderableObject ¶ added in v0.7.0
func (r RenderableObject) IncludeRenderableObject(obj RenderableObject) (output string)
func (RenderableObject) KStatus ¶ added in v0.7.2
func (r RenderableObject) KStatus() *kstatus.Result
KStatus return a Result object of kstatus for the object.
func (RenderableObject) Kind ¶ added in v0.7.0
func (r RenderableObject) Kind() (kind string)
func (RenderableObject) KubeGet ¶ added in v0.7.0
func (r RenderableObject) KubeGet(namespace string, args ...string) (out []RenderableObject)
func (RenderableObject) KubeGetByLabelsMap ¶ added in v0.7.0
func (r RenderableObject) KubeGetByLabelsMap(namespace, resourceType string, labels map[string]interface{}) (out []RenderableObject)
KubeGetByLabelsMap returns results similar to this:
> kubectl get -n {namespace} {resourceType} -l {label_key=label_val,...}
func (RenderableObject) KubeGetCalicoGlobalNetworkPoliciesMatchingPod ¶ added in v0.7.19
func (r RenderableObject) KubeGetCalicoGlobalNetworkPoliciesMatchingPod(namespace string, podLabels map[string]interface{}) (out []RenderableObject)
KubeGetCalicoGlobalNetworkPoliciesMatchingPod returns all Calico GlobalNetworkPolicies whose spec.selector matches podLabels and whose spec.namespaceSelector (if any) accepts the Pod's namespace. GlobalNetworkPolicy is cluster-scoped -- an empty namespaceSelector matches every namespace rather than being confined to the Pod's own namespace, unlike the namespaced Calico NetworkPolicy case -- so the Namespace object is fetched once to evaluate namespaceSelector against its labels (via calicoNamespaceSelectorMatches).
func (RenderableObject) KubeGetCalicoNetworkPoliciesMatchingPod ¶ added in v0.7.19
func (r RenderableObject) KubeGetCalicoNetworkPoliciesMatchingPod(namespace string, podLabels map[string]interface{}) (out []RenderableObject)
KubeGetCalicoNetworkPoliciesMatchingPod returns all Calico NetworkPolicies in namespace whose spec.selector matches podLabels. Calico's own NetworkPolicy kind is served under the crd.projectcalico.org/v1 group -- a different API group than both upstream networking.k8s.io/v1 NetworkPolicy and the projectcalico.org/v3 API calicoctl/the optional Calico API server present -- because kubectl-status only ever talks to the Kubernetes API server directly, and crd.projectcalico.org/v1 is what the CRD-backed ("Kubernetes datastore") storage actually serves there; "networkpolicies.crd.projectcalico.org" disambiguates the kind so the resource builder resolves the right CRD. See calicoPolicySelectsPod for why this evaluates Calico's own selector expression language rather than treating spec.selector as a Kubernetes LabelSelector. Degrades to "no policies found" the same way as KubeGetCiliumNetworkPoliciesMatchingPod when the CRD isn't registered.
func (RenderableObject) KubeGetCiliumClusterwideNetworkPoliciesMatchingPod ¶ added in v0.7.19
func (r RenderableObject) KubeGetCiliumClusterwideNetworkPoliciesMatchingPod(podLabels map[string]interface{}) (out []RenderableObject)
KubeGetCiliumClusterwideNetworkPoliciesMatchingPod returns all CiliumClusterwideNetworkPolicies whose endpointSelector matches podLabels. CiliumClusterwideNetworkPolicy is cluster-scoped, so unlike CiliumNetworkPolicy it can select Pods in any namespace -- there's no namespace filter on the list, only the label match. See KubeGetCiliumNetworkPoliciesMatchingPod for the missing-CRD handling, which applies here identically.
func (RenderableObject) KubeGetCiliumNetworkPoliciesMatchingPod ¶ added in v0.7.19
func (r RenderableObject) KubeGetCiliumNetworkPoliciesMatchingPod(namespace string, podLabels map[string]interface{}) (out []RenderableObject)
KubeGetCiliumNetworkPoliciesMatchingPod returns all CiliumNetworkPolicies in namespace whose spec/specs endpointSelector matches podLabels -- same client-side matching approach as KubeGetNetworkPoliciesMatchingPod, since CiliumNetworkPolicy has no back-reference to the Pods it covers either. CiliumNetworkPolicy is an optional CRD (only present when Cilium is the CNI); when it's not registered, r.repo.Objects returns an error (unknown resource type), which is swallowed the same way as any other listing error below -- this degrades to "no policies found" rather than failing the render, exactly like the upstream NetworkPolicy helper already does when e.g. RBAC denies the list.
func (RenderableObject) KubeGetContainerLogs ¶ added in v0.7.19
func (r RenderableObject) KubeGetContainerLogs(namespace, podName, containerName string, previous bool, tailLines int) string
KubeGetContainerLogs returns up to tailLines lines of log output for the named container in the named pod. When previous is true it fetches logs from the container's previous (terminated) instance, equivalent to `kubectl logs --previous`. Returns an empty string if there are no logs or the fetch fails.
func (RenderableObject) KubeGetEndpointSlicesForService ¶ added in v0.7.15
func (r RenderableObject) KubeGetEndpointSlicesForService(namespace, serviceName string) (out []RenderableObject)
KubeGetEndpointSlicesForService returns EndpointSlices associated with the given service.
func (RenderableObject) KubeGetEvents ¶ added in v0.7.0
func (r RenderableObject) KubeGetEvents() RenderableObject
func (RenderableObject) KubeGetFirst ¶ added in v0.7.0
func (r RenderableObject) KubeGetFirst(namespace string, args ...string) RenderableObject
KubeGetFirst returns a new RenderableObject with a nil Object when no object found.
func (RenderableObject) KubeGetIngressesMatchingService ¶ added in v0.7.0
func (r RenderableObject) KubeGetIngressesMatchingService(namespace, svcName string) (out []RenderableObject)
func (RenderableObject) KubeGetNetworkPoliciesMatchingPod ¶ added in v0.7.19
func (r RenderableObject) KubeGetNetworkPoliciesMatchingPod(namespace string, podLabels map[string]interface{}) (out []RenderableObject)
KubeGetNetworkPoliciesMatchingPod returns all NetworkPolicies in namespace whose spec.podSelector matches podLabels -- the mirror direction of KubeGetServicesMatchingPod: a Service's selector is matched against a Pod's labels via endpoints, but a NetworkPolicy has no reference back to the Pods it covers, so every policy in the Pod's namespace has to be listed and its podSelector checked client-side. See networkPolicySelectsPod for the selector-matching semantics.
func (RenderableObject) KubeGetNodeMetrics ¶ added in v0.7.19
func (r RenderableObject) KubeGetNodeMetrics(name string) RenderableObject
KubeGetNodeMetrics returns the NodeMetrics for the named node. It fetches NodeMetrics for the whole cluster once per render (via the KubeGet cache) so that rendering multiple nodes only requires a single metrics.k8s.io request instead of one per node.
func (RenderableObject) KubeGetNodeStatsSummary ¶ added in v0.7.0
func (r RenderableObject) KubeGetNodeStatsSummary(nodeName string) map[string]interface{}
func (RenderableObject) KubeGetNonTerminatedPodsOnNode ¶ added in v0.7.0
func (r RenderableObject) KubeGetNonTerminatedPodsOnNode(nodeName string) (podList []RenderableObject)
KubeGetNonTerminatedPodsOnNode returns details of all pods which are not in terminal status
func (RenderableObject) KubeGetOwners ¶ added in v0.7.0
func (r RenderableObject) KubeGetOwners() (out OwnersResult)
KubeGetOwners resolves the Owner references of an object, returning both the owners that could be found and any ownerReferences left dangling because their owner no longer exists.
func (RenderableObject) KubeGetPodDisruptionBudgetsMatchingLabels ¶ added in v0.7.19
func (r RenderableObject) KubeGetPodDisruptionBudgetsMatchingLabels(namespace string, labels_ map[string]interface{}) (out []RenderableObject)
KubeGetPodDisruptionBudgetsMatchingLabels returns all PodDisruptionBudgets in namespace whose spec.selector matches the given label set. PDB spec.selector is a full metav1.LabelSelector (matchLabels + matchExpressions), unlike Service selectors, so this uses real LabelSelectorAsSelector/.Matches semantics rather than the isSubset helper. An empty selector (spec.selector: {}) is valid in policy/v1 and matches every pod in the namespace, unlike the removed policy/v1beta1 where it matched none -- policy/v1beta1 is no longer served as of Kubernetes 1.25, so that legacy case isn't handled here.
func (RenderableObject) KubeGetPodMetrics ¶ added in v0.7.19
func (r RenderableObject) KubeGetPodMetrics(namespace, name string) RenderableObject
KubeGetPodMetrics returns the PodMetrics for the named pod. It first tries a single cluster-wide PodMetrics list, reused for every pod/node in the render (see AllNamespacesPodMetrics). If that's not available (e.g. RBAC only allows namespace-scoped access), it falls back to fetching PodMetrics for the whole namespace once per render, so that rendering multiple pods in the same namespace still only requires a single metrics.k8s.io request instead of one per pod.
func (RenderableObject) KubeGetRoutesMatchingService ¶ added in v0.7.18
func (r RenderableObject) KubeGetRoutesMatchingService(namespace, svcName string) (out []RenderableObject)
KubeGetRoutesMatchingService lists Gateway API route resources (HTTPRoute, GRPCRoute, TCPRoute, UDPRoute, TLSRoute) whose spec.rules[].backendRefs[] reference the given Service. All 5 route kinds share the same rules[].backendRefs[].name shape, so a single implementation covers them.
func (RenderableObject) KubeGetServicesMatchingLabels ¶ added in v0.7.0
func (r RenderableObject) KubeGetServicesMatchingLabels(namespace string, labels map[string]interface{}) (out []RenderableObject)
func (RenderableObject) KubeGetServicesMatchingPod ¶ added in v0.7.7
func (r RenderableObject) KubeGetServicesMatchingPod(namespace, podName string) (out []RenderableObject)
func (RenderableObject) KubeGetUnifiedDiffString ¶ added in v0.7.0
func (r RenderableObject) KubeGetUnifiedDiffString(resourceOrKind, namespace, nameA, nameB string) string
KubeGetUnifiedDiffString generates a unified diff between given 2 resources and ignores several keys which are known to be creating noise in diff, see the removeFieldsThatCreateDiffNoise function to see which fields are being dropped.
func (RenderableObject) KubeMetricsUnavailableReason ¶ added in v0.7.19
func (r RenderableObject) KubeMetricsUnavailableReason() string
KubeMetricsUnavailableReason reports why the metrics.k8s.io API (metrics-server) can't be used right now, or "" if it's healthy, so templates can tell users specifically whether it was never installed or is installed but unhealthy, instead of silently omitting the usage section either way. In shallow mode no cluster call is made (per this file's convention) and "" (available) is assumed, so callers don't spuriously warn about something that was never checked.
func (RenderableObject) Labels ¶ added in v0.7.0
func (r RenderableObject) Labels() (labels map[string]interface{})
func (RenderableObject) Metadata ¶ added in v0.7.0
func (r RenderableObject) Metadata() (metadata map[string]interface{})
func (RenderableObject) Name ¶ added in v0.7.0
func (r RenderableObject) Name() string
func (RenderableObject) Namespace ¶ added in v0.7.0
func (r RenderableObject) Namespace() string
func (RenderableObject) RolloutStatus ¶ added in v0.7.0
func (r RenderableObject) RolloutStatus(obj RenderableObject) map[string]interface{}
RolloutStatus returns a map[string]interface{} with 3 keys: done: bool, message, error: string
func (RenderableObject) Spec ¶ added in v0.7.0
func (r RenderableObject) Spec() (spec map[string]interface{})
func (RenderableObject) Status ¶ added in v0.7.0
func (r RenderableObject) Status() (status map[string]interface{})
func (RenderableObject) StatusConditions ¶ added in v0.7.0
func (r RenderableObject) StatusConditions() (conditions []interface{})
func (RenderableObject) String ¶ added in v0.7.0
func (r RenderableObject) String() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package calicoselector evaluates Calico's label-selector expression language (e.g.
|
Package calicoselector evaluates Calico's label-selector expression language (e.g. |