Skip to content

Commit 2f1732d

Browse files
Splunk-otel-collector Dockerfile for windows. (open-telemetry#637)
* Creating an otelcol Dockerfile for windows. * Adding circleci pipeline * Updating documentation for mounting config file * Update docs/getting-started/windows-manual.md Co-authored-by: Jeff Cheng <[email protected]> * Update docs/getting-started/windows-manual.md Co-authored-by: Jeff Cheng <[email protected]> * Updating documentation * Updating circleci to save the image archive Co-authored-by: Jeff Cheng <[email protected]>
1 parent 4f367f5 commit 2f1732d

File tree

4 files changed

+131
-4
lines changed

4 files changed

+131
-4
lines changed

.circleci/config.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ workflows:
8989
- docker-otelcol:
9090
requires:
9191
- cross-compile
92+
- windows-docker-otelcol:
93+
requires:
94+
- cross-compile
9295
- test:
9396
requires:
9497
- setup-environment
@@ -220,6 +223,40 @@ jobs:
220223
root: ~/
221224
paths: project/dist
222225

226+
windows-docker-otelcol:
227+
executor:
228+
name: win/default
229+
shell: powershell.exe
230+
steps:
231+
- attach_to_workspace
232+
- run:
233+
name: Build docker image
234+
command: |
235+
Copy-Item .\bin\otelcol_windows_amd64.exe .\cmd\otelcol\otelcol.exe
236+
docker build -t otelcol-windows --build-arg SMART_AGENT_RELEASE=$((Get-Content internal\buildscripts\packaging\smart-agent-release.txt).TrimStart("v")) -f .\cmd\otelcol\Dockerfile.windows .\cmd\otelcol\
237+
Remove-Item .\cmd\otelcol\otelcol.exe
238+
- run:
239+
name: Run docker image
240+
command: |
241+
docker run -d -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=fake-realm --name otelcol otelcol-windows:latest
242+
Start-Sleep 10
243+
$DockerOutput=$(docker ps --filter=status=running --filter=name=otelcol -q)
244+
if ( $DockerOutput -eq $null )
245+
{
246+
docker logs otelcol
247+
exit 1
248+
}
249+
- run:
250+
name: Save docker image
251+
command: |
252+
New-Item -ItemType Directory -Force -Path dist
253+
docker save -o dist\windows-image.tar otelcol-windows:latest
254+
- persist_to_workspace:
255+
root: ~/
256+
paths: project/dist
257+
- store_artifacts:
258+
path: dist/windows-image.tar
259+
223260
windows-test:
224261
executor:
225262
name: win/default

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ This distribution is supported on and packaged for a variety of platforms includ
120120
- [Installer script (recommended)](./docs/getting-started/windows-installer.md)
121121
- Configuration management
122122
- [Puppet](https://forge.puppet.com/modules/signalfx/splunk_otel_collector)
123-
- [Manual](./docs/getting-started/windows-manual.md) including MSI with GUI and Powershell
123+
- [Manual](./docs/getting-started/windows-manual.md) including MSI with GUI and Powershell, and Docker
124124

125125
You can consult additional use cases in the [examples](./examples) directory.
126126

cmd/otelcol/Dockerfile.windows

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM mcr.microsoft.com/windows/servercore:1809
2+
3+
# Setting PowerShell as a default executor.
4+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
5+
6+
WORKDIR "C:\\Program Files\Splunk\OpenTelemetry Collector"
7+
8+
# Copy the pre-built local binary
9+
COPY otelcol.exe ./
10+
11+
# Copy the local config
12+
WORKDIR "C:\ProgramData\Splunk\OpenTelemetry Collector"
13+
COPY config/collector/gateway_config.yaml ./
14+
COPY config/collector/otlp_config_linux.yaml ./
15+
COPY config/collector/agent_config.yaml ./
16+
COPY config/collector/fargate_config.yaml ./
17+
18+
WORKDIR "C:\\Program Files\Splunk\OpenTelemetry Collector"
19+
ARG SMART_AGENT_RELEASE
20+
21+
# Download and extract the smart agent bundle
22+
RUN Invoke-WebRequest -Uri "https://dl.signalfx.com/windows/release/zip/SignalFxAgent-$env:SMART_AGENT_RELEASE-win64.zip" -Outfile "SignalFxAgent-win64.zip"
23+
RUN Add-Type -AssemblyName System.IO.Compression.FileSystem ;\
24+
[System.IO.Compression.ZipFile]::ExtractToDirectory('SignalFxAgent-win64.zip', '.')
25+
RUN Rename-Item -Path "SignalFxAgent" -NewName "agent-bundle"
26+
27+
# Delete unnecessary files.
28+
RUN Remove-Item "SignalFxAgent-win64.zip" -force
29+
RUN Remove-Item "agent-bundle\bin" -force -Recurse
30+
RUN Remove-Item "agent-bundle\etc" -force -Recurse
31+
RUN Get-ChildItem -include __pycache__ -recurse -force | Remove-Item -force -Recurse
32+
33+
# Setting environment variables
34+
ENV SPLUNK_BUNDLE_DIR="C:\Program Files\Splunk\OpenTelemetry Collector\agent-bundle"
35+
ENV SPLUNK_CONFIG="C:\ProgramData\Splunk\OpenTelemetry Collector\gateway_config.yaml"
36+
# Category ENV_VAR: Forcing interactive mode instead of running as a service.
37+
# Reference - https://github.com/signalfx/splunk-otel-collector/pull/254
38+
ENV NO_WINDOWS_SERVICE="1"
39+
40+
ENTRYPOINT [ "otelcol.exe" ]
41+
EXPOSE 13133 14250 14268 4317 6060 8888 9411 9443 9080

docs/getting-started/windows-manual.md

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
# Windows Manual
22

3+
The following deployment options are supported:
4+
5+
- [MSI](#msi-installation)
6+
- [Docker](#docker)
7+
8+
## Getting Started
9+
10+
All installation methods offer [default
11+
configurations](https://github.com/signalfx/splunk-otel-collector/blob/main/cmd/otelcol/config/collector)
12+
which can be configured via environment variables. How these variables are
13+
configured depends on the installation method leveraged.
14+
15+
### MSI Installation
16+
317
A Windows MSI package (64-bit only) is available to download at
418
[https://github.com/signalfx/splunk-otel-collector/releases
519
](https://github.com/signalfx/splunk-otel-collector/releases).
620

7-
## Installation
8-
921
The collector will be installed to
1022
`\Program Files\Splunk\OpenTelemetry Collector`, and the
1123
`splunk-otel-collector` service will be created but not started.
@@ -30,7 +42,7 @@ PS> Start-Process -Wait msiexec "/i PATH_TO_MSI /qn"
3042
Replace `PATH_TO_MSI` with the *full* path to the downloaded package, e.g.
3143
`C:\your\download\folder\splunk-otel-collector-0.4.0-amd64.msi`.
3244

33-
## Configuration
45+
### Configuration
3446

3547
Before starting the `splunk-otel-collector` service, the following variables
3648
in the default config file need to be replaced by the appropriate values for
@@ -72,3 +84,40 @@ Start-Service splunk-otel-collector
7284
```
7385

7486
The collector logs and errors can be viewed in the Windows Event Viewer.
87+
88+
### Docker
89+
90+
Deploy the latest Docker image:
91+
92+
```bash
93+
$ docker run --rm -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=us0 `
94+
-p 13133:13133 -p 14250:14250 -p 14268:14268 -p 4317:4317 -p 6060:6060 `
95+
-p 8888:8888 -p 9080:9080 -p 9411:9411 -p 9943:9943 `
96+
--name=otelcol quay.io/signalfx/splunk-otel-collector-windows:latest
97+
```
98+
### Custom Configuration
99+
100+
If using a custom configuration file, you will need to mount the directory containing the file and either use the `SPLUNK_CONFIG=<path>` environment variable or the `--config=<path>` command line argument (replace `<path>` with the path to the custom file within the container).
101+
102+
Example with `SPLUNK_CONFIG`:
103+
104+
```bash
105+
$ docker run --rm -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=us0 `
106+
-e SPLUNK_CONFIG=c:\splunk_config\gateway_config.yaml -p 13133:13133 `
107+
-p 14250:14250 -p 14268:14268 -p 4317:4317 -p 6060:6060 -p 8888:8888 -p 9080:9080 `
108+
-p 9411:9411 -p 9943:9943 -v ${PWD}\splunk_config:c:\splunk_config:RO `
109+
--name otelcol quay.io/signalfx/splunk-otel-collector-windows:latest
110+
```
111+
112+
Example with `--config`:
113+
114+
```bash
115+
$ docker run --rm -e SPLUNK_ACCESS_TOKEN=12345 -e SPLUNK_REALM=us0 `
116+
-p 13133:13133 -p 14250:14250 -p 14268:14268 -p 4317:4317 -p 6060:6060 `
117+
-p 8888:8888 -p 9080:9080 -p 9411:9411 -p 9943:9943 `
118+
-v ${PWD}\splunk_config:c:\splunk_config:RO `
119+
--name otelcol quay.io/signalfx/splunk-otel-collector-windows:latest `
120+
--config c:\splunk_config\gateway_config.yaml
121+
```
122+
123+
> For mounting configuration files on a windows container, we have to specify a directory name in which the configuration file is present. because just like Linux containers we can not mount files to containers.

0 commit comments

Comments
 (0)