-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Addon] GitOps addon #411
[Addon] GitOps addon #411
Changes from all commits
3b12a7b
a4c9545
e8f6beb
50464d1
f5ff3ec
97846c1
79b774a
1c2511f
8bf3138
e6c2d0a
cd040fc
748a69e
e3660a4
84464bc
d6cf49f
2dc9af1
7a51545
9d672c6
8244655
04ca21c
7062581
0d05038
1009dac
ca4743c
ccc282f
eca7c10
cbc29ef
6c02385
ae5d46e
87a9b52
b4312e5
bf8377e
757cf5b
ee05c54
e5e2c25
dea6cd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# GitOps Addon Definitions | ||
<hr> | ||
This addon helps you simplify your continuous delivery (CD) using KubeVela by allowing you to specify which CD tool (agent) | ||
you want to use. | ||
|
||
# Installation | ||
<hr> | ||
|
||
```shell | ||
vela addon enable gitops agent=fluxcd [parameters...] | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,282 @@ | ||
gitops: { | ||
annotations: {} | ||
attributes: workload: definition: { | ||
apiVersion: "apps/v1" | ||
kind: "Application" | ||
} | ||
description: "KubeVela addon for implementing GitOps for continuous deployment using either fluxcd or argocd" | ||
type: "component" | ||
labels: {} | ||
} | ||
|
||
template: { | ||
|
||
if parameter.agent == "fluxcd" { | ||
output: { | ||
apiVersion: "source.toolkit.fluxcd.io/v1beta2" | ||
metadata: { | ||
name: context.name | ||
namespace: context.namespace | ||
} | ||
if parameter.repoType == "git" { | ||
kind: "GitRepository" | ||
spec: { | ||
url: parameter.url | ||
if parameter.git.branch != _|_ { | ||
ref: branch: parameter.git.branch | ||
} | ||
if paramter.git.provider != _|_ { | ||
if parameter.git.provider == "GitHub" { | ||
gitImplementation: "go-git" | ||
} | ||
if parameter.git.provider == "AzureDevOps" { | ||
gitImplementation: "libgit2" | ||
} | ||
} | ||
_secret | ||
_sourceCommonArgs | ||
} | ||
} | ||
if parameter.repoType == "oss" { | ||
kind: "Bucket" | ||
spec: { | ||
endpoint: parameter.url | ||
bucketName: parameter.oss.bucketName | ||
provider: parameter.oss.provider | ||
if parameter.oss.region != _|_ { | ||
region: parameter.oss.region | ||
} | ||
_secret | ||
_sourceCommonArgs | ||
} | ||
} | ||
|
||
} | ||
|
||
outputs: { | ||
if parameter.imageRepository != _|_ { | ||
imageRepo: { | ||
apiVersion: "image.toolkit.fluxcd.io/v1beta1" | ||
kind: "ImageRepository" | ||
metadat: { | ||
name: context.name | ||
namespace: context.namespace | ||
} | ||
spec: { | ||
image: parameter.imageRepository.image | ||
interval: parameter.pullInterval | ||
if parameter.imageRepository.secretRef != _|_ { | ||
secretRef: name: parameter.imageRepository.secretRef | ||
} | ||
} | ||
} | ||
|
||
imagePolicy: { | ||
apiVersion: "image.toolkit.fluxcd.io/v1beta1" | ||
kind: "ImagePolicy" | ||
metadata: { | ||
name: context.name | ||
namespace: context.namespace | ||
} | ||
spec: { | ||
imageRepositoryRef: name: context.name | ||
policy: parameter.imageRepository.policy | ||
if parameter.imageRepository.filterTags != _|_ { | ||
filterTags: parameter.imageRepository.filterTags | ||
} | ||
} | ||
} | ||
|
||
imageUpdate: { | ||
apiVersion: "image.toolkit.fluxcd.io/v1beta1" | ||
kind: "ImageUpdateAutomation" | ||
metadata: { | ||
name: context.name | ||
namespace: context.namespace | ||
} | ||
} | ||
spec: { | ||
interval: parameter.pullInterval | ||
sourceRed: { | ||
kind: "GitRepository" | ||
name: context.name | ||
} | ||
git: { | ||
checkout:ref:branch: parameter.git.branch | ||
commit: { | ||
author: { | ||
email: "kubevelabot@users.noreply.github.com" | ||
name: "kubevelabot" | ||
} | ||
if parameter.imageRepository.commitMessage != _|_ { | ||
messageTemplate: "Update image automatically.\n" + parameter.imageRepository.commitMessage | ||
} | ||
if parameter.imageRepository.commitMessage == _|_ { | ||
messageTemplate: "Update image automatically." | ||
} | ||
} | ||
push: branch: parameter.git.branch | ||
} | ||
update: { | ||
path: parameter.path | ||
strategy: "Setters" | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
_secret: { | ||
if parameter.secretRef != _|_ { | ||
secretRef: { | ||
name: parameter.secretRef | ||
} | ||
} | ||
} | ||
|
||
_sourceCommonArgs: { | ||
interval: parameter.pullInterval | ||
if parameter.timeout != _|_ { | ||
timeout: parameter.timeout | ||
} | ||
} | ||
|
||
} | ||
|
||
if parameter.agent == "argocd" { // we probably need to find a way to install the argocd resources (the one specified on the getting started page) | ||
output: { | ||
apiVersion: "argoproj.io/v1alpha1" | ||
kind: "Application" | ||
metadata: { | ||
name: context.name | ||
namespace: context.namespace | ||
} | ||
spec: { | ||
components: { | ||
project: default | ||
|
||
source: { | ||
repoURL: parameter.url | ||
targetRevision: HEAD | ||
path: "" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the path from user? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It represents the cluster path. 🤔 Thinking about it now, it could or could not be supplied by the user. I can make it user-supplied for more flexibility? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vela also has the capability of multi-cluster, maybe we can combine them together. |
||
|
||
destination: { | ||
server: "https://kubernetes.default.svc" | ||
if parameter.targetNamespace != _|_ { | ||
targetNamespace = parameter.targetNamespace | ||
} | ||
} | ||
|
||
syncPolicy: { | ||
syncOptions: { | ||
CreateNamespace=true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this a valid cue? I suppose the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not yet... |
||
} | ||
|
||
automated: { | ||
selfHeal: true | ||
prune: true | ||
} | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
outputs: { // for applications, multiple can be defined | ||
// should I use what is in experimental argocd (application.cue)? It seems like there is a lot of repetition | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be the ArgoCD gitops App.. |
||
} | ||
|
||
|
||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
||
parameter: { | ||
//+usage=determines which agent is installed on the cluster for GitOps | ||
agent: *"fluxcd" | "argocd" | ||
//+usage=TargetNamespace sets or overrides the namespace in the kustomization.yaml file, optional | ||
targetNamespace?: string | ||
// syncPolicy: "manual" | string // should things like sync policy be declared here? | ||
|
||
// +usage=The image repository for automatically updating image to git | ||
imageRepository?: { | ||
// +usage=The image url | ||
image: string | ||
|
||
// +usage=The name of the secret containing authentication credentials | ||
secretRef?: string | ||
|
||
// +usage=Policy gives the particulars of the policy to be followed in selecting the most recent image. | ||
policy: { | ||
|
||
// +usage=Alphabetical set of rules to use for alphabetical ordering of the tags. | ||
alphabetical?: { | ||
// +usage=Order specifies the sorting order of the tags. | ||
// +usage=Given the letters of the alphabet as tags, ascending order would select Z, and descending order would select A. | ||
order?: "asc" | "desc" | ||
} | ||
|
||
// +usage=Numerical set of rules to use for numerical ordering of the tags. | ||
numerical?: { | ||
// +usage=Order specifies the sorting order of the tags. | ||
// +usage=Given the integer values from 0 to 9 as tags, ascending order would select 9, and descending order would select 0. | ||
order: "asc" | "desc" | ||
} | ||
|
||
// +usage=SemVer gives a semantic version range to check against the tags available. | ||
semver?: { | ||
|
||
// +usage=Range gives a semver range for the image tag; the highest version within the range that's a tag yields the latest image. | ||
range: string | ||
} | ||
} | ||
|
||
// +usage=FilterTags enables filtering for only a subset of tags based on a set of rules. If no rules are provided, all the tags from the repository will be ordered and compared. | ||
filterTags?: { | ||
|
||
// +usage=Extract allows a capture group to be extracted from the specified regular expression pattern, useful before tag evaluation. | ||
extract?: string | ||
// +usage=Pattern specifies a regular expression pattern used to filter for image tags. | ||
pattern?: string | ||
} | ||
|
||
// +usage=The image url | ||
commitMessage?: string | ||
} | ||
|
||
// +usage=The interval at which to check for repository/bucket and release updates, default to 5m | ||
pullInterval: "5m" | string | ||
// +usage=The Git or Helm repository URL, OSS endpoint, accept HTTP/S or SSH address as git url, | ||
url: string | ||
// +usage=The name of the secret containing authentication credentials | ||
secretRef?: string | ||
// +usage=The timeout for operations like download index/clone repository, optional | ||
timeout?: string | ||
git?: { | ||
// +usage=The Git reference to checkout and monitor for changes, defaults to master branch | ||
branch: string | ||
// +usage=Determines which git client library to use. Defaults to GitHub, it will pick go-git. AzureDevOps will pick libgit2. | ||
provider?: *"GitHub" | "AzureDevOps" | ||
} | ||
oss?: { | ||
// +usage=The bucket's name, required if repoType is oss | ||
bucketName: string | ||
// +usage="generic" for Minio, Amazon S3, Google Cloud Storage, Alibaba Cloud OSS, "aws" for retrieve credentials from the EC2 service when credentials not specified, default "generic" | ||
provider: *"generic" | "aws" | ||
// +usage=The bucket region, optional | ||
region?: string | ||
} | ||
|
||
//+usage=Path to the directory containing the kustomization.yaml file, or the set of plain YAMLs a kustomization.yaml should be generated for. | ||
path: string | ||
//+usage=Whether to delete objects that have already been applyed | ||
prune: *true | bool | ||
//+usage=This flag tells the controller to suspend subsequent kustomize executions, it does not apply to already started executions. Defaults to false. | ||
suspend: *false | bool | ||
//+usage=Force instructs the controller to recreate resources when patching fails due to an immutable field change. | ||
force: *false | bool | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: gitops | ||
version: 1.0.0 | ||
description: "KubeVela addon for implementing GitOps for continuous deployment using either fluxcd or argocd" | ||
icon: "" | ||
url: "" | ||
|
||
tags: | ||
- gitops | ||
- fluxcd | ||
- argocd | ||
|
||
deployTo: | ||
control_plane: true | ||
runtimeCluster: true | ||
|
||
system: | ||
vela: ">=v1.4.0" | ||
kubernetes: ">=1.19.0-0" | ||
|
||
invisible: true | ||
|
||
dependencies: # depends on which agent you choose | ||
- name: fluxcd | ||
# - name: experimental/addons/argocd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest that you can separate the entire CR of fluxcd and argocd with if, not just the apiVersion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I am working on that now.