@@ -103,6 +103,9 @@ but with annotations, you can fine-tune the order and apply time-value injection
...
@@ -103,6 +103,9 @@ but with annotations, you can fine-tune the order and apply time-value injection
To provide the GitOps functionality, the GitLab agent for Kubernetes uses the [`cli-utils` library](https://github.com/kubernetes-sigs/cli-utils/),
To provide the GitOps functionality, the GitLab agent for Kubernetes uses the [`cli-utils` library](https://github.com/kubernetes-sigs/cli-utils/),
a Kubernetes SIG project. You can read more about the available annotations in the [`cli-utils` documentation](https://github.com/kubernetes-sigs/cli-utils/blob/master/README.md#apply-sort-ordering).
a Kubernetes SIG project. You can read more about the available annotations in the [`cli-utils` documentation](https://github.com/kubernetes-sigs/cli-utils/blob/master/README.md#apply-sort-ordering).
-[Learn more about apply sort ordering](https://github.com/kubernetes-sigs/cli-utils#apply-sort-ordering).
-[Learn more about apply-time mutation](https://github.com/kubernetes-sigs/cli-utils#apply-time-mutation).
## Additional resources
## Additional resources
The following documentation and examples can help you get started with a GitOps workflow.
The following documentation and examples can help you get started with a GitOps workflow.
info:To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---
# Advanced Kubernetes resource management
The GitLab agent for Kubernetes has annotations you can use to:
-**Sort resources**: Apply or delete resources in a specific order.
-**Use apply-time mutation**: Dynamically substitute fields from one resource configuration to another.
The agent has [default ordering](https://github.com/kubernetes-sigs/cli-utils/blob/...),
but with annotations, you can fine-tune the order and apply time-value injection.
To provide this functionality, the GitLab agent for Kubernetes uses the `cli-utils` library,
a Kubernetes SIG project.
There are special situations where the out-of-the-box resource ordering or configuration options are not good enough for a specific use case. The GitOps engine behind the GitLab agent for Kubernetes provides annotations in order to achieve:
-**Sorting**: adds optional resource sorting functionality to apply or delete objects in a particular order.
-**Apply Time Mutation**: adds optional functionality to dynamically substitute fields from one resource config into another.
While a [sane, default ordering](https://github.com/kubernetes-sigs/cli-utils/blob/d7d63f4b62897f584ca9e02b6faf4d2f327a9b09/pkg/ordering/sort.go#L74) is provided by the agent out of the box, annotations allow more fine-tuned ordering and even apply time value injection.
The GitLab agent for Kubernetes is based on the `cli-utils` library, a Kubernetes SIG project. You can read more about the `cli-utils` library and its advanced functions in [the project repository](https://github.com/kubernetes-sigs/cli-utils/). The following is based on the `cli-utils` documentation.
## Apply Sort Ordering
Adding an optional `config.kubernetes.io/depends-on: <OBJECT>` annotation to a
resource config provides apply ordering functionality. After manually specifying
the dependency relationship among applied resources with this annotation, the
library will sort the resources and apply/prune them in the correct order.
Importantly, the library will wait for an object to reconcile successfully within
the cluster before applying dependent resources. Prune (deletion) ordering is
the opposite of apply ordering.
In the following example, the `config.kubernetes.io/depends-on` annotation
identifies that `pod-c` must be successfully applied prior to `pod-a`