To enable GitOps on a KubeVela installation, you can use any of the available addons. For this example, let's use FluxCD. For this part of the tutorial, we recommend selecting the kubevela
kind cluster, but these instructions are valid for any other cluster from previous operations.
To install the addon use:
vela addon enable fluxcd
Which will result in the following output on success
I0411 17:27:59.625119 43063 apply.go:121] "creating object" name="kustomize" resource="core.oam.dev/v1beta1, Kind=ComponentDefinition"
I0411 17:27:59.703211 43063 apply.go:121] "creating object" name="helm" resource="core.oam.dev/v1beta1, Kind=ComponentDefinition"
I0411 17:27:59.783391 43063 apply.go:121] "creating object" name="kustomize-strategy-merge" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0411 17:27:59.829032 43063 apply.go:121] "creating object" name="kustomize-json-patch" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0411 17:27:59.909226 43063 apply.go:121] "creating object" name="kustomize-patch" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0411 17:27:59.929385 43063 apply.go:121] "creating object" name="helm-labels" resource="core.oam.dev/v1beta1, Kind=TraitDefinition"
I0411 17:28:00.143912 43063 apply.go:121] "creating object" name="config-template-helm-repository" resource="/v1, Kind=ConfigMap"
I0411 17:28:00.272730 43063 apply.go:121] "creating object" name="component-uischema-helm" resource="/v1, Kind=ConfigMap"
I0411 17:28:00.288563 43063 apply.go:121] "creating object" name="component-uischema-kustomize" resource="/v1, Kind=ConfigMap"
I0411 17:28:00.300739 43063 apply.go:121] "creating object" name="config-uischema-helm-repository" resource="/v1, Kind=ConfigMap"
Addon fluxcd enabled successfully.
Please access addon-fluxcd from the following endpoints:
+---------+--------------------------+----------------------------------------------+-------------------------------------------+-------+
| CLUSTER | COMPONENT | REF(KIND/NAMESPACE/NAME) | ENDPOINT | INNER |
+---------+--------------------------+----------------------------------------------+-------------------------------------------+-------+
| local | fluxcd-source-controller | Service/flux-system/fluxcd-source-controller | fluxcd-source-controller.flux-system:9090 | true |
| managed | fluxcd-source-controller | Service/flux-system/fluxcd-source-controller | fluxcd-source-controller.flux-system:9090 | true |
+---------+--------------------------+----------------------------------------------+-------------------------------------------+-------+
Notice that the FluxCD addon enables GitOps use cases and provides a component definition to deploy Helm charts.
Next, we will deploy an application on the cluster that will pull information from a git repository and create the associated entities. To do that, execute:
vela up -f scenarios/gitops/hello-gitops.yaml
With this command, the hello-gitops
application will deploy the hello-app
application from the repository and will periodically synchronize the state from the repository so that the deployed application matches the latest definition.
$ vela ls kind-kubevela/default
APP COMPONENT TYPE TRAITS PHASE HEALTHY STATUS CREATED-TIME
hello-app hello webservice gateway workflowFailed unhealthy Ready:0/1 2023-04-12 11:36:29 +0200 CEST
hello-gitops deploy-hello-world kustomize running healthy 2023-04-12 11:36:27 +0200 CEST
And you will be able to access the app using
$ curl http://localhost
Msg: Hello KubeCon
You have finished the KubeCon 2023 tutorial on OAM! Check the following references for more information:
- Open Application Model (OAM) specification.
- KubeVela K8s OAM runtime.
- Napptive platform.