Skip to content

Add support for gitlab.commonLabels, custom podLabels and podAnnotations for StatefulSet and Deployment

What does this MR do and why?

This MR

  • adds support for custom podLabels and podAnnotations for the StatefulSet and Deployment
  • adds gitlab.commonLabels to the template section in StatefulSet and Deployment
  • adds specs

References:

AI summary

This merge request adds support for configuring custom labels and annotations on pods at both the global chart level and for specific components (deployment and statefulSet).

The main changes include:

  • Updated the chart version from 3.5.1 to 3.6.0
  • Added new configuration options in values.yaml for podLabels and podAnnotations at both global and component-specific levels
  • Modified the Kubernetes templates to merge global and component-specific labels/annotations, with component-specific settings taking priority when there are conflicts
  • Added integration with GitLab's common labeling system for better compatibility when used as part of the larger GitLab chart
  • Included comprehensive test coverage to verify the new labeling and annotation functionality works correctly
  • Made minor code formatting improvements to test files

The feature allows users to add custom metadata to their pods either globally across all components or specifically to just the deployment or statefulSet components, providing more flexibility for monitoring, compliance, and operational requirements.

How to set up and validate locally

I tested this using both gitlab-chart and gitlab-zoekt repos in the same directory.

  1. within gitlab-chart directory update the Chart.yaml file
diff --git a/Chart.yaml b/Chart.yaml
index ce1b507e0..bbd1bd944 100644
--- a/Chart.yaml
+++ b/Chart.yaml
@@ -51,8 +51,8 @@ dependencies:
   version: "*.*.*"
   alias: nginx-ingress-geo
 - name: gitlab-zoekt
-  version: 3.4.0
-  repository: https://charts.gitlab.io/
+  version: 3.6.0
+  repository: file://../gitlab-zoekt
   condition: gitlab-zoekt.install
 - name: openbao
   version: 0.5.1
  1. run helm dependency update
  2. test with common labels set
helm template gitlab . \
  --set global.hosts.domain=example.com \
  --set gitlab-zoekt.install=true \
  --set gitlab-zoekt.indexer.internalApi.gitlabUrl="https://gitlab.example.com" \
  --set certmanager-issuer.email=test@example.com \
  --set gitlab-zoekt.indexer.internalApi.secretName="test-secret" \
  --set gitlab-zoekt.indexer.internalApi.secretKey="test-key" \
  --set gitlab-zoekt.common.labels.type="zoekt" \
--set gitlab-zoekt.common.labels.deployment="gitlab-zoekt" > tmp/output.yaml
  1. verify in tmp/output.yaml

StatefulSet

kind: StatefulSet
metadata:
  name: gitlab-gitlab-zoekt
  namespace: default
  labels:
    helm.sh/chart: gitlab-zoekt-3.6.0
    app.kubernetes.io/name: gitlab-zoekt
    app.kubernetes.io/instance: gitlab
    app.kubernetes.io/version: "1.4.4"
    app.kubernetes.io/managed-by: Helm
    app: gitlab-zoekt
    chart: gitlab-zoekt-3.6.0
    release: gitlab
    heritage: Helm

    deployment: "gitlab-zoekt"
    type: "zoekt"
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: gitlab-zoekt
      app.kubernetes.io/instance: gitlab
  serviceName: gitlab-gitlab-zoekt
  replicas: 1
  updateStrategy:
    rollingUpdate:
      partition: 0
    type: RollingUpdate
  template:
    metadata:
      annotations:
        checksum/config: ae3136b04d216495ca3681f767a1e5465e77435a4988efbb34bcd24af2a36533
      labels:
        app.kubernetes.io/name: gitlab-zoekt
        app.kubernetes.io/instance: gitlab

        deployment: "gitlab-zoekt"
        type: "zoekt"

Deployment example

# Source: gitlab/charts/gitlab-zoekt/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitlab-gitlab-zoekt-gateway
  namespace: default
  labels:
    helm.sh/chart: gitlab-zoekt-3.6.0
    app.kubernetes.io/name: gitlab-zoekt
    app.kubernetes.io/instance: gitlab
    app.kubernetes.io/version: "1.4.4"
    app.kubernetes.io/managed-by: Helm
    app: gitlab-zoekt
    chart: gitlab-zoekt-3.6.0
    release: gitlab
    heritage: Helm

    deployment: "gitlab-zoekt"
    type: "zoekt"
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: gitlab-zoekt-gateway
      app.kubernetes.io/instance: gitlab

  strategy:
    rollingUpdate:
      maxUnavailable: 10%
    type: RollingUpdate
  template:
    metadata:
      annotations:
        checksum/config: bfe8b30e399c7b81fd6492be3ca1d2cf44d32a1efd9533549b0950ee1e946f32
      labels:
        app.kubernetes.io/name: gitlab-zoekt-gateway
        app.kubernetes.io/instance: gitlab

        deployment: "gitlab-zoekt"
        type: "zoekt"
Edited by Terri Chu

Merge request reports

Loading