Configure Flux CD in Amazon EKS to Send Live Notifications to Microsoft Teams

Table of Contents

Introduction

Flux is a set of continuous and progressive delivery solutions for Kubernetes. This article demonstrates how to configure Flux to send realtime event notifications to a Teams channel. Although this article uses Amazon EKS, these steps should work as it is on any other Kubernetes platform as well.

Prerequisites

This article assumes you’re already familiar with Flux & that you’ve already bootstrapped Flux onto your cluster. If not, follow Flux’s excellent getting started guide to install Flux. When you’re done, you’ll have a Git repository & your cluster will be configured to sync your cluster objects from Kubernetes manifests in the repo.

Step 1: Get Teams Channel Webhook

First, select a Teams channel where you want to receive Flux notifications & open its Connectors menu:

Add the Incoming Webhook connector:

Open the channel’s connectors again & configure the webhook:

Provide a name & click Create. Copy the generated webhook URL.

Step 2: Create Flux Alert Providers & Alerts

Now we configure Flux to send notifications to Teams.

Start by creating a Flux alert provider:

apiVersion: notification.toolkit.fluxcd.io/v1beta1
kind: Provider
metadata:
  name: msteams
  namespace: flux-system
spec:
  type: msteams
  address: WEBHOOK_URL

Next, create a Flux alert to consume this provider:

apiVersion: notification.toolkit.fluxcd.io/v1beta1
kind: Alert
metadata:
  name: msteams
  namespace: flux-system
spec:
  providerRef:
    name: msteams
  eventSeverity: info
  eventSources:
  - kind: Bucket
    name: '*'
  - kind: GitRepository
    name: '*'
  - kind: Kustomization
    name: '*'
  - kind: HelmRelease
    name: '*'
  - kind: HelmChart
    name: '*'
  - kind: HelmRepository
    name: '*'
  - kind: ImageRepository
    name: '*'
  - kind: ImagePolicy
    name: '*'
  - kind: ImageUpdateAutomation
    name: '*'

This alert sends notifications for EVERY Flux event! To get only error notifications, set eventSeverity to error. Many more customizations are possible as described in the Flux docs.

Step 3: Deploy & Done

The ideal way to create the provider & alert in your cluster would be to commit them to your Flux Git repo & let Flux sync them over. But if you’re just testing stuff out, you may create these objects using kubectl apply.

As soon as these are created in your cluster, Flux notifications should start flowing to your Teams channel. If something seems wrong, check flux logs for any errors.

About the Author ✍🏻

Harish KM is a Principal DevOps Engineer at QloudX & a top-ranked AWS Ambassador since 2020. 👨🏻‍💻

With over a decade of industry experience as everything from a full-stack engineer to a cloud architect, Harish has built many world-class solutions for clients around the world! 👷🏻‍♂️

With over 20 certifications in cloud (AWS, Azure, GCP), containers (Kubernetes, Docker) & DevOps (Terraform, Ansible, Jenkins), Harish is an expert in a multitude of technologies. 📚

These days, his focus is on the fascinating world of DevOps & how it can transform the way we do things! 🚀

Leave a Reply

Your email address will not be published. Required fields are marked *