Skip to content

Commit

Permalink
Rename to applicationset-progressive-sync controller (#84)
Browse files Browse the repository at this point in the history
* Move from argocd-progressive-rollout to applicationset-progressive-sync

* Replace deployment.skyscanner.net with sync.skyscanner.net

* Replace progressive rollout with progressive sync

* Rename CRD

* Replace sync.skyscanner.net with argoproj.skyscanner.net

* Replace deploymentskyscannernetv1alpha1 with syncv1alpha1

* Update app version
  • Loading branch information
maruina authored May 14, 2021
1 parent 0d1565d commit 54f7b75
Show file tree
Hide file tree
Showing 48 changed files with 873 additions and 355 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-test-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Install external secret for chart testing
run: |
kubectl create namespace argocd
kubectl apply -f charts/argocd-progressive-rollout/ci/external-secret.yaml
kubectl apply -f charts/applicationset-progressive-sync/ci/external-secret.yaml
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
uses: docker/[email protected]
with:
push: true
tags: maruina/argocd-progressive-rollout:${{ steps.tagName.outputs.tag }}
tags: maruina/applicationset-progressive-sync:${{ steps.tagName.outputs.tag }}
2 changes: 1 addition & 1 deletion .github/workflows/test-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ jobs:
uses: docker/[email protected]
with:
push: true
tags: maruina/argocd-progressive-rollout:main
tags: maruina/applicationset-progressive-sync:main
if: github.event_name != 'pull_request'
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Contributing to argocd-progressive-rollout
# Contributing to applicationset-progressive-sync

We're glad you want to make a contribution!

Expand All @@ -8,7 +8,7 @@ Take note of the build status of your pull request, only builds that pass will b

## License

By contributing your code, you agree to license your contribution under the terms of the APLv2: <https://github.com/Skyscanner/argocd-progressive-rollout/blob/main/LICENSE>
By contributing your code, you agree to license your contribution under the terms of the APLv2: <https://github.com/Skyscanner/applicationset-progressive-sync/blob/main/LICENSE>

All files are released with the Apache 2.0 license.

Expand All @@ -30,4 +30,4 @@ If you are adding a new file it should have a header like this:
* See the License for the specific language governing permissions and
* limitations under the License.
*/
```
```
8 changes: 4 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
domain: deployment.skyscanner.net
repo: github.com/Skyscanner/argocd-progressive-rollout
domain: argoproj.skyscanner.net
repo: github.com/Skyscanner/applicationset-progressive-sync
resources:
- group: deployment.skyscanner.net
kind: ProgressiveRollout
- group: argoproj.skyscanner.net
kind: ProgressiveSync
version: v1alpha1
version: "2"
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# argocd-progressive-rollout
# applicationset-progressive-sync

`argocd-progressive-rollout` is a controller to allow a progressive rollout of ArgoCD Applications generated by an ApplicationSet.
`applicationset-progressive-sync` is a controller to allow a progressive sync of ArgoCD Applications generated by an ApplicationSet.

## Motivation

Expand All @@ -12,13 +12,13 @@ If we enable the `auto-sync` policy, we will update all the generated Applicatio

This might not be a problem if we have only one production cluster, but organizations with tens or hundreds of clusters need to avoid a global rollout. They need to release new versions of their application in a safer way.

The `argocd progressive rollout` controller allows operators and developers to decide _how_ they want to update their Applications.
The `applicationset-progressive-sync` controller allows operators and developers to decide _how_ they want to update their Applications.

## Example `spec`

```yaml
apiVersion: deployment.skyscanner.net/v1alpha1
kind: ProgressiveRollout
apiVersion: argoproj.skyscanner.net/v1alpha1
kind: ProgressiveSync
metadata:
name: myprogressiverollout
namespace: argocd
Expand Down Expand Up @@ -103,7 +103,7 @@ make install
make run
```

Please remember the `ARGOCD_AUTH_TOKEN`, `ARGOCD_SERVER_ADDR` and `ARGOCD_INSECURE` environment variables need to be present in order
Please remember the `ARGOCD_AUTH_TOKEN`, `ARGOCD_SERVER_ADDR` and `ARGOCD_INSECURE` environment variables need to be present in order
to run against a Kubernetes cluster with Argo CD. If the cluster was configured using the `hack/setup-dev.sh` script,
these variables are part of the `.env.local` file.

Expand All @@ -116,7 +116,7 @@ make install
make docker-build
make deploy
```

In order to do so, the target cluster needs to have a secret named `prc-config` containing the three necessary
variables: `ARGOCD_AUTH_TOKEN`, `ARGOCD_SERVER_ADDR` and `ARGOCD_INSECURE`. If using the dev environment
in the following section, this secret has already been created.
Expand Down Expand Up @@ -154,11 +154,11 @@ make deploy
this will install all the dependencies (`pre-commit`, `kubebuilder`, `argocd`, `kind`) and it will install the correct version of ArgoCD Application API package for you. If you omit `argocd-version` and/or `appset-version` it will default to the latest stable/tested versions of ArgoCD and Appset controller.

After running the script, you will have 3 kind clusters created locally:
- `kind-argocd-control-plane` - cluster hosting the argocd installation and the progressive rollout operator. This cluster is also registered with Argo so that we can simulate using the same process for deploying to control cluster as well
- `kind-argocd-control-plane` - cluster hosting the argocd installation and the progressive sync operator. This cluster is also registered with Argo so that we can simulate using the same process for deploying to control cluster as well
- `kind-prc-cluster-1` and `kind-prc-cluster-2` - are the target clusters for deploying the apps to.

This gives us a total of 3 clusters allowing us to play with multiple stages of deploying. It will also log you in argocd cli. You can find additional login details in `.env.local` file that will be generated for your convenience.

#### Regenerating your access

In case that your access to the local argocd has become broken, you can regenerate it by running
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/condition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ package v1alpha1

const (
// CompletedCondition is the condition type used
// to record the last progressive rollout result.
// to record the last progressive sync result.
CompletedCondition string = "Completed"

// StagesCompleteReason represent the fact that all
// the progressive rollout stages have been completed
// the progressive sync stages have been completed
StagesCompleteReason string = "StagesCompleted"

// StagesFailedReason represent the fact that a
// progressive rollout stage has failed
// progressive sync stage has failed
StagesFailedReason string = "StagesFailed"
)
6 changes: 3 additions & 3 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the deployment.skyscanner.net v1alpha1 API group
// Package v1alpha1 contains API Schema definitions for the argoproj.skyscanner.net v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=deployment.skyscanner.net
// +groupName=argoproj.skyscanner.net
package v1alpha1

import (
Expand All @@ -26,7 +26,7 @@ import (

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "deployment.skyscanner.net", Version: "v1alpha1"}
GroupVersion = schema.GroupVersion{Group: "argoproj.skyscanner.net", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
)

const ProgressiveRolloutFinalizer = "finalizers.deployment.skyscanner.net"
const ProgressiveSyncFinalizer = "finalizers.argoproj.skyscanner.net"

// ProgressiveRolloutSpec defines the desired state of ProgressiveRollout
type ProgressiveRolloutSpec struct {
// ProgressiveSyncSpec defines the desired state of ProgressiveSync
type ProgressiveSyncSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

Expand All @@ -34,11 +34,11 @@ type ProgressiveRolloutSpec struct {
SourceRef corev1.TypedLocalObjectReference `json:"sourceRef"`
// Stages defines a list of Progressive Rollout stages
//+kubebuilder:validation:Optional
Stages []ProgressiveRolloutStage `json:"stages,omitempty"`
Stages []ProgressiveSyncStage `json:"stages,omitempty"`
}

// ProgressiveRolloutStage defines a rollout stage
type ProgressiveRolloutStage struct {
// ProgressiveSyncStage defines a rollout stage
type ProgressiveSyncStage struct {
// Name is a human friendly name for the stage
//+kubebuilder:validation:Required
Name string `json:"name"`
Expand All @@ -50,11 +50,11 @@ type ProgressiveRolloutStage struct {
MaxTargets intstr.IntOrString `json:"maxTargets"`
// Targets is the targets to update in the stage
//+kubebuilder:validation:Optional
Targets ProgressiveRolloutTargets `json:"targets,omitempty"`
Targets ProgressiveSyncTargets `json:"targets,omitempty"`
}

// ProgressiveRolloutTargets defines the target of the Progressive Rollout
type ProgressiveRolloutTargets struct {
// ProgressiveSyncTargets defines the target of the Progressive Rollout
type ProgressiveSyncTargets struct {
// Clusters is the a cluster type of targets
//+kubebuilder:validation:Optional
Clusters Clusters `json:"clusters"`
Expand All @@ -67,21 +67,21 @@ type Clusters struct {
Selector metav1.LabelSelector `json:"selector"`
}

// ProgressiveRolloutStatus defines the observed state of ProgressiveRollout
type ProgressiveRolloutStatus struct {
// ProgressiveSyncStatus defines the observed state of ProgressiveSync
type ProgressiveSyncStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
Conditions []metav1.Condition `json:"conditions,omitempty"`
Stages []StageStatus `json:"stages,omitempty"`
}

// GetStatusConditions returns a pointer to the Status.Conditions slice
func (in *ProgressiveRollout) GetStatusConditions() *[]metav1.Condition {
func (in *ProgressiveSync) GetStatusConditions() *[]metav1.Condition {
return &in.Status.Conditions
}

// NewStatusCondition adds a new Condition
func (in *ProgressiveRollout) NewStatusCondition(t string, s metav1.ConditionStatus, r string, m string) metav1.Condition {
func (in *ProgressiveSync) NewStatusCondition(t string, s metav1.ConditionStatus, r string, m string) metav1.Condition {
return metav1.Condition{
Type: t,
Status: s,
Expand All @@ -91,8 +91,8 @@ func (in *ProgressiveRollout) NewStatusCondition(t string, s metav1.ConditionSta
}
}

// Owns returns true if the ProgressiveRollout object has a reference to one of the owners
func (in *ProgressiveRollout) Owns(owners []metav1.OwnerReference) bool {
// Owns returns true if the ProgressiveSync object has a reference to one of the owners
func (in *ProgressiveSync) Owns(owners []metav1.OwnerReference) bool {
for _, owner := range owners {
if owner.Kind == in.Spec.SourceRef.Kind && owner.APIVersion == *in.Spec.SourceRef.APIGroup && owner.Name == in.Spec.SourceRef.Name {
return true
Expand All @@ -104,7 +104,7 @@ func (in *ProgressiveRollout) Owns(owners []metav1.OwnerReference) bool {
// SetStageStatus sets the corresponding StageStatus in stageStatus to newStatus
// - If a stage doesn't exist, it will be added to StageStatus slice
// - If a stage already exists it will be updated
func (in *ProgressiveRollout) SetStageStatus(newStatus StageStatus, updateTime *metav1.Time) {
func (in *ProgressiveSync) SetStageStatus(newStatus StageStatus, updateTime *metav1.Time) {
// If StartedAt is not set and the stage is in progress, assign StartedAt
if newStatus.Phase == PhaseProgressing && newStatus.StartedAt.IsZero() {
newStatus.StartedAt = updateTime
Expand All @@ -131,24 +131,24 @@ func (in *ProgressiveRollout) SetStageStatus(newStatus StageStatus, updateTime *

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// ProgressiveRollout is the Schema for the progressiverollouts API
type ProgressiveRollout struct {
// ProgressiveSync is the Schema for the progressivesyncs API
type ProgressiveSync struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ProgressiveRolloutSpec `json:"spec,omitempty"`
Status ProgressiveRolloutStatus `json:"status,omitempty"`
Spec ProgressiveSyncSpec `json:"spec,omitempty"`
Status ProgressiveSyncStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

// ProgressiveRolloutList contains a list of ProgressiveRollout
type ProgressiveRolloutList struct {
// ProgressiveSyncList contains a list of ProgressiveSync
type ProgressiveSyncList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ProgressiveRollout `json:"items"`
Items []ProgressiveSync `json:"items"`
}

func init() {
SchemeBuilder.Register(&ProgressiveRollout{}, &ProgressiveRolloutList{})
SchemeBuilder.Register(&ProgressiveSync{}, &ProgressiveSyncList{})
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"
"time"

"github.com/Skyscanner/argocd-progressive-rollout/internal/utils"
"github.com/Skyscanner/applicationset-progressive-sync/internal/utils"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -38,9 +38,9 @@ func TestOwns(t *testing.T) {
}}

ref := utils.AppSetAPIGroup
pr := ProgressiveRollout{
pr := ProgressiveSync{
ObjectMeta: metav1.ObjectMeta{Name: "pr", Namespace: "namespace"},
Spec: ProgressiveRolloutSpec{
Spec: ProgressiveSyncSpec{
SourceRef: corev1.TypedLocalObjectReference{
APIGroup: &ref,
Kind: utils.AppSetKind,
Expand Down Expand Up @@ -143,17 +143,17 @@ func TestSetStageStatus(t *testing.T) {
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
ref := utils.AppSetAPIGroup
pr := ProgressiveRollout{
pr := ProgressiveSync{
ObjectMeta: metav1.ObjectMeta{Name: "pr", Namespace: "namespace"},
Spec: ProgressiveRolloutSpec{
Spec: ProgressiveSyncSpec{
SourceRef: corev1.TypedLocalObjectReference{
APIGroup: &ref,
Kind: utils.AppSetKind,
Name: "owner-app-set",
},
Stages: nil,
},
Status: ProgressiveRolloutStatus{
Status: ProgressiveSyncStatus{
Stages: testCase.stageStatus,
},
}
Expand Down
Loading

0 comments on commit 54f7b75

Please sign in to comment.