Skip to content

Commit 6b0c316

Browse files
dineshg13jackgopack4
authored andcommitted
Add deploy files
1 parent 7ada9ad commit 6b0c316

File tree

6 files changed

+597
-0
lines changed

6 files changed

+597
-0
lines changed

.gitlab-ci.yml

+205
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
# ENV VARS
2+
variables:
3+
CI_IMAGE: registry.ddbuild.io/ci/opentelemetry-collector-contrib:ci-image-2
4+
BUILD_DD_REGISTRY: registry.ddbuild.io/ci/opentelemetry-collector-contrib
5+
BUILD_DEMO_REGISTRY: 172597598159.dkr.ecr.us-east-1.amazonaws.com/otel-collector-contrib
6+
BUILD_SANDBOX_REGISTRY: 601427279990.dkr.ecr.us-east-1.amazonaws.com/otel-collector-contrib
7+
SANDBOX_CLUSTER_NAME: dd-otel
8+
DEMO_CLUSTER_NAME: prod-eks-otel-a-us-east-1
9+
SANDBOX_CLUSTER_ARN: "arn:aws:eks:us-east-1:601427279990:cluster/dd-otel"
10+
DEMO_CLUSTER_ARN: "arn:aws:eks:us-east-1:172597598159:cluster/prod-eks-otel-a-us-east-1"
11+
DEPLOY_SCRIPT: "./ci/scripts/ci-deploy.sh"
12+
# To use images from test-infra-definitions dev branches, set the SUFFIX variable to -dev
13+
# and check the job creating the image to make sure you have the right SHA prefix
14+
TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX: ""
15+
# Make sure to update test-infra-definitions version in go.mod as well
16+
TEST_INFRA_DEFINITIONS_BUILDIMAGES: b02a714d7de7
17+
18+
19+
# BUILD STAGES
20+
stages:
21+
- build-and-push-ci-image
22+
- build-collector-image
23+
- push-collector-image
24+
- e2e
25+
- staging-deploy
26+
- prod-deploy
27+
28+
# BUILD IMAGES
29+
build-ci-image:
30+
stage: build-and-push-ci-image
31+
tags: ["runner:docker"]
32+
image: $CI_IMAGE
33+
script:
34+
- TAG=ci-image-2
35+
- docker build --file ci/Dockerfile.gitlab --tag $BUILD_DD_REGISTRY:$TAG .
36+
- docker push $BUILD_DD_REGISTRY:$TAG
37+
38+
.build-collector-image: &build-collector-image
39+
stage: build-collector-image
40+
tags: ["runner:docker"]
41+
image: $CI_IMAGE
42+
script:
43+
- IMAGE_TAG_PREFIX=otelcolcontrib
44+
- TAG="$IMAGE_TAG_PREFIX-v$CI_COMMIT_SHORT_SHA"
45+
- docker build --file ci/Dockerfile --tag $BUILD_REGISTRY:$TAG --label target=staging .
46+
- docker push $BUILD_REGISTRY:$TAG
47+
build-collector-image-main:
48+
!!merge <<: *build-collector-image
49+
variables:
50+
BUILD_REGISTRY: $BUILD_DD_REGISTRY
51+
52+
# PUSH IMAGES
53+
.push-collector-image: &push-collector-image
54+
stage: push-collector-image
55+
tags: ["runner:docker"]
56+
image: $CI_IMAGE
57+
dependencies:
58+
- build-collector-image-main
59+
script:
60+
- IMAGE_TAG_PREFIX=otelcolcontrib
61+
- TAG="$IMAGE_TAG_PREFIX-v$CI_COMMIT_SHORT_SHA"
62+
- docker pull $BUILD_DD_REGISTRY:$TAG
63+
- docker tag $BUILD_DD_REGISTRY:$TAG $BUILD_REGISTRY:$TAG
64+
- docker push $BUILD_REGISTRY:$TAG
65+
push-collector-image-demo:
66+
!!merge <<: *push-collector-image
67+
variables:
68+
BUILD_REGISTRY: $BUILD_DEMO_REGISTRY
69+
push-collector-image-staging:
70+
!!merge <<: *push-collector-image
71+
variables:
72+
BUILD_REGISTRY: $BUILD_SANDBOX_REGISTRY
73+
push-collector-image-agent-qa:
74+
stage: push-collector-image
75+
needs: ['build-collector-image-main']
76+
trigger:
77+
project: DataDog/public-images
78+
branch: main
79+
strategy: depend
80+
variables:
81+
IMG_SOURCES: $BUILD_DD_REGISTRY:otelcolcontrib-v${CI_COMMIT_SHORT_SHA}
82+
IMG_DESTINATIONS: otel-collector-contrib:${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}
83+
IMG_REGISTRIES: agent-qa
84+
85+
# DEPLOY COLLECTOR STAGING
86+
.staging-deploy: &staging-deploy
87+
stage: staging-deploy
88+
tags: ["runner:docker", "size:large"]
89+
image: $CI_IMAGE
90+
dependencies:
91+
- push-collector-image-staging
92+
rules:
93+
- if: '$CI_COMMIT_REF_NAME =~ /-staging$/'
94+
script:
95+
- >-
96+
TEMP_AWS_ACCESS_KEY_ID=$(aws ssm get-parameter --region us-east-1 --name ci.opentelemetry-collector-contrib.sand-eks-deploy-api-key --with-decryption --query Parameter.Value --out text)
97+
- >-
98+
TEMP_AWS_SECRET_ACCESS_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.opentelemetry-collector-contrib.sand-eks-deploy-access-key --with-decryption --query Parameter.Value --out text)
99+
- export AWS_ACCESS_KEY_ID=$TEMP_AWS_ACCESS_KEY_ID
100+
- export AWS_SECRET_ACCESS_KEY=$TEMP_AWS_SECRET_ACCESS_KEY
101+
- bash $DEPLOY_SCRIPT
102+
#env:otel-staging
103+
staging-deploy:
104+
!!merge <<: *staging-deploy
105+
variables:
106+
CLUSTER_NAME: $SANDBOX_CLUSTER_NAME
107+
CLUSTER_ARN: $SANDBOX_CLUSTER_ARN
108+
NAMESPACE: otel-staging
109+
NODE_GROUP: ng-3
110+
MODE: daemonset
111+
REPLICA_COUNT: 1
112+
CLUSTER_ROLE: opentelemetry-collector
113+
REGISTRY: $BUILD_SANDBOX_REGISTRY
114+
115+
#env:otel-gateway
116+
staging-deploy-gateway:
117+
!!merge <<: *staging-deploy
118+
variables:
119+
CLUSTER_NAME: $SANDBOX_CLUSTER_NAME
120+
CLUSTER_ARN: $SANDBOX_CLUSTER_ARN
121+
NAMESPACE: otel-gateway
122+
NODE_GROUP: ng-5
123+
MODE: deployment
124+
REPLICA_COUNT: 3
125+
CLUSTER_ROLE: opentelemetry-collector-gateway
126+
REGISTRY: $BUILD_SANDBOX_REGISTRY
127+
128+
#env:otel-ds-gateway
129+
staging-deploy-ds-gateway:
130+
!!merge <<: *staging-deploy
131+
variables:
132+
CLUSTER_NAME: $SANDBOX_CLUSTER_NAME
133+
CLUSTER_ARN: $SANDBOX_CLUSTER_ARN
134+
NAMESPACE: otel-ds-gateway
135+
NODE_GROUP: ng-6
136+
MODE: deployment
137+
REPLICA_COUNT: 3
138+
CLUSTER_ROLE: opentelemetry-collector-ds-gateway
139+
REGISTRY: $BUILD_SANDBOX_REGISTRY
140+
141+
# DEPLOY COLLECTOR PROD
142+
.prod-deploy: &prod-deploy-demo-eks
143+
stage: prod-deploy
144+
tags: ["runner:docker", "size:large"]
145+
image: $CI_IMAGE
146+
dependencies:
147+
- push-collector-image-demo
148+
rules:
149+
# changing to staging for testing purposes.
150+
- if: '$CI_COMMIT_REF_NAME == "prod"'
151+
script:
152+
- >-
153+
TEMP_AWS_ACCESS_KEY_ID=$(aws ssm get-parameter --region us-east-1 --name ci.opentelemetry-collector-contrib.eks_access_key --with-decryption --query Parameter.Value --out text)
154+
- >-
155+
TEMP_AWS_SECRET_ACCESS_KEY=$(aws ssm get-parameter --region us-east-1 --name ci.opentelemetry-collector-contrib.eks_secret_access_key --with-decryption --query Parameter.Value --out text)
156+
- export AWS_ACCESS_KEY_ID=$TEMP_AWS_ACCESS_KEY_ID
157+
- export AWS_SECRET_ACCESS_KEY=$TEMP_AWS_SECRET_ACCESS_KEY
158+
- bash $DEPLOY_SCRIPT
159+
#env:otel
160+
prod-deploy:
161+
!!merge <<: *prod-deploy-demo-eks
162+
variables:
163+
CLUSTER_NAME: $DEMO_CLUSTER_NAME
164+
CLUSTER_ARN: $DEMO_CLUSTER_ARN
165+
NAMESPACE: otel
166+
NODE_GROUP:
167+
MODE: daemonset
168+
REPLICA_COUNT: 1
169+
CLUSTER_ROLE: opentelemetry-collector
170+
REGISTRY: $BUILD_DEMO_REGISTRY
171+
172+
.new_e2e_template:
173+
stage: e2e
174+
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/test-infra-definitions/runner$TEST_INFRA_DEFINITIONS_BUILDIMAGES_SUFFIX:$TEST_INFRA_DEFINITIONS_BUILDIMAGES
175+
tags: ["arch:amd64"]
176+
before_script:
177+
# Setup AWS Credentials
178+
- mkdir -p ~/.aws
179+
- aws ssm get-parameter --region us-east-1 --name "ci.opentelemetry-collector-contrib.agent-qa-profile" --with-decryption --query "Parameter.Value" --output text >> ~/.aws/config
180+
- export AWS_PROFILE=agent-qa-ci
181+
# Now all `aws` commands target the agent-qa profile
182+
- aws ssm get-parameter --region us-east-1 --name "ci.opentelemetry-collector-contrib.ssh_public_key" --with-decryption --query "Parameter.Value" --output text > $E2E_PUBLIC_KEY_PATH
183+
- touch $E2E_PRIVATE_KEY_PATH && chmod 600 $E2E_PRIVATE_KEY_PATH && aws ssm get-parameter --region us-east-1 --name "ci.opentelemetry-collector-contrib.ssh_private_key" --with-decryption --query "Parameter.Value" --output text > $E2E_PRIVATE_KEY_PATH
184+
# Use S3 backend
185+
- pulumi login "s3://dd-pulumi-state?region=us-east-1&awssdk=v2&profile=$AWS_PROFILE"
186+
variables:
187+
KUBERNETES_MEMORY_REQUEST: 12Gi
188+
KUBERNETES_MEMORY_LIMIT: 16Gi
189+
KUBERNETES_CPU_REQUEST: 6
190+
E2E_PIPELINE_ID: $CI_PIPELINE_ID
191+
E2E_COMMIT_SHORT_SHA: $CI_COMMIT_SHORT_SHA
192+
E2E_PUBLIC_KEY_PATH: /tmp/agent-qa-ssh-key.pub
193+
E2E_PRIVATE_KEY_PATH: /tmp/agent-qa-ssh-key
194+
E2E_KEY_PAIR_NAME: ci.open-telemetry-collector-contrib
195+
E2E_OUTPUT_DIR: $CI_PROJECT_DIR/e2e-output
196+
E2E_PULUMI_VERBOSE_PROGRESS_STREAMS: true
197+
script:
198+
- cd e2e-tests && go test $TARGETS/... -v -timeout 0 --args -docker_secret $(aws ecr get-login-password)
199+
200+
new-e2e-otel-collector:
201+
extends: .new_e2e_template
202+
needs: ['push-collector-image-agent-qa']
203+
variables:
204+
TARGETS: ./tests
205+
TEAM: otel

ci/Dockerfile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM registry.ddbuild.io/images/mirror/golang:1.23 AS build
2+
WORKDIR /src
3+
ADD . /src
4+
RUN make otelcontribcol
5+
6+
FROM 486234852809.dkr.ecr.us-east-1.amazonaws.com/base:focal
7+
USER root
8+
9+
RUN clean-apt install make \
10+
ca-certificates
11+
12+
RUN apt-get update && \
13+
apt-get -y install default-jre-headless
14+
15+
ADD https://github.com/open-telemetry/opentelemetry-java-contrib/releases/download/v1.27.0/opentelemetry-jmx-metrics.jar /opt/opentelemetry-jmx-metrics.jar
16+
17+
COPY --from=build /src/bin/otelcontribcol_* /otelcol-contrib
18+
USER 1001
19+
ENTRYPOINT ["/otelcol-contrib"]
20+
EXPOSE 4317 4318 55680 55679

ci/Dockerfile.gitlab

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:20.10.13
2+
3+
# Install Helm 3
4+
RUN curl https://get.helm.sh/helm-v3.11.2-linux-amd64.tar.gz -o /tmp/helm-v3.11.2-linux-amd64.tar.gz
5+
RUN tar -xzvf /tmp/helm-v3.11.2-linux-amd64.tar.gz
6+
RUN mv linux-amd64/helm /usr/local/bin/helm
7+
8+
# install kubectl
9+
RUN curl -LO "https://dl.k8s.io/v1.26.3/kubernetes-client-linux-arm64.tar.gz"
10+
RUN tar -xvzf kubernetes-client-linux-arm64.tar.gz
11+
RUN install -o root -g root -m 0755 kubernetes/client/bin/kubectl /usr/local/bin/kubectl
12+
13+
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
14+
RUN unzip awscliv2.zip
15+
RUN ./aws/install

ci/scripts/ci-deploy.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright The OpenTelemetry Authors
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
# This script is used to deploy collector on demo account cluster
7+
8+
set -euo pipefail
9+
IFS=$'\n\t'
10+
set -x
11+
12+
namespace=$NAMESPACE
13+
nodegroup=$NODE_GROUP
14+
mode=$MODE
15+
replicaCount=$REPLICA_COUNT
16+
clusterRole=$CLUSTER_ROLE
17+
clusterName=$CLUSTER_NAME
18+
clusterArn=$CLUSTER_ARN
19+
registry=$REGISTRY
20+
21+
install_collector() {
22+
release_name="opentelemetry-collector"
23+
24+
# Add open-telemetry helm repo (if repo already exists, helm 3+ will skip)
25+
helm --debug repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
26+
helm repo update open-telemetry
27+
28+
helm_cmd="helm --debug upgrade ${release_name} -n ${namespace} open-telemetry/opentelemetry-collector --install \
29+
-f ./ci/values.yaml \
30+
--set-string image.repository=${registry} \
31+
--set-string image.tag=otelcolcontrib-v$CI_COMMIT_SHORT_SHA \
32+
--set clusterRole.name=${clusterRole} \
33+
--set clusterRole.clusterRoleBinding.name=${clusterRole} \
34+
--set mode=${mode} \
35+
--set replicaCount=${replicaCount}"
36+
37+
if [ -n "$nodegroup" ]; then
38+
helm_cmd+=" --set nodeSelector.\"alpha\\.eksctl\\.io/nodegroup-name\"=${nodegroup}"
39+
fi
40+
41+
eval $helm_cmd
42+
43+
# only deploy otlp col for otel-ds-gateway
44+
if [ "$namespace" == "otel-ds-gateway" ]; then
45+
install_ds_otlp
46+
fi
47+
}
48+
49+
install_ds_otlp() {
50+
release_name="opentelemetry-collector-ds"
51+
52+
# daemonset with otlp exporter
53+
helm --debug upgrade "${release_name}" -n "${namespace}" open-telemetry/opentelemetry-collector --install \
54+
-f ./ci/values.yaml \
55+
-f ./ci/values-otlp-col.yaml \
56+
--set-string image.tag="otelcolcontrib-v$CI_COMMIT_SHORT_SHA" \
57+
--set-string image.repository=${registry}
58+
}
59+
60+
###########################################################################################################
61+
clusterName="${clusterName}"
62+
clusterArn="${clusterArn}"
63+
64+
aws eks --region us-east-1 update-kubeconfig --name "${clusterName}"
65+
kubectl config use-context "${clusterArn}"
66+
67+
install_collector

ci/values-otlp-col.yaml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
nodeSelector:
2+
alpha.eksctl.io/nodegroup-name: ng-6
3+
clusterRole:
4+
name: "opentelemetry-collector-ds"
5+
clusterRoleBinding:
6+
name: opentelemetry-collector-ds
7+
config:
8+
exporters:
9+
otlp:
10+
endpoint: opentelemetry-collector.otel-ds-gateway.svc.cluster.local:4317
11+
tls:
12+
insecure: true
13+
processors:
14+
k8sattributes:
15+
passthrough: true
16+
auth_type: "serviceAccount"
17+
receivers:
18+
otlp/2:
19+
protocols:
20+
grpc:
21+
endpoint: 0.0.0.0:1234
22+
service:
23+
pipelines:
24+
metrics:
25+
receivers: [otlp]
26+
processors: [k8sattributes, batch]
27+
exporters: [otlp]
28+
traces:
29+
receivers: [otlp]
30+
processors: [k8sattributes, batch]
31+
exporters: [otlp]
32+
# hack to disable this pipeline. otlp/2 does not receive data.
33+
traces/sampled:
34+
receivers: [otlp/2]
35+
processors: []
36+
exporters: [otlp]
37+
logs:
38+
processors: [k8sattributes, batch]
39+
exporters: [otlp]
40+
resources:
41+
limits:
42+
# necessary to decrease memory from 2 to 1 Gi in order to
43+
# have sufficient memory to schedule all pods on Nodes.
44+
memory: 1Gi

0 commit comments

Comments
 (0)