Deploy Config
ConfigHub can deploy configuration to Live Resources and keep track of config changes, drift and live status. In this step, we will use a local kind cluster to demonstrate deployment of a Kubernetes Config Unit.
The key thing to understand is that before a Unit can be applied to Live Infrastructure, it must be associated with a Target that represents that Live Infrastructure. The Target is advertised by a remote Worker which does the actual work of taking the config data from ConfigHub and applying it to a cluster (or other type of infrastructure).
Create a kind cluster
To experience deployment, we'll deploy the chat app to a kind cluster running on your local machine. You must have kind installed for this step. Create a new kind cluster with:
kind create cluster --name confighub
Create and deploy a Worker
Create a ConfigHub Worker:
cub worker create dev
This creates the worker entity in ConfigHub which includes an ID and secret that will be used by the worker deployment to connect back to ConfigHub. Create the Worker deployment in your kind cluster with:
cub worker install dev --include-secret --export | kubectl --context kind-confighub apply -f -
This will install a deployment of the ConfigHub Worker in your kind cluster and add the ID and secret from ConfigHub to its configuration.
Security Note
The secret will be stored as a regular environment variable for the purpose of this tutorial. Normally you will install secrets using your preferred mechanism for secrets handling, for example External Secrets Operator. Use the --export-secret-only flag with the worker install command to generate a secret resource.
When the ConfigHub Worker boots up in the cluster, it will connect to ConfigHub and automatically create a Target that can be used to deploy units to the cluster.
Assign Target to Unit
To deploy the resources in a Config Unit, it must be assigned a Target. A Target is a ConfigHub representation of the infrastructure that the Unit will be applied to. When a Worker process boots up, it will know which target infrastructures it has access to and when it connects to ConfigHub, it will auto-create a Target for each of these in ConfigHub.
Now that we have a place to deploy to and we have a ConfigHub Worker that can perform the deployment, all we need is to assign the Worker's target to the unit:
cub unit set-target chatapp-dev k8s-dev
k8s-dev is the name of the target that was auto-created by the Worker. It uses a naming convention that combines the name of the worker itself with the infrastructure type, in this case Kubernetes.
Apply Unit
The last step is to apply the unit:
cub unit apply chatapp-dev
ConfigHub will look up the Worker for the Unit's Target and send a message to the Worker to apply the unit's config data to the cluster. The Worker will report back on progress and eventually, the Unit will be marked as Live.
Test it
To check out your new AI Chat app, first do a port-forward to the frontend running in the cluster:
kubectl port-forward svc/frontend 9990:80
Then open http://localhost:9990 in your browser and you should see the Chat app.
Summary
- ConfigHub Units are deployed to live infrastructure via ConfigHub Workers that function a bit like GitOps operators
- Unlike GitOps, the deployment action is initiated from ConfigHub. You can think of it as equivalent to merging a PR in GitOps
- Workers expose Targets. Targets are assigned to Units. This layer of indirection enables a wide variety of topologies
- The Worker tells ConfigHub how an Apply action is progressing.
- When an Apply action is complete, the revision of config data that was applied is marked as Live.