This guide will walk you through how Camblet can be used with Kubernetes.
We are going to use a one node Kubernetes environment with a simple curl client pod and an echo server deployment.
Enter into the Lima VM
Configure Camblet agent
Camblet consist of two building blocks:
Kernel module: Handles transparent TLS and enforces policies.
Agent: Signs certificates and collects metadata for processes.
Camblet support various metadata sources, those can be configured under the metadataCollectors block within the configuration. Camblet can utilize metadata from these sources to identify processes and enforce policies. The procfs, linuxos, and sysfsdmi are enabled by default.
The Kubernetes metadata collector gathers data from the kubelet that runs on the same node as the agent, but it is not enabled by default.
Proper authentication credentials are necessary to enable that collector.
The agent configuration resides in /etc/camblet/config.yaml, modify it the enable the Kubernetes metadata collector.
The config should resemble the following:
The Camblet agent must be restarted after the configuration change.
Let’s check if the agent is indeed able to collect metadata from Kubernetes for a process that runs within a pod.
K3s comes with Traefik installed so the following command can be used as a test.
Upon successful Camblet re-configuration, Kubernetes-associated labels can be utilized for process identification as well.
Deploy workloads to Kubernetes
An echo server running as a Kubernetes deployment and a simple Alpine pod with cURL are going to be used to showcase how Camblet integrates with Kubernetes.
First, install the echo server using kubectl.
Let’s wait for the echo pod to be up and running.
Now create a simple Alpine pod which will host our cURL client.
Let’s wait for the alpine pod to come up.
Create policy for the echo server
It is time to assign strong identities to the workloads and transparently establish mTLS connections.
The policy can be written by hand, but the Camblet CLI can do the work for you with the generate-policy command. There are two mandatory parameters, the PID of the process and the workload ID.
Camblet will use these selectors to identify the echo server. In a well-written policy the selectors should describe a particular process as precisely as possible, there are various metadata collectors available to achieve that goal. The connection part configures the TLS settings where STRICT mTLS value means only clients with trusted certificates can communicate with it.
To verify that, let’s try it with cURL from the Alpine container
Inside the Alpine container, first, we have to install cURL (and openssl).
Next, try to connect to the echo server on echo.
The connection failed, as it was supposed to. Camblet now protects the echo-server workload with mTLS nothing can communicate with it without a trusted client certificate.
The protection can be simply checked by openssl s_client.
Create policy for cURL
Now exit from the Alpine container and let’s create a policy for cURL as well. A running process of cURL is the easiest way to create a new policy for cURL with the Camblet CLI. Since cURL is not running continuously like the server, a “dummy” command is needed to force it to run until generate the policy.
The following command will run a cURL process for 30 seconds, the 1.2.3.4 IP address is non-routed and the connection to it going to time out. This is plenty of time to generate the policy.
Let’s generate a policy for cURL.
Using this policy, cURL gets an identity and will use mTLS. Let’s try to communicate with the nginx once again.
Try to connect to the echo server with certificate
It still doesn’t work, one last piece of the puzzle is missing. Camblet must ascertain the target destination for the application of policies.
Enforcing policies on every egress connection implies that cURL won’t be able to reach destinations beyond the Camblet-managed environment.
Services has to be registered into the service registry through service definitions.
Sample Service discovery configuration file
Let’s ignore the labels part for now; it is meant for more advanced configuration.
The addresses section specifies the registered destination addresses to which the policies should be applied.
Let’s create a service registry entry for the echo-server service with the following command.
Try to connect to the echo server with certificate and configured Camblet
With the service registry entry for the echo-server service in place, let’s check if its indeed fixed the error.
To do that, execute once again into the Alpine container and run cURL.