infra: relocate docker-30 compose stack under vms-home/, add garage and frisbee-drills
Move the docker-30 service definitions (gitea, kanidm, vault, zot, nginx, lab-proxy, maru-hleda-byt, fuj-management) into vms-home/ to match the naming convention used for other hosts, and add the new garage object-storage and frisbee-drills services alongside it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
84
vms-home/docker-30/kanidm/gitea-action-kubernetes-access.md
Normal file
84
vms-home/docker-30/kanidm/gitea-action-kubernetes-access.md
Normal file
@@ -0,0 +1,84 @@
|
||||
## 1. Create Kanidm service account + OAuth2 client
|
||||
|
||||
```bash
|
||||
# Create a service account for CI
|
||||
kanidm service-account create gitea_ci "Gitea CI Deploy" idm_admins --name idm_admin
|
||||
|
||||
# Create a group and add the service account
|
||||
kanidm group create k8s_deployers
|
||||
kanidm group add-members k8s_deployers gitea_ci
|
||||
|
||||
# Create the OAuth2 client (or reuse existing k8s one)
|
||||
# If you already have a k8s OIDC client, just add scope maps:
|
||||
kanidm system oauth2 update-scope-map k8s k8s_deployers openid groups
|
||||
|
||||
# Generate an API token for the service account
|
||||
kanidm service-account api-token generate --name idm_admin gitea_ci "gitea-ci-token"
|
||||
# ⚠️ Save the output token — this is the subject_token for exchange
|
||||
```
|
||||
|
||||
## 2. RBAC in Kubernetes
|
||||
|
||||
```yaml
|
||||
apiVersion: rbac.authorization.k8s.io/v1
|
||||
kind: ClusterRoleBinding
|
||||
metadata:
|
||||
name: gitea-ci-deploy
|
||||
subjects:
|
||||
- kind: User
|
||||
name: "gitea_ci@idm.home.hrajfrisbee.cz" # matches preferred_username claim
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
roleRef:
|
||||
kind: ClusterRole
|
||||
name: edit # scope down as needed
|
||||
apiGroup: rbac.authorization.k8s.io
|
||||
|
||||
```
|
||||
|
||||
## 3. Token exchange + kubeconfig setup (test in bash)
|
||||
|
||||
```bash
|
||||
vault-login # prepared alias
|
||||
|
||||
#!/usr/bin/env bash
|
||||
# set -euo pipefail
|
||||
|
||||
KANIDM_URL="https://idm.home.hrajfrisbee.cz"
|
||||
OAUTH2_CLIENT_ID="k8s" # your k8s OIDC client name in Kanidm
|
||||
API_TOKEN=$(vault kv get -format=json -mount="secret" "k8s_home/gitea/gitea-ci-token" |jq -r .data.data.token)
|
||||
K8S_API="https://192.168.0.31:6443"
|
||||
|
||||
# Exchange the API token for an OIDC token via RFC 8693
|
||||
RESPONSE=$(curl -sf -X POST "${KANIDM_URL}/oauth2/token" \
|
||||
-d "grant_type=urn:ietf:params:oauth:grant-type:token-exchange" \
|
||||
-d "client_id=${OAUTH2_CLIENT_ID}" \
|
||||
-d "subject_token=${API_TOKEN}" \
|
||||
-d "subject_token_type=urn:ietf:params:oauth:token-type:access_token" \
|
||||
-d "audience=${OAUTH2_CLIENT_ID}" \
|
||||
-d "scope=openid groups")
|
||||
|
||||
ID_TOKEN=$(echo "$RESPONSE" | jq -r '.id_token')
|
||||
|
||||
# Inspect claims (sanity check)
|
||||
echo "$ID_TOKEN" | cut -d. -f2 | base64 -d 2>/dev/null | jq .
|
||||
|
||||
# Build kubeconfig
|
||||
export KUBECONFIG=$(mktemp)
|
||||
kubectl config set-cluster mycluster \
|
||||
--server="${K8S_API}" \
|
||||
--certificate-authority=/path/to/ca.crt
|
||||
|
||||
kubectl config set-credentials gitea-ci \
|
||||
--token="${ID_TOKEN}"
|
||||
|
||||
kubectl config set-context gitea-ci \
|
||||
--cluster=mycluster \
|
||||
--user=gitea-ci
|
||||
|
||||
kubectl config use-context gitea-ci
|
||||
|
||||
# Test
|
||||
kubectl auth whoami
|
||||
kubectl get ns
|
||||
|
||||
```
|
||||
169
vms-home/docker-30/kanidm/readme.md
Normal file
169
vms-home/docker-30/kanidm/readme.md
Normal file
@@ -0,0 +1,169 @@
|
||||
## Upgrade
|
||||
|
||||
```bash
|
||||
docker exec -it kanidmd kanidmd domain upgrade-check
|
||||
# make sure backup exists: /srv/docker/kanidm/data/kanidm/backups
|
||||
|
||||
# change container image in: /srv/docker/kanidm/run.sh
|
||||
|
||||
# kanidm data restore
|
||||
docker stop kanidmd
|
||||
docker run --rm -it \
|
||||
-v kanidmd:/data \
|
||||
-v kanidmd_backups:/backup \
|
||||
kanidm/server:latest \
|
||||
/sbin/kanidmd database restore -c /data/server.toml /backup/kanidm.backup.json
|
||||
docker start kanidmd
|
||||
```
|
||||
|
||||
## Recover passwords from kanidm instance
|
||||
|
||||
```bash
|
||||
docker exec -i -t kanidmd kanidmd recover-account idm_admin
|
||||
```
|
||||
|
||||
## add user to k8s group
|
||||
|
||||
based on: https://blog.kammel.dev/post/k8s_home_lab_2025_06/
|
||||
|
||||
```bash
|
||||
export GROUP_NAME=k8s_users
|
||||
kanidm group create ${GROUP_NAME}
|
||||
kanidm group add-members ${GROUP_NAME} novakj
|
||||
|
||||
|
||||
export OAUTH2_NAME=k8s
|
||||
kanidm system oauth2 create-public ${OAUTH2_NAME} ${OAUTH2_NAME} http://localhost:8000
|
||||
kanidm system oauth2 add-redirect-url ${OAUTH2_NAME} http://localhost:8000
|
||||
kanidm system oauth2 update-scope-map ${OAUTH2_NAME} ${GROUP_NAME} email openid profile groups
|
||||
kanidm system oauth2 enable-localhost-redirects ${OAUTH2_NAME}
|
||||
|
||||
|
||||
kubectl oidc-login setup \
|
||||
--oidc-issuer-url=https://idm.home.hrajfrisbee.cz/oauth2/openid/k8s \
|
||||
--oidc-client-id=k8s
|
||||
|
||||
|
||||
|
||||
kubectl config set-credentials oidc \
|
||||
--exec-api-version=client.authentication.k8s.io/v1 \
|
||||
--exec-interactive-mode=Never \
|
||||
--exec-command=kubectl \
|
||||
--exec-arg=oidc-login \
|
||||
--exec-arg=get-token \
|
||||
--exec-arg="--oidc-issuer-url=https://idm.home.hrajfrisbee.cz/oauth2/openid/k8s" \
|
||||
--exec-arg="--oidc-client-id=k8s"
|
||||
|
||||
kubectl create clusterrolebinding oidc-cluster-admin \
|
||||
--clusterrole=cluster-admin \
|
||||
--user='https://idm.home.hrajfrisbee.cz/oauth2/openid/k8s#35842461-a1c4-4ad6-8b29-697c5ddbfe84'
|
||||
|
||||
```
|
||||
## commands
|
||||
|
||||
```bash
|
||||
# recover admin password
|
||||
# on the docker host
|
||||
docker exec -i -t kanidmd kanidmd recover-account admin
|
||||
docker exec -i -t kanidmd kanidmd recover-account idm_admin
|
||||
|
||||
# kanidm mangement commands (could be run on any logged in client)
|
||||
kanidm person credential create-reset-token novakj
|
||||
kanidm person get novakj | grep memberof
|
||||
kanidm group get kanidm group get
|
||||
kanidm group get idm_all_accounts
|
||||
kanidm group get idm_all_persons
|
||||
kanidm group account-policy credential-type-minimum idm_all_accounts any
|
||||
kanidm person get novakj | grep memberof
|
||||
kanidm group get idm_people_self_name_write
|
||||
```
|
||||
|
||||
## configure oauth proxy
|
||||
|
||||
```bash
|
||||
kanidm system oauth2 create oauth2-proxy "OAuth2 Proxy" https://oauth2-proxy.lab.home.hrajfrisbee.cz/oauth2/callback
|
||||
kanidm system oauth2 set-landing-url oauth2-proxy https://oauth2-proxy.lab.home.hrajfrisbee.cz
|
||||
kanidm system oauth2 enable-pkce oauth2-proxy
|
||||
kanidm system oauth2 warning-insecure-client-disable-pkce oauth2-proxy # if proxy doesn't support PKCE
|
||||
kanidm system oauth2 get oauth2-proxy # note the client secret
|
||||
|
||||
# update incorrect urls if needed
|
||||
remove-redirect-url
|
||||
kanidm system oauth2 add-redirect-url oauth2-proxy https://oauth2-proxy.lab.home.hrajfrisbee.cz/oauth2/callback
|
||||
kanidm system oauth2 set-landing-url oauth2-proxy https://oauth2-proxy.lab.home.hrajfrisbee.cz
|
||||
|
||||
# output
|
||||
✔ Multiple authentication tokens exist. Please select one · idm_admin@idm.home.hrajfrisbee.cz
|
||||
---
|
||||
class: account
|
||||
class: key_object
|
||||
class: key_object_internal
|
||||
class: key_object_jwe_a128gcm
|
||||
class: key_object_jwt_es256
|
||||
class: memberof
|
||||
class: oauth2_resource_server
|
||||
class: oauth2_resource_server_basic
|
||||
class: object
|
||||
displayname: OAuth2 Proxy
|
||||
key_internal_data: 69df0a387991455f7c9800f13b881803: valid jwe_a128gcm 0
|
||||
key_internal_data: c5f61c48a9c0eb61ba993a36748826cc: valid jws_es256 0
|
||||
name: oauth2-proxy
|
||||
oauth2_allow_insecure_client_disable_pkce: true
|
||||
oauth2_rs_basic_secret: hidden
|
||||
oauth2_rs_origin_landing: https://oauth2-proxylab.home.hrajfrisbee.cz/
|
||||
oauth2_strict_redirect_uri: true
|
||||
spn: oauth2-proxy@idm.home.hrajfrisbee.cz
|
||||
uuid: d0dcbad5-90e4-4e36-a51b-653624069009
|
||||
|
||||
secret: 7KJbUe5x35NVCT1VbzZfhYBU19cz9Xe9Z1fvw4WazrkHX2c8
|
||||
|
||||
|
||||
|
||||
kanidm system oauth2 update-scope-map oauth2-proxy k8s_users openid profile email
|
||||
```
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
|
||||
docker run -d --name=kanidmd --restart=always \
|
||||
-p '8443:8443' \
|
||||
-p '3636:3636' \
|
||||
--volume /srv/docker/kanidm/data:/data \
|
||||
docker.io/kanidm/server:latest
|
||||
|
||||
docker run --rm -i -t -v --restart=always \
|
||||
-p '8443:8443' \
|
||||
-p '3636:3636' \
|
||||
--volume /srv/docker/kanidm/data:/data \
|
||||
docker.io/kanidm/server:latest \
|
||||
kanidmd cert-generate
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Service account for gitea runner
|
||||
|
||||
```bash
|
||||
# create service account
|
||||
#kanidm service-account create \
|
||||
# gitea_ci \ # account name
|
||||
# "Gitea CI Deploy" \ # display name
|
||||
# idm_admins \ # entry-managed-by (delegation group)
|
||||
# --name idm_admin # authenticate as this user
|
||||
|
||||
kanidm service-account create gitea_ci "Gitea CI Deploy" idm_admins --name idm_admin
|
||||
|
||||
# Create a group and add the service account
|
||||
kanidm group create k8s_deployers
|
||||
kanidm group add-members k8s_deployers gitea_ci
|
||||
|
||||
# Create the OAuth2 client (or reuse existing k8s one)
|
||||
# If you already have a k8s OIDC client, just add scope maps:
|
||||
kanidm system oauth2 update-scope-map k8s k8s_deployers openid groups
|
||||
|
||||
# Generate an API token for the service account
|
||||
kanidm service-account api-token generate --name idm_admin gitea_ci "gitea-ci-token"
|
||||
# ⚠️ Save the output token — this is the subject_token for exchange
|
||||
|
||||
```
|
||||
9
vms-home/docker-30/kanidm/run.sh
Normal file
9
vms-home/docker-30/kanidm/run.sh
Normal file
@@ -0,0 +1,9 @@
|
||||
docker rm -f kanidmd
|
||||
|
||||
docker run -d --name=kanidmd --restart=always \
|
||||
-p '8443:8443' \
|
||||
-p '3636:3636' \
|
||||
--volume /srv/docker/kanidm/data:/data \
|
||||
docker.io/kanidm/server:1.9.1
|
||||
|
||||
# previous version: 1.8.5
|
||||
136
vms-home/docker-30/kanidm/server.toml
Normal file
136
vms-home/docker-30/kanidm/server.toml
Normal file
@@ -0,0 +1,136 @@
|
||||
# The server configuration file version.
|
||||
version = "2"
|
||||
|
||||
# The webserver bind address. Requires TLS certificates.
|
||||
# If the port is set to 443 you may require the
|
||||
# NET_BIND_SERVICE capability. This accepts a single address
|
||||
# or an array of addresses to listen on.
|
||||
# Defaults to "127.0.0.1:8443"
|
||||
bindaddress = "0.0.0.0:8443"
|
||||
#
|
||||
# The read-only ldap server bind address. Requires
|
||||
# TLS certificates. If set to 636 you may require the
|
||||
# NET_BIND_SERVICE capability. This accepts a single address
|
||||
# or an array of addresses to listen on.
|
||||
# Defaults to "" (disabled)
|
||||
# ldapbindaddress = "0.0.0.0:3636"
|
||||
#
|
||||
# The path to the kanidm database.
|
||||
db_path = "/data/kanidm.db"
|
||||
#
|
||||
# If you have a known filesystem, kanidm can tune the
|
||||
# database page size to match. Valid choices are:
|
||||
# [zfs, other]
|
||||
# If you are unsure about this leave it as the default
|
||||
# (other). After changing this
|
||||
# value you must run a vacuum task.
|
||||
# - zfs:
|
||||
# * sets database pagesize to 64k. You must set
|
||||
# recordsize=64k on the zfs filesystem.
|
||||
# - other:
|
||||
# * sets database pagesize to 4k, matching most
|
||||
# filesystems block sizes.
|
||||
# db_fs_type = "zfs"
|
||||
#
|
||||
# The number of entries to store in the in-memory cache.
|
||||
# Minimum value is 256. If unset
|
||||
# an automatic heuristic is used to scale this.
|
||||
# You should only adjust this value if you experience
|
||||
# memory pressure on your system.
|
||||
# db_arc_size = 2048
|
||||
#
|
||||
# TLS chain and key in pem format. Both must be present.
|
||||
# If the server receives a SIGHUP, these files will be
|
||||
# re-read and reloaded if their content is valid.
|
||||
tls_chain = "/data/chain.pem"
|
||||
tls_key = "/data/key.pem"
|
||||
#
|
||||
# The log level of the server. May be one of info, debug, trace
|
||||
#
|
||||
# NOTE: this can be overridden by the environment variable
|
||||
# `KANIDM_LOG_LEVEL` at runtime
|
||||
# Defaults to "info"
|
||||
# log_level = "info"
|
||||
#
|
||||
# The DNS domain name of the server. This is used in a
|
||||
# number of security-critical contexts
|
||||
# such as webauthn, so it *must* match your DNS
|
||||
# hostname. It is used to create
|
||||
# security principal names such as `william@idm.example.com`
|
||||
# so that in a (future) trust configuration it is possible
|
||||
# to have unique Security Principal Names (spns) throughout
|
||||
# the topology.
|
||||
#
|
||||
# ⚠️ WARNING ⚠️
|
||||
#
|
||||
# Changing this value WILL break many types of registered
|
||||
# credentials for accounts including but not limited to
|
||||
# webauthn, oauth tokens, and more.
|
||||
# If you change this value you *must* run
|
||||
# `kanidmd domain rename` immediately after.
|
||||
domain = "idm.home.hrajfrisbee.cz"
|
||||
#
|
||||
# The origin for webauthn. This is the url to the server,
|
||||
# with the port included if it is non-standard (any port
|
||||
# except 443). This must match or be a descendent of the
|
||||
# domain name you configure above. If these two items are
|
||||
# not consistent, the server WILL refuse to start!
|
||||
# origin = "https://idm.example.com"
|
||||
# # OR
|
||||
# origin = "https://idm.example.com:8443"
|
||||
origin = "https://idm.home.hrajfrisbee.cz"
|
||||
|
||||
# HTTPS requests can be reverse proxied by a loadbalancer.
|
||||
# To preserve the original IP of the caller, these systems
|
||||
# will often add a header such as "Forwarded" or
|
||||
# "X-Forwarded-For". Some other proxies can use the PROXY
|
||||
# protocol v2 header. While we support the PROXY protocol
|
||||
# v1 header, we STRONGLY discourage it's use as it has
|
||||
# significantly greater overheads compared to v2 during
|
||||
# processing.
|
||||
# This setting allows configuration of the list of trusted
|
||||
# IPs or IP ranges which can supply this header information,
|
||||
# and which format the information is provided in.
|
||||
# Defaults to "none" (no trusted sources)
|
||||
# Only one option can be used at a time.
|
||||
# [http_client_address_info]
|
||||
# proxy-v2 = ["127.0.0.1", "127.0.0.0/8"]
|
||||
# # OR
|
||||
# [http_client_address_info]
|
||||
# x-forward-for = ["127.0.0.1", "127.0.0.0/8"]
|
||||
# # OR
|
||||
# [http_client_address_info]
|
||||
# # AVOID IF POSSIBLE!!!
|
||||
# proxy-v1 = ["127.0.0.1", "127.0.0.0/8"]
|
||||
|
||||
# LDAPS requests can be reverse proxied by a loadbalancer.
|
||||
# To preserve the original IP of the caller, these systems
|
||||
# can add a header such as the PROXY protocol v2 header.
|
||||
# While we support the PROXY protocol v1 header, we STRONGLY
|
||||
# discourage it's use as it has significantly greater
|
||||
# overheads compared to v2 during processing.
|
||||
# This setting allows configuration of the list of trusted
|
||||
# IPs or IP ranges which can supply this header information,
|
||||
# and which format the information is provided in.
|
||||
# Defaults to "none" (no trusted sources)
|
||||
# [ldap_client_address_info]
|
||||
# proxy-v2 = ["127.0.0.1", "127.0.0.0/8"]
|
||||
# # OR
|
||||
# [ldap_client_address_info]
|
||||
# # AVOID IF POSSIBLE!!!
|
||||
# proxy-v1 = ["127.0.0.1", "127.0.0.0/8"]
|
||||
|
||||
[online_backup]
|
||||
# The path to the output folder for online backups
|
||||
path = "/data/kanidm/backups/"
|
||||
# The schedule to run online backups (see https://crontab.guru/)
|
||||
# every day at 22:00 UTC (default)
|
||||
schedule = "00 22 * * *"
|
||||
# four times a day at 3 minutes past the hour, every 6th hours
|
||||
# schedule = "03 */6 * * *"
|
||||
# We also support non standard cron syntax, with the following format:
|
||||
# sec min hour day of month month day of week year
|
||||
# (it's very similar to the standard cron syntax, it just allows to specify the seconds
|
||||
# at the beginning and the year at the end)
|
||||
# Number of backups to keep (default 7)
|
||||
# versions = 7
|
||||
Reference in New Issue
Block a user