Skip to content

Commit

Permalink
feat: add upgradePolicy and upgradeJob
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksontong committed Apr 18, 2024
1 parent 695a089 commit 1821dc0
Show file tree
Hide file tree
Showing 61 changed files with 18,703 additions and 13,457 deletions.
5 changes: 5 additions & 0 deletions api/application/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&AppUpgradeOptions{},
&AppDeleteOptions{},
&AppCheckResultList{},

&UpgradePolicy{},
&UpgradePolicyList{},
&UpgradeJob{},
&UpgradeJobList{},
)

return nil
Expand Down
96 changes: 96 additions & 0 deletions api/application/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ type AppSpec struct {
Finalizers []FinalizerName
// +optional
DryRun bool
// +optional
UpgradePolicy string
}

// Chart is a description of a chart.
Expand Down Expand Up @@ -263,6 +265,10 @@ const (
AppPhaseInstallFailed AppPhase = "InstallFailed"
// Upgrading means the upgrade for the App is running.
AppPhaseUpgrading AppPhase = "Upgrading"
// UpgradingDaemonset means the upgrade for the App's daemonset is running.
AppPhaseUpgradingDaemonset AppPhase = "UpgradingDaemonset"
// UpgradingDaemonsetFailed means the upgrade for the App's daemonset is running.
AppPhaseUpgradingDaemonsetFailed AppPhase = "UpgradingDaemonsetFailed"
// Succeeded means the dry-run, installation, or upgrade for the
// App succeeded.
AppPhaseSucceeded AppPhase = "Succeeded"
Expand Down Expand Up @@ -413,3 +419,93 @@ const (
// AppCheckLevelRisk means risk unHealthy
AppCheckLevelRisk AppCheckLevel = "risk"
)

// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// UpgradePolicyList is a list of upgradePolicy objects.
type UpgradePolicyList struct {
metav1.TypeMeta
metav1.ListMeta

Items []UpgradePolicy
}

// UpgradePolicySpec is the specification of a upgradePolicy.
type UpgradePolicySpec struct {
BatchNum *int32
BatchIntervalSeconds *int32
MaxFailed *int32
MaxSurge *int32
}

// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// UpgradePolicy is an example type with a spec and a status.
type UpgradePolicy struct {
metav1.TypeMeta
metav1.ObjectMeta

Spec UpgradePolicySpec
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// UpgradeJobList is a list of upgradeJob objects.
type UpgradeJobList struct {
metav1.TypeMeta
metav1.ListMeta

Items []UpgradeJob
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// UpgradeJob is an example type with a spec and a status.
type UpgradeJob struct {
metav1.TypeMeta
metav1.ObjectMeta

Spec UpgradeJobSpec
Status UpgradeJobStatus
}

// UpgradeJobSpec is the specification of a upgradeJob.
type UpgradeJobSpec struct {
TenantID string
Target string
AppRefer string

BatchNum *int32
BatchIntervalSeconds *int32
MaxFailed *int32
MaxSurge *int32
Pause bool
}

// UpgradeJobStatus is the status of a upgradeJob.
type UpgradeJobStatus struct {
// +optional
BatchCompleteNum int32

// +optional
BatchOrder int32

// +optional
BatchUpdatedNode []string

// +optional
BatchStartTime metav1.Time

// +optional
BatchCompleteTime metav1.Time

// +optional
BatchCompleteNodes int32

// +optional
Reason *string
}
Loading

0 comments on commit 1821dc0

Please sign in to comment.