cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Pro Tip - Management Zones in Kubernetes environments (possible solution)

Mizső
DynaMight Guru
DynaMight Guru

Hi Folks,

I know that segments will be the future and MZ will be retired, but until that maybe you can use this possible solution for MZ management in kubernetes environments.

Let's assume you organize your applications by namespace level and you need MZ for filtering and access management purposes.

Basic of these Management zones are tags. So the first step is tagging the belonging entitis. Only one concrete value in this solution the namesapce name (or namespaces) . Rest of the tags are dinamic. I am trying to collect all relevant entities with in a namesapce. Only one entitiy type is missing the Cloud Application Insatance. It is not allowed to tag this entitiy type.

Here is an example for tagging. Atomatiacally applied tag name is okduat_8. The namespace selector is entityName.startsWith(\"uat8\")

"value": {
    "name": "okduat_8",
    "rules": [
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"SERVICE\"),serviceType(DATABASE_SERVICE),toRelationships.Calls(type(\"SERVICE\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"kafka:topic\"),toRelationships.Calls(type(\"kafka:consumer\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"kafka:topic\"),toRelationships.Calls(type(\"kafka:producer\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"kafka:producer\"),fromRelationships.IsSameAs(type(\"PROCESS_GROUP_INSTANCE\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"kafka:consumer\"),fromRelationships.IsSameAs(type(\"PROCESS_GROUP_INSTANCE\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"KUBERNETES_NODE\"),toRelationships.isClusterOfNode(type(\"KUBERNETES_CLUSTER\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"CONTAINER_GROUP\"),toRelationships.isInstanceOf(type(\"CONTAINER_GROUP_INSTANCE\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"CONTAINER_GROUP_INSTANCE\"),fromRelationships.isCgiOfNamespace(type(\"CLOUD_APPLICATION_NAMESPACE\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"CLOUD_APPLICATION\"),toRelationships.isNamespaceOfCa(type(\"CLOUD_APPLICATION_NAMESPACE\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"SERVICE\"),fromRelationships.RunsOn(type(\"PROCESS_GROUP\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"PROCESS_GROUP\"),toRelationships.isNamespaceOfPg(type(\"CLOUD_APPLICATION_NAMESPACE\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"PROCESS_GROUP_INSTANCE\"),fromRelationships.isInstanceOf(type(\"PROCESS_GROUP\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"KUBERNETES_SERVICE\"),toRelationships.isNamespaceOfKubernetesSvc(type(\"CLOUD_APPLICATION_NAMESPACE\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"HOST\"),toRelationships.RunsOn(type(\"PROCESS_GROUP\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"HOST_GROUP\"),toRelationships.isInstanceOf(type(\"HOST\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"CLOUD_APPLICATION_NAMESPACE\"),entityName.startsWith(\"uat8\")"
      },
      {
        "enabled": true,
        "valueNormalization": "Leave text as-is",
        "type": "SELECTOR",
        "entitySelector": "type(\"KUBERNETES_CLUSTER\"),fromRelationships.isClusterOfNamespace(type(\"CLOUD_APPLICATION_NAMESPACE\"),tag(\"okduat_8\"))"
      }
    ]
  }
 
Here is the result in the GUI, (some extra in it the kafka entities, but you can extend it with other types of entities):
 
Mizs_0-1756101914908.png

 

If your entities are tagged you can create the MZ rule. Here is an example for the MZ rule:

"value": {
    "name": "okduat_8",
    "rules": [
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"CLOUD_APPLICATION_INSTANCE\"),toRelationships.isNamespaceOfCai(type(\"CLOUD_APPLICATION_NAMESPACE\"),tag(\"okduat_8\"))"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"kafka:topic\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"kafka:producer\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"kafka:consumer\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"SERVICE\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"PROCESS_GROUP\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"PROCESS_GROUP_INSTANCE\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"KUBERNETES_SERVICE\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"KUBERNETES_NODE\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"KUBERNETES_CLUSTER\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"HOST\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"HOST_GROUP\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"CONTAINER_GROUP\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"CONTAINER_GROUP_INSTANCE\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"CLOUD_APPLICATION\"),tag(\"okduat_8\")"
      },
      {
        "enabled": true,
        "type": "SELECTOR",
        "entitySelector": "type(\"CLOUD_APPLICATION_NAMESPACE\"),tag(\"okduat_8\")"
      }
    ]
  }

 

Here is the GUI result of the MZ:

Mizs_1-1756102277915.png

 

You can modify or extend this collection and then you can use the Settings API and of course the Monaco to implement it...

Best regards,

János

Dynatrace Community RockStar 2024, Certified Dynatrace Professional
1 REPLY 1

prasad_arugonda
Contributor

Hi @Mizső 

Thanks for sharing this tip—it's quite similar to what we currently implement in our environments (no other choice).

That said, in large enterprise Kubernetes setups with hundreds of namespaces, the number of rules required can quickly become overwhelming. This not only adds operational overhead but could also have a noticeable impact on cluster performance (may be).

With Management Zones (MZs) being phased out in favor of Segments, this approach may not be sustainable in the long term. While it works for now, it might not be the most future-proof solution. 😉

Looking forward to seeing how Dynatrace evolves this transition and whether a more scalable, automated mapping between MZs and Segments will be introduced.🤞

Featured Posts