Skip to content

Commit

Permalink
Merge pull request #4534 from kang-makes/cleaning/kubernetes-manifests
Browse files Browse the repository at this point in the history
Cleaning/kubernetes manifests
  • Loading branch information
x8a committed Oct 26, 2021
2 parents 5cc975b + 70666c3 commit db3e966
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,30 @@ Here are some examples:
id="uninstall-kubernetes"
title="Kubernetes"
>
Each cluster will have a single node where `kubectl` is running. To uninstall the Kubernetes integration, use the following command on each of these nodes:
Ensure you are using the appropriate context in the machine where you will run Helm and `kubectl`:

You can check the available contexts with:

```
kubectl config get-contexts
```

And switch to the desired context using:

```
kubectl config use-context <var>CONTEXT_NAME</var>
```

If you used Helm to install the Kubernetes integration, just uninstall it using Helm:

```
helm uninstall --namespace <var>NAMESPACE_USED_DURING_INSTALLATION</var> <var>RELEASE_NAME</var>
```

If you installed Kubernetes integration using a manifest, use the same manifest to uninstall it:

```
kubectl delete -f newrelic-infrastructure-k8s-latest.yaml
kubectl delete -f newrelic-infrastructure.yaml
```
</Collapser>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,163 +11,80 @@ redirects:
- /docs/integrations/prometheus-integrations/get-started/install-update-or-uninstall-your-prometheus-openmetrics-integration
- /docs/integrations/prometheus-integrations/install-configure/install-update-or-uninstall-your-prometheus-openmetrics-integration
---
Before you install New Relic's Prometheus OpenMetrics integration, [review the requirements](/docs/integrations/prometheus-integrations/get-started/monitor-prometheus-new-relic#OpenMetrics-Compatibility).

import imgIntegrationK8S402X from './images/img-integration-k8.png';
## Install in Kubernetes [#kubernetes]

import dockerLogoCrop from './images/docker-logo-crop.png';
We encourage you to use our automated installer for servers, VMs, and unprivileged environments which also covers the configuration of the monitorization of Kubernetes clusters.

Before you install New Relic's Prometheus OpenMetrics integration, review the requirements for your environment:
You can find the documentation of how to install Kubernetes integration (which includes the feature flag for Prometheus OpenMetric's integration) here: [Kubernetes integration: install and configure](/docs/kubernetes-pixie/kubernetes-integration/installation/kubernetes-integration-install-configure)

- [Docker requirements](/docs/integrations/prometheus-integrations/get-started/monitor-prometheus-new-relic#OpenMetrics-Compatibility)
- [Kubernetes requirements](/docs/integrations/prometheus-integrations/get-started/monitor-prometheus-new-relic#OpenMetrics-Compatibility)
Alternatively, we also offer fully manual instructions for [deploying our integration using Helm](/docs/kubernetes-pixie/kubernetes-integration/installation/install-kubernetes-integration-using-helm).

## Install the integration [#install]
By default, the New Relic Prometheus OpenMetrics integration uses the same labels as Prometheus to discover targets. For more information, see the [metrics filtering](/docs/integrations/prometheus-integrations/configure/filter-prometheus-metrics) documentation.

To install the Prometheus OpenMetrics integration, follow the procedures for Docker or Kubernetes as applicable:
Confirm that the integration has been configured correctly: Wait a few minutes, then go to the New Relic UI, and run this NRQL query to see if data has been reported:

<CollapserGroup>
<Collapser
id="docker-install"
title={<><img src={dockerLogoCrop} title="Docker icon" alt="Docker icon" style={{ height: '35px', width: '40px' }}/> Docker installation</>}
>
To install the New Relic Prometheus OpenMetrics integration in a Docker environment:

1. Create a configuration file `config.yaml`. Use the [example configuration file](/docs/integrations/prometheus-integrations/install-configure/configure-prometheus-openmetrics-integration#example-configuration-file), or look at the [`nri-prometheus-latest.yaml`](https://download.newrelic.com/infrastructure_agent/integrations/kubernetes/nri-prometheus-latest.yaml) manifest file, which includes the `nri-prometheus-cfg` config map and an example configuration.

* **Required:** Add your [New Relic license key](/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key) and a cluster name to identify your Docker container.
* Add the endpoints to scrape; for example, add the `http://localhost:8080/metrics` endpoint to collect metrics about the integration itself.
* Specify which metrics you want to ignore or include according to the prefixes for the metrics and labels. For more information, see the [metrics filtering](/docs/integrations/prometheus-integrations/configure/filter-prometheus-metrics) documentation.
2. Start the integration in the background:

```
docker run -d --restart unless-stopped \
--name nri-prometheus \
-e LICENSE_KEY="<var>YOUR_LICENSE_KEY</var>" \
-v "$(pwd)/config.yaml:/config.yaml" \
newrelic/nri-prometheus:1.5
```
3. Confirm the container is running properly:

```
docker ps -f "name=nri-prometheus"
```
4. Confirm that the integration has been configured correctly: Wait a few minutes, then go to the New Relic UI, and run this NRQL query to see if data has been reported:

```
FROM Metric SELECT count(*) WHERE clusterName = '<var>YOUR_CLUSTER_NAME</var>' since 1 hour ago
```

</Collapser>
```
FROM Metric SELECT count(*) WHERE clusterName = '<var>YOUR_CLUSTER_NAME</var>' since 1 hour ago
```

<Collapser
id="kubernetes-install"
title={<><img src={imgIntegrationK8S402X} title="img-integration-k8s@2x.png" alt="img-integration-k8s@2x.png" style={{ height: '35px', width: '40px' }}/> Kubernetes installation</>}
>
<Callout variant="important">
To prevent your data from being duplicated, configure your New Relic Prometheus OpenMetrics integration [only with **one replica**](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/). Running two or more replicas will result in duplicated data. For more information, see the troubleshooting procedures for [restarts and gaps in data](/docs/integrations/prometheus-integrations/troubleshooting/restarts-gaps-data-kubernetes).
</Callout>
## Docker [#docker]

To install the New Relic Prometheus OpenMetrics integration in a Kubernetes environment:
### Install [#docker-install]

1. Download the integration manifest `.yaml` file:
To install the New Relic Prometheus OpenMetrics integration in a Docker environment:

```
curl -O https://download.newrelic.com/infrastructure_agent/integrations/kubernetes/nri-prometheus-latest.yaml
```
2. Edit the `nri-prometheus-latest.yaml` manifest file:
1. Create a configuration file `config.yaml`. Use the [example configuration file](/docs/integrations/prometheus-integrations/install-configure/configure-prometheus-openmetrics-integration#example-configuration-file), or look at the [`nri-prometheus-latest.yaml`](https://download.newrelic.com/infrastructure_agent/integrations/kubernetes/nri-prometheus-latest.yaml) manifest file, which includes the `nri-prometheus-cfg` config map and an example configuration.

**Required:** Add your [New Relic license key](/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key) and a cluster name to identify your Kubernetes cluster.
* **Required:** Add your [New Relic license key](/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key) and a cluster name to identify your Docker container.
* Add the endpoints to scrape; for example, add the `http://localhost:8080/metrics` endpoint to collect metrics about the integration itself.
* Specify which metrics you want to ignore or include according to the prefixes for the metrics and labels. For more information, see the [metrics filtering](/docs/integrations/prometheus-integrations/configure/filter-prometheus-metrics) documentation.

```
env: - name: LICENSE_KEY
value: "<var><YOUR_LICENSE_KEY></var>"
[...]
config.yaml: |
cluster_name: "<var><YOUR_CLUSTER_NAME></var>"
```
3. Specify which metrics you want to ignore or include according to the prefixes for the metrics and labels. By default, the New Relic Prometheus OpenMetrics integration uses the same labels as Prometheus to discover targets. For more information, see the [metrics filtering](/docs/integrations/prometheus-integrations/configure/filter-prometheus-metrics) documentation.
4. Deploy the integration in your Kubernetes cluster:
2. Start the integration in the background:

```
kubectl apply -f nri-prometheus-latest.yaml
```
5. To confirm that the deployment has been created successfully, look at the `CURRENT` replicas in the results generated by this command:
```
docker run -d --restart unless-stopped \
--name nri-prometheus \
-e LICENSE_KEY="<var>YOUR_LICENSE_KEY</var>" \
-v "$(pwd)/config.yaml:/config.yaml" \
newrelic/nri-prometheus:1.5
```
3. Confirm the container is running properly:

```
kubectl get deployments nri-prometheus
```
6. Confirm that the integration has been configured correctly: Wait a few minutes, then go to the New Relic UI, and run this NRQL query to see if data has been reported:
```
docker ps -f "name=nri-prometheus"
```

```
FROM Metric SELECT count(*) WHERE clusterName = '<var>YOUR_CLUSTER_NAME</var>' since 1 hour ago
```
4. Confirm that the integration has been configured correctly: Wait a few minutes, then go to the New Relic UI, and run this NRQL query to see if data has been reported:

</Collapser>
</CollapserGroup>
```
FROM Metric SELECT count(*) WHERE clusterName = '<var>YOUR_CLUSTER_NAME</var>' since 1 hour ago
```

## Update the integration [#update]
### Update the integration [#docker-update]

To update the Prometheus OpenMetrics integration, follow the procedures for Docker or Kubernetes as applicable:

<CollapserGroup>
<Collapser
id="docker-update"
title={<><img src={dockerLogoCrop} title="Docker icon" alt="Docker icon" style={{ height: '35px', width: '40px' }}/> Docker update procedures</>}
>
1. Remove the Docker container.
2. Follow [standard installation procedures](#docker-install) to start a new Docker container.

The integration logs its current version when it starts up. To determine the running version:

```
docker logs nri-prometheus 2>&1 | grep "Integration version"
```

Example output:

```
time="2019-02-26T09:21:21Z" level=info msg="Starting New Relic's Prometheus OpenMetrics Integration version <mark>1.0.0</mark>"
```
1. Remove the Docker container.
2. Follow [standard installation procedures](#docker-install) to start a new Docker container.

</Collapser>
The integration logs its current version when it starts up. To determine the running version:

<Collapser
id="kubernetes-update"
title={<><img src={imgIntegrationK8S402X} title="img-integration-k8s@2x.png" alt="img-integration-k8s@2x.png" style={{ height: '35px', width: '40px' }}/> Kubernetes update procedures</>}
>
1. Follow [standard installation procedures](#kubernetes-install).
2. Reapply the `nri-prometheus-latest.yaml` manifest file.

The integration logs its version when it starts up. To determine the running version:

```
kubectl logs deploy/nri-prometheus | grep "Integration version"
```

Example output:
```
docker logs nri-prometheus 2>&1 | grep "Integration version"
```

```
time="2019-02-26T09:21:21Z" level=info msg="Starting New Relic's Prometheus OpenMetrics Integration version <mark>1.0.0</mark>"
```
Example output:

</Collapser>
</CollapserGroup>
```
time="2019-02-26T09:21:21Z" level=info msg="Starting New Relic's Prometheus OpenMetrics Integration version <mark>1.0.0</mark>"
```

## Uninstall
### Uninstall [#docker-uninstall]

To uninstall the Prometheus OpenMetrics integration for Docker or Kubernetes, execute the following command:

<ImageSizing width="40px" height="35px">![Docker icon](./images/docker-logo-crop.png "Docker icon")</ImageSizing> **Docker:**

```
docker rm -f nri-prometheus
```

<ImageSizing width="40px" height="35px">
![img-integration-k8.png](./images/img-integration-k8.png
"img-integration-k8.png")
</ImageSizing> **Kubernetes:**

```
kubectl delete -f nri-prometheus-latest.yaml
```
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ helm upgrade --install <mark>newrelic</mark> newrelic/nri-bundle \
```

Please notice and adjust the following flags:
- `global.licenseKey=<var>YOUR_NEW_RELIC_LICENSE_KEY</var>`: Must be set to a valid License Key for your account.
- `global.cluster=<var>K8S_CLUSTER_NAME</var>`: Is used to identify the cluster in the New Relic UI, so should be a descriptive value not used by any other Kubernetes cluster configured in your New Relic account.
- `ksm.enabled=<mark>true</mark>`: Setting this to `true` will automatically install Kube State Metrics (KSM) for you, which is required for our integration to run. You can set this to false if KSM is already present in your cluster, even if it is on a different namespace.
- `newrelic-infrastructure.privileged=<mark>true</mark>`: Can be set to `false` to install a trimmed down version of our integration that does not require extra privileges, such as `hostPath` mounts or running containers as root.
- `global.licenseKey=YOUR_NEW_RELIC_LICENSE_KEY`: Must be set to a valid License Key for your account.
- `global.cluster=K8S_CLUSTER_NAME`: Is used to identify the cluster in the New Relic UI, so should be a descriptive value not used by any other Kubernetes cluster configured in your New Relic account.
- `ksm.enabled=true`: Setting this to `true` will automatically install Kube State Metrics (KSM) for you, which is required for our integration to run. You can set this to false if KSM is already present in your cluster, even if it is on a different namespace.
- `newrelic-infrastructure.privileged=true`: Can be set to `false` to install a trimmed down version of our integration that does not require extra privileges, such as `hostPath` mounts or running containers as root.
- Please note that this will disable detailed process collection from the host.
- For performance reasons, our logging solution still requires `hostPath` mounts, regardless of the value of this flag. If this is not allowedin your cluster, you will need to disable the logging solution by specifying `logging.enabled=false`.
- `prometheus.enabled=true`: Will deploy our Prometheus OpenMetrics integration, which automatically collects data from prometheus endpoints present in the cluster.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ In order to update an installation that was deployed using Helm command provided
### Upgrading using the automated installer and plain manifests

<Callout variant="tip">
We encourage you to deploy our integration using Helm, as it provides a cleaner upgrade path comapred to using manifests directly.
We encourage you to deploy our integration using Helm, as it provides a cleaner upgrade path compared to using manifests directly.
</Callout>

If custom manifests have been used instead of Helm, we encourage you to first remove the old installation using `kubectl delete -f <mark>previous-manifest-file.yml</mark>`, and then proceed through the guided installer again. This will generate an updated set of manifests that can be deployed using `kubectl apply -f <mark>manifest-file.yml</mark>`.
If custom manifests have been used instead of Helm, we encourage you to first remove the old installation using `kubectl delete -f previous-manifest-file.yml`, and then proceed through the guided installer again. This will generate an updated set of manifests that can be deployed using `kubectl apply -f manifest-file.yml`.

We do not recommend applying a new version of the manifest file without removing the previous one first, since it might leave some leftover components in your cluster.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,25 @@ The Kubernetes events integration requires you to:

## Install the Kubernetes events integration [#install]

To install the New Relic Kubernetes events integration in a Kubernetes environment:
We offer [instructions for deploying our integration using Helm](/docs/kubernetes-pixie/kubernetes-integration/installation/install-kubernetes-integration-using-helm).

1. Download the integration manifest YAML file:
Just be sure that, when you are configuring the chart, the webhook that inject the metadata is enabled. Notice that we are specifying `--dry-run` and `--debug`, so nothing will be installed in this step:

```
curl -O https://download.newrelic.com/infrastructure_agent/integrations/kubernetes/nri-kube-events-latest.yaml
```
2. Edit the `nri-kube-events-latest.yaml` manifest file, adding both a cluster name, to identify your Kubernetes cluster (required), and your [New Relic license key](/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key) (required).

```
clusterName: "<var>YOUR_CLUSTER_NAME</var>"
[...]
- name: "NRIA_LICENSE_KEY"
value: "<var>YOUR_LICENSE_KEY</var>"
```
3. Deploy the integration in your Kubernetes cluster:

```
kubectl apply -f nri-kube-events-latest.yaml
```
4. To confirm that the integration has been configured correctly, wait a few minutes, then go to **[one.newrelic.com](https://one.newrelic.com) > Query builder**, and run the following NRQL query to see if data has been reported:

```
FROM InfrastructureEvent SELECT count(*) WHERE clusterName = '<var>YOUR_CLUSTER_NAME</var>' since 1 hour ago
```
```
helm upgrade --install newrelic newrelic/nri-bundle \
--dry-run \
--debug \
--namespace newrelic --create-namespace \
--set global.licenseKey=<var>YOUR_NEW_RELIC_LICENSE_KEY</var> \
--set global.cluster=<var>K8S_CLUSTER_NAME</var> \
--set ksm.enabled=true \
--set newrelic-infrastructure.privileged=true \
--set infrastructure.enabled=true \
--set prometheus.enabled=true \
--set webhook.enabled=<mark>true</mark> \
--set kubeEvents.enabled=true \
--set logging.enabled=true
```

## View your Kubernetes events [#use-data]

Expand Down

0 comments on commit db3e966

Please sign in to comment.