From 5c873af59487bbc8c7edd1e343f7236f36f2bf29 Mon Sep 17 00:00:00 2001 From: Sean Morton Date: Wed, 21 Jun 2023 10:39:28 -0500 Subject: [PATCH] Add ADOT component --- gitops/components/adot/README.md | 1 + gitops/components/adot/kustomization.yaml | 74 +++++++++++ gitops/components/adot/resources.yaml | 116 ++++++++++++++++++ .../components/fluent-bit/kustomization.yaml | 1 + gitops/components/fluent-bit/resources.yaml | 1 - 5 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 gitops/components/adot/README.md create mode 100644 gitops/components/adot/kustomization.yaml create mode 100644 gitops/components/adot/resources.yaml diff --git a/gitops/components/adot/README.md b/gitops/components/adot/README.md new file mode 100644 index 0000000..74c3292 --- /dev/null +++ b/gitops/components/adot/README.md @@ -0,0 +1 @@ +# Amazon Distro for Open Telemetry (OTEL) diff --git a/gitops/components/adot/kustomization.yaml b/gitops/components/adot/kustomization.yaml new file mode 100644 index 0000000..839a13c --- /dev/null +++ b/gitops/components/adot/kustomization.yaml @@ -0,0 +1,74 @@ +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +resources: + - ./resources.yaml + +patches: + - target: + group: argoproj.io + version: v1alpha1 + kind: AppProject + name: admins + patch: |- + - op: add + path: /spec/sourceRepos/- + value: https://aws-observability.github.io/aws-otel-helm-charts + - op: add + path: /spec/destinations/- + value: + namespace: adot + server: https://kubernetes.default.svc + +replacements: + - source: + version: v1 + kind: ConfigMap + name: kustomize-environment + fieldPath: data.ADOT_ROLE_ARN + targets: + - select: + version: v1 + kind: ServiceAccount + name: adot-collector + fieldPaths: + - metadata.annotations.eks\.amazonaws\.com/role-arn + - source: + version: v1 + kind: ConfigMap + name: kustomize-environment + fieldPath: data.CLUSTER_NAME + targets: + - select: + group: argoproj.io + version: v1alpha1 + kind: Application + name: adot-collector + fieldPaths: + - spec.source.helm.parameters.[name=clusterName].value + - source: + version: v1 + kind: ConfigMap + name: kustomize-environment + fieldPath: data.AWS_REGION + targets: + - select: + group: argoproj.io + version: v1alpha1 + kind: Application + name: adot-collector + fieldPaths: + - spec.source.helm.parameters.[name=awsRegion].value + - source: + version: v1 + kind: ConfigMap + name: kustomize-environment + fieldPath: data.AMP_RW_ENDPOINT + targets: + - select: + group: argoproj.io + version: v1alpha1 + kind: Application + name: adot-collector + fieldPaths: + - spec.source.helm.parameters.[name=ampexporters.endpoint].value diff --git a/gitops/components/adot/resources.yaml b/gitops/components/adot/resources.yaml new file mode 100644 index 0000000..15ee0e7 --- /dev/null +++ b/gitops/components/adot/resources.yaml @@ -0,0 +1,116 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: adot +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: adot-collector + namespace: adot + annotations: + eks.amazonaws.com/role-arn: ADOT_ROLE_ARN + eks.amazonaws.com/sts-regional-endpoints: "true" +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: adot-collector + namespace: argocd + finalizers: + - resources-finalizer.argocd.argoproj.io +spec: + project: admins + source: + chart: adot-exporter-for-eks-on-ec2 + repoURL: https://aws-observability.github.io/aws-otel-helm-charts + targetRevision: 0.13.0 + helm: + releaseName: adot-collector + parameters: + - name: clusterName + value: CLUSTER_NAME + - name: awsRegion + value: AWS_REGION + - name: ampexporters.endpoint + value: AMP_RW_ENDPOINT + # https://aps-workspaces.us-west-2.amazonaws.com/workspaces/ws-30b74c49-746c-4cc2-b93c-539f15d45259/api/v1/remote_write + values: | + serviceAccount: + create: false + name: "adot-collector" + adotCollector: + daemonSet: + createNamespace: false + namespace: adot + serviceAccount: + create: false + name: "adot-collector" + resources: + limits: + memory: 200Mi + requests: + cpu: 200m + memory: 200Mi + ampreceivers: + scrapeInterval: 15s + scrapeTimeout: 10s + scrapeConfigs: | + - job_name: 'pod_metrics_scrape' + sample_limit: 10000 + metrics_path: /metrics + kubernetes_sd_configs: + - role: pod + relabel_configs: + - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape] + action: keep + regex: true + - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path] + action: replace + regex: (.+) + target_label: __metrics_path__ + - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port] + action: replace + regex: ([^:]+)(?::\d+)?;(\d+) + replacement: $$1:$$2 + target_label: __address__ + - source_labels: [__meta_kubernetes_namespace] + action: replace + target_label: Namespace + - source_labels: [__meta_kubernetes_pod_name] + action: replace + target_label: PodName + - job_name: 'kubelets-cadvisor-metrics' + sample_limit: 10000 + scheme: https + kubernetes_sd_configs: + - role: node + tls_config: + ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt + bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token + relabel_configs: + - action: labelmap + regex: __meta_kubernetes_node_label_(.+) + # Only for Kubernetes ^1.7.3. + # See: https://github.com/prometheus/prometheus/issues/2916 + - target_label: __address__ + # Changes the address to Kube API server's default address and port + replacement: kubernetes.default.svc:443 + - source_labels: [__meta_kubernetes_node_name] + regex: (.+) + target_label: __metrics_path__ + # Changes the default metrics path to kubelet's proxy cadvdisor metrics endpoint + replacement: /api/v1/nodes/$${1}/proxy/metrics/cadvisor + metric_relabel_configs: + # extract readable container/pod name from id field + - action: replace + source_labels: [id] + regex: '^/machine\.slice/machine-rkt\\x2d([^\\]+)\\.+/([^/]+)\.service$' + target_label: rkt_container_name + replacement: '$${2}-$${1}' + - action: replace + source_labels: [id] + regex: '^/system\.slice/(.+)\.service$' + target_label: systemd_service_name + replacement: '$${1}' diff --git a/gitops/components/fluent-bit/kustomization.yaml b/gitops/components/fluent-bit/kustomization.yaml index 7216bb9..efb799f 100644 --- a/gitops/components/fluent-bit/kustomization.yaml +++ b/gitops/components/fluent-bit/kustomization.yaml @@ -18,6 +18,7 @@ patches: path: /spec/destinations/- value: namespace: fluent-bit + server: https://kubernetes.default.svc replacements: - source: diff --git a/gitops/components/fluent-bit/resources.yaml b/gitops/components/fluent-bit/resources.yaml index c5b9731..8534191 100644 --- a/gitops/components/fluent-bit/resources.yaml +++ b/gitops/components/fluent-bit/resources.yaml @@ -42,7 +42,6 @@ spec: [OUTPUT] name loki host loki.loki.svc.cluster.local - tenant_id b87173c0-e9fc-4209-8896-a93dfd073adb match * labels job=fluentbit auto_kubernetes_labels on