Tracking usage of Network Policies in Auto Deploy using Usage Data API

Problem to solve

As part of the removal of one-click apps (&4280), we stopped updating the associated database records. This inadvertently broke a piece of Cilium's usage metrics that relied the presence of Cilium's application record to measure usage. We need a replacement.

Details

From this discussion (internal link), the desired outcome is

[measuring] the number of clusters that are managing their Network Policies through GitLab regardless of how Cilium was installed

GitLab offers two ways to manage (Cilium) Network Policies:

  1. Auto DevOps (this issue), and
  2. A UI based policy editor

This issue is about tracking (1). Work on (2) is being tracked in #334090 (closed)

Proposal

  1. Add a CI_KUBERNETES_CLUSTER_ID deployment variable with the cluster being used
  2. Extend the usage data API with an increment_unique_values endpoint so we can call it with the cluster ID. We may also need extend access to the API to CI jobs
  3. Use the endpoint from auto-deploy-image when we detect network policies being used
Edited by Hordur Freyr Yngvason