Skip to content

Commit

Permalink
fixing content deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRollins committed Nov 5, 2024
1 parent a36f3a5 commit deb4ed6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 105 deletions.
35 changes: 34 additions & 1 deletion tyk-docs/content/api-management/automations.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,39 @@ The following custom resources can be used to configure [Tyk Classic Developer P
| PortalAPICatalogue | tyk.tyk.io | v1alpha1 | Configures [Portal API Catalogue]({{<ref "getting-started/key-concepts/api-catalogue">}}). |
| PortalConfig | tyk.tyk.io | v1alpha1 | Configures [Portal Configuration]({{<ref "tyk-apis/tyk-portal-api/portal-configuration">}}). |


#### Reconcilation With Tyk Operator
##### Controllers & Operators
In Kubernetes, [controllers](https://kubernetes.io/docs/concepts/architecture/controller/) watch one or more Kubernetes resources, which can be built-in types like *Deployments* or custom resources like *ApiDefinition* - in this case, we refer to Controller as Operator. The purpose of a controller is to match the desired state by using Kubernetes APIs and external APIs.

> A [Kubernetes operator](https://www.redhat.com/en/topics/containers/what-is-a-kubernetes-operator) is an application-specific controller that extends the functionality of the Kubernetes API to create, configure, and manage instances of complex applications on behalf of a Kubernetes user.
##### Desired State vs Observed State
Let’s start with the *Desired State*. It is defined through Kubernetes Manifests, most likely YAML or JSON, to describe what you want your system to be in. Controllers will watch the resources and try to match the actual state (the observed state) with the desired state for Kubernetes Objects. For example, you may want to create a Deployment that is intended to run three replicas. So, you can define this desired state in the manifests, and Controllers will perform necessary operations to make it happen.

How about *Observed State*? Although the details of the observed state may change controller by controller, usually controllers update the status field of Kubernetes objects to store the observed state. For example, in Tyk Operator, we update the status to include *api_id*, so that Tyk Operator can understand that the object was successfully created on Tyk.

##### Reconciliation
Reconciliation is a special design paradigm used in Kubernetes controllers. Tyk Operator also uses the same paradigm, which is responsible for keeping our Kubernetes objects in sync with the underlying external APIs - which is Tyk in our case.

**When would reconciliation happen?**
Before diving into Tyk Operator reconciliation, let's briefly mention some technical details about how and when reconciliation happens. Reconciliation only happens when certain events happen on your cluster or objects. Therefore, Reconciliation will **NOT** be triggered when there is an update or modification on Tyk’s side. It only watches certain Kubernetes events and is triggered based on them. Usually, the reconciliation happens when you modify a Kubernetes object or when the cache used by the controller expires - side note, controllers, in general, use cached objects to reduce the load in the Kube API server. Typically, caches expire in ~10 hours or so but the expiration time might change based on Operator configurations.

So, in order to trigger Reconciliation, you can either
- modify an object, which will trigger reconciliation over this modified object or,
- restart Tyk Operator pod, which will trigger reconciliation over each of the objects watched by Tyk Operator.

**What happens during Reconciliation?**
Tyk Operator will compare desired state of the Kubernetes object with the observed state in Tyk. If there is a drift, Tyk Operator will update the actual state on Tyk with the desired state. In the reconciliation, Tyk Operator mainly controls three operations; DELETE, CREATE, and UPDATE.

- **CREATE** - an object is created in Kubernetes but not exists in Tyk
- **UPDATE** - an object is in different in Kubernetes and Tyk (we compare that by hash)
- **DELETE** - an object is deleted in Kubernetes but exists in Tyk

**Drift Detection**
If human operators or any other system delete or modify ApiDefinition from Tyk Gateway or Dashboard, Tyk Operator will restore the desired state back to Tyk during reconciliation. This is called Drift Detection. It can protect your systems from unauthorized or accidental modifications. It is a best practice to limit user access rights on production environment to read-only in order to prevent accidental updates through API Manager directly.


#### CRD Versioning

Tyk follows standard practices for naming and versioning custom resources as outlined by the Kubernetes Custom Resource Definition [versioning guidelines](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definition-versioning/). Although we are currently on the `v1alpha1` version, no breaking changes will be introduced to existing Custom Resources without a version bump. This means that any significant changes or updates that could impact existing resources will result in a new version (e.g., `v1beta1` or `v1`) and Operator will continue supporting all CRD versions for a reasonable time before deprecating an older version. This ensures a smooth transition and compatibility, allowing you to upgrade without disrupting your current configurations and workflows.
Expand Down Expand Up @@ -2798,7 +2831,7 @@ To make use of the TykOasApiDefinition template, make sure to add annotations `t
The value of the `kubernetes.io/ingress.class` annotation identifies the IngressClass that will process Ingress objects.

Tyk Operator by default looks for the value `tyk` and will ignore all other ingress classes. If you wish to override this default behavior,
you may do so by setting the environment variable `WATCH_INGRESS_CLASS` in the operator manager deployment. [See Installing Tyk Operator]({{<ref "tyk-stack/tyk-operator/installing-tyk-operator">}}) for further information.
you may do so by setting the environment variable `WATCH_INGRESS_CLASS` in the operator manager deployment. [See Installing Tyk Operator]({{<ref "/tyk-stack/tyk-operator/installing-tyk-operator">}}) for further information.

#### API name

Expand Down
57 changes: 0 additions & 57 deletions tyk-docs/content/tyk-operator.md

This file was deleted.

This file was deleted.

0 comments on commit deb4ed6

Please sign in to comment.