Skip to content

Commit

Permalink
Add helmtemplate-controller and Redesign gitops.kubesphere.io/Applica…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
chengleqi committed Jul 18, 2022
1 parent c7ba5b3 commit 223d964
Show file tree
Hide file tree
Showing 11 changed files with 523 additions and 217 deletions.
7 changes: 7 additions & 0 deletions cmd/controller/app/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ func getAllControllers(mgr manager.Manager, client k8s.Client, informerFactory i
Client: mgr.GetClient(),
}

fluxcdHelmtemplateReconciler := &fluxcd.HelmTemplateReconciler{
Client: mgr.GetClient(),
}

fluxcdApplicationReconciler := &fluxcd.ApplicationReconciler{
Client: mgr.GetClient(),
}
Expand Down Expand Up @@ -206,6 +210,9 @@ func getAllControllers(mgr manager.Manager, client k8s.Client, informerFactory i
if err = fluxcdGitRepoReconciler.SetupWithManager(mgr); err != nil {
return
}
if err = fluxcdHelmtemplateReconciler.SetupWithManager(mgr); err != nil {
return
}
return fluxcdApplicationReconciler.SetupWithManager(mgr)
},
}
Expand Down
164 changes: 103 additions & 61 deletions config/crd/bases/gitops.kubesphere.io_applications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -875,27 +875,49 @@ spec:
config:
properties:
helmRelease:
description: Two Application Type
description: HelmRelease for FluxCD HelmRelease
properties:
chart:
description: Chart defines the template of the v1beta2.HelmChart
that should be created for this HelmRelease.
properties:
apiVersion:
description: APIVersion of the referent.
chart:
description: The name or path the Helm chart is
available at in the SourceRef.
type: string
kind:
description: Kind of the referent, valid values
are ('HelmRepository', 'GitRepository', 'Bucket').
interval:
description: Interval at which to check the v1beta2.Source
for updates. Defaults to 'HelmReleaseSpec.Interval'.
type: string
name:
description: Name of the referent.
reconcileStrategy:
description: Determines what enables the creation
of a new artifact. Valid values are ('ChartVersion',
'Revision'). See the documentation of the values
for an explanation on their behavior. Defaults
to ChartVersion when omitted.
type: string
valuesFiles:
description: Alternative list of values files
to use as the chart values (values.yaml is not
included by default), expected to be a relative
path in the SourceRef. Values files are merged
in the order of this list with the last file
overriding the first. Ignored when omitted.
items:
type: string
type: array
version:
default: '*'
description: Version semver expression, ignored
for charts from v1beta2.GitRepository and v1beta2.Bucket
sources. Defaults to latest when omitted.
type: string
required:
- kind
- name
- chart
type: object
spec:
deploy:
description: HelmReleaseConfig stand for multi-clusters
and multi-targetNamespace config
items:
properties:
dependsOn:
Expand All @@ -919,6 +941,55 @@ spec:
- name
type: object
type: array
destination:
description: Destination stand for the destination
of the helmrelease
properties:
kubeConfig:
description: The KubeConfig for reconciling
the Kustomization on a remote cluster.
When used in combination with KustomizationSpec.ServiceAccountName,
forces the controller to act on behalf
of that Service Account at the target
cluster. If the --default-service-account
flag is set, its value will be used as
a controller level fallback for when KustomizationSpec.ServiceAccountName
is empty.
properties:
secretRef:
description: SecretRef holds the name
of a secret that contains a key with
the kubeconfig file as the value.
If no key is set, the key will default
to 'value'. The secret must be in
the same namespace as the Kustomization.
It is recommended that the kubeconfig
is self-contained, and the secret
is regularly updated if credentials
such as a cloud-access-token expire.
Cloud specific `cmd-path` auth helpers
will not function without adding binaries
and credentials to the Pod that is
responsible for reconciling the Kustomization.
properties:
key:
description: Key in the Secret,
when not specified an implementation-specific
default key is used.
type: string
name:
description: Name of the Secret.
type: string
required:
- name
type: object
type: object
targetNamespace:
description: TargetNamespace to target when
performing operations for the HelmRelease.
Defaults to the namespace of the HelmRelease.
type: string
type: object
install:
description: Install holds the configuration
for Helm install actions for this HelmRelease.
Expand Down Expand Up @@ -1554,16 +1625,33 @@ spec:
type: object
type: array
required:
- destination
- interval
type: object
type: array
template-ref:
description: Template ref a HelmTemplate that has
been saved before
properties:
apiVersion:
description: APIVersion of the referent.
type: string
kind:
description: Kind of the referent, valid values
are ('HelmRepository', 'GitRepository', 'Bucket').
type: string
name:
description: Name of the referent.
type: string
required:
- kind
- name
type: object
required:
- chart
- spec
- deploy
type: object
kustomization:
description: KustomizationSpec defines the configuration
to calculate the desired state from a Source using Kustomize.
description: Kustomization for FluxCD Kustomization
properties:
decryption:
description: Decrypt Kubernetes secrets before applying
Expand Down Expand Up @@ -1976,51 +2064,6 @@ spec:
- prune
type: object
type: object
destination:
items:
properties:
kubeConfig:
description: The KubeConfig for reconciling the Kustomization
on a remote cluster. When used in combination with
KustomizationSpec.ServiceAccountName, forces the controller
to act on behalf of that Service Account at the target
cluster. If the --default-service-account flag is
set, its value will be used as a controller level
fallback for when KustomizationSpec.ServiceAccountName
is empty.
properties:
secretRef:
description: SecretRef holds the name of a secret
that contains a key with the kubeconfig file as
the value. If no key is set, the key will default
to 'value'. The secret must be in the same namespace
as the Kustomization. It is recommended that the
kubeconfig is self-contained, and the secret is
regularly updated if credentials such as a cloud-access-token
expire. Cloud specific `cmd-path` auth helpers
will not function without adding binaries and
credentials to the Pod that is responsible for
reconciling the Kustomization.
properties:
key:
description: Key in the Secret, when not specified
an implementation-specific default key is
used.
type: string
name:
description: Name of the Secret.
type: string
required:
- name
type: object
type: object
targetNamespace:
description: TargetNamespace to target when performing
operations for the HelmRelease. Defaults to the namespace
of the HelmRelease.
type: string
type: object
type: array
source:
properties:
sourceRef:
Expand Down Expand Up @@ -2048,7 +2091,6 @@ spec:
type: object
required:
- config
- destination
- source
type: object
type: object
Expand Down
21 changes: 15 additions & 6 deletions config/samples/gitops/fluxcd-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kind: Application
metadata:
name: chengleqi-test-application
namespace: my-devops-projecthmhx2
labels:
gitops.kubesphere.io/save-helmtemplate: "true"
spec:
kind: fluxcd
fluxApp:
Expand All @@ -15,15 +17,22 @@ spec:
config:
helmRelease:
chart:
kind: GitRepository
name: hello-kubernetes
spec:
- interval: 1m0s
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: app
interval: 1m0s
upgrade:
remediation:
remediateLastFailure: true
force: true
install:
createNamespace: true
destination:
- targetNamespace: app
Loading

0 comments on commit 223d964

Please sign in to comment.