Skip to content

Commit

Permalink
Merge pull request #16 from dynatrace-oss/fix-outdated-custom-resource
Browse files Browse the repository at this point in the history
Migrate to new operator & fixes
  • Loading branch information
heckelmann authored Oct 30, 2023
2 parents 8b24fff + 5cb0463 commit 633d054
Show file tree
Hide file tree
Showing 10 changed files with 4,829 additions and 15,726 deletions.
72 changes: 9 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,14 @@
# Dynatrace Add-On for Amazon EKS Blueprints
[![main](https://github.com/dynatrace-oss/dynatrace-eks-blueprints-addon/actions/workflows/main.yml/badge.svg)](https://github.com/dynatrace-oss/dynatrace-eks-blueprints-addon/actions/workflows/main.yml)

The Dynatrace Add-On for Amazon EKS Blueprints enables platform administrators to install the Dynatrace OneAgent Operator during the bootstrapping process of an [EKS](https://aws.amazon.com/eks/) cluster.

Therefore, this add-on installs the [Dynatrace Operator Helm Chart](https://github.com/Dynatrace/helm-charts/tree/master/dynatrace-operator) and configures the operator to use a Dynatrace Tenant with credentials specified by variables or a Amazon Secrets Manager Secret.

## Prerequisites

### Dynatrace Tokens
Create API and PaaS Tokens as described here: https://www.dynatrace.com/support/help/reference/dynatrace-concepts/why-do-i-need-an-environment-id/#create-user-generated-access-tokens

### AWS Secret Manager Secrets
If you plan to use Secret Manager Secrets, you need to create a secret first. #

Therefore:
* Open your AWS Console
* Search for "Secrets Manager"
* Create a new secret ("Store a new secret")
* Secret Type: "Other type of secret"
* Key/value pairs
* API_URL="https://<dynatrace-tenant-url>/api"
* API_TOKEN="<your-api-token>"
* PAAS_TOKEN="your-paas-token>"
* Remember the name you assigned to the secret
The Dynatrace Add-On for Amazon EKS Blueprints enables platform administrators to install the Dynatrace Operator during the bootstrapping process of an [EKS](https://aws.amazon.com/eks/) cluster. Therefore, this add-on installs the [Dynatrace Operator Helm Chart](https://github.com/Dynatrace/dynatrace-operator/tree/main/config/helm/repos/stable).

## Usage
The add-on can be used by either specifying the name of a Secrets Manager secret or the API Tokens.

You can find informations how to get started with SSP Projects [here](https://aws-quickstart.github.io/cdk-eks-blueprints/getting-started/).
The add-on installs the Dynatrace Operator for you. In a second step, creating a DynaKube resource configures monitoring of the cluster.

### Deploy operator

### Example Configuration (secrets in Secrets Manager):
```typescript
import 'source-map-support/register';
import * as cdk from '@aws-cdk/core'
Expand All @@ -38,10 +17,7 @@ import * as blueprints from '@aws-quickstart/eks-blueprints'

const app = new cdk.App();

const Dynatrace = new dt.DynatraceOperatorAddOn({
// In this example, the secret is called "dynatrace-tokens"
ssmSecretName: "dynatrace-tokens"
})
const Dynatrace = new dt.DynatraceAddOn()


const addOns: Array<blueprints.ClusterAddOn> = [
Expand All @@ -51,43 +27,13 @@ const addOns: Array<blueprints.ClusterAddOn> = [
const account = '<aws-account-id>';
const region = '<aws-region>';
const props = { env: { account, region } };
new blueprints.EksBlueprint(app, { id: '<aws-eks-cluster-name>', addOns}, props);
new blueprints.EksBlueprint(app, { id: '<aws-eks-cluster-name>', version: 'auto', addOns}, props);
```

### Example Configuration (secrets in code):

```typescript
import 'source-map-support/register';
import * as cdk from '@aws-cdk/core'
import * as dt from '@dynatraceoss/dynatrace-eks-blueprints-addon'
import * as blueprints from '@aws-quickstart/eks-blueprints'

const app = new cdk.App();

const Dynatrace = new dt.DynatraceAddOn({
apiUrl: "https://<your-dynatrace-tenant-url>/api",
apiToken: "<your-api-token",
paasToken: "<your-paas-token>"
})

### Create DynaKube

const addOns: Array<blueprints.ClusterAddOn> = [
Dynatrace,
];

const account = '<aws-account-id>';
const region = '<aws-region>';
const props = { env: { account, region } };
new blueprints.EksBlueprint(app, { id: '<aws-eks-cluster-name>', addOns}, props);
```

## Adding your EKS Cluster to Dynatrace
After creating your EKS Cluster, connect to this cluster with kubectl and find out the UUID of the "kube-system" Namespace of this:
```
kubectl get ns kube-system -ojsonpath='{.metadata.uid}'
```
Create a DynaKube resource as described in the [README file of the Dynatrace Operator](https://www.dynatrace.com/support/help/setup-and-configuration/setup-on-k8s/reference/dynakube-parameters).

Afterwards, open Dynatrace in your browser, click on "Infrastructure -> Kubernetes" and "Connect manually". Check "Connect containerized ActiveGate to local Kubernetes API endpoint", add a name and copy the UUID of the kube-system namespace into the "Kubernetes cluster ID" field. Afterwards, click save.

## Enhancements / Bugs
## Enhancements / Bugs
You are welcome to use issues to report bugs or request enhancements.
19 changes: 0 additions & 19 deletions addon/.eslintrc.js

This file was deleted.

8 changes: 8 additions & 0 deletions addon/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.js
!jest.config.js
*.d.ts
node_modules

# CDK asset staging directory
.cdk.staging
cdk.out
6 changes: 6 additions & 0 deletions addon/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.ts
!*.d.ts

# CDK asset staging directory
.cdk.staging
cdk.out
15 changes: 0 additions & 15 deletions addon/Makefile

This file was deleted.

22 changes: 22 additions & 0 deletions addon/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ClusterInfo } from '@aws-quickstart/eks-blueprints';
import { Construct } from 'constructs'
import { HelmAddOn, HelmAddOnProps } from "@aws-quickstart/eks-blueprints/dist/addons/helm-addon";

export const defaultProps: HelmAddOnProps = {
name: 'dynatrace-operator',
chart: 'dynatrace-operator',
release: 'eks-blueprints-addon-dynatrace',
namespace: "dynatrace",
repository: "https://raw.githubusercontent.com/Dynatrace/dynatrace-operator/main/config/helm/repos/stable",
version:"0.13.0"
}

export class DynatraceAddOn extends HelmAddOn {
constructor(){
super({...defaultProps});
}

deploy(clusterInfo: ClusterInfo): void | Promise<Construct> {
return Promise.resolve(this.addHelmChart(clusterInfo, {installCRD: true}));
}
}
Loading

0 comments on commit 633d054

Please sign in to comment.