Skip to content

Commit

Permalink
Merge branch 'dev' into kristof-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofre authored Nov 7, 2024
2 parents c1edf9d + b28a56b commit 8f34825
Show file tree
Hide file tree
Showing 18 changed files with 429 additions and 58 deletions.
13 changes: 13 additions & 0 deletions terraform/aws/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ This terraform script supports the use of custom domains via Route53.
route53_zone_name = "" # Name of route53 zone (defaults to public zones)
```

## Send OpenTelemetry Traces to Dynatrace

It is possible to leverage the [Ansible OpenTelemetry callback plugin](https://docs.ansible.com/ansible/latest/collections/community/general/opentelemetry_callback.html) to send Traces to the Dynatraces API.

The following variable need to be set to enable it:

```hcl
otel_export_enable = true
```

> Note: The traces will be sent to the `dt_tenant/api/v2/otlp` endpoint
> Note: The api token specified in the `dt_api_token` variable needs to have the additional `openTelemetryTrace.ingest` scope

## Useful Terraform Commands

Command | Result
Expand Down
1 change: 1 addition & 0 deletions terraform/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ module "provisioner" {
extra_vars = var.extra_vars
dashboard_user = var.dashboard_user
dashboard_password = local.dashboard_password
otel_export_enable = var.otel_export_enable

depends_on = [
aws_instance.acebox
Expand Down
6 changes: 6 additions & 0 deletions terraform/aws/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,9 @@ variable "vpc_enable_nat_gateway" {
type = bool
default = false
}

variable "otel_export_enable" {
type = bool
description = "Enable openetelemetry export to Dynatrace"
default = false
}
14 changes: 14 additions & 0 deletions terraform/azure/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

```hcl
azure_location = "" # azure location where you want to provision the resources
azure_subscription_id = "" # azure subscription id in which subcsription you want to provision the resources
```

Check out `variables.tf` for a complete list of variables
Expand Down Expand Up @@ -64,6 +65,19 @@ This terraform script supports the use of custom domains via Azure DNS.
dns_zone_name = "example.com" # Name of Azure DNS zone
```

## Send OpenTelemetry Traces to Dynatrace

It is possible to leverage the [Ansible OpenTelemetry callback plugin](https://docs.ansible.com/ansible/latest/collections/community/general/opentelemetry_callback.html) to send Traces to the Dynatraces API.

The following variable need to be set to enable it:

```hcl
otel_export_enable = true
```

> Note: The traces will be sent to the `dt_tenant/api/v2/otlp` endpoint
> Note: The api token specified in the `dt_api_token` variable needs to have the additional `openTelemetryTrace.ingest` scope

## Useful Terraform Commands


Expand Down
3 changes: 2 additions & 1 deletion terraform/azure/acebox-azure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,5 @@ module "provisioner" {
extra_vars = var.extra_vars
dashboard_user = var.dashboard_user
dashboard_password = local.dashboard_password
}
otel_export_enable = var.otel_export_enable
}
1 change: 1 addition & 0 deletions terraform/azure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ terraform {

provider "azurerm" {
features {}
subscription_id = var.azure_subscription_id
}


Expand Down
10 changes: 10 additions & 0 deletions terraform/azure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

variable "azure_subscription_id" {
description = "Azure Subscription ID for provisioning the Azure resources"
}

variable "name_prefix" {
description = "Prefix to distinguish the instance"
default = "ace-box-cloud"
Expand Down Expand Up @@ -92,3 +96,9 @@ variable "dashboard_password" {
description = "ACE-Box dashboard password."
default = ""
}

variable "otel_export_enable" {
type = bool
description = "Enable openetelemetry export to Dynatrace"
default = false
}
5 changes: 5 additions & 0 deletions terraform/azure/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ terraform {
required_version = ">= 0.12.20"

required_providers {
/* azurerm = {
source = "hashicorp/azurerm"
version = "~> 4.x"
}
*/
random = "~> 3.3.2"
local = "~> 2.2.2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ Check the [EasyTrade documentation](https://github.com/Dynatrace/easytrade/blob/
## Using the role

### Role Requirements

This role depends on the following roles to be deployed beforehand:

```yaml
- include_role:
name: microk8s
name: k3s
```
> Note: we highly recommend to use k3s, but it is also possible to use microk8s. More information below
### Deploying EasyTrade
```yaml
Expand Down Expand Up @@ -71,15 +75,13 @@ To enable monaco:

```

### (Optional) k3s compatibility
### (Alternative) microk8s

In order to make easytrade work for k3s, add the following variable:
If for some reason you are facing issues with k3s as the prerequisite, you can also deploy microk8s:

```yaml
- include_role:
name: app-easytrade
vars:
easytrade_ingress_class: "traefik"
name: microk8s
```
### Add to ACE Dashboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
meta.helm.sh/release-name: easytrade
labels:
app: easytrade
name: easytrade-ingress
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
# dt-operator

This currated role can be used to deploy Dynatrace k8s operator (Dynakube) with a classic full-stack, cloud native full-stack or app-only injection deployment strategy.
This currated role deploys the Dynatrace Operator to monitor your Kubernetes cluster. Dynatrace provides different deployment options: `application-only + k8s-api`, `cloudNativeFullStack`, and `classicFullStack`. Notice that the prerequisites for each are different

## Prerequisites

### (RECOMMENDED) application-only + k8s-api or cloudNativeFullStack

This role depends on the following roles to be deployed beforehand:

```yaml
- include_role:
name: k3s
```
> Note: if you deploy k3s, you don't need to deploy microk8s and viceversa
### classicFullStack
This role depends on the following roles to be deployed beforehand:
```yaml
- include_role:
name: microk8s
```
> Note: if you deploy microk8s, you don't need to deploy k3s and viceversa
Dynatrace Operator manages classic full-stack injection after the following resources are deployed.
Expand All @@ -12,41 +35,56 @@ Dynatrace Operator manages classic full-stack injection after the following reso
For the details, please check this link: https://www.dynatrace.com/support/help/shortlink/dto-deploy-options-k8s#classic
## Using the role
### Role Requirements
This role depends on the following roles to be deployed beforehand:
## Deploying Dynatrace K8s Operator
```yaml
- include_role:
name: microk8s
name: dt-operator
```
The Operator gets deployed in application only mode approach, check the `roles/dt-operator/defaults/main.yml`:

```yaml
operator_mode: "applicationMonitoring" # default & prefered deployment option
dt_operator_release: "1.3.0-rc.0" # operator release should be linked with the right operator mode
log_monitoring: "fluentbit"
edge_connect: false
```

### Deploying Dynatrace K8s Operator
> Note: log monitoring is enabled by default, using the fluentbit collector and edge connect is disabled by default, but can be switched to
To deploy the Operator in application only mode (and default approach), variables can be set as follow:

```yaml
- include_role:
name: dt-operator
vars:
edge_connect: true
```

Variables that can be set are as follows:
If you decide to use the classicFullStack approach, you need to specify the variables as follow:

```yaml
---
dt_operator_release: "v0.9.1" # the latest supported dynatrace operator release
dt_operator_namespace: "dynatrace"
host_group: "ace-box"
operator_mode: "classicFullStack"
cluster_name: "your-cluster-name"
- include_role:
name: dt-operator
vars:
operator_mode: "classicFullStack"
dt_operator_release: "1.2.2"
```

Possible values for operator_mode:
- applicationMonitoring
- classicFullStack
- cloudNativeFullStack
## Extra variables

You can configure the cluster name and host group as follows:

```yaml
- include_role:
name: dt-operator
vars:
host_group: custom_host_group
cluster_name: custom_cluster_name
```

This role creates a namespace in the Kubernetes cluster and deploys the Dynatrace operator along with the Dynakube custom resource.

### Other Tasks in the Role
## Other Tasks in the Role

"source-secrets" retrieves the Operator bearer token and stores it in the following variable:
- `dt_operator_kube_bearer_token`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
# limitations under the License.

---
dt_operator_release: "v1.2.2"
operator_mode: "applicationMonitoring" # default & prefered deployment option
dt_operator_release: "1.3.0-rc.0" # operator release should be linked with the right operator mode
log_monitoring: "fluentbit"
edge_connect: false

# operator_mode: "classicFullStack"
# dt_operator_release: "1.2.2"

dt_operator_namespace: "dynatrace"
host_group: "ace-box"
dt_operator_dt_access_token_name: "ace_box_dt_operator_api_token"
dt_operator_dt_data_ingest_token_name: "ace_box_dt_operator_ingest_token"
operator_mode: "classicFullStack"
cluster_name: dynakube
cluster_name: dynakube
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@
retries: 20
delay: 5
until: dt_operator is not failed
when: operator_mode != "applicationMonitoring"

- name: Add stable chart repo
kubernetes.core.helm:
name: dynatrace-operator
chart_ref: "oci://public.ecr.aws/dynatrace/dynatrace-operator"
# set_values:
# - value: imageRef.repository=gcr.io/dynatrace-marketplace-prod/dynatrace-operator
# value_type: string
release_namespace: dynatrace
create_namespace: true
atomic: true
chart_version: "{{dt_operator_release}}"
when: operator_mode == "applicationMonitoring"

- block:
- name: Download CSI manifest
Expand All @@ -65,7 +79,7 @@
retries: 20
delay: 5
until: dt_operator_csi is not failed
when: operator_mode != "classicFullStack"
when: operator_mode != "applicationMonitoring"

- block:
- name: Template Dynakube manifest
Expand All @@ -84,6 +98,7 @@
delay: 20
until: dynakube is not failed

- block:
- name: Wait for at least one Dynatrace OneAgent pod to be created
kubernetes.core.k8s_info:
kind: Pod
Expand All @@ -94,7 +109,6 @@
until: dt_oneagent_pods_creation.resources | length > 0
retries: 20
delay: 20

- name: Wait for at least one Dynatrace ActiveGate pod to be created
kubernetes.core.k8s_info:
kind: Pod
Expand All @@ -105,7 +119,6 @@
until: dt_activegate_pods_creation.resources | length > 0
retries: 20
delay: 20

- name: Ensure all Dynatrace OneAgent pods are in Running state and ready
kubernetes.core.k8s_info:
kind: Pod
Expand All @@ -117,7 +130,6 @@
dt_oneagent_pods.resources | selectattr('status.phase', 'equalto', 'Running') | map(attribute='status.containerStatuses') | selectattr('0.ready', 'equalto', true) | length == dt_oneagent_pods.resources | length
retries: 20
delay: 20

- name: Ensure all Dynatrace ActiveGate pods are in Running state and ready
kubernetes.core.k8s_info:
kind: Pod
Expand All @@ -128,4 +140,13 @@
until: >
dt_activegate_pods.resources | selectattr('status.phase', 'equalto', 'Running') | map(attribute='status.containerStatuses') | selectattr('0.ready', 'equalto', true) | length == dt_activegate_pods.resources | length
retries: 20
delay: 20
delay: 20
when: operator_mode == "classicFullStack"

- include_role:
name: fluentbit
when: log_monitoring == "fluentbit"

- include_role:
name: edge-connect
when: edge_connect == true
Loading

0 comments on commit 8f34825

Please sign in to comment.