Skip to content
Open
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
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,20 @@ jobs:
matrix:
# Latest patch version can be found in https://github.com/kubernetes/website/blob/main/content/en/releases/patch-releases.md
# Some versions might not be available yet in https://storage.googleapis.com/kubernetes-release/release/v1.X.Y/bin/linux/amd64/kubelet
k8sVersion: [ "v1.34.0", "v1.33.4", "v1.32.8", "v1.31.12", "v1.30.14", "v1.29.15", "v1.28.15", "v1.31.1", "v1.30.5", "v1.29.9", "v1.28.14", "v1.27.16", "v1.26.15" ]
k8sVersion: [ "v1.34.1", "v1.33.5", "v1.32.9", "v1.31.13", "v1.30.14", "v1.33.4", "v1.32.8", "v1.31.12", "v1.29.15" ]
steps:
- name: Checkout GitHub Repository
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1

- name: Download minikube
run: |
if test "${{ matrix.k8sVersion }}" == "v1.33.4" || test "${{ matrix.k8sVersion }}" == "v1.32.8" || test "${{ matrix.k8sVersion }}" == "v1.31.12" || test "${{ matrix.k8sVersion }}" == "v1.29.15"; then exit 0; fi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this unnecessary since the matrix doesn't have these versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'm a bit disappointed in the github api. I should have permission to remove them (they're required actions), but they are not visible to me unless I add them, but even if I remove the requirement later it doesn't fix the issue. It's hacky, but I don't have another solution.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tried through the UI? I can show you how to change the required ones.

image

curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube && rm minikube-linux-amd64

- name: Run E2E tests
run: |
if test "${{ matrix.k8sVersion }}" == "v1.33.4" || test "${{ matrix.k8sVersion }}" == "v1.32.8" || test "${{ matrix.k8sVersion }}" == "v1.31.12" || test "${{ matrix.k8sVersion }}" == "v1.29.15"; then exit 0; fi
cd tests/e2e
./e2e-tests.sh --k8s_version ${{ matrix.k8sVersion }} --license_key ${{ secrets.K8S_AGENTS_E2E_LICENSE_KEY }} --run_tests

Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ BIN_DIR = ./bin
TMP_DIR = $(shell pwd)/tmp

LICENSE_KEY ?= fake-abc123
E2E_K8S_VERSION ?= v1.33.0
ALL_E2E_K8S_VERSIONS ?= v1.33.0 v1.32.0 v1.31.1 v1.30.5 v1.29.9 v1.28.14 v1.27.16 v1.26.15
E2E_K8S_VERSION ?= v1.34.1
ALL_E2E_K8S_VERSIONS ?= v1.34.1 v1.33.5 v1.32.9 v1.31.13 v1.30.14

K8S_AGENTS_OPERATOR_VERSION = ""

.DEFAULT_GOAL := help

# Go packages to test
TEST_PACKAGES = ./api/v1beta2 \
TEST_PACKAGES = ./api/v1beta3 \
./api/v1beta2 \
./api/v1beta1 \
./api/v1alpha2 \
./internal/apm \
Expand All @@ -24,7 +25,8 @@ TEST_PACKAGES = ./api/v1beta2 \
./internal/migrate/upgrade \
./internal/version \
./internal/webhook \
./internal/util
./internal/util \
./cmd

## Tool Versions
SETUP_ENVTEST ?= $(LOCALBIN)/setup-envtest
Expand All @@ -39,8 +41,8 @@ HELM_UNITTEST ?= $(LOCALBIN)/helm-unittest
GOIMPORTS ?= $(LOCALBIN)/goimports

# Kubebuilder variables
SETUP_ENVTEST_K8S_VERSION ?= 1.34.0
ALL_SETUP_ENVTEST_K8S_VERSIONS ?= 1.34.0 1.33.0 1.32.0 1.31.0 1.30.3 1.29.5 1.28.3 1.27.1 1.26.1 #https://raw.githubusercontent.com/kubernetes-sigs/controller-tools/master/envtest-releases.yaml
SETUP_ENVTEST_K8S_VERSION ?= 1.34.1
ALL_SETUP_ENVTEST_K8S_VERSIONS ?= 1.34.1 1.33.0 1.32.0 1.31.0 1.30.3 #curl https://raw.githubusercontent.com/kubernetes-sigs/controller-tools/master/envtest-releases.yaml | yq '.releases|keys' | sort

# controller-gen crd options
CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true"
Expand Down
41 changes: 37 additions & 4 deletions api/current/current.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package current

import currentapi "github.com/newrelic/k8s-agents-operator/api/v1beta2"
import currentapi "github.com/newrelic/k8s-agents-operator/api/v1beta3"

type (
Agent = currentapi.Agent
Expand All @@ -22,13 +22,46 @@ type (
ImageSelectorOperator = currentapi.ImageSelectorOperator
NameSelectorOperator = currentapi.NameSelectorOperator

ImageSelectorKey = currentapi.ImageSelectorKey
NameSelectorKey = currentapi.NameSelectorKey

EnvSelectorRequirement = currentapi.EnvSelectorRequirement
ImageSelectorRequirement = currentapi.ImageSelectorRequirement
NameSelectorRequirement = currentapi.NameSelectorRequirement
)

var (
AddToScheme = currentapi.AddToScheme
GroupVersion = currentapi.GroupVersion
SchemeBuilder = currentapi.SchemeBuilder
AddToScheme = currentapi.AddToScheme
GroupVersion = currentapi.GroupVersion
SchemeBuilder = currentapi.SchemeBuilder
SetupWebhookWithManager = currentapi.SetupWebhookWithManager

EnvSelectorOpIn = currentapi.EnvSelectorOpIn
EnvSelectorOpNotIn = currentapi.EnvSelectorOpNotIn
EnvSelectorOpEquals = currentapi.EnvSelectorOpEquals
EnvSelectorOpNotEquals = currentapi.EnvSelectorOpNotEquals
EnvSelectorOpExists = currentapi.EnvSelectorOpExists
EnvSelectorOpDoesNotExist = currentapi.EnvSelectorOpDoesNotExist

NameSelectorKeyInitContainer = currentapi.NameSelectorKeyInitContainer
NameSelectorKeyContainer = currentapi.NameSelectorKeyContainer
NameSelectorKeyAnyContainer = currentapi.NameSelectorKeyAnyContainer

NameSelectorOpEquals = currentapi.NameSelectorOpEquals
NameSelectorOpNotEquals = currentapi.NameSelectorOpNotEquals
NameSelectorOpIn = currentapi.NameSelectorOpIn
NameSelectorOpNotIn = currentapi.NameSelectorOpNotIn

ImageSelectorKeyUrl = currentapi.ImageSelectorKeyUrl

ImageSelectorOpEquals = currentapi.ImageSelectorOpEquals
ImageSelectorOpNotEquals = currentapi.ImageSelectorOpNotEquals
ImageSelectorOpIn = currentapi.ImageSelectorOpIn
ImageSelectorOpNotIn = currentapi.ImageSelectorOpNotIn
ImageSelectorOpStartsWith = currentapi.ImageSelectorOpStartsWith
ImageSelectorOpNotStartsWith = currentapi.ImageSelectorOpNotStartsWith
ImageSelectorOpEndsWith = currentapi.ImageSelectorOpEndsWith
ImageSelectorOpNotEndsWith = currentapi.ImageSelectorOpNotEndsWith
ImageSelectorOpContains = currentapi.ImageSelectorOpContains
ImageSelectorOpNotContains = currentapi.ImageSelectorOpNotContains
)
152 changes: 150 additions & 2 deletions api/v1beta2/instrumentation_conversion.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,152 @@
package v1beta2

// Hub marks this type as a conversion hub.
func (*Instrumentation) Hub() {}
import (
"github.com/newrelic/k8s-agents-operator/api/current"
"sigs.k8s.io/controller-runtime/pkg/conversion"
)

// ConvertTo converts this Instrumentation to the Hub version.
func (src *Instrumentation) ConvertTo(dstRaw conversion.Hub) error {
dst := dstRaw.(*current.Instrumentation)

// ObjectMeta
dst.ObjectMeta = src.ObjectMeta

for _, srcExpr := range src.Spec.ContainerSelector.ImageSelector.MatchExpressions {
dst.Spec.ContainerSelector.ImageSelector.MatchExpressions = append(dst.Spec.ContainerSelector.ImageSelector.MatchExpressions, current.ImageSelectorRequirement{
Key: current.ImageSelectorKey(srcExpr.Key), Operator: current.ImageSelectorOperator(srcExpr.Operator), Values: srcExpr.Values,
})
}
for _, srcExpr := range src.Spec.ContainerSelector.EnvSelector.MatchExpressions {
dst.Spec.ContainerSelector.EnvSelector.MatchExpressions = append(dst.Spec.ContainerSelector.EnvSelector.MatchExpressions, current.EnvSelectorRequirement{
Key: srcExpr.Key, Operator: current.EnvSelectorOperator(srcExpr.Operator), Values: srcExpr.Values,
})
}
for _, srcExpr := range src.Spec.ContainerSelector.NameSelector.MatchExpressions {
dst.Spec.ContainerSelector.NameSelector.MatchExpressions = append(dst.Spec.ContainerSelector.NameSelector.MatchExpressions, current.NameSelectorRequirement{
Key: current.NameSelectorKey(srcExpr.Key), Operator: current.NameSelectorOperator(srcExpr.Operator), Values: srcExpr.Values,
})
}

dst.Spec.ContainerSelector.ImageSelector.MatchImages = src.Spec.ContainerSelector.ImageSelector.MatchImages
dst.Spec.ContainerSelector.EnvSelector.MatchEnvs = src.Spec.ContainerSelector.EnvSelector.MatchEnvs
dst.Spec.ContainerSelector.NameSelector.MatchNames = src.Spec.ContainerSelector.NameSelector.MatchNames
dst.Spec.ContainerSelector.NamesFromPodAnnotation = src.Spec.ContainerSelector.NamesFromPodAnnotation

dst.Spec.PodLabelSelector = src.Spec.PodLabelSelector
dst.Spec.NamespaceLabelSelector = src.Spec.NamespaceLabelSelector
dst.Spec.LicenseKeySecret = src.Spec.LicenseKeySecret
dst.Spec.AgentConfigMap = src.Spec.AgentConfigMap
dst.Spec.Agent = current.Agent{
Language: src.Spec.Agent.Language,
Image: src.Spec.Agent.Image,
VolumeSizeLimit: src.Spec.Agent.VolumeSizeLimit,
Env: src.Spec.Agent.Env,
Resources: src.Spec.Agent.Resources,
ImagePullPolicy: src.Spec.Agent.ImagePullPolicy,
SecurityContext: src.Spec.Agent.SecurityContext,
}
dst.Spec.HealthAgent = current.HealthAgent{
Image: src.Spec.HealthAgent.Image,
Env: src.Spec.HealthAgent.Env,
ImagePullPolicy: src.Spec.HealthAgent.ImagePullPolicy,
SecurityContext: src.Spec.HealthAgent.SecurityContext,
Resources: src.Spec.HealthAgent.Resources,
}
var unhealthyPodErrors []current.UnhealthyPodError
if l := len(src.Status.UnhealthyPodsErrors); l > 0 {
unhealthyPodErrors = make([]current.UnhealthyPodError, l)
for i, e := range src.Status.UnhealthyPodsErrors {
unhealthyPodErrors[i] = current.UnhealthyPodError{
Pod: e.Pod,
LastError: e.LastError,
}
}
}
dst.Status = current.InstrumentationStatus{
PodsMatching: src.Status.PodsMatching,
PodsUnhealthy: src.Status.PodsUnhealthy,
PodsHealthy: src.Status.PodsHealthy,
PodsInjected: src.Status.PodsInjected,
PodsOutdated: src.Status.PodsOutdated,
PodsNotReady: src.Status.PodsNotReady,
UnhealthyPodsErrors: unhealthyPodErrors,
LastUpdated: src.Status.LastUpdated,
ObservedVersion: src.Status.ObservedVersion,
}
return nil
}

// ConvertFrom converts from the Hub version to this version.
func (dst *Instrumentation) ConvertFrom(srcRaw conversion.Hub) error {
src := srcRaw.(*current.Instrumentation)

// ObjectMeta
dst.ObjectMeta = src.ObjectMeta

// Spec

for _, srcExpr := range src.Spec.ContainerSelector.ImageSelector.MatchExpressions {
dst.Spec.ContainerSelector.ImageSelector.MatchExpressions = append(dst.Spec.ContainerSelector.ImageSelector.MatchExpressions, ImageSelectorRequirement{
Key: ImageSelectorKey(srcExpr.Key), Operator: ImageSelectorOperator(srcExpr.Operator), Values: srcExpr.Values,
})
}
for _, srcExpr := range src.Spec.ContainerSelector.EnvSelector.MatchExpressions {
dst.Spec.ContainerSelector.EnvSelector.MatchExpressions = append(dst.Spec.ContainerSelector.EnvSelector.MatchExpressions, EnvSelectorRequirement{
Key: srcExpr.Key, Operator: EnvSelectorOperator(srcExpr.Operator), Values: srcExpr.Values,
})
}
for _, srcExpr := range src.Spec.ContainerSelector.NameSelector.MatchExpressions {
dst.Spec.ContainerSelector.NameSelector.MatchExpressions = append(dst.Spec.ContainerSelector.NameSelector.MatchExpressions, NameSelectorRequirement{
Key: NameSelectorKey(srcExpr.Key), Operator: NameSelectorOperator(srcExpr.Operator), Values: srcExpr.Values,
})
}

dst.Spec.ContainerSelector.ImageSelector.MatchImages = src.Spec.ContainerSelector.ImageSelector.MatchImages
dst.Spec.ContainerSelector.EnvSelector.MatchEnvs = src.Spec.ContainerSelector.EnvSelector.MatchEnvs
dst.Spec.ContainerSelector.NameSelector.MatchNames = src.Spec.ContainerSelector.NameSelector.MatchNames
dst.Spec.ContainerSelector.NamesFromPodAnnotation = src.Spec.ContainerSelector.NamesFromPodAnnotation

dst.Spec.PodLabelSelector = src.Spec.PodLabelSelector
dst.Spec.NamespaceLabelSelector = src.Spec.NamespaceLabelSelector
dst.Spec.LicenseKeySecret = src.Spec.LicenseKeySecret
dst.Spec.Agent = Agent{
Env: src.Spec.Agent.Env,
Image: src.Spec.Agent.Image,
ImagePullPolicy: src.Spec.Agent.ImagePullPolicy,
Language: src.Spec.Agent.Language,
Resources: src.Spec.Agent.Resources,
SecurityContext: src.Spec.Agent.SecurityContext,
VolumeSizeLimit: src.Spec.Agent.VolumeSizeLimit,
}
dst.Spec.HealthAgent = HealthAgent{
Env: src.Spec.HealthAgent.Env,
Image: src.Spec.HealthAgent.Image,
ImagePullPolicy: src.Spec.HealthAgent.ImagePullPolicy,
Resources: src.Spec.HealthAgent.Resources,
SecurityContext: src.Spec.HealthAgent.SecurityContext,
}
dst.Spec.AgentConfigMap = src.Spec.AgentConfigMap
var unhealthyPodErrors []UnhealthyPodError
if l := len(src.Status.UnhealthyPodsErrors); l > 0 {
unhealthyPodErrors = make([]UnhealthyPodError, l)
for i, e := range src.Status.UnhealthyPodsErrors {
unhealthyPodErrors[i] = UnhealthyPodError{
Pod: e.Pod,
LastError: e.LastError,
}
}
}
dst.Status = InstrumentationStatus{
PodsMatching: src.Status.PodsMatching,
PodsUnhealthy: src.Status.PodsUnhealthy,
PodsHealthy: src.Status.PodsHealthy,
PodsInjected: src.Status.PodsInjected,
PodsOutdated: src.Status.PodsOutdated,
PodsNotReady: src.Status.PodsNotReady,
UnhealthyPodsErrors: unhealthyPodErrors,
LastUpdated: src.Status.LastUpdated,
ObservedVersion: src.Status.ObservedVersion,
}
return nil
}
Loading
Loading