cluster

Infrastructure files for Nordgedanken and Midnightthoughts.
git clone git://archive.git.mtrnord.blog/MTRNord/cluster.git
Log | Files | Refs | README

commit 2769b444e794e8e3046fa2b8b612523baafeb2f1
parent c2f25972ef40712720a7ee6242c3fca89f226a18
Author: MTRNord <MTRNord@users.noreply.github.com>
Date:   Tue, 14 Oct 2025 20:42:54 +0200

try setting up a blog

Signed-off-by: MTRNord <MTRNord@users.noreply.github.com>

Diffstat:
Aapps/talos_cluster/blog/docker/Dockerfile | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Aapps/talos_cluster/blog/docker/php.ini | 6++++++
Aapps/talos_cluster/blog/docker/startup.sh | 19+++++++++++++++++++
Aapps/talos_cluster/blog/docker/wordpress.conf | 47+++++++++++++++++++++++++++++++++++++++++++++++
Aapps/talos_cluster/blog/docker/wp-config.php | 69+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aapps/talos_cluster/blog/kustomization.yaml | 7+++++++
Aapps/talos_cluster/blog/mysql-cm.yaml | 10++++++++++
Aapps/talos_cluster/blog/mysql.yaml | 94+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Aapps/talos_cluster/blog/secret.yaml | 39+++++++++++++++++++++++++++++++++++++++
Aapps/talos_cluster/blog/wordpress.yaml | 161+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 504 insertions(+), 0 deletions(-)

diff --git a/apps/talos_cluster/blog/docker/Dockerfile b/apps/talos_cluster/blog/docker/Dockerfile @@ -0,0 +1,52 @@ +# Use Ubuntu as the base image +FROM ubuntu:25.10 + +# Set the Timezone to UTC +ENV TZ=UTC + +# Install Nginx, and other necessary Packages +RUN apt-get update && apt-get install -y \ + software-properties-common \ + nginx \ + curl \ + wget \ + sudo \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# Add PHP repository +# RUN sudo add-apt-repository ppa:ondrej/php + +# Install PHP +RUN apt-get update && apt-get install -y \ + php8.4 php8.4-fpm php8.4-mysql php8.4-cli php8.4-gd \ + && rm -rf /var/lib/apt/lists/* +ADD php.ini /etc/php/8.4/nginx/ + +# Install Wordpress +RUN wget https://wordpress.org/latest.zip \ + && unzip latest.zip -d /var/www/html/ \ + && rm latest.zip + +# Add Nginx config file +RUN rm /etc/nginx/sites-enabled/default +ADD wordpress.conf /etc/nginx/sites-available/ +RUN ln -s /etc/nginx/sites-available/wordpress.conf /etc/nginx/sites-enabled/ + +# Add WordPress config file +RUN rm /var/www/html/wordpress/wp-config-sample.php +ADD wp-config.php /var/www/html/wordpress/wp-config.php + +# Change the user and Permission of WordPress root directory +RUN chown -R www-data:www-data /var/www/html/wordpress \ + && chmod -R 755 /var/www/html/wordpress + +# Exposing container to port 8080 +EXPOSE 8080 + +# Copy the startup script and give excuitable permission +COPY startup.sh /usr/local/bin/startup.sh +RUN chmod +x /usr/local/bin/startup.sh + +# Command to run the startup script +CMD ["/usr/local/bin/startup.sh"] diff --git a/apps/talos_cluster/blog/docker/php.ini b/apps/talos_cluster/blog/docker/php.ini @@ -0,0 +1,6 @@ +file_uploads = On +allow_url_fopen = On +memory_limit = 256M +upload_max_filesize = 150M +max_execution_time = 350 +date.timezone = Europe/Berlin diff --git a/apps/talos_cluster/blog/docker/startup.sh b/apps/talos_cluster/blog/docker/startup.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +WP_CONFIG="/var/www/html/wordpress/wp-config.php" + +sed -i "s/\${DB_NAME}/${DB_NAME}/g" $WP_CONFIG +sed -i "s/\${DB_USER}/${DB_USER}/g" $WP_CONFIG +sed -i "s/\${DB_PASSWORD}/${DB_PASSWORD}/g" $WP_CONFIG +sed -i "s/\${DB_HOST}/${DB_HOST}/g" $WP_CONFIG +sed -i "s/\${AUTH_KEY}/${AUTH_KEY}/g" $WP_CONFIG +sed -i "s/\${SECURE_AUTH_KEY}/${SECURE_AUTH_KEY}/g" $WP_CONFIG +sed -i "s/\${LOGGED_IN_KEY}/${LOGGED_IN_KEY}/g" $WP_CONFIG +sed -i "s/\${NONCE_KEY}/${NONCE_KEY}/g" $WP_CONFIG +sed -i "s/\${AUTH_SALT}/${AUTH_SALT}/g" $WP_CONFIG +sed -i "s/\${SECURE_AUTH_SALT}/${SECURE_AUTH_SALT}/g" $WP_CONFIG +sed -i "s/\${LOGGED_IN_SALT}/${LOGGED_IN_SALT}/g" $WP_CONFIG +sed -i "s/\${NONCE_SALT}/${NONCE_SALT}/g" $WP_CONFIG + +service php8.4-fpm start +nginx -g 'daemon off;' diff --git a/apps/talos_cluster/blog/docker/wordpress.conf b/apps/talos_cluster/blog/docker/wordpress.conf @@ -0,0 +1,47 @@ +server { + listen 8080; + root /var/www/html/wordpress; + index index.php; + + server_name _; + + location = /favicon.ico { + log_not_found off; + access_log off; + } + + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac). + # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) + location ~ /\. { + deny all; + } + + # Deny access to any files with a .php extension in the uploads directory + # Works in sub-directory installs and also in multisite network + # Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban) + location ~* /(?:uploads|files)/.*\.php$ { + deny all; + } + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/var/run/php/php8.4-fpm.sock; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } + + location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { + expires max; + log_not_found off; + } +} diff --git a/apps/talos_cluster/blog/docker/wp-config.php b/apps/talos_cluster/blog/docker/wp-config.php @@ -0,0 +1,69 @@ +<?php +define( 'DB_NAME', '${DB_NAME}' ); +define( 'DB_USER', '${DB_USER}' ); +define( 'DB_PASSWORD', '${DB_PASSWORD}' ); +define( 'DB_HOST', '${DB_HOST}' ); +define( 'DB_CHARSET', 'utf8' ); +define( 'DB_COLLATE', '' ); + +/**#@+ + * Authentication unique keys and salts. + * + * Change these to different unique phrases! You can generate these using + * the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}. + * + * You can change these at any point in time to invalidate all existing cookies. + * This will force all users to have to log in again. + * + * @since 2.6.0 + */ +define( 'AUTH_KEY', '${AUTH_KEY}' ); +define( 'SECURE_AUTH_KEY', '${SECURE_AUTH_KEY}' ); +define( 'LOGGED_IN_KEY', '${LOGGED_IN_KEY}' ); +define( 'NONCE_KEY', '${NONCE_KEY}' ); +define( 'AUTH_SALT', '${AUTH_SALT}' ); +define( 'SECURE_AUTH_SALT', '${SECURE_AUTH_SALT}' ); +define( 'LOGGED_IN_SALT', '${LOGGED_IN_SALT}' ); +define( 'NONCE_SALT', '${NONCE_SALT}' ); + +/**#@-*/ + +/** + * WordPress database table prefix. + * + * You can have multiple installations in one database if you give each + * a unique prefix. Only numbers, letters, and underscores please! + * + * At the installation time, database tables are created with the specified prefix. + * Changing this value after WordPress is installed will make your site think + * it has not been installed. + * + * @link https://developer.wordpress.org/advanced-administration/wordpress/wp-config/#table-prefix + */ +$table_prefix = 'wp_'; + +/** + * For developers: WordPress debugging mode. + * + * Change this to true to enable the display of notices during development. + * It is strongly recommended that plugin and theme developers use WP_DEBUG + * in their development environments. + * + * For information on other constants that can be used for debugging, + * visit the documentation. + * + * @link https://developer.wordpress.org/advanced-administration/debug/debug-wordpress/ + */ +define( 'WP_DEBUG', false ); + +/* Add any custom values between this line and the "stop editing" line. */ + + + +/* That's all, stop editing! Happy publishing. */ + +if ( ! defined( 'ABSPATH' ) ) { + define( 'ABSPATH', __DIR__ . '/' ); +} + +require_once ABSPATH . 'wp-settings.php'; diff --git a/apps/talos_cluster/blog/kustomization.yaml b/apps/talos_cluster/blog/kustomization.yaml @@ -0,0 +1,7 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: blog +resources: + - secret.yaml + - mysql-cm.yaml + - mysql.yaml diff --git a/apps/talos_cluster/blog/mysql-cm.yaml b/apps/talos_cluster/blog/mysql-cm.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: mysql-configmap + namespace: blog +data: + init.sql: | + CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD'; + GRANT ALL PRIVILEGES ON '$MYSQL_DATABASE'.* TO '$MYSQL_USER'@'%'; + FLUSH PRIVILEGES; diff --git a/apps/talos_cluster/blog/mysql.yaml b/apps/talos_cluster/blog/mysql.yaml @@ -0,0 +1,94 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mysql + namespace: blog +spec: + serviceName: "mysql" + replicas: 1 + selector: + matchLabels: + app: mysql + template: + metadata: + labels: + app: mysql + spec: + containers: + - name: mysql + image: mariadb:12.0 + env: + - name: MARIADB_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-cred + key: admin-password + - name: MARIADB_USER + valueFrom: + secretKeyRef: + name: mysql-cred + key: username + - name: MARIADB_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-cred + key: password + - name: MARIADB_DATABASE + valueFrom: + secretKeyRef: + name: mysql-cred + key: db-name + volumeMounts: + - name: mysql-volume + mountPath: /var/lib/mysql + - name: mysql-config + mountPath: /docker-entrypoint-initdb.d + resources: + requests: + memory: "256Mi" + cpu: "100m" + limits: + memory: "512Mi" + cpu: "200m" + livenessProbe: + tcpSocket: + port: 3306 + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 3 + readinessProbe: + tcpSocket: + port: 3306 + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 3 + volumes: + - name: mysql-config + configMap: + name: mysql-configmap + volumeClaimTemplates: + - metadata: + name: mysql-volume + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 2Gi +--- +apiVersion: v1 +kind: Service +metadata: + name: mysql-service + namespace: blog +spec: + type: ClusterIP + selector: + app: mysql + ports: + - protocol: TCP + port: 3306 + targetPort: 3306 diff --git a/apps/talos_cluster/blog/secret.yaml b/apps/talos_cluster/blog/secret.yaml @@ -0,0 +1,39 @@ +apiVersion: v1 +kind: Secret +metadata: + name: mysql-cred + namespace: blog +type: Opaque +stringData: + admin-password: ENC[AES256_GCM,data:DBKunxb540WTJEYgQY7EyC9RgFNn0wxJv4hIdeX7oRWK6jqFuYAaCBM+1yzrwxO6X6T8Bg69ILiEGhm8mmSKyA==,iv:ykIwKdgpLTJByJOoiDb0caCVGV6cCe2wi0mgCkGwY2g=,tag:ff917giksXZ1bCxliOwS5Q==,type:str] + username: ENC[AES256_GCM,data:EBaButLoMhMB,iv:nevzbMC2NP4kC0x+yJEtwbh7oPnTJlrv9sToHHaMoFg=,tag:75p79QwoVlPrbkulTDj9Nw==,type:str] + password: ENC[AES256_GCM,data:M6EHSMW4h4/YANZSCrlrSdrLjgj9BjvoAHf5aCGlmlz3EdRNInxvGCXaivS3SDJDSukfAhpR5L3jkfnk3l8XHg==,iv:+figK9aAnzF+4tefQhiaoKN/v+V+ni+Qfqo6ICki6pM=,tag:Diqh1QBI6UpkdKLwsRhiQw==,type:str] + db-name: ENC[AES256_GCM,data:drXBn9jb/ue7,iv:DjQZfZzUVfwD00VBLKlqEGmmO+qtTvYzaXr7p9jSlII=,tag:dNoVvUx3w0IIC2JEz5lNLg==,type:str] + auth-key: ENC[AES256_GCM,data:LEESzcBss0V896dRi4sw9Tn0OVgPhd+IpC3kgd8nBjOuCb08es3bs5uM4OYVNyTZgUe07DEcoyRpxHbpjg7+tw==,iv:ri8jNARjrG61DAZDJwGRvwdaMxpjr6vvejkc/cy0sF4=,tag:UEs3AAy/A66bWoHQ/8DaXw==,type:str] + secure-auth-key: ENC[AES256_GCM,data:W9C5YmfMGH9ZyPIB0iPqobKerjyLcsmaqDbEiiQ4ZGhInvohpt3j8BLKFFAJz7ULEDzLHyQd6ooi2vTsePN1Hw==,iv:glrfS51o5UZtPt/kCYLEIN1wIrit/hBJrqFD40rs98M=,tag:b07T8ycUk6j62sUiHyqrrQ==,type:str] + logged-in-key: ENC[AES256_GCM,data:c9y9j/xZRt5dk060gxmGJNkgffsxCrnxHDIR9ey9elnb8yRbSLdjoIl9VGzGBpvpT2xVyhB88mnleuO0/F4PqQ==,iv:tUisdS3dnOjiGnRoCX4ehlGf/1vhKhXPiZNwMoVjHj0=,tag:k0knB6j7/psmMCQb7h3lWg==,type:str] + nonce-key: ENC[AES256_GCM,data:nLTsYAGpWaXg5q1ygDe6K1BOy0rkVzVYHzueLLFmFtxFhy5tIDy6HiJGijZX/wZx46SC+2QgIAsgrPD2HpLIzA==,iv:7oYOFte0WgqgpFs4TjYzXUYfbpAGMPN3GYYdOOL/6+c=,tag:X8+ErHaOqGPx8Aqf5TVIGA==,type:str] + auth-salt: ENC[AES256_GCM,data:GirPK2JWDmtl6Cc6XuLm9FN05LRViE/AKptrpyOn5yNGyQLoGEKVm+ucf4KJg6NWWwBosnax7izBZQ1nhfTt3Q==,iv:upubPZ66G+Dlr6VZjDXyzsVDM76BWnTg/ETNciuFH5Q=,tag:HqrJvLF3bG+J7//SKjgM4A==,type:str] + secure-auth-salt: ENC[AES256_GCM,data:IysSWJxtmPs6ih49bZMvJKhmWUedr5DOP/JcoixH6XvGTHCN72O9/4tz7kxgl4cQ+gqYsIxV0GD1AGMAlkGpNw==,iv:74QCx3KnKjN1pjHzkl26gYzJYDKBerpC4cmKCyTrfHo=,tag:eDEOSLgBH/E+qQP6u7BjZg==,type:str] + logged-in-salt: ENC[AES256_GCM,data:/FL/p2qHUdB4Jt/Q73/Qr5RGn+fwjF/G6RQ8pvMHi4tUWmbfMP3S//wW/h6C7+JZkpCKf8zp5mreRr0/mffUjg==,iv:4HafawrSBLd2kJZolnsAUSKB52sBsFvcBkfJU4msgYs=,tag:7PvB6kvpZUggjK85tbD7cg==,type:str] + nonce-salt: ENC[AES256_GCM,data:NQeBOg+y557d6TpVFSzE82YKEWkO7QtiVaIBS1Dy5K4+ddr8M9s2kEaHpWFQJ6+7CWshEPnIMrLTJwICntkGmw==,iv:bNzV3TmfKpu+ad/mw3cmrFD6BCPUejLaFPp/efTVJPw=,tag:vgQ4MnK24yuRC4ZWk6Kf7g==,type:str] +sops: + kms: [] + gcp_kms: [] + azure_kv: [] + hc_vault: [] + age: + - recipient: age1esjyg2qfy49awv0ptkzvpk425adczjr38m37w2mmcahzc4p8n54sll2nzh + enc: | + -----BEGIN AGE ENCRYPTED FILE----- + YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBlTENRTjFtaEdlNDFENStZ + RUk3am1seEdjdDZCNGUwN1kzQWJpMTkwa1ZBCnAzYkJVT1BPUUY0Qzl5R1c4Qkx5 + cVVBcVJKSW5hVEtPZTRMRXBBeEh6RUkKLS0tIHdwSFUwL1RFbnRNNWIxcFNuclha + Vkh2OEJ1RTRJcjhwd1dIU3dla2FEcjQKVtSFYwZJGEi+PYbj1unQr0607F0/M3YT + +f9U3oJqTy04aGEjvWArmatMBPnq8EknL78ZHBmzqeQCsdOmt/9O6Q== + -----END AGE ENCRYPTED FILE----- + lastmodified: "2025-10-14T17:39:47Z" + mac: ENC[AES256_GCM,data:h75hEf9T52oS7zKswKOFBY/Airyi2myM2YKyN3DwDGm6UnisglyvCjDvGOpoX5PDX55CkJSRym/mKULqzO3vUaWopAiSCXsKfiKX7adfFUsLC5ldVS9fxp0eF9n1J5FPOcEJPs1TPO3MxgT78QRcueWe6uTAcd9Lcr9yTzduWsU=,iv:BSEDWNawJKTzkUBbsqflC87KNLKa4l2o1XZo4Hm3cH4=,tag:71Sxaxgr++jov8RsrIXCNQ==,type:str] + pgp: [] + encrypted_regex: ^(harborAdminPassword|kimaiAppSecret|kimaiAdminPassword|GITHUB_CLIENT_ID|GITHUB_CLIENT_SECRET|GITHUB_PRIVATE_KEY|woosh|root_password|rspamd_password|pgdb_password|matrix_access_token|pgdb_remote_url|hmac_secret_key|adminPassword|adminEmail|jenkinsAdminEmail|securityRealm|gerrit.config|routing_key|DATABASE_URL|SMTP_PASSWORD|SECRET_KEY_BASE|admin_password|extraCommands|key|clickhouseDatabaseURL|databaseURL|client_id|client_secret|secret_key_base|otp_secret|private_key|public_key|primaryKey|deterministicKey|keyDerivationSalt|token|clientId|secretKey|installationId|installationKey|uriOverride|adminToken.value|password.value|sql_password|erlangCookie|AUTHENTICATION_PASSWORD|ROOM_API_SECRET_KEY|adminPassword|configPassword|adminUser|configUser|MAIL_PASSWORD|APP_KEY|api_key|api_secret|keys|livekit_key|livekit_secret|secret_key|admin_pass|admin_email|mariadbPassword|mariadbRootPassword|privateKey|data|stringData|PASSWD|password|pass|postgresPassword|postgresqlPassword|redminePassword|smtpPassword|registration_shared_secret|shared_secret|secret|admin_token|integrationKey|rootPassword)$ + version: 3.9.1 diff --git a/apps/talos_cluster/blog/wordpress.yaml b/apps/talos_cluster/blog/wordpress.yaml @@ -0,0 +1,161 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: wordpress-pvc + namespace: blog +spec: + accessModes: + - ReadWriteMany + resources: + requests: + storage: 2Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: wordpress + namespace: blog +spec: + replicas: 1 + selector: + matchLabels: + app: wordpress + template: + metadata: + labels: + app: wordpress + spec: + securityContext: + fsGroup: 33 + containers: + - name: wordpress + image: ghcr.io/mtrnord/blog:latest + env: + - name: DB_HOST + value: mysql-service.wordpress.svc.cluster.local + - name: DB_USER + valueFrom: + secretKeyRef: + name: mysql-cred + key: username + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: mysql-cred + key: password + - name: DB_NAME + valueFrom: + secretKeyRef: + name: mysql-cred + key: db-name + - name: AUTH_KEY + valueFrom: + secretKeyRef: + name: mysql-cred + key: auth-key + - name: SECURE_AUTH_KEY + valueFrom: + secretKeyRef: + name: mysql-cred + key: secure-auth-key + - name: LOGGED_IN_KEY + valueFrom: + secretKeyRef: + name: mysql-cred + key: logged-in-key + - name: NONCE_KEY + valueFrom: + secretKeyRef: + name: mysql-cred + key: nonce-key + - name: AUTH_SALT + valueFrom: + secretKeyRef: + name: mysql-cred + key: auth-salt + - name: SECURE_AUTH_SALT + valueFrom: + secretKeyRef: + name: mysql-cred + key: secure-auth-salt + - name: LOGGED_IN_SALT + valueFrom: + secretKeyRef: + name: mysql-cred + key: logged-in-salt + - name: NONCE_SALT + valueFrom: + secretKeyRef: + name: mysql-cred + key: nonce-salt + ports: + - containerPort: 8080 + name: wordpress + resources: + requests: + memory: "256Mi" + cpu: "100m" + limits: + memory: "512Mi" + cpu: "200m" + volumeMounts: + - name: wordpress-persistent-storage + mountPath: /var/www/html/wordpress/wp-content/uploads + readinessProbe: + httpGet: + path: /wp-login.php + port: 8080 + scheme: "HTTP" + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 3 + livenessProbe: + httpGet: + path: /wp-admin/install.php + port: 8080 + scheme: "HTTP" + initialDelaySeconds: 60 + periodSeconds: 10 + timeoutSeconds: 5 + successThreshold: 1 + failureThreshold: 3 + volumes: + - name: wordpress-persistent-storage + persistentVolumeClaim: + claimName: wordpress-pvc +--- +kind: Service +apiVersion: v1 +metadata: + name: wordpress-service + namespace: blog +spec: + type: ClusterIP + selector: + app: wordpress + ports: + - name: http + protocol: TCP + port: 8080 + targetPort: 8080 +# --- +# apiVersion: gateway.networking.k8s.io/v1 +# kind: HTTPRoute +# metadata: +# name: blog +# namespace: blog +# spec: +# parentRefs: +# - name: envoy-gateway +# namespace: envoy-gateway +# hostnames: +# - mtrnord.blog +# rules: +# - backendRefs: +# - name: wordpress-service +# port: 8080 +# timeouts: +# request: 240s +# backendRequest: 0s