Use GitOps to Achieve Continuous Deployment of Applications
In KubeSphere 3.3, we introduce the GitOps concept, which is a way of implementing continuous deployment for cloud-native applications. The core component of GitOps is a Git repository that always stores applications and declarative description of the infrastructure for version control. With GitOps and Kubernetes, you can enable CI/CD pipelines to apply changes to any cluster, which ensures consistency in cross-cloud deployment scenarios.
This section walks you through the process of deploying an application using a continuous deployment.
You have a workspace, a DevOps project and a user (
project-regular) invited to the DevOps project with the
operatorrole. If they are not ready yet, please refer to Create Workspaces, Projects, Users and Roles.
You need to enable the KubeSphere DevOps system.
Import a Code Repository
Log in to the KubeSphere console as
project-regular. In the navigation pane on the left, click DevOps Projects.
On the DevOps Projects page, click the DevOps project you created.
In the navigation pane on the left, click Code Repositories.
On the Code Repositories page on the left, click Import.
In the Import Code Repository dialog box, enter the name of code repository, for example,
open-podcasts, and select a code repository. Optionally, you can set an alias and add description.
In the Select Code Repository dialog box, click Git. In Code Repository URL, enter the URL of the code repository, for example,
https://github.com/kubesphere-sigs/open-podcasts, and click OK.
NoteAs the imported code repository is a public repository, it is not necessary to create a credential. However, if you add a private repository, a credential is required. For more information about how to create a credential, please refer to Credential Management.
Create a Continuous Deployment
In the navigation pane on the left, click Continuous Deployments.
On the Continuous Deployments page, click Create.
On the Basic Information tab, enter a name of the continuous deployment, for example,
open-podcasts, and choose a code repository. Then, click Next. Optionally, you can set an alias and add description.
On the Deployment Settings tab, choose the cluster and project that the continuous deployment will be deployed.
In Code Repository Settings, set a branch or tag of the repository and specify the path of the manifest file, for example,
In Sync Strategy, you can choose either Manual Sync or Auto Sync. If you choose Auto Sync, select Prune resources and Self-heal as needed.
- Prune resources: Automatically deletes resources that are no longer defined in Git.
- Self-heal: Always synchronizes the state defined in Git.
In Sync Settings, select the following options as needed:
- skip schema validation: Does not validate resources.
- Auto create project: Automatically creates a project during synchronization.
- Prune last: Deletes resources that no longer exist after all resources have been synchronized and become healthy.
- Apply out of sync only: Skips syncing resources that are already in the desired state.
In Prune Propagation Policy, choose a deletion policy:
- foreground: Deletes dependents first, and then deletes owners.
- background: Deletes owners first, and then deletes dependents.
- orphan: Deletes owners while retaining dependents.
In Replace Resource, decide whether you want to replace resources that already exist. Click Create.
On the Continuous Deployments page, you can view the created continuous deployment, as shown in the following table.
Item Description Name Name of the continuous deployment. Health Status Health status of the continuous deployment, which includes the following:
- Healthy: Resources are healthy.
- Degraded: Resources are degraded.
- Progressing: Resources are being synchronized. This is the default state.
- Suspended: Resources have been suspended and are waiting to be resumed.
- Unknown: The resource state is unknown.
- Missing: Resources are missing.
Sync Status Synchronization status of the continuous deployment, which includes the following:
- Synced: Resources have been synchronized.
- Out of sync: The actual running state of resources is not as desired.
- Unknown: The resource synchronization state is unknown.
Deployment Location Cluster and project where resources are deployed. Update Time Time when resources are updated.
Click on the right of the continuous deployment, and you can perform the following:
- Edit Information: Edits the alias and description.
- Edit YAML: Edits the YAML file.
- Sync: Triggers resources synchronization.
- Delete: Deletes the continuous deployment.
- Click the created continuous deployment to go to its details page, where you can view the synchronization status and result.
Access the Created Application
Go to the project where the continuous deployment resides, in the navigation pane on the left, click Services.
On the Services page on the left, click on the right of the deployed application, and click Edit External Access.
In Access Mode, select NodePort, and click OK.
In the External Access column, check the exposed port, and access the application by
Was this page Helpful?
Receive the latest news, articles and updates from KubeSphere
Thanks for the feedback. If you have a specific question about how to use KubeSphere, ask it on Slack. Open an issue in the GitHub repo if you want to report a problem or suggest an improvement.