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

proposal:Single cluster deployment application #654

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
title: Single cluster deployment application
authors:
- @yeyeye2333
reviewers:
approvers:

creation-date: 2024-07-24

---

## Single Cluster Deployment Application

### Summary

This proposal aims to modify the application API to allow setting the application's destination to a cluster, reducing the operational steps required for Kurator in a single-cluster environment and increasing Kurator's flexibility.

### Motivation

Kurator leverages Fleet for multi-cluster management. However, this has resulted in the current application deployment being tightly coupled with Fleet, even requiring Fleet creation for single-cluster usage. Therefore, we aim to decouple the single-cluster client from Fleet.
yeyeye2333 marked this conversation as resolved.
Show resolved Hide resolved

#### Goals

- Modify the application API to support setting the application's destination to a cluster.
- Simplify the deployment process for single-cluster environments by eliminating the need for Fleet.

### Proposal

Currently, the application registration is handled in the fleet-manager. The proposal is to move the application registration to the cluster-operator to support setting the application's destination to a cluster.

### Design Details

We will delve into the API design required to support setting the application's destination to a cluster. The following are the specific changes to the application:
yeyeye2333 marked this conversation as resolved.
Show resolved Hide resolved

```go
// ApplicationDestination defines the configuration to dispatch an artifact to a fleet or specific clusters.
// Fleet and cluster are mutually exclusive.
type ApplicationDestination struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

change fleet-manager API or cluster-operator API ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The application is currently under fleet-manager, and I want to put it under cluster-operator

Copy link
Contributor

Choose a reason for hiding this comment

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

application as a feature that depends on fleet, why put it in cluster-operator?
Even if you don't rely on fleet in a single cluster, fleet is still needed in a multi-cluster environment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deployment of application in single cluster without Fleet, does it mean that Fleet Manager does not need to be installed? So I need to register the application in cluster-operator. Will registering the application in cluster-operator affect fleet's use of the application?

Copy link
Contributor

Choose a reason for hiding this comment

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

No.
Deployment of application in single cluster without Fleet, means not need to create fleet.
Rather than do not install fleet manager.

// Fleet defines the fleet to dispatch the artifact.
// +optional
Fleet *FleetInfo `json:"fleetInfo,omitempty"`

// Cluster specifies a cluster to dispatch the artifact to.
// +optional
Cluster *corev1.ObjectReference `json:"clusters,omitempty"`
}

type FleetInfo struct {
// Name identifies the name of the fleet.
// +required
Name string `json:"name"`
// ClusterSelector specifies the selectors to select the clusters within the fleet.
// If unspecified, all clusters in the fleet will be selected.
// +optional
ClusterSelector *ClusterSelector `json:"clusterSelector,omitempty"`
}
```

The preliminary discussion results are as follows:

- The destination can only be either a fleet or a cluster. The `ApplicationWebhook.validate()` will check if only one of fleet or cluster is specified.
- When updating the destination configuration, no actions will be taken on applications deployed in the old clusters (no deletion).

In the specific code, replace all `fleet *fleetapi.Fleet` type parameters in the `Reconcile` method with `destinationObject interface{}`. In functions like `fetchClusterList` (previously `fetchFleetClusterList`) that need to parse `destinationObject`, use a `switch destinationObject.(type)` statement for different logical processing to improve code reusability.

#### Test Plan

During the coding phase, add unit tests covering core functionalities and edge cases. After completing the coding work, design integration tests to ensure the proper deployment of applications in a single cluster, and subsequently, provide examples of deploying applications in a single cluster.