Skip to content

Commit

Permalink
Add sample resources for argo rollout
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Dec 5, 2023
1 parent d9870e5 commit 0ea5d20
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 6 deletions.
28 changes: 28 additions & 0 deletions config/samples/argorollout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: rollout-sample
spec:
replicas: 2
revisionHistoryLimit: 2
selector:
matchLabels:
app: rollout-sample
template:
metadata:
labels:
app: rollout-sample
spec:
containers:
- name: nginx
image: nginx:1.25.0
imagePullPolicy: Always
ports:
- containerPort: 80
strategy:
blueGreen:
activeService: rollout-bluegreen-active
previewService: rollout-bluegreen-preview
autoPromotionEnabled: true
# Do not scaleDown from ArgoRollout
scaleDownDelaySeconds: 0
4 changes: 4 additions & 0 deletions config/samples/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## Append samples of your project ##
namespace: rollout-test

resources:
- service.yaml
- argorollout.yaml
- rollout_v1alpha1_rolloutscaledown.yaml
#+kubebuilder:scaffold:manifestskustomizesamples
4 changes: 2 additions & 2 deletions config/samples/rollout_v1alpha1_rolloutscaledown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ metadata:
app.kubernetes.io/created-by: rollout-optimizer-controller
name: rolloutscaledown-sample
spec:
targetRollout: "example"
targetRollout: "rollout-sample"
terminatePerOnce: 1
coolTimeSeconds: 40
coolTimeSeconds: 40
26 changes: 26 additions & 0 deletions config/samples/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
apiVersion: v1
kind: Service
metadata:
name: rollout-bluegreen-active
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: rollout-sample
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: rollout-bluegreen-preview
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: rollout-sample
type: ClusterIP
9 changes: 5 additions & 4 deletions internal/controller/argorollout_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,21 @@ func (r *ArgoRolloutReconciler) Reconcile(ctx context.Context, req ctrl.Request)
}
}
if targetScaleDown == nil {
logger.V(2).Info("%s/%s is not target of ScaleDown", req.Namespace, req.Name)
logger.V(2).Info("Not target of ScaleDown", req.Namespace, req.Name)
return ctrl.Result{}, nil
}
argoRollout := &argorolloutsapiv1alpha1.Rollout{}
err = r.Get(ctx, types.NamespacedName{Name: req.Name, Namespace: req.Namespace}, argoRollout)
if err != nil && errors.IsNotFound(err) {
logger.V(1).Info("Not found ArgoRollout %s/%s", req.Namespace, req.Name)
logger.V(1).Info("Not found ArgoRollout", req.Namespace, req.Name)
return ctrl.Result{}, nil
} else if err != nil {
logger.V(1).Error(err, "Failed to get ArgoRollout %s/%s", req.Namespace, req.Name)
logger.V(1).Error(err, "Failed to get ArgoRollout", req.Namespace, req.Name)
return ctrl.Result{}, err
}

logger.V(1).Info("Target ArgoRollout %s/%s", argoRollout.Namespace, argoRollout.Name)
logger.V(1).Info("Target ArgoRollout", argoRollout.Namespace, argoRollout.Name)
// TODO: Check ArgoRollout status and scaledown if needed

return ctrl.Result{}, nil
}
Expand Down

0 comments on commit 0ea5d20

Please sign in to comment.