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

feat: add ability to entirely opt-out of argo cd and rollouts integrations #1382

Merged
merged 10 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ k8s_resource(
'kargo-controller:rolebinding',
'kargo-controller:serviceaccount',
'kargo-controller-argocd:clusterrole',
'kargo-controller-argocd:clusterrolebinding'
'kargo-controller-argocd:clusterrolebinding',
'kargo-controller-rollouts:clusterrole',
'kargo-controller-rollouts:clusterrolebinding'
],
resource_deps=['back-end-compile']
)
Expand Down
52 changes: 50 additions & 2 deletions api/v1alpha1/stage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,44 @@
StagePhaseVerifying StagePhase = "Verifying"
)

type VerificationPhase string

// Note: VerificationPhases are identical to AnalysisRunPhases. In almost all
// cases, the VerificationPhase will be a reflection of the underlying
// AnalysisRunPhase. There are exceptions to this, such as in the case where an
// AnalysisRun cannot be launched successfully.

const (
// VerificationPhasePending denotes a verification process that has not yet
// started yet.
VerificationPhasePending VerificationPhase = "Pending"
// VerificationPhaseRunning denotes a verification that is currently running.
VerificationPhaseRunning VerificationPhase = "Running"
// VerificationPhaseSuccessful denotes a verification process that has
// completed successfully.
VerificationPhaseSuccessful VerificationPhase = "Successful"
// VerificationPhaseFailed denotes a verification process that has completed
// with a failure.
VerificationPhaseFailed VerificationPhase = "Failed"
// VerificationPhaseError denotes a verification process that has completed
// with an error.
VerificationPhaseError VerificationPhase = "Error"
// VerificationPhaseInconclusive denotes a verification process that has
// completed with an inconclusive result.
VerificationPhaseInconclusive VerificationPhase = "Inconclusive"
)

// IsTerminal returns true if the VerificationPhase is a terminal one.
func (v *VerificationPhase) IsTerminal() bool {
switch *v {

Check warning on line 52 in api/v1alpha1/stage_types.go

View check run for this annotation

Codecov / codecov/patch

api/v1alpha1/stage_types.go#L51-L52

Added lines #L51 - L52 were not covered by tests
case VerificationPhaseSuccessful, VerificationPhaseFailed,
VerificationPhaseError, VerificationPhaseInconclusive:
return true
default:
return false

Check warning on line 57 in api/v1alpha1/stage_types.go

View check run for this annotation

Codecov / codecov/patch

api/v1alpha1/stage_types.go#L54-L57

Added lines #L54 - L57 were not covered by tests
}
}

// +kubebuilder:validation:Enum={ImageAndTag,Tag,ImageAndDigest,Digest}
type ImageUpdateValueType string

Expand Down Expand Up @@ -485,7 +523,7 @@
Charts []Chart `json:"charts,omitempty"`
// VerificationInfo is information about any verification process that was
// associated with this Freight for this Stage.
VerificationInfo *VerificationInfo `json:"verificationResult,omitempty"`
VerificationInfo *VerificationInfo `json:"verificationInfo,omitempty"`
Copy link
Member Author

Choose a reason for hiding this comment

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

This was an oops to begin with.

}

type FreightReferenceStack []FreightReference
Expand Down Expand Up @@ -673,7 +711,17 @@
// VerificationInfo contains information about the currently running
// Verification process.
type VerificationInfo struct {
AnalysisRun AnalysisRunReference `json:"analysisRun"`
// Phase describes the current phase of the Verification process. Generally,
// this will be a reflection of the underlying AnalysisRun's phase, however,
// there are exceptions to this, such as in the case where an AnalysisRun
// cannot be launched successfully.
Phase VerificationPhase `json:"phase,omitempty"`
// Message may contain additional information about why the verification
// process is in its current phase.
Message string `json:"message,omitempty"`
Comment on lines +714 to +721
Copy link
Member Author

Choose a reason for hiding this comment

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

These are the main changes to the resources types.

It's always been possible that something could go wrong with a verification other than an AnalysisRun failing or erroring, so really, this is the way things should have been done from the start. Added Phase and Message fields for reporting such problems.

The specific problem that is more likely to occur, starting with this PR, is that verification is requested, but the controller doesn't have Rollouts integration enabled. This means an AnalysisRun cannot even be launched.

// AnalysisRun is a reference to the Argo Rollouts AnalysisRun that implements
// the Verification process.
AnalysisRun *AnalysisRunReference `json:"analysisRun,omitempty"`
}

// AnalysisRunReference is a reference to an AnalysisRun.
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@ message AnalysisRunArgument {

message VerificationInfo {
AnalysisRunReference analysis_run = 1 [json_name = "analysisRun"];
string phase = 2 [json_name = "phase"];
string message = 3 [json_name = "message"];
}

message AnalysisRunReference {
Expand Down
8 changes: 6 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 47 additions & 44 deletions charts/kargo/README.md

Large diffs are not rendered by default.

56 changes: 43 additions & 13 deletions charts/kargo/crds/kargo.akuity.io_stages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -602,12 +602,13 @@ spec:
type: string
type: object
type: array
verificationResult:
verificationInfo:
description: VerificationInfo is information about any verification
process that was associated with this Freight for this Stage.
properties:
analysisRun:
description: AnalysisRunReference is a reference to an AnalysisRun.
description: AnalysisRun is a reference to the Argo Rollouts
AnalysisRun that implements the Verification process.
properties:
name:
description: Name is the name of the AnalysisRun.
Expand All @@ -624,8 +625,17 @@ spec:
- namespace
- phase
type: object
required:
- analysisRun
message:
description: Message may contain additional information about
why the verification process is in its current phase.
type: string
phase:
description: Phase describes the current phase of the Verification
process. Generally, this will be a reflection of the underlying
AnalysisRun's phase, however, there are exceptions to this,
such as in the case where an AnalysisRun cannot be launched
successfully.
type: string
type: object
type: object
currentPromotion:
Expand Down Expand Up @@ -724,13 +734,13 @@ spec:
type: string
type: object
type: array
verificationResult:
verificationInfo:
description: VerificationInfo is information about any verification
process that was associated with this Freight for this Stage.
properties:
analysisRun:
description: AnalysisRunReference is a reference to an
AnalysisRun.
description: AnalysisRun is a reference to the Argo Rollouts
AnalysisRun that implements the Verification process.
properties:
name:
description: Name is the name of the AnalysisRun.
Expand All @@ -747,8 +757,18 @@ spec:
- namespace
- phase
type: object
required:
- analysisRun
message:
description: Message may contain additional information
about why the verification process is in its current
phase.
type: string
phase:
description: Phase describes the current phase of the
Verification process. Generally, this will be a reflection
of the underlying AnalysisRun's phase, however, there
are exceptions to this, such as in the case where an
AnalysisRun cannot be launched successfully.
type: string
type: object
type: object
name:
Expand Down Expand Up @@ -915,12 +935,13 @@ spec:
type: string
type: object
type: array
verificationResult:
verificationInfo:
description: VerificationInfo is information about any verification
process that was associated with this Freight for this Stage.
properties:
analysisRun:
description: AnalysisRunReference is a reference to an AnalysisRun.
description: AnalysisRun is a reference to the Argo Rollouts
AnalysisRun that implements the Verification process.
properties:
name:
description: Name is the name of the AnalysisRun.
Expand All @@ -937,8 +958,17 @@ spec:
- namespace
- phase
type: object
required:
- analysisRun
message:
description: Message may contain additional information
about why the verification process is in its current phase.
type: string
phase:
description: Phase describes the current phase of the Verification
process. Generally, this will be a reflection of the underlying
AnalysisRun's phase, however, there are exceptions to
this, such as in the case where an AnalysisRun cannot
be launched successfully.
type: string
type: object
type: object
type: array
Expand Down
8 changes: 8 additions & 0 deletions charts/kargo/templates/api/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,12 @@ rules:
verbs:
- patch
- update
{{- if .Values.api.rollouts.integrationEnabled }}
- apiGroups:
- argoproj.io
resources:
- analysistemplates
verbs:
- "*"
{{- end }}
Comment on lines +79 to +86
Copy link
Member Author

Choose a reason for hiding this comment

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

This fixes #1379

{{- end }}
1 change: 1 addition & 0 deletions charts/kargo/templates/api/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ data:
ARGOCD_NAMESPACE: {{ .Values.controller.argocd.namespace }}
ARGOCD_URLS: {{ range $key, $val := .Values.api.argocd.urls }}{{ $key }}={{ $val }},{{- end }}
{{- end }}
ROLLOUTS_INTEGRATION_ENABLED: {{ quote .Values.api.rollouts.integrationEnabled }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/kargo/templates/argocd/role-binding.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if or .Values.controller.argocd.watchArgocdNamespaceOnly .Values.controller.argocd.enableCredentialBorrowing }}
{{- if and .Values.controller.argocd.integrationEnabled (or .Values.controller.argocd.watchArgocdNamespaceOnly .Values.controller.argocd.enableCredentialBorrowing) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
Expand Down
2 changes: 1 addition & 1 deletion charts/kargo/templates/argocd/role.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if or .Values.controller.argocd.watchArgocdNamespaceOnly .Values.controller.argocd.enableCredentialBorrowing }}
{{- if and .Values.controller.argocd.integrationEnabled (or .Values.controller.argocd.watchArgocdNamespaceOnly .Values.controller.argocd.enableCredentialBorrowing) }}
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
Expand Down
20 changes: 19 additions & 1 deletion charts/kargo/templates/controller/cluster-role-bindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ subjects:
- kind: ServiceAccount
namespace: {{ .Release.Namespace }}
name: kargo-controller
{{- if and .Values.controller.argocd.integrationEnabled (not .Values.controller.argocd.watchArgocdNamespaceOnly) }}
---
{{- if not .Values.controller.argocd.watchArgocdNamespaceOnly }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand All @@ -32,4 +32,22 @@ subjects:
namespace: {{ .Release.Namespace }}
name: kargo-controller
{{- end }}
{{- if .Values.controller.rollouts.integrationEnabled }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kargo-controller-rollouts
labels:
{{- include "kargo.labels" . | nindent 4 }}
{{- include "kargo.controller.labels" . | nindent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: kargo-controller-rollouts
subjects:
- kind: ServiceAccount
namespace: {{ .Release.Namespace }}
name: kargo-controller
{{- end }}
{{- end }}
15 changes: 13 additions & 2 deletions charts/kargo/templates/controller/cluster-roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ rules:
- get
- list
- watch
{{- if and .Values.controller.argocd.integrationEnabled (not .Values.controller.argocd.watchArgocdNamespaceOnly) }}
---
{{- if not .Values.controller.argocd.watchArgocdNamespaceOnly }}
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
Expand All @@ -91,6 +91,17 @@ rules:
- list
- patch
- watch
{{- end }}
{{- if .Values.controller.rollouts.integrationEnabled }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: kargo-controller-rollouts
labels:
{{- include "kargo.labels" . | nindent 4 }}
{{- include "kargo.controller.labels" . | nindent 4 }}
rules:
- apiGroups:
- argoproj.io
resources:
Expand All @@ -100,5 +111,5 @@ rules:
- get
- list
- watch
{{- end }}
{{- end }}
{{- end }}
10 changes: 7 additions & 3 deletions charts/kargo/templates/controller/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ data:
KUBECONFIG: /etc/kargo/kubeconfigs/kubeconfig.yaml
{{- end }}
GLOBAL_CREDENTIALS_NAMESPACES: {{ join "," .Values.controller.globalCredentials.namespaces }}
ARGOCD_INTEGRATION_ENABLED: {{ quote .Values.controller.argocd.integrationEnabled }}
{{- if .Values.controller.argocd.integrationEnabled }}
{{- if .Values.kubeconfigSecrets.argocd }}
ARGOCD_KUBECONFIG: /etc/kargo/kubeconfigs/argocd-kubeconfig.yaml
{{- end }}
{{- if .Values.kubeconfigSecrets.rollouts }}
ROLLOUTS_KUBECONFIG: /etc/kargo/kubeconfigs/rollouts-kubeconfig.yaml
{{- end }}
ARGOCD_NAMESPACE: {{ .Values.controller.argocd.namespace }}
ARGOCD_ENABLE_CREDENTIAL_BORROWING: {{ quote .Values.controller.argocd.enableCredentialBorrowing }}
ARGOCD_WATCH_ARGOCD_NAMESPACE_ONLY: {{ quote .Values.controller.argocd.watchArgocdNamespaceOnly }}
{{- end }}
ROLLOUTS_INTEGRATION_ENABLED: {{ quote .Values.controller.rollouts.integrationEnabled }}
{{- if and .Values.controller.rollouts.integrationEnabled .Values.kubeconfigSecrets.rollouts }}
ROLLOUTS_KUBECONFIG: /etc/kargo/kubeconfigs/rollouts-kubeconfig.yaml
{{- end }}
{{- end }}
15 changes: 14 additions & 1 deletion charts/kargo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ api:
# "": https://argocd.example.com
# "shard2": https://argocd2.example.com

## All settings relating to the use of Argo Rollouts by the API Server.
rollouts:
## @param api.rollouts.integrationEnabled Specifies whether Argo Rollouts integration is enabled. When not enabled, the API server will not be capable of creating/updating/applying AnalysesTemplate resources in the Kargo control plane. When enabled, the API server will perform a sanity check at startup. If Argo Rollouts CRDs are not found, the API server will proceed as if this integration had been explicitly disabled. Explicitly disabling is still preferable if this integration is not desired, as it will grant fewer permissions to the API server.
integrationEnabled: true

## @section Controller
## All settings for the controller component
controller:
Expand All @@ -213,16 +218,24 @@ controller:
## @param controller.shardName [nullable] Set a shard name only if you are running multiple controllers backed by a single underlying control plane. Setting a shard name will cause this controller to operate **only** on resources with a matching shard name. Leaving the shard name undefined will designate this controller as the default controller that is responsible exclusively for resources that are **not** assigned to a specific shard. Leaving this undefined is the correct choice when you are not using sharding at all. It is also the correct setting if you are using sharding and want to designate a controller as the default for handling resources not assigned to a specific shard. In most cases, this setting should simply be left alone.
# shardName:

## All settings relating to the Argo CD control plane this controller will
## All settings relating to the Argo CD control plane this controller might
## integrate with.
argocd:
## @param controller.argocd.integrationEnabled Specifies whether Argo CD integration is enabled. When not enabled, the controller will not watch Argo CD Application resources or factor Application health and sync state into determinations of Stage health. Argo CD-based promotion mechanisms will also fail. When enabled, the controller will perform a sanity check at startup. If Argo CD CRDs are not found, the controller will proceed as if this integration had been explicitly disabled. Explicitly disabling is still preferable if this integration is not desired, as it will grant fewer permissions to the controller.
integrationEnabled: true
## @param controller.argocd.namespace The namespace into which Argo CD is installed.
namespace: argocd
## @param controller.argocd.watchArgocdNamespaceOnly Specifies whether the reconciler that watches Argo CD Applications for the sake of forcing related Stages to reconcile should only watch Argo CD Application resources residing in Argo CD's own namespace. Note: Older versions of Argo CD only supported Argo CD Application resources in Argo CD's own namespace, but newer versions support Argo CD Application resources in any namespace. This should usually be left as `false`.
watchArgocdNamespaceOnly: false
## @param controller.argocd.enableCredentialBorrowing Specifies whether Kargo may borrow repository credentials (specially formatted and specially annotated Secrets) from Argo CD.
enableCredentialBorrowing: true

## All settings relating to the use of Argo Rollouts AnalysisTemplates and
## AnalysisRuns as a means of verifying Stages after a Promotion.
rollouts:
## @param controller.rollouts.integrationEnabled Specifies whether Argo Rollouts integration is enabled. When not enabled, the controller will not reconcile Argo Rollouts AnalysisRun resources and attempts to verify Stages via Analysis will fail. When enabled, the controller will perform a sanity check at startup. If Argo Rollouts CRDs are not found, the controller will proceed as if this integration had been explicitly disabled. Explicitly disabling is still preferable if this integration is not desired, as it will grant fewer permissions to the controller.
integrationEnabled: true

## @param controller.logLevel The log level for the controller.
logLevel: INFO

Expand Down
Loading
Loading