0:00 David Flanagan: Today we are deploying Zitadel using Helm to a Kubernetes cluster. So needless to say, there is a prerequisite. Number one, have a Kubernetes cluster. You can use kind, minikube, or even a real cloud-based cluster. Anything you want, as long as you can run kubectl commands and Helm commands; you should be good to go. With the boring bit out the way. Let's get straight over to the terminal. So here we have a Git clone of zitadel/zitadel-charts. This is the officially supported Zitadel Helm charts for deploying Zitadel to Kubernetes. Here we have the README. We're looking at it in VSCode, and if we scroll down, you'll see that we
0:56 have a bunch of examples that we can reference as we explore the different mechanisms or the different ways to deploy Zitadel to a Kubernetes Cluster. These are all inside of the Examples directory, and you can see we can do Postgrads and Secure Postgrad Secure. Bring in our own Secrets, machine users and self sign certificate. So there's a few different things that we've got to cover for today's video. Now, no matter which approach you decide to take after watching today's demo, one thing will be consistent. You need to provide your own Postgres. Now, this is a good thing.
1:34 If you've ever deployed any application with a Helm chart before and they come with their own dependencies and they provide their own Postgres, Redis, Kafka, et cetera, you will have felt the pain that is Helm dependencies. So providing Postgres by yourself is the best approach. Now, you can use CloudNativePg, or any other Postgres operator. You can use Supabase, you can use NeonDB or you could use Planet Scale. Whatever one you want to use is perfectly okay. Let's get back to the terminal. All right, let's run kubectl get pods. You'll see that I have something called default-1, terrible name.
2:16 I'll take the blame for that. This is my Postgres cluster provided by CloudNativePg. If we pop open my demo directory, you'll see here I have a very simple cluster of kind, called defaults one instance, one gig of storage, easiest Postgres cluster ever. That is our prerequisites met for the first demo. Now, if we take a look at the examples for deploying Zitadel, we'll go straight into Postgres Insecure, and we have a README, let's pop that open on preview, and you'll see that you can use the Bitnami charts if you want. That's how they kind of recommend you get started with the insecure approach.
2:54 But the most important line that we need for today is helm repo add charts.zitadel.com. This is gonna make sure that our Helm has the charts available for us to deploy. All right, so we can head to the terminal paste in helm repo add zitadel. Nice and simple. Popping back to VS Code. We can pop open, uh, the Insecure Postgres example and grab the Zitadel values fail that we'll need for our demo. Now that we have some values files to provide the Zitadel chart, we can start to work our way through the configuration. Now, the master key is very important.
3:35 This is what is going to keep your data secure. It needs to be. A 32 byte string. It should be generated and random and should come from a secure location. We'll see how to do that with an existing secret. In the next demo, we're going to skip over the external secure domain and TLS for now to focus on the database configuration. If we run kubectl get svc, you'll see that we have access to defaults-rw read write. This is a service that we are going to use with our Zitadel service. We have the Postgres port, we have some sort of database that'll need
4:16 to exist, and then we have the admin user and normal user to handle. General SQL queries and of course our migrations and other admin stuff We can run get secrets. M will see that we have defaults-app and defaults-superuser. So let's grab our defaults-app YAML. From here we have our database name, host, et cetera, et cetera, et cetera. So what we are interested in is the username of the user. You may notice that this is also our DB name and the username is there twice. And if you're not familiar with Base 64 values, or you haven't seen this
4:55 one a million times like I have, this is just app, meaning our database is app and our normal user is app. We will provide the password in a moment. Now we need to provide our admin username so we can run get secrets again, but superuser -oyaml and learn how to spell scroll up. And here we have good old cg. And again, if you haven't seen this a million times, it's just postgres. So, so far, so good. Now what about those passwords? Now, if you've watched the docker-compose video, you know that we can configure these secret values through environment variables, and
5:53 that's what we're gonna do today too. Now, in order to understand how to do that, I'm not just going to modify this YAML, but show you how to discover this for yourself. So we're gonna pop open the charts directory, which has the Zitadel chart, and we have the values YAML. Now, you can go through this and read all the comments if you want. It's gonna give you a great deal of understanding in how to configure the Zitadel chart by yourself. So far, we've been using configmapConfig, like you can see here. This is just passed straight into the Zitadel config.
6:33 Meaning we don't really want to put any secret material in it whatsoever. We also have the ability to pass in a secret config, which we could also use if we want. If we scroll down, we'll see that we have our master key like we're currently using, but we can also use master key secret name. So now that we know we can take that secret material out of our values file and make it available as a Kubernetes secret. If we continue to scroll down, we'll see we can modify debugging, init containers, extra containers, replica counts, images, and on and on and on, and anything that
7:09 you need to change is in this file. Get comfortable with it. Now we can see that we have the ability to pass in extra environment variables, and it already gives you an example of doing this for ZITADEL_DATABASE_POSTGRES_HOST. But of course we want to do this for ZITADEL_DATABASE_POSTGRES_ADMIN_PASSWORD and POSTGRES_USER_PASSWORD. So we can go ahead and copy this like so. Now let's come in above our config map, paste this in and fix our formatting. We don't need an empty list anymore 'cause we're passing in an actual environment variable. We're gonna pass in our ZITADEL_DATABASE_POSTGRES_ADMIN_PASSWORD, and this is going to come from our defaults-superuser secret.
8:00 Now we need to provide the key, which was password. We can do the exact same for the user password only this time it's defaults-app like so. , And before I apply this, I make a big mistake. This actually lives at the top level. Not Zitadel. As could be seen. Zitadel at the top, also at the top. So given that I think we're now in a position we can apply this So let's do Helm install. We'll call this Zitadel. We're using the Zitadel Zitadel chart, and of course we need to provide our Zitadel values file like so.
9:00 Now let me just take a moment. So let's snap back in just a second. And done easy. We can run kubectl get pods. We will see the Zitadel setup completed. We now have three Zitadel pods running and we have a Zitadel service. We can do a port forward like so on 8080. We can open our browser: localhost:8080. And we get a small error telling us our external domain is configured using the sslip.io. So we paste that in and now we have the Zitadel login screen. Now of course, when you're deploying locally, you will be losing, you will
10:01 be using some sort of temporary DNS name, like xip, sslip, et cetera. There are loads of them go nuts. So you do have to browse to that To correctly get the Zitadel Console. In production, you'll have your DNS records set up in advance and hopefully with TLS and you should be good to go. Now, how do we log in to our instance? Well, we can pop over to the README for the insecure example, and you'll see here that the username is Zitadel admin add Zitadel, followed by your domain. The password is Password1!. So Paste, And we're in.
10:42 We can skip the two fa prompt and update our password like so. And now we're ready to set up our first project. Now we'll be covering that in our next video. But why don't we take a look at a few more customizations you can make when deploying Zitadel with the official helm chart. So the first thing we're gonna take a look at is the referenced secrets example, if we pop open, the Zitadel values file It's pretty much the same as the one we've been working with throughout this video. However, at the bottom we have a config secret name and a config secret key.
11:37 This just means that we're going to pull in a secret with the name existing-zitadel-secrets, and we're going to look for a key called config.yaml. If we pop this open, you'll see that we have a secret with some string data. Now this is exact same format as we have in our Zitadel values. Where we have database, Postgres, port, et cetera, only here we're providing the host. Now, this could be that we provide a password and let's reuse the one that we get by default, like so. This is going to be merged with our config inside of the values
12:21 YAML and any config within a config map if you use that option too. So this is a nice way to provide secrets like so, although you may prefer to use the environment variable approach that I've already demonstrated, if we open this values file again, we'll see that we have a secret name for the master key. And that just takes a master key key with your secret value. Now, you also don't need to use string data here. You could decide to provide this via some sort of in cluster secret generation using a secrets operator. The choice is yours.
12:59 So let's take a look in the values file one more time. Let's go past all the stuff we've kinda covered with configuring Zitadel itself. Now we want to take a look at some of the extra nicities that are provided by this Helm chart. First of all, we get a highly available Zitadel setup running three, but if you want to overwrite the replica account, feel free. We can also scroll down to take a look at the security context and what we're gonna see here. Is that our application does not run as a root user, meaning we get a
13:32 slightly safer by default setup when we run Zitadel with the helm chart, which is also a very nice touch. Scrolling down a little bit more, we see that we can configure the ingress into a cluster. Clearly you're gonna wanna make this Zitadel available to the world so you can turn on ingress is true. And put in your ingress controller class name, which may be just nginx-ingress. Please do the remember to update your host to be whatever your Cluster is configured with. Like all helm charts, we can configure the resources node selector, tolerations, affinity, topology spread constraints.
14:18 All of that good fun stuff for production. But the last thing I really wanna take a look at is down at our day two operations, I encourage you to turn on metrics so that you can scrape your Zitadel setup with a Prometheus service and pod monitor. And in fact, if you want to turn on the service monitor, you can do this here too. Do you need a pod disruption budget? Potentially, I'm assuming you're gonna want to keep your Zitadel instance up to date. They release fast and often, and I encourage you to update fast and often.
14:56 So a pod disruption budget would just mean that our service is never unavailable for our customers unless something really hits a fan. Lastly, we have this nice convenience thing where you can deploy your own manifest too. So if you do want to deploy anything alongside your Z Whether that be the secrets, some service mesh configuration, or maybe an open telemetry collector. You could do that right from the helm chart, keeping your config all in one place. That's it for this video, and that concludes our installation module. By now, you should have a fully working Zitadel setup that allows you to move
15:39 on to setting up our first project. Now, if you're wondering why we haven't dove in to day two, operations monitoring, observability, upgrades, et cetera, fear not! Those will be coming towards the end of this course. So remember to check back if they're not already there. Now let's set up a Zitadel project. We'll see you in the next video.