Managing and deploying Kubernetes add-ons seamlessly can often be a complex and time-consuming task. However, with the introduction of Sveltos and its remarkable features, add-on deployment has become a breeze. Sveltos offers a range of options to suit your preferences, whether you prefer Helm charts, resource YAMLs, or sources containing Kustomize files.
Understanding Sveltos and Its Advantages
Sveltos is a lightweight application specifically designed to effortlessly manage hundreds of clusters. By selecting a set of managed clusters and listing the add-ons you want deployed, Sveltos takes care of the rest. It automatically detects new clusters and seamlessly manages any configuration changes that occur. Let Sveltos simplify your cluster management, giving you more time to focus on other important aspects of your project.
Helm, YAMLs, and Kustomize Files: Comprehensive Deployment Options
Sveltos offers a comprehensive range of deployment options, ensuring flexibility and choice for your add-on deployments. In previous articles, we explored deploying add-ons with Sveltos using Helm charts and resource YAMLs. If you're interested in those methods, be sure to check out these articles: here and here. They provide valuable insights into deploying add-ons with Sveltos using these approaches.
Now, let's delve into Sveltos' integration with Kustomize. By the end of this article, you'll gain the knowledge and understanding to effortlessly deploy Kubernetes add-ons using Sveltos and Kustomize. This integration enhances your development workflow, allowing you to customize and fine-tune your add-on deployments with ease.
Flux integration
Sveltos seamlessly integrates with Flux, a popular tool for GitOps-based continuous delivery. Flux allows you to sync Git repositories, OCI repositories, and buckets. By incorporating Flux into Sveltos, you can automate the synchronization of your desired add-ons, eliminating manual intervention and ensuring consistent deployment across your clusters.
Let's explore an example that showcases the integration with a Git repository, specifically github.com/gianlucam76/kustomize
, which contains Kustomize files.
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: flux-system
namespace: flux-system
spec:
interval: 1m0s
ref:
branch: main
secretRef:
name: flux-system
timeout: 60s
url: ssh://git@github.com/gianlucam76/kustomize
apiVersion: config.projectsveltos.io/v1alpha1
kind: ClusterProfile
metadata:
name: flux-system
spec:
clusterSelector: env=fv
syncMode: Continuous
kustomizationRefs:
- namespace: flux-system
name: flux-system
kind: GitRepository
path: ./helloWorld/
targetNamespace: eng
The directory helloWorld
in the git repository contains:
├── deployment.yaml
├── kustomization.yaml
├── service.yaml
└── configmap.yaml
Whenever there are changes in the Git repository, Sveltos leverages the Kustomize SDK to retrieve the list of resources and deploys them in any cluster that matches the cluster selector, specifically in the eng
namespace.
To view the deployed add-ons, you can use the following command:
kubectl exec -it -n projectsveltos sveltosctl-0 -- ./sveltosctl show addons
+-------------------------------------+-----------------+-----------+----------------+---------+-------------------------------+------------------+
| CLUSTER | RESOURCE TYPE | NAMESPACE | NAME | VERSION | TIME | CLUSTER PROFILES |
+-------------------------------------+-----------------+-----------+----------------+---------+-------------------------------+------------------+
| default/sveltos-management-workload | apps:Deployment | eng | the-deployment | N/A | 2023-05-16 00:48:11 -0700 PDT | flux-system |
| default/sveltos-management-workload | :Service | eng | the-service | N/A | 2023-05-16 00:48:11 -0700 PDT | flux-system |
| default/sveltos-management-workload | :ConfigMap | eng | the-map | N/A | 2023-05-16 00:48:11 -0700 PDT | flux-system |
+-------------------------------------+-----------------+-----------+----------------+---------+-------------------------------+------------------+
Kustomize with ConfigMap/Secret
Sveltos also supports using ConfigMap and Secret to store your Kustomize files in a convenient tar.gz format. Here's an example of creating a ConfigMap:
1) First, clone the repository:
bash git clone git@github.com:gianlucam76/kustomize.git
2) Create the tar.gz file containing the Kustomize files:
bash tar -czf kustomize.tar.gz -C kustomize/helloWorldWithOverlays .
3) Create the ConfigMap:
kubectl create configmap kustomize --from-file=kustomize.tar.gz
The directory helloWorldWithOverlays
contains:
base
├── deployment.yaml
├── kustomization.yaml
├── service.yaml
└── configmap.yaml
overlays/production
├── deployment.yaml
└── kustomization.yaml
Now, let's see how we can incorporate this ConfigMap into a ClusterProfile:
apiVersion: config.projectsveltos.io/v1alpha1
kind: ClusterProfile
metadata:
name: kustomize-with-configmap
spec:
clusterSelector: env=fv
syncMode: Continuous
kustomizationRefs:
- namespace: default
name: kustomize
kind: ConfigMap
path: ./overlays/production/
targetNamespace: production
In this case, the ClusterProfile named "kustomize-with-configmap" utilizes the ConfigMap named "kustomize" as its source. The specified path indicates the location of the Kustomize files within the ConfigMap, and the targetNamespace determines where the resources will be deployed in the managed cluster.
Conclusion
Sveltos ensures a smooth and flexible deployment experience by supporting Helm charts, resource YAMLs, and sources containing Kustomize files. This versatility enables you to deploy applications in a way that aligns with your preferences and requirements. With Sveltos, you have the freedom to choose the deployment method that works best for your project, while enjoying the powerful management capabilities that Sveltos brings to the table.
Contributing to projectsveltos
❤️ Your contributions are always welcome! If you want to contribute, have questions, noticed any bug or want to get the latest project news, you can connect with us in the following ways:
- Open a bug/feature enhancement on github
- Chat with us on the Slack in the #projectsveltos channel
Top comments (0)