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: health sidecar #112

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
36 changes: 18 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@ TEST_PACKAGES = ./src/internal/config \
./src/apm

# Kubebuilder variables
SETUP_ENVTEST = $(LOCALBIN)/setup-envtest
SETUP_ENVTEST_VERSION ?= release-0.19
SETUP_ENVTEST_K8S_VERSION ?= 1.29.0
ALL_SETUP_ENVTEST_K8S_VERSIONS ?= 1.30.0 1.29.3 1.28.3 1.27.1 1.26.1 #https://storage.googleapis.com/kubebuilder-tools
SETUP_ENVTEST = $(LOCALBIN)/setup-envtest #https://github.com/kubernetes-sigs/controller-runtime/releases
SETUP_ENVTEST_VERSION ?= v0.19.3
SETUP_ENVTEST_K8S_VERSION ?= 1.29.0 #https://github.com/kubernetes-sigs/controller-tools/releases
ALL_SETUP_ENVTEST_K8S_VERSIONS ?= 1.32.0 1.31.0 1.30.0 1.29.3 1.28.3 1.27.1 1.26.1 #https://storage.googleapis.com/kubebuilder-tools

## Tool Versions
KUSTOMIZE ?= $(LOCALBIN)/kustomize
KUSTOMIZE_VERSION ?= v5.4.3
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
CONTROLLER_TOOLS_VERSION ?= v0.14.0
HELMIFY ?= $(LOCALBIN)/helmify
HELMIFY_VERSION ?= v0.3.34
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.61.0
HELM ?= $(LOCALBIN)/helm
HELM_VERSION ?= v3.16.1
HELM_DOCS ?= $(LOCALBIN)/helm-docs
KUSTOMIZE ?= $(LOCALBIN)/kustomize #https://github.com/kubernetes-sigs/kustomize
KUSTOMIZE_VERSION ?= v5.5.0
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen #https://github.com/kubernetes-sigs/controller-tools/releases
CONTROLLER_TOOLS_VERSION ?= v0.16.5
HELMIFY ?= $(LOCALBIN)/helmify #https://github.com/arttor/helmify
HELMIFY_VERSION ?= v0.4.17
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint #https://github.com/golangci/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.62.2
HELM ?= $(LOCALBIN)/helm #https://github.com/helm/helm
HELM_VERSION ?= v3.16.4
HELM_DOCS ?= $(LOCALBIN)/helm-docs #https://github.com/norwoodj/helm-docs
HELM_DOCS_VERSION ?= v1.14.2
HELM_DOCS_VERSION_ST ?= $(subst v,,$(HELM_DOCS_VERSION))
CT ?= $(LOCALBIN)/ct
CT ?= $(LOCALBIN)/ct #https://github.com/helm/chart-testing
CT_VERSION ?= v3.11.0
HELM_UNITTEST ?= $(LOCALBIN)/helm-unittest
HELM_UNITTEST_VERSION ?= v0.6.2
HELM_UNITTEST ?= $(LOCALBIN)/helm-unittest #https://github.com/helm-unittest/helm-unittest
HELM_UNITTEST_VERSION ?= v0.7.0

CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true"

Expand Down
203 changes: 197 additions & 6 deletions charts/k8s-agents-operator/templates/instrumentation-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: CustomResourceDefinition
metadata:
name: instrumentations.newrelic.com
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.16.4
labels:
{{- include "newrelic.common.labels" . | nindent 4 }}
spec:
Expand All @@ -22,6 +22,24 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .status.podsMatching
name: PodsMatching
type: integer
- jsonPath: .status.podsInjected
name: PodsInjected
type: integer
- jsonPath: .status.podsNotReady
name: PodsNotReady
type: integer
- jsonPath: .status.podsOutdated
name: PodsOutdated
type: integer
- jsonPath: .status.podsHealthy
name: PodsHealthy
type: integer
- jsonPath: .status.podsUnhealthy
name: PodsUnhealthy
type: integer
name: v1alpha2
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -85,10 +103,13 @@ spec:
description: The key to select.
type: string
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
optional:
description: Specify whether the ConfigMap or its
Expand Down Expand Up @@ -147,10 +168,13 @@ spec:
be a valid secret key.
type: string
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
TODO: Add other useful fields. apiVersion, kind, uid?
type: string
optional:
description: Specify whether the Secret or its key
Expand Down Expand Up @@ -179,11 +203,9 @@ spec:
Claims lists the names of resources, defined in spec.resourceClaims,
that are used by this container.


This is an alpha field and requires enabling the
DynamicResourceAllocation feature gate.


This field is immutable. It can only be set for containers.
items:
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
Expand All @@ -194,6 +216,12 @@ spec:
the Pod where this field is used. It makes that resource available
inside a container.
type: string
request:
description: |-
Request is the name chosen for a request in the referenced claim.
If empty, everything from the claim is made available, otherwise
only the result of this request.
type: string
required:
- name
type: object
Expand Down Expand Up @@ -222,7 +250,7 @@ spec:
description: |-
Requests describes the minimum amount of compute resources required.
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
otherwise to an implementation-defined value.
otherwise to an implementation-defined value. Requests cannot exceed Limits.
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
type: object
type: object
Expand All @@ -243,6 +271,134 @@ spec:
description: Endpoint is address of the collector with OTLP endpoint.
type: string
type: object
healthAgent:
description: HealthAgent defines configuration for healthAgent instrumentation.
properties:
env:
description: |-
Env defines Go specific env vars. There are four layers for env vars' definitions and
the precedence order is: `original container env vars` > `language specific env vars` > `common env vars` > `instrument spec configs' vars`.
If the former var had been defined, then the other vars would be ignored.
items:
description: EnvVar represents an environment variable present
in a Container.
properties:
name:
description: Name of the environment variable. Must be a C_IDENTIFIER.
type: string
value:
description: |-
Variable references $(VAR_NAME) are expanded
using the previously defined environment variables in the container and
any service environment variables. If a variable cannot be resolved,
the reference in the input string will be unchanged. Double $$ are reduced
to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e.
"$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)".
Escaped references will never be expanded, regardless of whether the variable
exists or not.
Defaults to "".
type: string
valueFrom:
description: Source for the environment variable's value.
Cannot be used if value is not empty.
properties:
configMapKeyRef:
description: Selects a key of a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
optional:
description: Specify whether the ConfigMap or its
key must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
fieldRef:
description: |-
Selects a field of the pod: supports metadata.name, metadata.namespace, `metadata.labels['<KEY>']`, `metadata.annotations['<KEY>']`,
spec.nodeName, spec.serviceAccountName, status.hostIP, status.podIP, status.podIPs.
properties:
apiVersion:
description: Version of the schema the FieldPath is
written in terms of, defaults to "v1".
type: string
fieldPath:
description: Path of the field to select in the specified
API version.
type: string
required:
- fieldPath
type: object
x-kubernetes-map-type: atomic
resourceFieldRef:
description: |-
Selects a resource of the container: only resources limits and requests
(limits.cpu, limits.memory, limits.ephemeral-storage, requests.cpu, requests.memory and requests.ephemeral-storage) are currently supported.
properties:
containerName:
description: 'Container name: required for volumes,
optional for env vars'
type: string
divisor:
anyOf:
- type: integer
- type: string
description: Specifies the output format of the exposed
resources, defaults to "1"
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
resource:
description: 'Required: resource to select'
type: string
required:
- resource
type: object
x-kubernetes-map-type: atomic
secretKeyRef:
description: Selects a key of a secret in the pod's namespace
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
optional:
description: Specify whether the Secret or its key
must be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
type: object
required:
- name
type: object
type: array
image:
description: Image is a container image with Go SDK and auto-instrumentation.
type: string
type: object
licenseKeySecret:
description: |-
LicenseKeySecret defines where to take the licenseKeySecret.
Expand Down Expand Up @@ -278,11 +434,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
Expand Down Expand Up @@ -323,11 +481,13 @@ spec:
items:
type: string
type: array
x-kubernetes-list-type: atomic
required:
- key
- operator
type: object
type: array
x-kubernetes-list-type: atomic
matchLabels:
additionalProperties:
type: string
Expand Down Expand Up @@ -393,6 +553,37 @@ spec:
type: object
status:
description: InstrumentationStatus defines the observed state of Instrumentation
properties:
lastUpdated:
format: date-time
type: string
podsHealthy:
format: int64
type: integer
podsInjected:
format: int64
type: integer
podsMatching:
format: int64
type: integer
podsNotReady:
format: int64
type: integer
podsOutdated:
format: int64
type: integer
podsUnhealthy:
format: int64
type: integer
unhealthyPodsErrors:
items:
properties:
lastError:
type: string
pod:
type: string
type: object
type: array
type: object
type: object
served: true
Expand Down
Loading
Loading