This feature is still in development, but we encourage you to try it out!
New Relic supports monitoring Kubernetes workloads on EKS Fargate by automatically injecting a sidecar containing the infrastructure agent and the
nri-kubernetes integration in each pod that needs to be monitored.
If the same Kubernetes cluster also contains EC2 nodes, our solution will also be deployed as a
DaemonSet in all of them. No sidecar will be injected into pods scheduled in EC2 nodes, and no
DaemonSet will be deployed to Fargate nodes. Here's an example of a hybrid instance with both Fargate and EC2 nodes:
New Relic collects all the supported metrics for all Kubernetes objects regardless of where they are scheduled, whether it's Fargate or EC2 nodes. Please note that, due to the limitations imposed by Fargate, the New Relic integration is limited to running in unprivileged mode on Fargate nodes. This means that metrics that are usually fetched from the host directly, like running processes, will not be available for Fargate nodes.
The agent in both scenarios will scrape data from Kube State Metrics (KSM), Kubelet, and cAdvisor and send data in the same format.
Just like for any other Kubernetes cluster, our solution still requires you to deploy and monitor a Kube State Metrics (KSM) instance. Our Helm Chart and/or installer will do so automatically by default, although this behavior can be disabled if your cluster already has a working instance of KSM. This KSM instance will be monitored as any other workload: By injecting a sidecar if it gets scheduled in a Fargate node or with the local instance of the
DaemonSet if it gets scheduled on an EC2 node.
Other components of the New Relic solution for Kubernetes, such as
nri-kube-events, do not have any particularities and will be deployed by our Helm Chart normally as they would in non-Fargate environments.
New Relic Logging is not yet supported on Fargate nodes.
You can choose between two alternatives for installing New Relic full observability in your EKS Fargate cluster:
Regardless of the approach you choose, the experience is exactly the same after it's installed. The only difference is how the container is injected. We do recommend setting up automatic injection with the New Relic Infrastructure Operator since it will eliminate the need to manually edit each deployment you want to monitor.
By default, when Fargate support is enabled, New Relic will deploy an operator to the cluster (
newrelic-infra-operator). Once deployed, this operator will automatically inject the monitoring sidecar to pods that are scheduled into Fargate nodes, while also managing the creation and the update of
ClusterRoleBindings, and any other related resources.
This operator accepts a variety of advanced configuration options that can be used to narrow or widen the scope of the injection, through the use of label selectors for both pods and namespaces.
Behind the scenes, the operator sets up a
MutatingWebhookConfiguration, which allows it to modify the pod objects that are about to be created in the cluster. On this event, and when the pod being created matches the user’s configuration, the operator will:
- Add a sidecar container to the pod containing the New Relic Kubernetes integration.
- If a secret doesn't exist, create one in the same namespace as the pod containing the New Relic license key, which is needed for the sidecar to report data.
- Add the pod’s service account to a
ClusterRoleBindingpreviously created by the operator chart, which will grant this sidecar the required permissions to hit the Kubernetes metrics endpoints.
ClusterRoleBinding grants the following permissions to the pod being injected:
- apiGroups: [""]resources:- "nodes"- "nodes/metrics"- "nodes/stats"- "nodes/proxy"- "pods"- "services"verbs: ["get", "list"]- nonResourceURLs: ["/metrics"]verbs: ["get"]
In order for the sidecar to be injected, and therefore to get metrics from pods deployed before the operator has been installed, you need to manually perform a rollout (restart) of the affected deployments. This way, when the pods are created, the operator will be able to inject the monitoring sidecar. New Relic has chosen not to do this automatically in order to prevent unexpected service disruptions and resource usage spikes.
Here's the injection workflow:
The following steps are for a default setup. Before completing these, we suggest you take a look at the Configuration section below to see if you want to modify any aspects of the automatic injection.
In order to install the operator in charge of injecting the infrastructure sidecar, it is enough to run the following command. Please note that this command is the same one that is used for the general installation command for
nri-kubernetes, with two extra fargate-specific flags (highlighted):
helm upgrade --install newrelic newrelic/nri-bundle \ --namespace newrelic --create-namespace \ --set global.licenseKey=YOUR_NEW_RELIC_LICENSE_KEY \ --set global.cluster=K8S_CLUSTER_NAME \ --set infrastructure.enabled=true \ --set prometheus.enabled=true \ --set webhook.enabled=true \ --set ksm.enabled=true \ --set kubeEvents.enabled=true \ --set global.fargate=true \ --set newrelic-infra-operator.enabled=true
When deploying the solution on a hybrid cluster (with both EC2 and Fargate nodes), please make sure that the solution is not selected by any Fargate profiles; otherwise, the
DaemonSet instances will be stuck in a pending state. For fargate-only environments this is not a concern because no
DaemonSet instances are created.
You can configure different aspects of the automatic injection. By default, the operator will inject the monitoring sidecar to all pods deployed in Fargate nodes which are not part of a
Job or a
This behavior can be changed through configuration options. For example, you can define selectors to narrow or widen the selection of pods that are injected, assign resources to the operator, and tune the sidecar. Also, you can add other attributes, labels, and environment variables. Please refer to the chart README.md and values.yaml.
Specifying your own custom injection rules will discard the default ruleset that prevents sidecar injection on pods that are not scheduled in Fargate. Please ensure that your custom rules have the same effect; otherwise, on hybrid clusters which also have the
DaemonSet deployed, pods scheduled in EC2 will be monitored twice, leading to incorrect or duplicate data.
To update to the latest version of the EKS Fargate integration, upgrade the chart and reinstall the bundle by simply running again the command above.
To update the configuration of the infrastructure agent injected or the operator itself, modify the
values.yaml and upgrade the Helm release with the new configuration. The operator is updated immediately. However, another rollout of the workloads is needed in order to inject the infrastructure agent sidecar with the new configuration.
$ kubectl rollout restart deployment YOUR_DEPLOY
In order to uninstall the sidecar performing the automatic injection but keep the rest of the New Relic solution, using Helm, disable the infra-operator by setting
false, either in the
values.yaml file or in the command line (
--set), and re-run the installation command above.
We strongly recommend keeping the
--set global.fargate=true flag, since it does not enable automatic injection but makes other components of the installation Fargate-aware, preventing unwanted behavior.
To uninstall the whole solution:
- Completely uninstall the Helm release.
- Rollout the pods in order to remove the sidecar:
$ kubectl rollout restart deployment YOUR_APP
- Garbage collect the secrets:
$ kubectl delete secrets -n YOUR_NAMESPACE -l newrelic/infra-operator-created=true
Here are some issues to be aware of when using automatic injection:
Currently there is no controller that watches the whole cluster to make sure that secrets that are no longer needed are garbage collected. However, all objects share the same label that you can use to remove all resources, if needed. We inject the label
newrelic/infra-operator-created: true, which you can use to delete resources with a single command.
At the moment, it's not possible to use the injected sidecar to monitor services running in the pod. The sidecar will only monitor Kubernetes itself. However, advanced users might want to exclude these pods from automatic injection and manually inject a customized version of the sidecar with on-host integrations enabled by configuring them and mounting their configurations in the proper place. For help, see this tutorial.
If you have any concerns about the automatic injection, you can inject the sidecar manually directly by modifying the manifests of the workloads scheduled that are going to be scheduled on Fargate nodes. Please note that adding the sidecar into deployments scheduled into EC2 nodes may lead into incorrect or duplicate data, especially if those nodes are already being monitored with the
The following objects are required for the sidecar to successfully report data:
ClusterRoleproviding the permission needed by the
ClusterRoleand the service account of the pod
- The secret storing the New Relic
licenseKeyin each Fargate namespace
- The sidecar container in the spec template of the monitored workload
These manual setup steps are for a generic installation. Before completing these, take a look at the Configuration section below to see if you want to modify any aspects of the automatic injection.
Complete the following for manual injection:
ClusterRoledoesn't exist, create it and grant the permissions required to hit the metrics endpoints. This only needs to be done once, even for monitoring multiple applications in the same cluster.
For each workload you want to monitor, add an additional sidecar container for the
newrelic/infrastructure-k8simage. Here is an example of an injected sidecar.
ClusterRoleBinding, or add to a previously created one the
ServiceAccountof the application that is going to be monitored. All the workloads may share the same
ClusterRoleBinding, but the
ServiceAccountof each one must be added to it.
Create a secret containing the New Relic license key. Each namespace needs its own secret.
When adding the manifest of the sidecar agent manually, you can use any agent configuration option to configure the agent behavior. For help, see Infrastructure agent configuration settings.
To update any of the components, you just need to modify the deployed yaml.
Updating any of the fields of the injected container will cause the pod to be re-created.
The agent cannot hot load the New Relic license key. After updating the secret, you need to rollout the deployments again.
To remove the injected container and the related resources, you just have to remove the following:
- The sidecar from the workloads that should be no longer monitored.
- All the secrets containing the newrelic license.
Notice that removing the sidecar container will cause the pod to be re-created.
If you notice that any Infra
DaemonSet replicas are being scheduled on Fargate nodes, it might be because the
nodeAffinity rules are not configured properly.
Double-check that the solution was installed with the
global.fargate option to
true, either through the command line (
--set global.fargate=true) or in the
values.yaml file. If the installation method was not Helm, you’ll need to manually add
nodeAffinity rules to exclude Fargate nodes.
Here's an example of what a Fargate node looks like in the New Relic UI:
To view your AWS data:
- Go to one.newrelic.com > Infrastructure > Kubernetes and do one of the following:
- Select an integration name to view data.
- Select the Explore data icon to view AWS data.
- Filter your data using two Fargate tags:
fargateProfile=[name of the Fargate profile to which the workload belongs]
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's and and documentation.