Skip to content

Commit

Permalink
Extend gitops.kubesphere.io/Application CRD and support basic operati…
Browse files Browse the repository at this point in the history
…on on FluxCD HelmRelease and Kustomization
  • Loading branch information
chengleqi committed Jul 25, 2022
1 parent 3bfb282 commit a9a1cc9
Show file tree
Hide file tree
Showing 12 changed files with 3,732 additions and 3 deletions.
11 changes: 9 additions & 2 deletions cmd/controller/app/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ func getAllControllers(mgr manager.Manager, client k8s.Client, informerFactory i
JenkinsClient: jenkinsCore,
}

fluxcdApplicationReconciler := &fluxcd.ApplicationReconciler{
Client: mgr.GetClient(),
}

return map[string]func(mgr manager.Manager) error{
gitRepoReconcilers.GetName(): func(mgr manager.Manager) error {
return gitRepoReconcilers.SetupWithManager(mgr)
Expand Down Expand Up @@ -207,8 +211,11 @@ func getAllControllers(mgr manager.Manager, client k8s.Client, informerFactory i
argcdImageUpdaterReconciler.GetGroupName() + "-image-updater": func(mgr manager.Manager) error {
return argcdImageUpdaterReconciler.SetupWithManager(mgr)
},
"fluxcd": func(mgr manager.Manager) error {
return fluxcdGitRepoReconciler.SetupWithManager(mgr)
fluxcdApplicationReconciler.GetGroupName(): func(mgr manager.Manager) (err error) {
if err = fluxcdGitRepoReconciler.SetupWithManager(mgr); err != nil {
return
}
return fluxcdApplicationReconciler.SetupWithManager(mgr)
},
}
}
996 changes: 996 additions & 0 deletions config/crd/bases/gitops.kubesphere.io_applications.yaml

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,26 @@ rules:
- get
- list
- watch
- apiGroups:
- helm.toolkit.fluxcd.io
resources:
- helmreleases
verbs:
- create
- delete
- get
- list
- update
- apiGroups:
- kustomize.toolkit.fluxcd.io
resources:
- kustomizations
verbs:
- create
- delete
- get
- list
- update
- apiGroups:
- source.toolkit.fluxcd.io
resources:
Expand All @@ -326,3 +346,10 @@ rules:
- get
- list
- update
- apiGroups:
- source.toolkit.fluxcd.io/v1beta2
resources:
- helmcharts
verbs:
- get
- list
48 changes: 48 additions & 0 deletions config/samples/gitops/fluxcd-application-helmrelease.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: gitops.kubesphere.io/v1alpha1
kind: Application
metadata:
name: chengleqi-test-helm
namespace: my-devops-projecthmhx2
labels:
gitops.kubesphere.io/save-helm-template: "true"
spec:
kind: fluxcd
fluxApp:
spec:
source:
sourceRef:
kind: GitRepository
name: fluxcd-github-repo
namespace: my-devops-projecthmhx2
config:
helmRelease:
chart:
interval: 5m0s
chart: ./helm-chart
version: "0.1.0"
valuesFiles:
- ./helm-chart/values.yaml
- ./helm-chart/aliyun-values.yaml
reconcileStrategy: Revision
template:
deploy:
- destination:
kubeConfig:
targetNamespace: helm-app
interval: 1m0s
upgrade:
remediation:
remediateLastFailure: true
force: true
install:
createNamespace: true
- destination:
kubeConfig:
targetNamespace: another-helm-app
interval: 1m0s
upgrade:
remediation:
remediateLastFailure: true
force: true
install:
createNamespace: true
25 changes: 25 additions & 0 deletions config/samples/gitops/fluxcd-application-helmtemplate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: gitops.kubesphere.io/v1alpha1
kind: Application
metadata:
name: chengleqi-test-template
namespace: my-devops-projecthmhx2
spec:
kind: fluxcd
fluxApp:
spec:
source:
config:
helmRelease:
chart:
template: my-devops-projecthmhx2-chengleqi-test-helm
deploy:
- destination:
kubeConfig:
targetNamespace: template-app
interval: 1m0s
upgrade:
remediation:
remediateLastFailure: true
force: true
install:
createNamespace: true
22 changes: 22 additions & 0 deletions config/samples/gitops/fluxcd-application-kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: gitops.kubesphere.io/v1alpha1
kind: Application
metadata:
name: chengleqi-test-kus
namespace: my-devops-projecthmhx2
spec:
kind: fluxcd
fluxApp:
spec:
source:
sourceRef:
kind: GitRepository
name: fluxcd-gitee-repo
namespace: my-devops-projecthmhx2
config:
kustomization:
- destination:
kubeConfig:
targetNamespace: default
interval: 8m0s
prune: true
path: "nginx"
Loading

0 comments on commit a9a1cc9

Please sign in to comment.