azure-aksnewrelicnewrelic-platform

Newrelic infra agent on AKS Node pool


I would like to install and configure newrelic infra agent on AKS node pool. I have explored links but couldn't find any helpful. Could anyone help to start working on this?

enter image description here

enter image description here


Solution

  • I have got my solution via deamonset and configmap with nodeinstaller. Below links really helped me but not through terraform as AKS won't support custom script to automate via terraform.(Hi can I have a custom script to be executed in AKS node group?)

    Reference links: https://medium.com/@patnaikshekhar/initialize-your-aks-nodes-with-daemonsets-679fa81fd20e

    https://github.com/patnaikshekhar/AKSNodeInstaller

    daemonset.yml

    apiVersion: v1
    kind: Namespace
    metadata:
      name: node-installer
    ---
    apiVersion: apps/v1
    kind: DaemonSet
    metadata:
      name: installer
      namespace: node-installer
    spec:
      selector:
        matchLabels:
          job: installer
      template:
        metadata:
          labels:
            job: installer
        spec:
          hostPID: true
          restartPolicy: Always
          containers:
          - image: patnaikshekhar/node-installer:1.3
            name: installer
            securityContext:
              privileged: true
            volumeMounts:
            - name: install-script
              mountPath: /tmp
            - name: host-mount
              mountPath: /host
          volumes:
          - name: install-script
            configMap:
              name: sample-installer-config
          - name: host-mount
            hostPath:
              path: /tmp/install
    

    sampleconfigmap.yml

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: sample-installer-config
      namespace: node-installer
    data:
      install.sh: |
        #!/bin/bash
    
        # install newrelic-infra
        echo "license_key: #{NEW_RELIC_LICENSE_KEY}#" | sudo tee -a /etc/newrelic-infra.yml
        echo "enabled: #{NEW_RELIC_INFRA_AGENT_ENABLED}#" | sudo tee -a /etc/newrelic-infra.yml
    
        curl -s https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg | sudo apt-key add -
        printf "deb https://download.newrelic.com/infrastructure_agent/linux/apt bionic main" | sudo tee -a /etc/apt/sources.list.d/newrelic-infra.list
        sudo apt-get update -y
        sudo apt-get install newrelic-infra -y
        sudo systemctl status newrelic-infra
        echo "Newrelic infra agent installation is done"
    
        # enable log forwarding
        echo "logs:" | sudo tee -a /etc/newrelic-infra/logging.d/logs.yml
        echo "  - name: log-files-in-folder" | sudo tee -a /etc/newrelic-infra/logging.d/logs.yml
        echo "    file: /var/log/onefc/*/*.newrelic.log" | sudo tee -a /etc/newrelic-infra/logging.d/logs.yml
        echo "    max_line_kb: 256" | sudo tee -a /etc/newrelic-infra/logging.d/logs.yml
    # trigger log forwarding
    sudo newrelic-infra-ctl