Skip to content

Commit

Permalink
Canary CRD refactoring
Browse files Browse the repository at this point in the history
- set canaries.flagger.app version to v1alpha1
- replace old Canary spec with CanaryDeployment
  • Loading branch information
stefanprodan committed Oct 10, 2018
1 parent 5a14125 commit 302de10
Show file tree
Hide file tree
Showing 40 changed files with 295 additions and 1,984 deletions.
1 change: 1 addition & 0 deletions Gopkg.lock

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

4 changes: 2 additions & 2 deletions artifacts/canaries/canary.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: flagger.app/v1beta1
kind: CanaryDeployment
apiVersion: flagger.app/v1alpha1
kind: Canary
metadata:
name: podinfo
namespace: test
Expand Down
73 changes: 10 additions & 63 deletions artifacts/flagger/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ metadata:
name: canaries.flagger.app
spec:
group: flagger.app
version: v1beta1
version: v1alpha1
versions:
- name: v1beta1
- name: v1alpha1
served: true
storage: true
names:
Expand All @@ -19,75 +19,22 @@ spec:
properties:
spec:
required:
- targetKind
- virtualService
- primary
- canary
- canaryAnalysis
- targetRef
- service
- canaryAnalysis
properties:
targetKind:
type: string
virtualService:
properties:
name:
type: string
primary:
targetRef:
properties:
name:
apiVersion:
type: string
host:
kind:
type: string
canary:
properties:
name:
type: string
host:
type: string
canaryAnalysis:
service:
properties:
threshold:
type: number
maxWeight:
port:
type: number
stepWeight:
type: number
metrics:
type: array
properties:
items:
type: object
properties:
name:
type: string
interval:
type: string
pattern: "^[0-9]+(m)"
threshold:
type: number
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: canarydeployments.flagger.app
spec:
group: flagger.app
version: v1beta1
versions:
- name: v1beta1
served: true
storage: true
names:
plural: canarydeployments
singular: canarydeployment
kind: CanaryDeployment
scope: Namespaced
validation:
openAPIV3Schema:
properties:
spec:
required:
- canaryAnalysis
properties:
canaryAnalysis:
properties:
threshold:
Expand Down
42 changes: 0 additions & 42 deletions artifacts/rollouts/podinfo.yaml

This file was deleted.

36 changes: 0 additions & 36 deletions artifacts/rollouts/podinfoc.yaml

This file was deleted.

32 changes: 12 additions & 20 deletions charts/flagger/templates/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
name: canaries.flagger.app
spec:
group: flagger.app
version: v1beta1
version: v1alpha1
versions:
- name: v1beta1
- name: v1alpha1
served: true
storage: true
names:
Expand All @@ -20,30 +20,22 @@ spec:
properties:
spec:
required:
- targetKind
- virtualService
- primary
- canary
- canaryAnalysis
- targetRef
- service
- canaryAnalysis
properties:
targetKind:
type: string
virtualService:
targetRef:
properties:
name:
type: string
primary:
properties:
name:
apiVersion:
type: string
host:
kind:
type: string
canary:
properties:
name:
type: string
host:
type: string
service:
properties:
port:
type: number
canaryAnalysis:
properties:
threshold:
Expand Down
31 changes: 5 additions & 26 deletions cmd/flagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"log"
"time"

"github.com/stefanprodan/flagger/pkg/operator"

_ "github.com/istio/glog"
sharedclientset "github.com/knative/pkg/client/clientset/versioned"
"github.com/knative/pkg/signals"
Expand Down Expand Up @@ -71,9 +69,8 @@ func main() {
logger.Fatalf("Error building example clientset: %s", err.Error())
}

rolloutInformerFactory := informers.NewSharedInformerFactory(rolloutClient, time.Second*30)
rolloutInformer := rolloutInformerFactory.Flagger().V1beta1().Canaries()
canaryDeploymentInformer := rolloutInformerFactory.Flagger().V1beta1().CanaryDeployments()
canaryInformerFactory := informers.NewSharedInformerFactory(rolloutClient, time.Second*30)
canaryInformer := canaryInformerFactory.Flagger().V1alpha1().Canaries()

logger.Infof("Starting flagger version %s revision %s", version.VERSION, version.REVISION)

Expand All @@ -98,28 +95,17 @@ func main() {
kubeClient,
sharedClient,
rolloutClient,
rolloutInformer,
controlLoopInterval,
metricsServer,
logger,
)

cd := operator.NewController(
kubeClient,
sharedClient,
rolloutClient,
canaryDeploymentInformer,
canaryInformer,
controlLoopInterval,
metricsServer,
logger,
)

rolloutInformerFactory.Start(stopCh)
canaryInformerFactory.Start(stopCh)

logger.Info("Waiting for informer caches to sync")
for _, synced := range []cache.InformerSynced{
rolloutInformer.Informer().HasSynced,
canaryDeploymentInformer.Informer().HasSynced,
canaryInformer.Informer().HasSynced,
} {
if ok := cache.WaitForCacheSync(stopCh, synced); !ok {
logger.Fatalf("Failed to wait for cache sync")
Expand All @@ -133,12 +119,5 @@ func main() {
}
}(c)

// start controller
go func(ctrl *operator.Controller) {
if err := ctrl.Run(2, stopCh); err != nil {
logger.Fatalf("Error running controller: %v", err)
}
}(cd)

<-stopCh
}
2 changes: 1 addition & 1 deletion hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${SCRIPT_ROOT}; ls -d -1 ./vendor/k8s.io/code-ge

${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \
github.com/stefanprodan/flagger/pkg/client github.com/stefanprodan/flagger/pkg/apis \
flagger:v1beta1 \
flagger:v1alpha1 \
--go-header-file ${SCRIPT_ROOT}/hack/boilerplate.go.txt

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ limitations under the License.

// +k8s:deepcopy-gen=package

// Package v1beta1 is the v1beta1 version of the API.
// Package v1alpha1 is the v1alpha1 version of the API.
// +groupName=flagger.app
package v1beta1
package v1alpha1
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package v1beta1
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -25,7 +25,7 @@ import (
)

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: rollout.GroupName, Version: "v1beta1"}
var SchemeGroupVersion = schema.GroupVersion{Group: rollout.GroupName, Version: "v1alpha1"}

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
Expand All @@ -47,8 +47,6 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&Canary{},
&CanaryList{},
&CanaryDeployment{},
&CanaryDeploymentList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
Expand Down
Loading

0 comments on commit 302de10

Please sign in to comment.