Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: DotnetWindowsInjector #1

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/draft-image-release-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ version-resolver:
template: |
$CHANGES

**Full Changelog**: https://github.com/newrelic/k8s-agents-operator/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
**Full Changelog**: https://github.com/newrelic-experimental/k8s-agents-operator-windows/compare/$PREVIOUS_TAG...v$RESOLVED_VERSION
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ jobs:
run: |
make test

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: ./tmp/cover.out
# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# with:
# files: ./tmp/cover.out

e2e-tests:
name: E2E tests
Expand Down Expand Up @@ -154,8 +154,7 @@ jobs:
id: metadata
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: |
newrelic/k8s-agents-operator
images: ghcr.io/${{ github.repository_owner }}/k8s-agents-operator-windows
tags: |
# reflects the last commit of the active branch
type=edge
Expand All @@ -166,12 +165,13 @@ jobs:
# push tag event
type=semver,pattern={{major}}.{{minor}}

- name: Login to Docker Hub
- name: Login to GitHub Package Registry
if: github.event_name != 'pull_request' && !startsWith(github.ref, 'refs/heads/renovate')
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
uses: docker/login-action@v3
with:
username: ${{ secrets.K8S_AGENTS_DOCKERHUB_USERNAME }}
password: ${{ secrets.K8S_AGENTS_DOCKERHUB_TOKEN }}
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.K8S_AGENTS_GHCR_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3.7.1
Expand Down
106 changes: 106 additions & 0 deletions .github/workflows/publish-newrelic-instrumentation-dotnet-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: "Publish Dotnet Newrelic-Instrumentation for Windows"

on:
push:
paths:
- 'src/apm/dotnet_windows/**'
- '.github/workflows/publish-newrelic-instrumentation-dotnet-windows.yml'
branches:
- main
pull_request:
paths:
- 'src/apm/dotnet_windows/**'
- '.github/workflows/publish-newrelic-instrumentation-dotnet-windows.yml'
workflow_dispatch:

jobs:
read-version:
name: Read Version
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.get_version.outputs.VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Read version
id: get_version
run: |
VERSION=$(cat src/apm/dotnet_windows/version.txt)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT

build-publish-containers:
name: Build and Publish Containers
runs-on: ${{ matrix.os }}
needs: read-version
strategy:
max-parallel: 2
matrix:
os: [windows-2019, windows-2022]
include:
- os: windows-2019
base: ltsc2019
file: src/apm/dotnet_windows/Dockerfile.windows
tag: ghcr.io/${{ github.repository_owner }}/k8s-agents-operator-windows/newrelic-dotnet-init-windows-ltsc2019-amd64:${{ needs.read-version.outputs.VERSION }}
- os: windows-2022
base: ltsc2022
file: src/apm/dotnet_windows/Dockerfile.windows
tag: ghcr.io/${{ github.repository_owner }}/k8s-agents-operator-windows/newrelic-dotnet-init-windows-ltsc2022-amd64:${{ needs.read-version.outputs.VERSION }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Login to GitHub Package Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.K8S_AGENTS_GHCR_TOKEN }}

- name: Build and Push Docker image
run: |
docker build -f ${{ matrix.file }} --build-arg BASE=${{ matrix.base }} --build-arg VERSION=${{ needs.read-version.outputs.VERSION }} -t ${{ matrix.tag }} .
docker push ${{ matrix.tag }}

publish-manifest:
name: Publish Manifest
runs-on: ubuntu-latest
needs: build-publish-containers
steps:
- name: Checkout
uses: actions/checkout@v3

# Redundant GITHUB_OUTPUT will not propigate to this job
- name: Read version
id: get_version
run: |
VERSION=$(cat src/apm/dotnet_windows/version.txt)
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Login to GitHub Package Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.K8S_AGENTS_GHCR_TOKEN }}

- name: Docker Manifest
run: |
docker manifest create ghcr.io/${{ github.repository_owner }}/k8s-agents-operator-windows/newrelic-dotnet-init-windows:${{ env.VERSION }} \
--amend ghcr.io/${{ github.repository_owner }}/k8s-agents-operator-windows/newrelic-dotnet-init-windows-ltsc2019-amd64:${{ env.VERSION }} \
--amend ghcr.io/${{ github.repository_owner }}/k8s-agents-operator-windows/newrelic-dotnet-init-windows-ltsc2022-amd64:${{ env.VERSION }}

- name: Docker Annotate
run: |
docker manifest annotate --os windows --arch amd64 \
--os-version "10.0.17763.6414" \
ghcr.io/${{ github.repository_owner }}/k8s-agents-operator-windows/newrelic-dotnet-init-windows:${{ env.VERSION }} ghcr.io/${{ github.repository_owner }}/k8s-agents-operator-windows/newrelic-dotnet-init-windows-ltsc2019-amd64:${{ env.VERSION }}

docker manifest annotate --os windows --arch amd64 \
--os-version "10.0.20348.2762" \
ghcr.io/${{ github.repository_owner }}/k8s-agents-operator-windows/newrelic-dotnet-init-windows:${{ env.VERSION }} ghcr.io/${{ github.repository_owner }}/k8s-agents-operator-windows/newrelic-dotnet-init-windows-ltsc2022-amd64:${{ env.VERSION }}

- name: Docker Push Manifest
run: |
docker manifest push ghcr.io/${{ github.repository_owner }}/k8s-agents-operator-windows/newrelic-dotnet-init-windows:${{ env.VERSION }}
4 changes: 2 additions & 2 deletions charts/k8s-agents-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ dependencies:
version: 1.3.0
repository: "https://helm-charts.newrelic.com"
appVersion: '0.16.1'
home: https://github.com/newrelic/k8s-agents-operator/blob/main/charts/k8s-agents-operator/README.md
home: https://github.com/newrelic-experimental/k8s-agents-operator-windows/blob/main/charts/k8s-agents-operator/README.md
sources:
- https://github.com/newrelic/k8s-agents-operator
- https://github.com/newrelic-experimental/k8s-agents-operator-windows
maintainers:
- name: csongnr
url: https://github.com/csongnr
Expand Down
27 changes: 20 additions & 7 deletions charts/k8s-agents-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

A Helm chart for the Kubernetes Agents Operator

**Homepage:** <https://github.com/newrelic/k8s-agents-operator/blob/main/charts/k8s-agents-operator/README.md>
**Homepage:** <https://github.com/newrelic-experimental/k8s-agents-operator-windows/blob/main/charts/k8s-agents-operator/README.md>

## Prerequisites

Expand All @@ -14,16 +14,16 @@ A Helm chart for the Kubernetes Agents Operator

### Requirements

Add the `k8s-agents-operator` Helm chart repository:
Add the `k8s-agents-operator-windows` Helm chart repository:
```shell
helm repo add k8s-agents-operator https://newrelic.github.io/k8s-agents-operator
helm repo add k8s-agents-operator-windows https://newrelic-experimental.github.io/k8s-agents-operator-windows/
```

### Instrumentation

Install the [`k8s-agents-operator`](https://github.com/newrelic/k8s-agents-operator) Helm chart:
Install the [`k8s-agents-operator`](https://github.com/newrelic-experimental/k8s-agents-operator-windows) Helm chart:
```shell
helm upgrade --install k8s-agents-operator k8s-agents-operator/k8s-agents-operator \
helm upgrade --install k8s-agents-operator-windows k8s-agents-operator-windows/k8s-agents-operator \
--namespace newrelic \
--create-namespace \
--values your-custom-values.yaml
Expand Down Expand Up @@ -55,6 +55,19 @@ spec:
image: newrelic/newrelic-dotnet-init:latest
# env: ...
```
For .NET on Windows

```yaml
apiVersion: newrelic.com/v1alpha2
kind: Instrumentation
metadata:
name: newrelic-instrumentation-dotnet-windows
spec:
agent:
language: dotnet-windows
image: ghrc.io/andrew-lozoya/newrelic-dotnet-windows-init:10.32.0
# env: ...
```

For Java

Expand Down Expand Up @@ -215,11 +228,11 @@ To see the available charts:
helm search repo k8s-agents-operator
```

If you want to see a list of all available charts and releases, check [index.yaml](https://newrelic.github.io/k8s-agents-operator/index.yaml).
If you want to see a list of all available charts and releases, check [index.yaml](https://newrelic-experimental.github.io/k8s-agents-operator-windows/index.yaml).

## Source Code

* <https://github.com/newrelic/k8s-agents-operator>
* <https://github.com/newrelic-experimental/k8s-agents-operator-windows>

## Requirements

Expand Down
24 changes: 19 additions & 5 deletions charts/k8s-agents-operator/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@

### Requirements

Add the `k8s-agents-operator` Helm chart repository:
Add the `k8s-agents-operator-windows` Helm chart repository:
```shell
helm repo add k8s-agents-operator https://newrelic.github.io/k8s-agents-operator
helm repo add k8s-agents-operator-windows https://newrelic-experimental.github.io/k8s-agents-operator-windows/
```

### Instrumentation

Install the [`k8s-agents-operator`](https://github.com/newrelic/k8s-agents-operator) Helm chart:
Install the [`k8s-agents-operator`](https://github.com/newrelic-experimental/k8s-agents-operator-windows) Helm chart:
```shell
helm upgrade --install k8s-agents-operator k8s-agents-operator/k8s-agents-operator \
helm upgrade --install k8s-agents-operator-windows k8s-agents-operator-windows/k8s-agents-operator \
--namespace newrelic \
--create-namespace \
--values your-custom-values.yaml
Expand Down Expand Up @@ -58,6 +58,20 @@ spec:
# env: ...
```

For .NET on Windows

```yaml
apiVersion: newrelic.com/v1alpha2
kind: Instrumentation
metadata:
name: newrelic-instrumentation-dotnet-windows
spec:
agent:
language: dotnet-windows
image: ghrc.io/andrew-lozoya/newrelic-dotnet-windows-init:10.32.0
# env: ...
```

For Java

```yaml
Expand Down Expand Up @@ -217,7 +231,7 @@ To see the available charts:
helm search repo k8s-agents-operator
```

If you want to see a list of all available charts and releases, check [index.yaml](https://newrelic.github.io/k8s-agents-operator/index.yaml).
If you want to see a list of all available charts and releases, check [index.yaml](https://newrelic-experimental.github.io/k8s-agents-operator-windows/index.yaml).

{{ template "chart.sourcesSection" . }}

Expand Down
2 changes: 1 addition & 1 deletion charts/k8s-agents-operator/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ kubectl get deployments -o wide -w --namespace {{ .Release.Namespace }} {{ inclu
WARNING: This deployment will be incomplete until you configure your Instrumentation custom resource definition.
=====================================

Please visit https://github.com/newrelic/k8s-agents-operator for instructions on how to create & configure the
Please visit https://github.com/newrelic-experimental/k8s-agents-operator-windows for instructions on how to create & configure the
Instrumentation custom resource definition required by the Operator.
{{- else }}

Expand Down
7 changes: 7 additions & 0 deletions charts/k8s-agents-operator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ Returns if the template should render, it checks if the required values are set.
{{- $licenseKey := include "newrelic.common.license._licenseKey" . -}}
{{- and (or $licenseKey)}}
{{- end -}}
{{/*
Create a node selector for Linux nodes
*/}}
{{- define "linux.nodeSelector" -}}
nodeSelector:
kubernetes.io/os: linux
{{- end -}}
1 change: 1 addition & 0 deletions charts/k8s-agents-operator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ spec:
control-plane: controller-manager
{{- include "newrelic.common.labels" . | nindent 8 }}
spec:
{{ include "linux.nodeSelector" . | nindent 6 }}
containers:
- args:
- --metrics-addr=127.0.0.1:8080
Expand Down
4 changes: 2 additions & 2 deletions charts/k8s-agents-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ controllerManager:

manager:
image:
repository: newrelic/k8s-agents-operator
tag:
repository: ghcr.io/newrelic-experimental/k8s-agents-operator-windows
tag: edge
pullPolicy:
resources:
requests:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/newrelic/k8s-agents-operator
module github.com/newrelic-experimental/k8s-agents-operator-windows

go 1.23.2

Expand Down
2 changes: 1 addition & 1 deletion src/apm/dotnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

corev1 "k8s.io/api/core/v1"

"github.com/newrelic/k8s-agents-operator/src/api/v1alpha2"
"github.com/newrelic-experimental/k8s-agents-operator-windows/src/api/v1alpha2"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion src/apm/dotnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"

"github.com/newrelic/k8s-agents-operator/src/api/v1alpha2"
"github.com/newrelic-experimental/k8s-agents-operator-windows/src/api/v1alpha2"
)

func TestDotnetInjector_Language(t *testing.T) {
Expand Down
14 changes: 14 additions & 0 deletions src/apm/dotnet_windows/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use the Windows Nano Server as the base image
ARG BASE
FROM mcr.microsoft.com/windows/nanoserver:${BASE}

# Argument to specify the version of the New Relic agent
ARG VERSION

# Set the working directory
WORKDIR C:\\instrumentation

# Download and extract the New Relic .NET agent
RUN curl.exe -L -o newrelic-agent.zip https://download.newrelic.com/dot_net_agent/latest_release/NewRelicDotNetAgent_%VERSION%_x64.zip\
&& tar.exe -xzf newrelic-agent.zip\
&& del newrelic-agent.zip
1 change: 1 addition & 0 deletions src/apm/dotnet_windows/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
10.32.0
Loading
Loading