On this page
Data Storage Overview
This guide provides a brief summary of ways to manage data when the Curity Identity Server runs in Kubernetes. The content includes some example commands for developers new to Kubernetes data storage. If you use the Curity Token Handler there is no backend data storage to manage, since HTTP cookies contain all state.
The Curity Identity Server uses configuration data for most security settings, to support parameterized deployments. For other data, like user accounts, user credentials, session data and token-related information, it depends on one or more data sources.
Curity Identity Server Data Sources
By default, the Curity Identity Server uses a simple in-memory database, which provides convenient options to enable developers to get started quickly. Workloads lose all identity data when they restart, so in-memory storage is only suitable for demo environments. For other environments, update to a durable data source.
The System Admin Guide provides details on the supported data protocols, like JDBC, LDAP, SCIM or DynamoDB Managed Storage. More generally, the Curity Identity Server just uses connection strings to data sources. To prepare for external storage, define a single data source and express its parameters in the configuration.
<data-sources><data-source><id>default-datasource</id><jdbc xmlns="https://curity.se/ns/ext-conf/jdbc"><connection-string>#{DB_CONNECTION}</connection-string><driver>#{DB_DRIVER}</driver><password>#{DB_PASSWORD}</password><username>#{DB_USER}</username></jdbc></data-source></data-sources>
You should be able to use the same type of data storage for the Curity Identity Server that you already use for APIs, like PostgreSQL, MySQL or Microsft SQL Server. For each provider there is a database initialization script to create the schema in the $IDVSR_HOME/etc
folder of the Curity Identity Server or its Docker image. You can deploy the initialization script as a ConfigMap.
The System Admin Guide explains how you can use data sources in a basic way or scale to more advanced deployments, with multiple regions and tenants. Data source deployments can combine the capabilities of the database software, the hosting platform and the storage options that Kubernetes provides.
Select the Type of Storage
A basic durable solution might provision external disk storage from a cloud provider, with RAID-like guarantees and snapshotting capabilities to enable data backup and restore. Once the disk is ready, your database pod can use that storage to persist its data.
To enable external storage, providers implement the Container Storage Interface (CSI). You may need to install a Container Storage Interface (CSI) driver that you grant permissions to use external storage, using a technique like IAM Roles for Service Accounts. The driver provides Kubernetes Storage Classes that you use to request a persistent volume for data storage.
Use Persistent Volumes
To avoid data loss if a pod or node gets replaced or even if you redeploy the entire cluster, use Persistent Volumes. One option is dynamic provisioning where you declare a PersistentVolumeClaim that references a storage class name and size. The CSI driver for the storage class then automatically creates the PersistentVolume object and binds it to the claim, to mount an external volume into the data source pod.
apiVersion: v1kind: PersistentVolumeClaimmetadata:name: idsvr-claimlabels:app: postgresspec:storageClassName: ebs-scaccessModes:- ReadWriteOnceresources:requests:storage: 1Gi
Test Local Persistent Volumes
If you are new to Kubernetes data storage, you can rehearse durable deployments on a local computer. To simulate external storage in KIND you can create a cluster and share a folder from the host computer to Kubernetes nodes.
cat << EOF > cluster.yamlkind: ClusterapiVersion: kind.x-k8s.io/v1alpha4name: oauthnodes:- role: control-plane- role: workerextraMounts:- hostPath: ./externalstoragecontainerPath: /var/local-path-provisioner/hostEOFkind create cluster --name=example --config=cluster.yaml
A KIND cluster uses the local-path-provisioner storage class and assigns it a name of standard
. The Helm chart for the Curity product includes an option to use a PersistentVolume to store configuration data, which you can use for testing. Use static provisioning to create a PersistentVolume with the storage location and use storageClassName=standard
.
cat <<EOF | kubectl apply -f -apiVersion: v1kind: PersistentVolumemetadata:name: pv-configurationspec:accessModes:- ReadWriteOncecapacity:storage: 1GipersistentVolumeReclaimPolicy: RetainstorageClassName: standardvolumeMode: FilesystemhostPath:path: /var/local-path-provisioner/host/idsvr-configurationtype: DirectoryOrCreateEOF
Then use the following Helm values.yaml
file, so that the Helm chart creates a PersistentVolumeClaim. The claim will bind to the PersistentVolume since its StorageClass matches and the PersistentVolume is available.
replicaCount: 2image:repository: curity.azurecr.io/curity/idsvrtag: latestcurity:adminUiHttp: trueadmin:logging:level: INFOruntime:logging:level: INFOconfig:uiEnabled: truepersistentConfigVolume:enabled: truestorageClass: standardaccessModes: ReadWriteOncesize: 1Gi
Run the Helm chart with the following options, to use the curity
namespace referenced in the pv-configuration
PersistentVolume.
helm install curity curity/idsvr --values=values.yaml --namespace curity --create-namespace \--set curity.config.password=Password1
Next, query deployed resources:
kubectl get storageclass,pv,pvc
You should see the PersistentVolume and PersistentVolumeClaim bound together:
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASSpersistentvolume/pv-configuration 1Gi RWO Retain Bound curity/curity-idsvr standardNAMESPACE NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASScurity persistentvolumeclaim/curity-idsvr Bound pv-configuration 1Gi RWO standard
View configuration data in the ./externalstorage/idsvr-configuration
folder on the host computer. If you delete a pod or even redeploy the whole local cluster, the next deployment continues to use the existing configuration data.
Example Database Deployment
The GitHub link at the top of this page provides some Kubernetes example deployments for a local computer. The Curity Identity Server
example includes a basic deployment of a PostgreSQL database with a storage class and persistent volume that store files on the local filesystem. The example deployment also shows how to activate the DevOps Dashboard to administer user accounts and other identity data. Finally, the tutorial shows how to connect to the database and query its data, to get to know the schema.
Summary
The Curity Identity Server can run in Kubernetes and connect to many types of new or existing data sources using standard protocols. Deploy data sources so that data saves to PersistentVolumes. You can provide either basic durability or a more advanced deployment for multiple regions or availability zones.
Join our Newsletter
Get the latest on identity management, API Security and authentication straight to your inbox.
Start Free Trial
Try the Curity Identity Server for Free. Get up and running in 10 minutes.
Start Free Trial