Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

An easy way to define global annotations, labels #540

Open
surajssd opened this issue Dec 20, 2017 · 3 comments
Open

An easy way to define global annotations, labels #540

surajssd opened this issue Dec 20, 2017 · 3 comments

Comments

@surajssd
Copy link
Member

Type:

/kind RFE

Description:

I am trying to kedgify the configurations which consists of lot of annotations and labels which are same. So it is really hard/redundant to copy those config parts to each and every type of object defined in one kedge app file. I would like to see a simple and easy way to define annotations and label which is populated across all the configs that are generated.

I have kegified this configuration

name: auth-db
controller: DeploymentConfig

annotations:
  fabric8.io/git-commit: todo-parameterize
  fabric8.io/git-branch: todo-parameterize
labels:
  service: auth-db
  app: auth-db
  provider: fabric8
  version: todo-parameterize
  group: io.fabric8.platform.apps

revisionHistoryLimit: 2
triggers:
- type: ConfigChange
strategy:
  rollingParams:
    timeoutSeconds: 7200
  type: Rolling

containers:
- name: auth-db
  image: registry.centos.org/postgresql/postgresql:9.6
  imagePullPolicy: IfNotPresent
  env:
  - name: POSTGRESQL_ADMIN_PASSWORD
    valueFrom:
      secretKeyRef:
        key: db.password
        name: auth
  - name: POD_IP
    valueFrom:
      fieldRef:
        fieldPath: status.podIP
  livenessProbe:
    exec:
      command:
      - sh
      - -c
      - exec pg_isready --host $POD_IP
    failureThreshold: 6
    initialDelaySeconds: 60
    timeoutSeconds: 5
  readinessProbe:
    exec:
      command:
      - sh
      - -c
      - exec pg_isready --host $POD_IP
    initialDelaySeconds: 20
    periodSeconds: 5
    timeoutSeconds: 3
  volumeMounts:
  - mountPath: /var/lib/pgsql
    name: auth-db-postgresql-data

services:
- portMappings:
  - 5432
  
volumeClaims:
- name: auth-db-postgresql-data
  size: 1Gi

secrets:
- name: auth
  data:
    db.user: cG9zdGdyZXM=
    db.password: bXlzZWNyZXRwYXNzd29yZA==
    keycloak.realm: ZmFicmljOA==
    keycloak.secret: Yjc4NzNmODAtNmFkNy00NGE1LTk3Y2ItYmQyMTA3ODllYjQx
    token.publickey: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlHZU1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTUFEQ0JpQUtCZ0VqbFpOMVE3d2c1UU9IelhHcXlOZi9xL1ZIUTBvSjJOZGVPRHMxOHh1WkpHSkxEZVA4ZU5QY2trbGdWb1RJaFZzOTlaNXRMTTFoUCs5R213ODI1dVVXRnZsNHg1MGoyYW0yNUFIOGlpUGhreUw2aEx6dThzYnd3clU5R1RpcllqRVM5RlNRVWF6TmlWMVhYSGR5TGRvRm03dzMzZDVobFdpT1M4NmNmRnNGN0FnTUJBQUU9Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=
    tenantsvc.url: aHR0cDovL2Y4dGVuYW50Ojgw
  type: Opaque

Which comes from following configuration.

- apiVersion: v1
  kind: Secret
  metadata:
    annotations:
      maven.fabric8.io/source-url: jar:file:/home/jenkins/workspace/8io_fabric8-platform_master-4P5FOSFKYBLAPGDO7GHHNEOGKKERYH26KXBFORI5V7MRVJFY3QWA/apps/auth/target/auth-4.0.208.jar!/META-INF/fabric8/openshift.yml
    labels:
      app: auth
      provider: fabric8
      version: 4.0.208
      group: io.fabric8.platform.apps
    name: auth
  data:
    db.user: cG9zdGdyZXM=
    db.password: bXlzZWNyZXRwYXNzd29yZA==
    keycloak.realm: ZmFicmljOA==
    keycloak.secret: Yjc4NzNmODAtNmFkNy00NGE1LTk3Y2ItYmQyMTA3ODllYjQx
    token.publickey: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlHZU1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTUFEQ0JpQUtCZ0VqbFpOMVE3d2c1UU9IelhHcXlOZi9xL1ZIUTBvSjJOZGVPRHMxOHh1WkpHSkxEZVA4ZU5QY2trbGdWb1RJaFZzOTlaNXRMTTFoUCs5R213ODI1dVVXRnZsNHg1MGoyYW0yNUFIOGlpUGhreUw2aEx6dThzYnd3clU5R1RpcllqRVM5RlNRVWF6TmlWMVhYSGR5TGRvRm03dzMzZDVobFdpT1M4NmNmRnNGN0FnTUJBQUU9Ci0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=
    tenantsvc.url: aHR0cDovL2Y4dGVuYW50Ojgw
  type: Opaque
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      fabric8.io/git-commit: d537a75a59f2305791c3e5adc838cb04f0329b18
      fabric8.io/git-branch: release-v4.0.208
      fabric8.io/scm-con-url: scm:git:[email protected]:fabric8io/fabric8-platform.git/apps/auth-db
      fabric8.io/scm-devcon-url: scm:git:[email protected]:fabric8io/fabric8-platform.git/apps/auth-db
      fabric8.io/scm-tag: app-console-2.0.1
      fabric8.io/scm-url: http://github.com/fabric8io/fabric8-platform/apps/auth-db
      maven.fabric8.io/source-url: jar:file:/home/jenkins/workspace/8io_fabric8-platform_master-4P5FOSFKYBLAPGDO7GHHNEOGKKERYH26KXBFORI5V7MRVJFY3QWA/apps/auth-db/target/auth-db-4.0.208.jar!/META-INF/fabric8/openshift.yml
    labels:
      service: auth-db
      app: auth-db
      provider: fabric8
      version: 4.0.208
      group: io.fabric8.platform.apps
    name: auth-db
  spec:
    ports:
    - name: postgres
      port: 5432
      protocol: TCP
      targetPort: 5432
    selector:
      service: auth-db
      app: auth-db
      provider: fabric8
      group: io.fabric8.platform.apps
    type: ClusterIP
- apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    annotations:
      maven.fabric8.io/source-url: jar:file:/home/jenkins/workspace/8io_fabric8-platform_master-4P5FOSFKYBLAPGDO7GHHNEOGKKERYH26KXBFORI5V7MRVJFY3QWA/apps/auth-db/target/auth-db-4.0.208.jar!/META-INF/fabric8/openshift.yml
    labels:
      app: auth-db
      provider: fabric8
      version: 4.0.208
      group: io.fabric8.platform.apps
    name: auth-db-postgresql-data
  spec:
    accessModes:
    - ReadWriteOnce
    resources:
      requests:
        storage: 1Gi
- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    annotations:
      fabric8.io/git-commit: d537a75a59f2305791c3e5adc838cb04f0329b18
      fabric8.io/metrics-path: dashboard/file/kubernetes-pods.json/?var-project=auth-db&var-version=4.0.208
      fabric8.io/scm-con-url: scm:git:[email protected]:fabric8io/fabric8-platform.git/apps/auth-db
      fabric8.io/scm-url: http://github.com/fabric8io/fabric8-platform/apps/auth-db
      fabric8.io/git-branch: release-v4.0.208
      fabric8.io/scm-devcon-url: scm:git:[email protected]:fabric8io/fabric8-platform.git/apps/auth-db
      fabric8.io/scm-tag: app-console-2.0.1
      maven.fabric8.io/source-url: jar:file:/home/jenkins/workspace/8io_fabric8-platform_master-4P5FOSFKYBLAPGDO7GHHNEOGKKERYH26KXBFORI5V7MRVJFY3QWA/apps/auth-db/target/auth-db-4.0.208.jar!/META-INF/fabric8/openshift.yml
    labels:
      service: auth-db
      app: auth-db
      provider: fabric8
      version: 4.0.208
      group: io.fabric8.platform.apps
    name: auth-db
  spec:
    replicas: 1
    revisionHistoryLimit: 2
    selector:
      app: auth-db
      provider: fabric8
      group: io.fabric8.platform.apps
    strategy:
      rollingParams:
        timeoutSeconds: 7200
      type: Rolling
    template:
      metadata:
        annotations:
          fabric8.io/git-commit: d537a75a59f2305791c3e5adc838cb04f0329b18
          fabric8.io/metrics-path: dashboard/file/kubernetes-pods.json/?var-project=auth-db&var-version=4.0.208
          fabric8.io/scm-con-url: scm:git:[email protected]:fabric8io/fabric8-platform.git/apps/auth-db
          fabric8.io/scm-url: http://github.com/fabric8io/fabric8-platform/apps/auth-db
          fabric8.io/git-branch: release-v4.0.208
          fabric8.io/scm-devcon-url: scm:git:[email protected]:fabric8io/fabric8-platform.git/apps/auth-db
          fabric8.io/scm-tag: app-console-2.0.1
        labels:
          service: auth-db
          app: auth-db
          provider: fabric8
          version: 4.0.208
          group: io.fabric8.platform.apps
      spec:
        containers:
        - env:
          - name: POSTGRESQL_ADMIN_PASSWORD
            valueFrom:
              secretKeyRef:
                key: db.password
                name: auth
          - name: POD_IP
            valueFrom:
              fieldRef:
                fieldPath: status.podIP
          image: registry.centos.org/postgresql/postgresql:9.6
          imagePullPolicy: IfNotPresent
          livenessProbe:
            exec:
              command:
              - sh
              - -c
              - exec pg_isready --host $POD_IP
            failureThreshold: 6
            initialDelaySeconds: 60
            timeoutSeconds: 5
          name: auth-db
          ports:
          - containerPort: 5432
            name: postgresql
            protocol: TCP
          readinessProbe:
            exec:
              command:
              - sh
              - -c
              - exec pg_isready --host $POD_IP
            initialDelaySeconds: 20
            periodSeconds: 5
            timeoutSeconds: 3
          volumeMounts:
          - mountPath: /var/lib/pgsql
            name: auth-db-postgresql-data
            readOnly: false
        volumes:
        - name: auth-db-postgresql-data
          persistentVolumeClaim:
            claimName: auth-db-postgresql-data
    triggers:
    - type: ConfigChange

The complete one is available in: http://central.maven.org/maven2/io/fabric8/platform/packages/fabric8-system/4.0.208/fabric8-system-4.0.208-openshift.json

If I use that kedge file the annotations and labels are only added to deploymentconfig and rest all the objects get a generic app: appName label. Please add a way to define global annotations and labels.

@kadel
Copy link
Member

kadel commented Dec 21, 2017

How you propose to do that?
We can't use Deployments annotations/labels, as that will make it impossible to add Deployment specific labels without adding them to other objects.

One way we could do that would be adding something like globalLabels and globalAnnotations

@surajssd
Copy link
Member Author

Can't we make labels and annotations a global field like name field is. If you think about it name does a global setting unless someone wants to set anything else in some specific resource they still have way of doing it using respective name field.

But yeah not sure how do we enable controller/deployment only labels or annotations with this approach.

@kadel
Copy link
Member

kadel commented Dec 21, 2017

name is a bit different case, as it is a required field, it has to be set for every object, and it is just single value.

labels and annotations are lists, there is a lot of complications when handling this if we try to use annotations and labels from controller object. For example, how would kedge handle cases where different labels are set in for the controller and for service? Should service labels be a combination of both, or should it be just what is specified for service? How it will be handled if I want one global label for every object, but I have also some object-specific labels?

labels:
   - aaa:aaa
service:
  - labels:
     - bbb:bbb

Global annotations/labels make sense and they are useful, but we have to use a separate key for it.

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

No branches or pull requests

2 participants