Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into perenesenko/argo-…
Browse files Browse the repository at this point in the history
…rollouts-1255
  • Loading branch information
perenesenko committed Jun 21, 2021
2 parents fc7d8d9 + 96ba030 commit a939fe1
Show file tree
Hide file tree
Showing 68 changed files with 2,214 additions and 143 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ plugin-darwin: ui/dist
cp -r ui/dist/app/* server/static
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${PLUGIN_CLI_NAME}-darwin-amd64 ./cmd/kubectl-argo-rollouts

.PHONY: plugin-docs
plugin-docs:
go run ./hack/gen-plugin-docs/main.go
.PHONY: docs
docs:
go run ./hack/gen-docs/main.go

.PHONY: builder-image
builder-image:
Expand Down Expand Up @@ -259,7 +259,7 @@ clean:
precheckin: test lint

.PHONY: release-docs
release-docs: plugin-docs
release-docs: docs
docker run --rm -it \
-v ~/.ssh:/root/.ssh \
-v ${CURRENT_DIR}:/docs \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Argo Rollouts (optionally) integrates with ingress controllers and service meshe

```
kubectl create namespace argo-rollouts
kubectl apply -n argo-rollouts -f https://raw.githubusercontent.com/argoproj/argo-rollouts/stable/manifests/install.yaml
kubectl apply -n argo-rollouts -f https://github.com/argoproj/argo-rollouts/releases/latest/download/install.yaml
```

Follow the full [getting started guide](docs/getting-started.md) to walk through creating and then updating a rollout object.
Expand Down
10 changes: 10 additions & 0 deletions cmd/rollouts-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ func newCommand() *cobra.Command {
clusterDynamicInformerFactory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(dynamicClient, resyncDuration, metav1.NamespaceAll, instanceIDTweakListFunc)
// 3. We finally need an istio dynamic informer factory which does not use a tweakListFunc.
istioDynamicInformerFactory := dynamicinformer.NewFilteredDynamicSharedInformerFactory(dynamicClient, resyncDuration, namespace, nil)

controllerNamespaceInformerFactory := kubeinformers.NewSharedInformerFactoryWithOptions(
kubeClient,
resyncDuration,
kubeinformers.WithNamespace(defaults.Namespace()))
configMapInformer := controllerNamespaceInformerFactory.Core().V1().ConfigMaps()
secretInformer := controllerNamespaceInformerFactory.Core().V1().Secrets()
cm := controller.NewManager(
namespace,
kubeClient,
Expand All @@ -153,6 +160,8 @@ func newCommand() *cobra.Command {
tolerantinformer.NewTolerantClusterAnalysisTemplateInformer(clusterDynamicInformerFactory),
istioDynamicInformerFactory.ForResource(istioutil.GetIstioVirtualServiceGVR()).Informer(),
istioDynamicInformerFactory.ForResource(istioutil.GetIstioDestinationRuleGVR()).Informer(),
configMapInformer,
secretInformer,
resyncDuration,
instanceID,
metricsPort,
Expand All @@ -166,6 +175,7 @@ func newCommand() *cobra.Command {
clusterDynamicInformerFactory.Start(stopCh)
}
kubeInformerFactory.Start(stopCh)
controllerNamespaceInformerFactory.Start(stopCh)
jobInformerFactory.Start(stopCh)

// Check if Istio installed on cluster before starting dynamicInformerFactory
Expand Down
51 changes: 40 additions & 11 deletions controller/controller.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package controller

import (
"encoding/json"
"fmt"
"time"

"github.com/argoproj/argo-rollouts/utils/queue"

"github.com/argoproj/notifications-engine/pkg/api"
"github.com/argoproj/notifications-engine/pkg/controller"
"github.com/pkg/errors"
smiclientset "github.com/servicemeshinterface/smi-sdk-go/pkg/gen/client/split/clientset/versioned"
log "github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/util/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/wait"
Expand All @@ -28,11 +30,14 @@ import (
"github.com/argoproj/argo-rollouts/controller/metrics"
"github.com/argoproj/argo-rollouts/experiments"
"github.com/argoproj/argo-rollouts/ingress"
"github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1"
clientset "github.com/argoproj/argo-rollouts/pkg/client/clientset/versioned"
rolloutscheme "github.com/argoproj/argo-rollouts/pkg/client/clientset/versioned/scheme"
informers "github.com/argoproj/argo-rollouts/pkg/client/informers/externalversions/rollouts/v1alpha1"
"github.com/argoproj/argo-rollouts/rollout"
"github.com/argoproj/argo-rollouts/service"
"github.com/argoproj/argo-rollouts/utils/defaults"
"github.com/argoproj/argo-rollouts/utils/queue"
"github.com/argoproj/argo-rollouts/utils/record"
)

Expand Down Expand Up @@ -61,12 +66,13 @@ const (

// Manager is the controller implementation for Argo-Rollout resources
type Manager struct {
metricsServer *metrics.MetricsServer
rolloutController *rollout.Controller
experimentController *experiments.Controller
analysisController *analysis.Controller
serviceController *service.Controller
ingressController *ingress.Controller
metricsServer *metrics.MetricsServer
rolloutController *rollout.Controller
experimentController *experiments.Controller
analysisController *analysis.Controller
serviceController *service.Controller
ingressController *ingress.Controller
notificationsController controller.NotificationController

rolloutSynced cache.InformerSynced
experimentSynced cache.InformerSynced
Expand All @@ -77,6 +83,8 @@ type Manager struct {
ingressSynced cache.InformerSynced
jobSynced cache.InformerSynced
replicasSetSynced cache.InformerSynced
configMapSynced cache.InformerSynced
secretSynced cache.InformerSynced

rolloutWorkqueue workqueue.RateLimitingInterface
serviceWorkqueue workqueue.RateLimitingInterface
Expand Down Expand Up @@ -110,6 +118,8 @@ func NewManager(
clusterAnalysisTemplateInformer informers.ClusterAnalysisTemplateInformer,
istioVirtualServiceInformer cache.SharedIndexInformer,
istioDestinationRuleInformer cache.SharedIndexInformer,
configMapInformer coreinformers.ConfigMapInformer,
secretInformer coreinformers.SecretInformer,
resyncPeriod time.Duration,
instanceID string,
metricsPort int,
Expand Down Expand Up @@ -139,8 +149,22 @@ func NewManager(
ingressWorkqueue := workqueue.NewNamedRateLimitingQueue(queue.DefaultArgoRolloutsRateLimiter(), "Ingresses")

refResolver := rollout.NewInformerBasedWorkloadRefResolver(namespace, dynamicclientset, discoveryClient, rolloutWorkqueue, rolloutsInformer.Informer())

recorder := record.NewEventRecorder(kubeclientset, metrics.MetricRolloutEventsTotal)
apiFactory := api.NewFactory(record.NewAPIFactorySettings(), defaults.Namespace(), secretInformer.Informer(), configMapInformer.Informer())
recorder := record.NewEventRecorder(kubeclientset, metrics.MetricRolloutEventsTotal, apiFactory)
notificationsController := controller.NewController(dynamicclientset.Resource(v1alpha1.RolloutGVR), rolloutsInformer.Informer(), apiFactory,
controller.WithToUnstructured(func(obj metav1.Object) (*unstructured.Unstructured, error) {
data, err := json.Marshal(obj)
if err != nil {
return nil, err
}
res := &unstructured.Unstructured{}
err = json.Unmarshal(data, res)
if err != nil {
return nil, err
}
return res, nil
}),
)

rolloutController := rollout.NewController(rollout.ControllerConfig{
Namespace: namespace,
Expand Down Expand Up @@ -229,6 +253,8 @@ func NewManager(
analysisTemplateSynced: analysisTemplateInformer.Informer().HasSynced,
clusterAnalysisTemplateSynced: clusterAnalysisTemplateInformer.Informer().HasSynced,
replicasSetSynced: replicaSetInformer.Informer().HasSynced,
configMapSynced: configMapInformer.Informer().HasSynced,
secretSynced: secretInformer.Informer().HasSynced,
rolloutWorkqueue: rolloutWorkqueue,
experimentWorkqueue: experimentWorkqueue,
analysisRunWorkqueue: analysisRunWorkqueue,
Expand All @@ -239,6 +265,7 @@ func NewManager(
ingressController: ingressController,
experimentController: experimentController,
analysisController: analysisController,
notificationsController: notificationsController,
dynamicClientSet: dynamicclientset,
refResolver: refResolver,
namespace: namespace,
Expand All @@ -260,7 +287,7 @@ func (c *Manager) Run(rolloutThreadiness, serviceThreadiness, ingressThreadiness

// Wait for the caches to be synced before starting workers
log.Info("Waiting for controller's informer caches to sync")
if ok := cache.WaitForCacheSync(stopCh, c.serviceSynced, c.ingressSynced, c.jobSynced, c.rolloutSynced, c.experimentSynced, c.analysisRunSynced, c.analysisTemplateSynced, c.replicasSetSynced); !ok {
if ok := cache.WaitForCacheSync(stopCh, c.serviceSynced, c.ingressSynced, c.jobSynced, c.rolloutSynced, c.experimentSynced, c.analysisRunSynced, c.analysisTemplateSynced, c.replicasSetSynced, c.configMapSynced, c.secretSynced); !ok {
return fmt.Errorf("failed to wait for caches to sync")
}
// only wait for cluster scoped informers to sync if we are running in cluster-wide mode
Expand All @@ -277,6 +304,8 @@ func (c *Manager) Run(rolloutThreadiness, serviceThreadiness, ingressThreadiness
go wait.Until(func() { c.ingressController.Run(ingressThreadiness, stopCh) }, time.Second, stopCh)
go wait.Until(func() { c.experimentController.Run(experimentThreadiness, stopCh) }, time.Second, stopCh)
go wait.Until(func() { c.analysisController.Run(analysisThreadiness, stopCh) }, time.Second, stopCh)
go wait.Until(func() { c.notificationsController.Run(rolloutThreadiness, stopCh) }, time.Second, stopCh)

log.Info("Started controller")

go func() {
Expand Down
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Does Argo Rollouts depend on Argo CD or any other Argo project?

Argo Rollouts is a standalone project. Even though it works great with Argo CD and other Argo projects, it can by used
Argo Rollouts is a standalone project. Even though it works great with Argo CD and other Argo projects, it can be used
on its own for Progressive Delivery scenarios. More specifically, argo Rollouts does **NOT** require that you also have installed Argo CD on the same cluster.

### How does Argo Rollouts integrate with Argo CD?
Expand Down
74 changes: 74 additions & 0 deletions docs/features/helm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Using Argo Rollouts with Helm

Argo Rollouts will always respond to changes in Rollouts resources regardless of how the change was made.
This means that Argo Rollouts is compatible with all templating solutions that you might use to manage
your deployments.

Argo Rollouts manifests can be managed with the [Helm package manager](https://helm.sh/). If your Helm chart contains Rollout Resources,
then as soon as you install/upgrade your chart, Argo Rollouts will take over and initiate the progressive delivery
process.

Here is an example Rollout that is managed with Helm:

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Rollout
metadata:
name: {{ template "helm-guestbook.fullname" . }}
labels:
app: {{ template "helm-guestbook.name" . }}
chart: {{ template "helm-guestbook.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
revisionHistoryLimit: 3
selector:
matchLabels:
app: {{ template "helm-guestbook.name" . }}
release: {{ .Release.Name }}
strategy:
blueGreen:
activeService: {{ template "helm-guestbook.fullname" . }}
previewService: {{ template "helm-guestbook.fullname" . }}-preview
template:
metadata:
labels:
app: {{ template "helm-guestbook.name" . }}
release: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}

```


You can find the full example at [https://github.com/argoproj/argo-rollouts/tree/master/examples/helm-blue-green](https://github.com/argoproj/argo-rollouts/tree/master/examples/helm-blue-green).
Loading

0 comments on commit a939fe1

Please sign in to comment.