Skip to content

Be able to compute the status from an object list #4

@jlore-decathlon

Description

@jlore-decathlon

Discussed in #3

Originally posted by GregoireW October 5, 2023
In case we push multiple object in kubernetes to deploy one application it may be interesting to compute a status from all the object.

Example: your repository is a mono repo with a front app, an api, a worker. You deploy all of them when you put your application in production, you want to check all them to be deployed to declare a deployment succesful.

The CRD could be modified to something like this:

apiVersion: github.decathlon.com/v1beta1
kind: GitHubDeployment
metadata:
  name: example
spec:
  sourceRef:
    apiVersion: apps/v1
    kind: Deployment
    name: podinfo-primary
    namespace: test

  additionnalRef:
    -  apiVersion: apps/v1
       kind: Deployment
       name: front-app
      namespace: test
    - apiVersion: apps/v1
      kind: Deployment
      name: worker
      namespace: test


  extract:  # Extract the ref on which to GitHub will create the deployment ( commit sha1, tag, etc... )
    containerName: podinfod  #  get the tag of the image of this container. If it is not set, a `jsonPath` option has to be given.
    # jsonPath: $.metadata.annotations.source-ref # a jsonPath to extract a value. Mandatory is `containerName` is not set  
    regexp: main-.*-(.*) # optional. If present, extract a substring from the tag. Capture a single group (can be named "ref")
    # template: "{}"  # optional. If present, use this template to build the GitHub ref from the extracted string. "{}" will be replaced by the extract string. 
                      # For instance if you capture "1.2.3", a template like 'tag-{}' will send to GitHub a ref "tag-123"  
  repository:
    name: my-repo  # your repo name (no need to set the org/user, you can just set the repo name)
    environment: staging # the environment name. It can be anything like  production, staging, ..

Extract / template to get the commit point in git would be extracted from the sourceRef object, but the overall status would be the minimum status from all the objects from additionalRef + sourceRef.

  • If one object is in error, the global status is in error
  • else if one object is in pending, the global status is pending
  • else if ALL object are current, the result is current.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions