Deploy with Helm chart
authgear/helm-charts is the recommended way to deploy Authgear on Kubernetes.
Requirements
This section includes information about the software and the hardware requirements to run Authgear on Kubernetes.
Kubernetes requirements
The minimum supported version of Kubernetes is 1.19.
Storage requirements
Authgear does not store persist data on disk. It stores data in a PostgreSQL database and a Redis.
Authgear allows the end-user to upload their profile image. This feature is disabled by default. If you enable it, then Authgear requires a cloud object store. The supported cloud object store are AWS S3, GCP GCS, and Azure Blob Storage.
CPU requirements
The CPU requirements depend on the number of users, workload and how active the users are. There are 4 scalable pods, 1 non-scalable pod and 1 images server in the basic setup. The scalable pods have a limit of 500m
CPU, the non-scalable one has 300m
, the images server has 1000m
. 2 Cores is recommended for the basic setup.
Memory requirements
The scalable pods have a limit of 256MiB
of memory, the non-scalable one has 64MiB
, the images server have a limit of 1GiB
of memory. 1 GB of memory is recommended for the basic setup.
Database requirements
PostgreSQL is the only supported database. PostgreSQL 12 is recommended. The PostgreSQL database must have the extension pg_partman
installed, the version must be >= 4.0.
The database must have at least 5GB storage. The exact amount of storage depend on the number of users. About 100MB of storage is required to store 10,000 users.
Authgear stores its main data in a PostgreSQL database, and log data in another PostgreSQL database. 2 separate PostgreSQL databases are required. It is strongly recommended that the PostgreSQL databases are not shared with other software. The database account must have full access to the PostgreSQL database it connects to. Authgear uses the public
schema.
Do not make changes to the PostgreSQL databases, the schemas, the tables, the columns, or the rows.
Redis requirements
Authgear stores user sessions and other ephemeral data in Redis. The requirement is roughly 30kB per user. The recommended version of Redis is >= 6.2.
Elasticsearch requirements
Authgear portal provides the search feature with Elasticsearch. A minimal setup of Elasticsearch consists of 3 Elasticsearch nodes. Each node requires 1 Core of CPU and 2GB of memory.
Web browser requirements
Authgear supports the following web browsers:
Apple Safari
Google Chrome
Microsoft Edge
Mozilla Firefox
The latest two major versions of the supported browsers are supported.
Hardware requirements summary
CPU: 2 Cores CPU for the k8s nodes; 3 Cores for Elasticsearch
Memory: 1GB memory for the k8s nodes; 6GB memory for Elasticsearch
PostgreSQL 12 with
pg_partman>=4.0
, at least 5GB storageRedis >= 6.2, with 30kB per user. 10000 users require 300MB.
How to install this Helm chart
This section provides detailed steps on how to install this Helm chart.
Preparation on your local machine
You need to install the following tools on your local machine.
kubectl
with a version matching the Kubernetes server version. For example, if the server is 1.21, then you should be using the latest version ofkubectl
1.21.x.Helm v3. You should use the latest version.
Docker daemon. You need to be able to run Docker container on your local machine. If Docker daemon is unavailable, you need to download the binary release of Authgear to proceed. See Download binary release for details.
Download binary release
This step is optional if your local machine has a running Docker daemon.
If for some reason your local machine cannot have Docker daemon running, you can download the binary release of Authgear.
Visit https://github.com/authgear/authgear-server/releases to download the binary.
You should choose a release closest to your intended version of Authgear.
Currently, the binary is built for linux amd64 only.
The name of the binary is in the format
authgear-lite-<platform>-<arch>-<tag>
andauthgear-portal-lite-<platform>-<arch>-<tag>
.You need to download both.
The following guide assumes you have downloaded the binary to your working directory and renamed them to ./authgear
and ./authgear-portal
respectively.
Obtain a domain name
You need to obtain a domain name from a Internet domain registrar. If you already have a domain name, you can skip this step.
Overview of the subdomains
This Helm chart assumes you have a apex domain dedicated to Authgear. Assume your apex domain is myapp.com
.
Here is the list of subdomain assignments.
Provision the Kubernetes cluster
If you have a Kubernetes cluster already, you can skip creating a new one. Otherwise, follow the instructions from your cloud provider to create a new one. Refer to the Hardware requirements summary to configure the node pool.
Provision the PostgreSQL database instance
It is strongly recommended that you set up an external production-ready PostgreSQL instance, instead of relying on a in-cluster PostgreSQL deployment like bitnami/postgresql.
If you have a PostgreSQL database instance already, you can skip creating a new one. Otherwise, follow the instructions from your cloud provider to create a new one. Refer to the Database requirements to configure the instance.
Create 2 PostgreSQL databases within the instance. Create 1 PostgreSQL user for each PostgreSQL database. Make sure the PostgreSQL user has full access to the PostgreSQL database. See Database requirements for details.
Provision the Redis instance
It is strongly recommended that you set up an external production-ready Redis instance, instead of relying on a in-cluster Redis deployment like bitnami/redis.
If you have a Redis instance already, you can skip creating a new one. Otherwise, follow the instructions from your cloud provider to create a new one. Refer to the Redis requirements to configure the instance.
You should reserve 1 Redis database for Authgear.
Provision the cloud object store
This step is optional if you do not enable profile image.
Follow the corresponding guide of supported cloud object stores to create and configure.
For S3, Authgear needs the region, bucket name, access key ID and secret access key.
For GCS, Authgear needs the bucket name, service account and the credential JSON file.
For Azure Blob Storage, Authgear needs the storage account, container and access key.
It is recommended that you configure the object store to be non-public.
Provision the SMTP server
If you have a SMTP server already, you can skip this step. Otherwise, you can subscribe to services such as SendGrid.
Provision the NGINX ingress controller
If the Kubernetes cluster has NGINX ingress controller set up already, you can skip this step. Otherwise, you can use the Helm chart from NGINX ingress controller.
Note that Authgear expects the source IP of the incoming request to be correct. The source IP is used in rate limiting. If the source IP is incorrect, all requests are considered as coming the same source IP, making the limit being reached very soon.
One way correct the source IP is to set externalTrafficPolicy
to Local
. The caveat of this approach is that if the request is routed to a node without any NGINX ingress controller running on, the request is dropped. The simplest way to ensure one NGINX ingress controller running on a node is to use DaemonSet.
You need to change your DNS record so that all traffic of your domain go to the Kubernetes cluster.
Provision the cert-manager
cert-manager automates the process of obtaining, renewing and using TLS certificates issued by Let's Encrypt.
If you decide to manage TLS certificates by yourself, you can skip this step. Otherwise, you can use the Helm chart from cert-manager
Note that it is recommended that you install the CRDs independent of the Helm chart. The advantage of this approach is that the CRD resources can stay intact even if you uninstall the Helm chart.
Create 2 namespaces
It is recommended to create these 2 namespaces.
authgear
: Install the helm chart in this namespaceauthgear-apps
: Authgear-generated resources are in this namespace.
Create your own Helm chart
You need to create a few Kubernetes resources to support the Authgear Helm chart. So the best way is to create your own Helm chart and make the Authgear Helm chart a dependency.
Create the Helm chart
Create your Helm chart and then remove the generated boilerplate .yaml
in the templates/
directory.
Add Authgear as dependency
Open Chart.yaml
with your editor and make the following changes. The latest version can be found here.
Run the following to download dependencies.
Create cert-manager HTTP01 issuer and DNS01 issuer
You need to create a HTTP01 issuer and a DNS01 issuer in both namespaces. So there are 4 issuers you need to create in total.
Run database migration
Create Elasticsearch index
This step is optional if you do not enable Elasticsearch.
Create deployment-specific authgear.secrets.yaml
Create a Secret that contains a authgear.secrets.yaml
shared by all apps.
For example,
Create the "accounts" app
Create the following directory structure
Generate the authgear.yaml
and authgear.secrets.yaml
. Save the files to resources/authgear
folder.
Create the "accounts" app
Prepare the values.yaml
Refer to Helm chart values reference and prepare the ./authgear-deploy/values.yaml
.
Remember to provide the correct client ID. The client ID can be found in the generated authgear.yaml
.
Install your Helm chart
Install your helm chart with
How to upgrade Authgear
If there are no breaking changes that require migration to be performed between the running version and the target version, an upgrade is as simple as setting authgear.mainServer.image
and authgear.portalServer.image
to a newer value.
If there are breaking changes, migration usually will be provided as a subcommand.
New features usually require database migration to add new tables and new columns. You may need to run database migration before you run helm upgrade
. We try hard to make sure the modification to the database is backward-compatible, which means older version of Authgear can run with a higher version of database schema.
Helm chart values reference
Name | Type | Required | Description |
---|---|---|---|
| String | No | The namespace to store Kubernetes resources created by Authgear. It is recommended to create a new namespace instead of reusing an existing one. You must create this namespace in advance. The default is |
| String | Yes | The database URL for Authgear to store its main data |
| String | Yes | The database schema for Authgear to store its main data |
| String | Yes | The Redis URL for Authgear to store data with expiration, such as user sessions. |
| String | No | The log level |
| String | No | The sentry DSN to report error logs |
| Boolean | No | Whether to create Ingresses according to the convention of this Helm chart |
| String | No | The Ingress class. Only NGINX ingress controller is supported. The default is |
| Boolean | No | Whether cert-manager was installed by you and is available for this Helm chart to use. The default is |
| String | Depends | The name of the DNS01 issuer. It is required when cert-manager is enabled |
| String | Depends | The kind of the DNS01 issuer. The default is |
| String | Depends | The group of the DNS01 issuer. The default is |
| String | Depends | The name of the HTTP01 issuer. It is required when cert-manager is enabled |
| String | Depends | The kind of the HTTP01 issuer. The default is |
| String | Depends | The group of the HTTP01 issuer. The default is |
| String | Yes | The apex domain you assign to Authgear, for example |
| String | No | The name of the Secret to store the wildcard TLS certificate |
| String | No | The name of the Secret to store the portal TLS certificate |
| String | No | The name of the Secret to store the portal Authgear TLS certificate |
| String | Yes | The SMTP host |
| Integer | No | The SMTP port. The default is |
| String | No | The SMTP mode. Valid values are |
| String | No | The SMTP username |
| String | No | The SMTP password |
| Boolean | No | Whether elasticsearch was deployed by you separately and is available for Authgear to use. The default is |
| String | Depends | The URL to the elasticsearch |
| String | Depends | The account SID of your Twilio subscription. It is required if you allow your users to authenticate with SMS. Either one of Twilio or Nexmo is enough |
| String | Depends | The auth token SID of your Twilio subscription. |
| String | Depends | The API key of your Nexmo subscription. It is required if you allow your users to authenticate with SMS. Either one of Twilio or Nexmo is enough |
| String | Depends | The API secret of your Nexmo subscription. |
| Boolean | No | Whether to make audit log available to view on the portal |
| Boolean | No | Whether to enable the cronjob to run |
| String | No | The cron expression |
| String | Yes | The database URL for Authgear to store its log data |
| String | Yes | The database schema for Authgear to store its log data |
| Boolean | No | Whether to collect analytic data. The default is |
| String | Yes | The Redis URL for Authgear to store analytic data |
| String | Yes | The Authgear server image |
| Object | No | Kubernetes ResourceRequirements for the main server |
| Object | No | Kubernetes ResourceRequirements for the admin API server |
| Object | No | Kubernetes ResourceRequirements for the resolver server |
| Object | No | Kubernetes ResourceRequirements for the background daemon |
| String | No | The CDN host for serving images |
| String | No | The object store type. Valid values are |
| String | No | The S3 region |
| String | No | The S3 bucket name |
| String | No | The S3 access key ID |
| String | No | The S3 secret access key |
| String | No | The GCS bucket name |
| String | No | The GCS service account. Typically in form of an email address. |
| String | No | The content of the GCS credential JSON. |
| String | No | The name of the storage account |
| String | No | The name of the container |
| String | No | The access key |
| String | No | The Nginx sidecar image |
| String | Yes | The Authgear portal server image |
| String | No | The email header Sender |
| String | No | The email header Reply-To |
| String | Yes | The app ID of the Authgear providing authentication for the portal server |
| String | Yes | The client ID for the portal server to use Authgear |
| String | Yes | The endpoint of the Authgear used by the portal server |
| String | Yes | The static endpoint to the Admin API server. Normally this is an HTTP URL with cluster-local service name. |
| Object | No | Kubernetes ResourceRequirements for the portal server |
| String | No | The custom resources directory applied to every app. It provides global theming for this particular deployment. |
| Object | No | Kubernetes Volume without the name field |
| String | No | The custom resources directory applied to the portal server. It provides theming for this particular deployment. |
| Object | No | Kubernetes Volume without the name field |
Troubleshooting
Duplicate Ingress definition
When you upgrade the Helm chart from v5 to v6, the Ingress admission controller will complain about duplicate Ingress definition. To resolve this problem, you have to manually delete the existing Ingress resources first. So the upgrade has downtime.
Appendices
Customize the subdomain assignment
This Helm chart has its own convention on the subdomain assignment and CANNOT be customized. If you want to customize the assignment, you can set authgear.ingress.enabled
to false
. You can then study the source code of this Helm chart, and create the Ingresses to suit your needs.
Last updated