1
0
Fork 0
Commit Graph

127 Commits (cf7ec7dd64baf9e3d09f2210b9015fa9c402ea82)

Author SHA1 Message Date
Dustin cf7ec7dd64 postgresql: Fix pod secrets
When migrating the `pod-secrets` Secret to a SealedSecret, I
accidentally created it using the `--from-file` instead of
`--from-env-file` argument to `kubectl secret create generic`.  This had
the effect of creating a single key named `pod.secrets` with the entire
contents of the file as its value.  This broke backups to MinIO, since
the PostgreSQL containers could no longer read the credentials from the
environment.  Regenerating the SealedSecret with the correct arguments
resolves this issue.
2023-10-19 07:12:16 -05:00
Dustin b07e141fa3 authelia: Convert to a stateless service
By default, Authelia uses a local SQLite database for persistent data
(e.g. authenticator keys, TOTP secrets, etc.) and keeps session data in
memory.  Together, these have some undesirable side effects.  First,
since needing access to the filesystem to store the SQLite database
means that the pod has to be managed by a StatefulSet.  Restarting
StatefulSet pods means stopping them all and then starting them back up,
which causes downtime.  Additionally, the SQLite database file needs to
be backed up, which I never got around to setting up.  Further, any time
the service is restarted, all sessions are invalidated, so users have to
sign back in.

All of these issues can be resolved by configuring Authelia to store all
of its state externally.  The persistent data can be stored in a
PostgreSQL database and the session state can be stored in Redis.  Using
a database managed by the existing Postgres Operator infrastructure
automaticaly enables high availability and backups as well.

To migrate the contents of the database, I used [pgloader].  With
Authelia shut down, I ran the migration job.  Authelia's database schema
is pretty simple, so there were no problems with the conversion.
Authelia started back up with the new database configuration without any
issues.

Session state are still stored only in memory of the Redis process.
This is probably fine, since Redis will not need restarted often, except
for updates.  At least restarting Authelia to adjust its configuration
will not log everyone out.

[pgloader]: https://pgloader.readthedocs.io/en/latest/ref/sqlite.html
2023-10-19 07:12:02 -05:00
Dustin 7698e039d1 postgresql: Use a private CA-signed TLS cert
The PostgreSQL server managed by *Postgres Operator* uses a self-signed
certificate by default.  In order to enable full validation of the
server certificate, we need to use a certificate signed by a known CA
that the clients can trust.  To that end, I have added a *cert-manager*
Issuer specifically for PostgreSQL.  The CA certificate is also managed
by *cert-manager*; it is self-signed and needs to be distributed to
clients out-of-band.
2023-10-18 18:47:09 -05:00
Dustin ba070e74a9 home-assistant: Upgrade ZWaveJS UI to 9.1.2 2023-10-14 22:26:09 -05:00
Dustin 29ec26c369 home-assistant: Upgrade Zigbee2MQTT to 1.33.1 2023-10-14 22:25:56 -05:00
Dustin 29e51e3641 home-assistant: Upgrade to 2023.10.3 2023-10-14 22:20:26 -05:00
Dustin 5d0d002efd argocd/apps: kitchen: Initial commit 2023-10-14 22:13:09 -05:00
Dustin 0eb121b833 kitchen: Remove config.yml ConfigMap generator
The `config.yml` document for *kitchen* contains several "secret" values
(e.g. passwords to Nextcloud, MQTT, etc.).  We don't want to commit
these to the Git repository, of course, but as long as Kustomize expects
to find the `config.yml` file, we won't be able to manage the
application with Argo CD.  Ultimately, *kitchen* needs to be modified to
be able to read secrets separately from config, but until then, we will
have to avoid managing `config.yml` with Kustomize.
2023-10-14 22:01:26 -05:00
Dustin 53a057666a kitchen: Set instance label for Argo CD
Argo CD wants every resource managed by an application to have that
application's name as the value of the `app.kubernetes.io/instance`
label.
2023-10-14 21:45:01 -05:00
Dustin c5c63d2684 kitchen: Migrate to Sealed Secrets 2023-10-14 21:44:47 -05:00
Dustin 28e8ac58db postgresql: Set instance label for Argo CD
Argo CD wants every resource managed by an application to have that
application's name as the value of the `app.kubernetes.io/instance`
label.
2023-10-14 21:32:29 -05:00
Dustin 3b05ab5b75 argocd/apps: Add PostgreSQL
The *postgresql* application monitors the PostgreSQL operator and its
assocaited resources.
2023-10-14 21:30:49 -05:00
Dustin 6ef8d3256e postgresql/default-cluster: Add Home Assistant DB
I actually created this a long time ago, but forgot to update the
manifest in Git.

The *homeassistant* database is used by Home Assistant for its
*recorder* component, which stores long-term statistics.  The data
stored here are only used for e.g. History and Logbook; current entity
states are still stored on the filesystem.
2023-10-14 21:28:41 -05:00
Dustin c23aa38eff postgresql: Migrate to Sealed Secrets 2023-10-14 21:28:32 -05:00
Dustin ccec71213a photoframesvc: Initial commit
The photo frame service has actually been deployed for a while, I just
forgot to commit it.
2023-10-14 11:25:50 -05:00
Dustin 5611ba5f8c argocd/apps: Add authelia 2023-10-14 11:17:16 -05:00
Dustin 629d1bb93a argocd: Configure SSO for CLI
The `argocd` command needs to have its own OIDC client configuration,
since it works like a "public" client.  To log in, run

```sh
argocd login argocd.pyrocufflink.blue --sso
```
2023-10-14 11:13:06 -05:00
Dustin e6f0261a44 phpipam: Migrate to Sealed Secrets 2023-10-14 10:56:20 -05:00
Dustin 721edd0d59 authelia: Use ConfigMap name suffix hash
Without `disableNameSuffixHash` enabled, Kustomize will create a unique
ConfigMap any time the contents of source file change.  It will also
update any Deployment, StatefulSet, etc resources to point to the new
ConfigMap.  This has the effect of restarting any pods that refer to the
ConfigMap whenever its contents change.

I had avoided using this initially because Kustomize does *not* delete
previous ConfigMap resources whenever it creates a new one.  Now that we
have Argo CD, though, this is not an issue, as it will clean up the old
resources whenever it synchronizes.
2023-10-14 10:47:23 -05:00
Dustin 7bdf1f86b9 authelia: Set instance label for Argo CD
Argo CD wants every resource managed by an application to have that
application's name as the value of the `app.kubernetes.io/instance`
label.
2023-10-14 10:47:07 -05:00
Dustin 63ff1bf637 authelia: Migrate to Sealed Secrets 2023-10-14 10:35:54 -05:00
Dustin fdbf1d3432 argocd: Deploy Argo CD
[Argo CD] is a Kubernetes-native GitOps/continuous deployment manager.
It monitors the state of Kubnernetes resources, such as Pods,
Deployments, ConfigMaps, Secrets, and Custom Resources, and synchronizes
them with their canonical definitions from a Git repository.

*Argo CD* consists of various components, including a Repository
Service, an Application Controller, a Notification Controller, and an
API server/Web UI.  It also has some optional components, such as a
bundled Dex server for authentication/authorization, and an
ApplicationSet controller, which we will not be using.

[Argo CD]: https://argo-cd.readthedocs.io/
2023-10-14 10:17:04 -05:00
Dustin 8ccac0e845 dynk8s-provisioner: Set instance label for Argo CD
Argo CD wants every resource managed by an application to have that
application's name as the value of the `app.kubernetes.io/instance`
label.
2023-10-14 07:43:37 -05:00
Dustin c317931f9c firefly-iii: Set instance label for Argo CD
Argo CD wants every resource managed by an application to have that
application's name as the value of the `app.kubernetes.io/instance`
label.
2023-10-14 07:40:14 -05:00
Dustin 3fb44e7ed6 phpipam: Set instance label for Argo CD
Argo CD wants every resource managed by an application to have that
application's name as the value of the `app.kubernetes.io/instance`
label.
2023-10-14 07:35:23 -05:00
Dustin 4081a2c8c4 paperless-ngx: Set instance label for Argo CD
Argo CD wants every resource managed by an application to have that
application's name as the value of the `app.kubernetes.io/instance`
label.
2023-10-14 07:33:27 -05:00
Dustin 1a83e4be89 ntfy: Set instance label for Argo CD
Argo CD wants every resource managed by an application to have that
application's name as the value of the `app.kubernetes.io/instance`
label.
2023-10-14 07:28:05 -05:00
Dustin 860bfb1e2c jenkins: Set instance label for Argo CD
Argo CD wants every resource managed by an application to have that
application's name as the value of the `app.kubernetes.io/instance`
label.
2023-10-14 07:24:42 -05:00
Dustin f3fcb92066 home-assistant: Set instance label for Argo CD
Argo CD wants every resource managed by an application to have that
application's name as the value of the `app.kubernetes.io/instance`
label.
2023-10-14 07:19:28 -05:00
Dustin 9f06e48269 firefly-iii: Migrate to sealed secrets 2023-10-13 21:32:58 -05:00
Dustin 84091869f1 home-assistant: Migrate to Sealed Secrets
The only Secret object in the *home-assistant* namespace is the `passwd`
file for Mosquitto.
2023-10-13 19:07:21 -05:00
Dustin 0592f450c4 sealed-secrets: Deploy Bitnami Sealed Secrets
[Sealed Secrets] will allow us to store secret values in the Git
repository, since the actual secrets are encrypted and can only be
decrypted using the private key stored in the Kubernetes cluster.

I have been looking for a better way to deal with secrets for some time
now.  For one thing, having the secret files ignored by Git means they
only exist on my main desktop.  If I need to make changes to an
application from another machine, I have to not only clone the
repository, but also manually copy the secret files.  That sort of
makes my desktop a single point-of-failure.  I tried moving all the
secret files to another (private) repository and adding it as a
submodule, but Kustomize did not like that; it will only load files from
the current working directory, or another Kustomize project.  Having to
create two projects for each application, one for the secrets and one
for everything else, would be tedious and annoying.  I also considered
encrypting all the secret files with e.g. GnuPG and creating Make
recipies for each project to decrypt them before running `kubectl
apply`.  I eventually want to use Argo CD, though, so that prerequisite
step would make that a lot more complex.  Eventually, I discovered
[KSOPS] and *Sealed Secrets*.  KSOPS operates entirely on the client
side, and thus requires a plugin for Kustomize and/or Argo CD in order
to work, so it's not significantly different than the GnuPG/Make idea.
I like that Sealed Secrets does not require anything on the client side,
except when initially creating the manifests for the SealedSecret
objects, so Argo CD will "just work" without any extra tools or
configuration.

[Sealed Secrets]: https://github.com/bitnami-labs/sealed-secrets
[KSOPS]: https://github.com/viaduct-ai/kustomize-sops
2023-10-13 18:34:01 -05:00
Dustin d943c936a7 phpipam: Update PVC storage class name
The other day, when I was dealing with the mess that I accidentally
created by letting the *phpipam* MySQL database automaticall upgrade
itself, I attempted to restore from a Longhorn backup to try to get the
database working again.  This did work, but as a side-effect, it changed
the storage class name of the *phpipam-pvc* persistent volume claim from
`longhorn` to `longhorn-static`.  Now, when attempting to apply the
YAML manifest, `kubectl` complains because this field is immutable.  As
such, the manifest needs to be updated to reflect the value set by
Longhorn when the backup was restored and the PVC was recreated.
2023-10-10 22:42:14 -05:00
Dustin 934c07ceba device-plugins: Add fuse-device-plugin DaemonSet
The *fuse-device-plugin* handles mapping the `/dev/fuse` device into
unprivileged containers, e.g. for `buildah`.

Although *fuse-device-plugin* was recommended by Red Hat in their
blog post [How to use Podman inside of Kubernetes][0], it's probably
not the best choice any more.  It's working for now, giving me the
ability to build container images in Kubernetes without running
`buildah` in a privileged container, but I will probably investigate
replacing it with the [generic-device-plugin][1] eventually.

[0]: https://www.redhat.com/sysadmin/podman-inside-kubernetes
[1]: https://github.com/squat/generic-device-plugin
2023-10-10 22:31:44 -05:00
Dustin f7a8f391ea dch-webhooks: Configure SSH cert signer
The *dch-webhooks* tool now provides an operation for hosts to request a
signed SSH certificate from the SSH CA.  It's primarily useful for
unattended deployments like CoreOS Ignition, where hosts do not have
any credentials to authenticate with the CA directly.
2023-10-10 22:31:44 -05:00
Dustin 92a5aee7b4 authelia: Add OIDC client for step-ca
*step-ca* uses OpenID Connect to authenticate requests for SSH and X.509
certificates.
2023-10-10 22:31:44 -05:00
Dustin 0a9596d8bd step-ca: Deploy Step CA service
[Step CA] is an open-source online X.509 and SSH certificate authority
service.  It supports issuing certificates via various protocols,
including ACME and its own HTTP API via the `step` command-line utility.
Clients can authenticate using a variety of methods, such as JWK, Open
ID Connect, or mTLS.  This makes it very flexible and easy to introduce
to an existing ecosystem.

Although the CA service is mostly stateless, it does have an on-disk
database where stores some information, notably the list of SSH hosts
for which it has signed certificates.  Most other operations, though, do
not require any persistent state; the service does not keep track of
every single certificate it signed, for example.  It can be configured
to store authentication information (referred to as "provisioners") in
the database instead of the configuration file, by enabling the "remote
provisioner management" feature.  This has the advantage of being able
to modify authentication configuration without updating a Kubernetes
ConfigMap and restarting the service.

The official Step CA documentation recommends using the `step ca init`
command initialize a new certificate authority.  This command performs a
few steps:

* Generates an ECDSA key pair and uses it to create a self-signed root
  certificate
* Generates a second ECDSA key pair and signs an intermediate CA
  certificate using the root CA key
* Generates an ECDSA key pair and SSH root certificate
* Creates a `ca.json` configuration file

These steps can be performed separately, and in fact, I created the
intermediate CA certificate and signed it with the (offline) *dch Root
CA* certificate.

When the service starts for the first time, because
`authority/enableAdmin` is `true` and `authority/provisioners` is empty,
a new "Admin JWK" provisioner will be created automatically.  This key
will be encrypted with the same password used to encrypt the
intermediate CA certificate private key, and can be used to create other
provisioners.

[Step CA]: https://smallstep.com/docs/step-ca/
2023-10-10 22:31:44 -05:00
Dustin 6cd7eae0d3 phpipam: Use Authelia for authentication
phpIPAM supports "Apache authentication" which effectively delegates
authentication to the web server and trusts the `PHP_AUTH_USER` server
variable.  This variable is usually set by an Apache authentication
module, but it can be set manually in the config.  Here, we're using
`SetEnvIf` to populate it from the value of the `Remote-User` header
set by Authelia.
2023-09-22 21:24:24 -05:00
Dustin 2867210d38 phpipam: Pin to MariaDB 10.9.3
Using the *latest* tag for MariaDB is particularly problematic, as a
new version of the container may be pulled when the pod is scheduled on
a different host.  MariaDB will not start in this case, as it recognizes
that the data on disk need to be upgraded.

To prevent database outages in situations like this, we need to pin to a
specific version of MariaDB, ensuring that every pod runs the same
version.
2023-09-22 21:17:18 -05:00
Dustin ec537b0230 home-assistant: Update to 2023.8.4
Also need to update Whisper and Piper because apparently the
communication protocol has changed.
2023-08-29 09:13:15 -05:00
Dustin 64514e4b2a cert-manager: Drop acmeDNS solver
ACME DNS seems to have stopped working (401 Unauthorized for all
requests).  I've migrated the rest of the domains to use Cloudflare.
2023-08-28 12:00:23 -05:00
Dustin 8f7c42e054 firefly-iii: Update to v6.0.19 2023-08-09 14:04:52 -05:00
Dustin 0c8480ba21 jenkins: Update to v2.401.3 2023-08-09 14:04:23 -05:00
Dustin ce898a7590 home-assistant: Update ZWaveJS2MQTT to v8.22.3 2023-07-20 18:02:03 -05:00
Dustin 81266d4ef9 home-assistant: Use subdomain for Zigbee/Z-wave UI
Having the Z-Wave and Zigbee admin interfaces exposed as sub-paths under
*homeassistant.pyrocufflink.blue* made it difficult to use Authelia.
Since I have a Firefox container tab specifically for Home Assistant,
the login redirect would open a new tab in a different container, since
Authelia is hosted at *auth.pyrocufflink.blue*.  In order to log in, I
would have to temporarily disable "designated sites only" for the Home
Assistant tab container.  Using subdomains for the admin interfaces
avoids this issue, since I can use a different container for them, one
that does not have the "designated sites only" setting, since I am less
worried about accidentally leaking data to sites on the Internet from
them.
2023-08-02 20:13:45 -05:00
Dustin 0cbda0fd73 home-assistant: Deploy Piper and Whisper
Piper is the new text-to-speech service for Home Assistant.  Whisper is
a speech-to-text service.  Together, these services, which communicate
with Home Assistant via the Wyoming protocol, provide the speech
interface to the new Home Assistant Voice Assistant feature.
2023-08-02 20:13:45 -05:00
Dustin a7eac14d39 home-assistant: Deploy Home Assistant
This commit adds resources for deploying the Home Assistant ecosystem
inside Kubernetes.  Home Assistant itself, as well as Mosquitto, are
just normal Pods, managed by StatefulSets, that can run anywhere.
ZWaveJS2MQTT and Zigbee2MQTT, on the other hand, have to run on a
special node (a Raspberry Pi), where the respective controllers are
attached.

The Home Assistant UI is exposed externally via an Ingress resource.
The MQTT broker is also exposed externally, using the TCP proxy feature
of *ingress-nginx*.  Additionally, the Zigbee2MQTT and ZWaveJS2MQTT
control panels are exposed via Ingress resources, but these are
protected by Authelia.
2023-07-24 17:53:58 -05:00
Dustin 2153097930 firefly-iii: Increase client body size limit
This allows attaching larger files to transactions (e.g. receipts).
2023-07-13 08:43:33 -05:00
Dustin 43d0e99741 scanservjs: Update to v2.27.0 2023-07-08 07:06:10 -05:00
Dustin 2c6eb63bbb scanservjs: Update Canon IP address
Switched the Canon Pixma G7020 to WiFi in the new house, so its IP
address changed.
2023-07-08 07:05:29 -05:00