conjur-config-namespace-prep
by papanito
A Helm chart which prepares a Namespace for using CyberArk Conjur authenticator clients
About this chart
Conjur NameSpace Preparation Helm Chart
- Conjur NameSpace Preparation Helm Chart
- Overview
- Prerequisites
- Objects Created
- Conjur Enterprise Documentation Reference
- Configuration
- Examples
- Fresh Installation
- Upgrading
- Alternative: Creating K8s Resources with
kubectlinstead of Helm
- Issues with Helm "lookup"
- Using the Conjur Connection ConfigMap in your application deployment manifest
- Overview
Overview
The purpose of this Helm chart is to prepare a new NameSpace with credentials needed for applications to connect to a Conjur instance, either in the same cluster, or elsewhere.
This is done by retrieving the necessary Kubernetes and Conjur credentials, stored in the "Golden Configmap", and making them available within the NameSpace through a ConfigMap and RoleBinding of its own. These objects will expose the credentials as environment variables and prepare for communication for any Kubernetes authenticators in the given Conjur NameSpace.
Prerequisites
- A running Conjur instance inside or outside of a Kubernetes cluster
- A NameSpace configured to contain a "Golden Configmap"
Objects Created
The per-Kubernetes-NameSpace resources created by this Helm chart include:
-
Conjur Connection Configmap
The Conjur Connection Configmap contains references to Conjur credentials, taken from the "Golden Configmap". These can be used to enable Conjur authentication for applications to retrieve secrets securely.
-
Authenticator RoleBinding
The Authenticator RoleBinding grants permissions to the Conjur Authenticator ServiceAccount for the Authn-Kubernetes ClusterRole, which provides a list of Kubernetes API access permissions. This is required to validate application identities.
Configuration
The following table lists the configurable parameters of the Conjur Namespace-prep-chart and their default values.
| Parameter | Description | Default |
|---|---|---|
authnK8s.goldenConfigMap | Name for the "Golden Configmap" containing authn-k8s and Conjur credentials (Required) | "" |
authnK8s.namespace: | The NameSpace name where the "Golden Configmap" resides. (Required) | "" |
authnRoleBinding.create | Flag to generate the authenticator RoleBinding. | true |
authnRoleBinding.name | Name for the RoleBinding generated if the create flag is set to true. | "conjur-RoleBinding" |
conjurConfigMap.create | Flag to generate the ConfigMap with credentials for accessing Conjur instance. | true |
conjurConfigMap.name | Name for the ConfigMap generated if the create flag is set to true | "conjur-connect" |
conjurConfigMap.authnMethod | Authentication method to conjur. Can be either "authn-k8s" or "authn-jwt" | "authn-k8s" |
Examples
Fresh Installation
In this example, we will be installing the helm chart in a new NameSpace.
While you can edit values.yaml to modify settings, we will be
using the default entries in values.yaml.
- Create a new NameSpace
kubectl create NameSpace my-NameSpace
- Install the chart in your new NameSpace. Note that we set the values for
authnK8s.goldenConfigMapandauthnK8s.namespaceto match the name and NameSpace location for our "Golden Configmap", respectively.
helm install NameSpace-prep . -n "my-NameSpace" \
--set authnK8s.goldenConfigMap="conjur-configmap" \
--set authnK8s.namespace="default"
If successful, this should output the details of your chart installation,
including the new ConfigMap and RoleBinding. Your NameSpace can now utilize
the Conjur API to access your Conjur instance using the environment variables
located in conjur-configmap. To view these, use the following command:
kubectl describe configmap -n my-NameSpace
Upgrading
No special changes need to be made when upgrading. If the location of your "Golden Configmap" changes, follow the example for a "fresh installation", but use the helm upgrade command in place of helm install. This will generate a new Configmap and RoleBinding to reflect the changed information.
For example:
helm upgrade NameSpace-prep . -n "my-NameSpace" \
--set authnK8s.goldenConfigMap="conjur-configmap" \
--set authnK8s.NameSpace="new-NameSpace"
Alternative: Creating K8s Resources with kubectl instead of Helm
If Helm can not be used to deploy Kubernetes resources, the raw Kubernetes manifests can instead be generated ahead of time with the helm template command. The generated manifests can then be applied with kubectl.
helm template NameSpace-prep . -n "my-NameSpace" \
--set authnK8s.goldenConfigMap="conjur-configmap" \
--set authnK8s.NameSpace="default" > conjur-config-namespace-prep.yaml
kubectl apply -f conjur-config-namespace-prep.yaml
Issues with Helm "lookup"
When using helm install --dry-run or helm lint, you may notice that the
outputted ConfigMap and RoleBinding do not contain the actual credentials
that would be retrieved from your "Golden Configmap". This is due to the
Helm lookup function, which retrieves Kubernetes objects and data, not being
supported by --dry-run or lint.
Using the Conjur Connection ConfigMap in your application deployment manifest
In order to leverage the standardized ConfigMap containing Conjur connection details, it needs to be exposed as environment variables to the Kubernetes Authenticator Client. Edit the relevant container and/or image subsections of your application manifest to include the ConfigMap in the container environment, as seen in the example below:
containers:
- name: test-app
envFrom:
- configMapRef:
name: conjur-connect
- image: cyberark/conjur-authn-k8s-client
envFrom:
- configMapRef:
name: conjur-connect
Applications using Secrets Provider or Secretless Broker can be modified similarly to make use of the ConfigMap values.
Deploy conjur-config-namespace-prep with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has conjur-config-namespace-prep on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartconjur-config-namespace-prep is pinned at v0.2.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply