Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-11841. Add support for additional service labels and annotations #13

Merged

Conversation

dnskr
Copy link
Contributor

@dnskr dnskr commented Dec 2, 2024

What changes were proposed in this pull request?

The PR adds support for additional service labels and annotations which can be added to a Helm chart releases via values.

The change is needed in some scenarios, for example:

  • Add prometheus related annotations to scrape metrics
    apiVersion: v1
    kind: Service
    metadata:
      annotations:
        prometheus.io/port: "9500"
        prometheus.io/scrape: "true"
  • Add additional labels for different environments

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-11841

How was this patch tested?

1. Test that service templates are the same with default values (no extra labels and annotations)

helm template ozone charts/ozone -s templates/datanode/datanode-service.yaml \
                                                   -s templates/om/om-service.yaml \
                                                   -s templates/s3g/s3g-service.yaml \
                                                   -s templates/scm/scm-service.yam

Output

---
# Source: ozone/templates/datanode/datanode-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: ozone-datanode
  labels:
    helm.sh/chart: ozone-0.1.1
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/version: "1.4.1-rocky"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: datanode
spec:
  type: ClusterIP
  ports:
    - name: ui
      port: 9882
  selector:
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/component: datanode
---
# Source: ozone/templates/om/om-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: ozone-om
  labels:
    helm.sh/chart: ozone-0.1.1
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/version: "1.4.1-rocky"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: om
spec:
  type: ClusterIP
  ports:
    - name: ui
      port: 9874
  selector:
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/component: om
---
# Source: ozone/templates/s3g/s3g-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: ozone-s3g
  labels:
    helm.sh/chart: ozone-0.1.1
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/version: "1.4.1-rocky"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: s3g
spec:
  type: ClusterIP
  ports:
    - name: rest
      port: 9878
  selector:
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/component: s3g
---
# Source: ozone/templates/scm/scm-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: ozone-scm
  labels:
    helm.sh/chart: ozone-0.1.1
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/version: "1.4.1-rocky"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: scm
spec:
  type: ClusterIP
  ports:
    - name: ui
      port: 9876
  selector:
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/component: scm

2. Test that templates are correct with provided additional labels and annotations

helm template ozone charts/ozone --set datanode.service.labels.test=datanode \
                                                   --set datanode.service.annotations.path=datanode \
                                                   --set om.service.labels.test=om \
                                                   --set om.service.annotations.path=om \
                                                   --set s3g.service.labels.test=s3g \
                                                   --set s3g.service.annotations.path=s3g \
                                                   --set scm.service.labels.test=scm \
                                                   --set scm.service.annotations.path=scm \
                                                   -s templates/datanode/datanode-service.yaml \
                                                   -s templates/om/om-service.yaml \
                                                   -s templates/s3g/s3g-service.yaml \
                                                   -s templates/scm/scm-service.yaml

Output

---
# Source: ozone/templates/datanode/datanode-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: ozone-datanode
  labels:
    helm.sh/chart: ozone-0.1.1
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/version: "1.4.1-rocky"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: datanode
    test: datanode
  annotations:
    path: datanode
spec:
  type: ClusterIP
  ports:
    - name: ui
      port: 9882
  selector:
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/component: datanode
---
# Source: ozone/templates/om/om-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: ozone-om
  labels:
    helm.sh/chart: ozone-0.1.1
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/version: "1.4.1-rocky"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: om
    test: om
  annotations:
    path: om
spec:
  type: ClusterIP
  ports:
    - name: ui
      port: 9874
  selector:
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/component: om
---
# Source: ozone/templates/s3g/s3g-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: ozone-s3g
  labels:
    helm.sh/chart: ozone-0.1.1
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/version: "1.4.1-rocky"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: s3g
    test: s3g
  annotations:
    path: s3g
spec:
  type: ClusterIP
  ports:
    - name: rest
      port: 9878
  selector:
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/component: s3g
---
# Source: ozone/templates/scm/scm-service.yaml
apiVersion: v1
kind: Service
metadata:
  name: ozone-scm
  labels:
    helm.sh/chart: ozone-0.1.1
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/version: "1.4.1-rocky"
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/component: scm
    test: scm
  annotations:
    path: scm
spec:
  type: ClusterIP
  ports:
    - name: ui
      port: 9876
  selector:
    app.kubernetes.io/name: ozone
    app.kubernetes.io/instance: ozone
    app.kubernetes.io/component: scm

Copy link

@kerneltime kerneltime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@adoroszlai adoroszlai merged commit 1619b1a into apache:main Dec 4, 2024
1 check passed
@adoroszlai
Copy link
Contributor

Thanks @dnskr for the patch, @kerneltime for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants