Skip to content

Gitops controller#56

Open
machacekondra wants to merge 1 commit into
mainfrom
gitops
Open

Gitops controller#56
machacekondra wants to merge 1 commit into
mainfrom
gitops

Conversation

@machacekondra

Copy link
Copy Markdown
Collaborator

No description provided.

Signed-off-by: Ondra Machacek <omachace@redhat.com>

The proposal introduces two resources and a controller:

1. **`GitRepository` resource** -- a new DCM API object that configures a

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think PUT/PATCH and DELETE should be supported so an user can remove the git repo from the watch list or update the polling frequency and/or path to watch.

If an user deletes the git repo, I would not alter the already deployed resources

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nevermind the fisrt part, I see the endpoints are defined later

#### Story 3 -- Application removed from Git

A developer removes an Application YAML file from the watched path and merges
the change. If `pruneEnabled` is `true`, the GitOps controller detects the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

to reply to the open question about this: I think have the flag is enough to proceed with the automatic deletion. Maybe for deletion some sort of cooldown should be applied: marked for deletion then after some time, perform the deletion (with the timeout being configurable). This would give the user the opportunity to identify wrong deletion. WDYT?

Comment on lines +106 to +109
A developer modifies an Application YAML file in a feature branch, opens a pull
request, gets it reviewed and merged to `main`. Within the next polling
interval, the GitOps controller detects the new commit, diffs the Application
files, and submits the updated Application through the catalog/placement flow.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why not having a flag to enable/disable automatic update as it is done for deletion?

My main concern is malicious attack when a malicious PR get merged and reach main. It may be useful for some specific, sensitive, repos

end
```

## Implementation History

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do we want to keep this empty section?


## Open Questions

1. Should the GitOps controller run as a separate process or as a package inside

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

my main concern about having it running inside DCM is the scalability: it will consume a bit of resources to watch git repos and to run the diffs on all resources hosted on each git repo

On a first iteration, I guess it's fine but we should be careful to not intricates the behaviours too much. Once we will gain experience on this, we can adapt

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I agree, first iteration let's keep it inside, but long term it should definitely be standalone process.

An operator manually modifies an Application via the DCM API that was originally
submitted by the GitOps controller. On the next poll cycle, the controller
detects that DCM state has drifted from Git state, reports this in the
`GitRepository` status, and re-applies the Git version to restore consistency.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what is the update doing? Did we defined it already?

what if the new changes breaks DCM flow? Meaning for instance that the update re-evaluate the policies and that the policies reject the request, what would happen? Would the retryPolicy be used to stop retrying to fix the drift? But then when a new PR is merged to fix the issue, we must reset this

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1 on this. I think we need to define update


This enhancement adds Git-driven Application lifecycle management to DCM. A new
`GitRepository` API resource lets users point DCM at a Git repository containing
Application YAML definitions. A GitOps controller inside the control plane

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it a CatalogItem or something else?

them.

The declarative-api enhancement already identifies "User/GitOps" as a submission
source (see the architecture diagram in declarative-api.md), confirming that

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: add a link if possible

- Integrate with the existing catalog/placement flow -- the GitOps controller
submits Applications through the same internal path as API-driven submissions.
- Provide sync status reporting and drift detection (Git state vs DCM state).
- Define the behavior for create, update, and delete of Applications based on

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

IIRC, update was not in scope/implemented so far for the API. Do you think it's a problem? any extra work to do in dcm?

An operator manually modifies an Application via the DCM API that was originally
submitted by the GitOps controller. On the next poll cycle, the controller
detects that DCM state has drifted from Git state, reports this in the
`GitRepository` status, and re-applies the Git version to restore consistency.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1 on this. I think we need to define update


### Implementation Details/Notes/Constraints

#### GitRepository Resource Schema

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How do we handle git authentication? I think users will use private gh repo so it's important to handle git credentials


| Status | Meaning |
| ------------- | ----------------------------------------- |
| `Synced` | DCM state matches Git at lastSyncedCommit |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you clarify this status? When it's synced? What "entities" are we comparing?

handles `POST /api/v1alpha1/catalog-item-instances`. Catalog resolves the
blueprint, placement builds the DAG, policy evaluates, and SPRM provisions.

2. **Update**: Controller submits an update through catalog.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That's the missing point in DCM

- `gitops.dcm.io/source-path: apps/production/my-app.yaml`
- `gitops.dcm.io/commit: <sha>`

This metadata enables drift detection and prevents conflicts with manually

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How are Git files mapped to DCM instances? What happens on file rename or duplicate names? Is it possible?

GC->>DB: Update lastSyncedCommit + status
else No new commit
GC->>DB: Load git-managed Applications
GC->>GC: Compare spec hashes

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Which fields are in the hash?

Comment on lines +284 to +293
SPRM-->>GC: 202 Accepted
end
opt pruneEnabled and files deleted
loop Each deleted Application
GC->>Cat: Delete CatalogItemInstance
Cat->>PM: Delete flow
PM->>SPRM: Delete instance
end
end
GC->>DB: Update lastSyncedCommit + status

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CAn you clarify this part?
The diagram sets sync complete after 202.
But, for n-tier applications, the status can be Synced while provisioning is still in progress in this way, no?

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