Adopt Pre-Existing Resources
Introduction
In this tutorial, you will create a test workload prior to initializing Zarf. After that you will then use Zarf to adopt those workloads, so you can manage their future lifecycle with Zarf.
System Requirements
- You'll need an internet connection to grab the Zarf Init Package if it's not already on your machine.
Prerequisites
Prior to this tutorial you'll want to have a working cluster. But unlike our other tutorials you don't want Zarf initialzed.
Zarf binary installed on your $PATH: (Installing Zarf)
Youtube Tutorial
Creating a Test Component
We're going to use the manifests from the Deploying a Retro Arcade tutorial for this example. So if you haven't yet, clone the Zarf repository, and navigate to the cloned repository's root directory.
- Create the dos-games namespace
- Use the dos-games example manifests, to deploy the dos-games deployment and service to your Kubernetes cluster.
Test to see that this is working
- Use the
kubectl port-forward
command to confirm you've deployed the manifests properly.
- Navigate to
http://localhost:8000
in your browser to view the dos-games application. It will look something like this:
Remember to press ctrl+c
in your terminal when you're done with the port-forward.
Initialize Zarf
- Use the Initializing a K8s Cluster tutorial, to initialize Zarf in the cluster.
You'll notice the dos-games namespace has been excluded from Zarf management as it has the zarf.dev/agent=ignore
label. This means that Zarf will not manage any resources in this namespace.
The iframe was pointing to the wrong file, and this likely would be better as an admonition.
Deploy the Package, Adopting the Workloads
- Use the
zarf package deploy
command with the--adopt-existing-resources
flag to adopt the existing dos-games resources in thedos-games
namespace.
Notice that in this example the dos-games resources were contained in their own namespace. When running a deploy with --adopt-existing-resources
it is recommended that this be the case as you could break other non-Zarf deployments if resources are shared.
Test to see that this is working
- You'll notice the dos-games namespace is no longer excluded from Zarf management as it has the
app.kubernetes.io/managed-by=zarf
label. This means that Zarf will now manage any resources in this namespace.
- You can also now use the
zarf connect
command to connect to the dos-games application. Again it will look something like this.
Again, remember to press ctrl+c
in your terminal, when you're done with the connection.
Conclusion
At this point the dos-game package is managed by Zarf and will behave just like a package initially deployed with Zarf.