Compare commits
1 Commits
apps/homea
...
apps/codim
Author | SHA1 | Date | |
---|---|---|---|
![]() |
10c67169b5 |
51
apps/codimd/db-init-job.yaml
Normal file
51
apps/codimd/db-init-job.yaml
Normal file
@@ -0,0 +1,51 @@
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: codimd-db-init
|
||||
labels:
|
||||
component: db-init
|
||||
spec:
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
component: db-init
|
||||
spec:
|
||||
containers:
|
||||
- name: db-init
|
||||
image: {{ .apps.postgres.image }}
|
||||
command: ["/bin/bash", "-c"]
|
||||
args:
|
||||
- |
|
||||
PGPASSWORD=${POSTGRES_ADMIN_PASSWORD} psql -h ${DB_HOSTNAME} -U postgres <<EOF
|
||||
DO \$\$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT FROM pg_catalog.pg_roles WHERE rolname = '${DB_USERNAME}') THEN
|
||||
CREATE USER ${DB_USERNAME} WITH ENCRYPTED PASSWORD '${DB_PASSWORD}';
|
||||
ELSE
|
||||
ALTER USER ${DB_USERNAME} WITH ENCRYPTED PASSWORD '${DB_PASSWORD}';
|
||||
END IF;
|
||||
END
|
||||
\$\$;
|
||||
|
||||
SELECT 'CREATE DATABASE ${DB_DATABASE_NAME}' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = '${DB_DATABASE_NAME}')\gexec
|
||||
ALTER DATABASE ${DB_DATABASE_NAME} OWNER TO ${DB_USERNAME};
|
||||
GRANT ALL PRIVILEGES ON DATABASE ${DB_DATABASE_NAME} TO ${DB_USERNAME};
|
||||
EOF
|
||||
env:
|
||||
- name: POSTGRES_ADMIN_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-secrets
|
||||
key: apps.postgres.password
|
||||
- name: DB_HOSTNAME
|
||||
value: "{{ .apps.codimd.dbHost }}"
|
||||
- name: DB_DATABASE_NAME
|
||||
value: "{{ .apps.codimd.dbName }}"
|
||||
- name: DB_USERNAME
|
||||
value: "{{ .apps.codimd.dbUser }}"
|
||||
- name: DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: codimd-secrets
|
||||
key: apps.codimd.dbPassword
|
||||
restartPolicy: OnFailure
|
113
apps/codimd/deployment.yaml
Normal file
113
apps/codimd/deployment.yaml
Normal file
@@ -0,0 +1,113 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: codimd
|
||||
namespace: codimd
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: Recreate
|
||||
selector:
|
||||
matchLabels:
|
||||
component: web
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
component: web
|
||||
spec:
|
||||
securityContext:
|
||||
fsGroup: 1500
|
||||
runAsGroup: 1500
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1500
|
||||
containers:
|
||||
- name: codimd
|
||||
image: "{{ .apps.codimd.image }}"
|
||||
imagePullPolicy: IfNotPresent
|
||||
env:
|
||||
- name: CMD_DOMAIN
|
||||
value: "{{ .apps.codimd.domain }}"
|
||||
- name: CMD_URL_ADDPORT
|
||||
value: "false"
|
||||
- name: CMD_PROTOCOL_USESSL
|
||||
value: "{{ .apps.codimd.useSSL }}"
|
||||
- name: CMD_USECDN
|
||||
value: "{{ .apps.codimd.useCDN }}"
|
||||
- name: CMD_DB_URL
|
||||
value: "postgres://{{ .apps.codimd.dbUser }}:$(CMD_DB_PASSWORD)@{{ .apps.codimd.dbHost }}:{{ .apps.codimd.dbPort }}/{{ .apps.codimd.dbName }}"
|
||||
- name: CMD_DB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: codimd-secrets
|
||||
key: apps.codimd.dbPassword
|
||||
- name: CMD_SESSION_SECRET
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: codimd-secrets
|
||||
key: apps.codimd.sessionSecret
|
||||
- name: CMD_SESSION_LIFE
|
||||
value: "{{ .apps.codimd.sessionLifeTime }}"
|
||||
- name: CMD_HSTS_ENABLE
|
||||
value: "{{ .apps.codimd.hstsEnable }}"
|
||||
- name: CMD_HSTS_MAX_AGE
|
||||
value: "{{ .apps.codimd.hstsMaxAge }}"
|
||||
- name: CMD_HSTS_INCLUDE_SUBDOMAINS
|
||||
value: "false"
|
||||
- name: CMD_HSTS_PRELOAD
|
||||
value: "true"
|
||||
- name: CMD_CSP_ENABLE
|
||||
value: "{{ .apps.codimd.cspEnable }}"
|
||||
- name: CMD_ALLOW_GRAVATAR
|
||||
value: "{{ .apps.codimd.allowGravatar }}"
|
||||
- name: CMD_RESPONSE_MAX_LAG
|
||||
value: "70"
|
||||
- name: CMD_IMAGE_UPLOAD_TYPE
|
||||
value: "{{ .apps.codimd.imageUploadType }}"
|
||||
- name: CMD_ALLOW_FREEURL
|
||||
value: "{{ .apps.codimd.allowFreeURL }}"
|
||||
- name: CMD_FORBIDDEN_NOTE_IDS
|
||||
value: "robots.txt,favicon.ico,api"
|
||||
- name: CMD_DEFAULT_PERMISSION
|
||||
value: "{{ .apps.codimd.defaultPermission }}"
|
||||
- name: CMD_ALLOW_ANONYMOUS_EDITS
|
||||
value: "{{ .apps.codimd.allowAnonymousEdits }}"
|
||||
- name: CMD_ALLOW_ANONYMOUS_VIEWS
|
||||
value: "{{ .apps.codimd.allowAnonymousViews }}"
|
||||
- name: CMD_ALLOW_PDF_EXPORT
|
||||
value: "{{ .apps.codimd.allowPdfExport }}"
|
||||
- name: CMD_DEFAULT_USE_HARD_BREAK
|
||||
value: "{{ .apps.codimd.useHardBreak }}"
|
||||
- name: CMD_LINKIFY_HEADER_STYLE
|
||||
value: "{{ .apps.codimd.linkifyHeaderStyle }}"
|
||||
- name: CMD_AUTO_VERSION_CHECK
|
||||
value: "{{ .apps.codimd.autoVersionCheck }}"
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .apps.codimd.port }}
|
||||
volumeMounts:
|
||||
- mountPath: /home/hackmd/app/public/uploads
|
||||
name: uploads
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
port: {{ .apps.codimd.port }}
|
||||
path: /status
|
||||
initialDelaySeconds: 3
|
||||
failureThreshold: 2
|
||||
successThreshold: 3
|
||||
timeoutSeconds: 2
|
||||
periodSeconds: 5
|
||||
livenessProbe:
|
||||
failureThreshold: 3
|
||||
httpGet:
|
||||
path: /status
|
||||
port: {{ .apps.codimd.port }}
|
||||
scheme: HTTP
|
||||
initialDelaySeconds: 3
|
||||
periodSeconds: 5
|
||||
successThreshold: 1
|
||||
timeoutSeconds: 2
|
||||
restartPolicy: Always
|
||||
volumes:
|
||||
- name: uploads
|
||||
persistentVolumeClaim:
|
||||
claimName: codimd-uploads
|
24
apps/codimd/ingress.yaml
Normal file
24
apps/codimd/ingress.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: codimd-public
|
||||
namespace: codimd
|
||||
annotations:
|
||||
external-dns.alpha.kubernetes.io/target: "{{ .apps.codimd.domain }}"
|
||||
external-dns.alpha.kubernetes.io/cloudflare-proxied: "false"
|
||||
spec:
|
||||
rules:
|
||||
- host: "{{ .apps.codimd.domain }}"
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: codimd
|
||||
port:
|
||||
number: 3000
|
||||
tls:
|
||||
- secretName: wildcard-wild-cloud-tls
|
||||
hosts:
|
||||
- "{{ .apps.codimd.domain }}"
|
@@ -1,10 +1,10 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
namespace: homeassistant
|
||||
namespace: codimd
|
||||
labels:
|
||||
- includeSelectors: true
|
||||
pairs:
|
||||
app: homeassistant
|
||||
app: codimd
|
||||
managedBy: kustomize
|
||||
partOf: wild-cloud
|
||||
resources:
|
||||
@@ -13,4 +13,4 @@ resources:
|
||||
- service.yaml
|
||||
- ingress.yaml
|
||||
- pvc.yaml
|
||||
|
||||
- db-init-job.yaml
|
37
apps/codimd/manifest.yaml
Normal file
37
apps/codimd/manifest.yaml
Normal file
@@ -0,0 +1,37 @@
|
||||
name: codimd
|
||||
description: CodiMD is a realtime collaborative markdown notes editor
|
||||
version: 2.5.1
|
||||
icon: https://github.com/hackmdio/codimd/raw/master/public/logo.png
|
||||
requires:
|
||||
- name: postgres
|
||||
defaultConfig:
|
||||
image: nabo.codimd.dev/hackmdio/hackmd:2.5.1
|
||||
domain: codimd.{{ .cloud.domain }}
|
||||
port: 3000
|
||||
storage: 10Gi
|
||||
dbName: codimd
|
||||
dbUser: codimd
|
||||
dbHost: postgres.postgres.svc.cluster.local
|
||||
dbPort: 5432
|
||||
timezone: UTC
|
||||
useSSL: false
|
||||
useCDN: false
|
||||
allowFreeURL: false
|
||||
defaultPermission: editable
|
||||
allowAnonymousEdits: true
|
||||
allowAnonymousViews: true
|
||||
allowPdfExport: false
|
||||
allowGravatar: true
|
||||
imageUploadType: filesystem
|
||||
sessionLifeTime: 1209600000
|
||||
hstsEnable: true
|
||||
hstsMaxAge: 31536000
|
||||
cspEnable: true
|
||||
autoVersionCheck: true
|
||||
useHardBreak: true
|
||||
linkifyHeaderStyle: keep-case
|
||||
tlsSecretName: wildcard-wild-cloud-tls
|
||||
requiredSecrets:
|
||||
- apps.codimd.dbPassword
|
||||
- apps.codimd.sessionSecret
|
||||
- apps.codimd.dbUrl
|
@@ -1,4 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: homeassistant
|
||||
name: codimd
|
@@ -1,11 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: homeassistant-pvc
|
||||
name: codimd-uploads
|
||||
namespace: codimd
|
||||
spec:
|
||||
storageClassName: longhorn
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
storageClassName: longhorn
|
||||
resources:
|
||||
requests:
|
||||
storage: {{ .apps.homeassistant.storage }}
|
||||
storage: "{{ .apps.codimd.storage }}"
|
12
apps/codimd/service.yaml
Normal file
12
apps/codimd/service.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: codimd
|
||||
namespace: codimd
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
component: web
|
||||
ports:
|
||||
- port: 3000
|
||||
targetPort: {{ .apps.codimd.port }}
|
@@ -1,37 +0,0 @@
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
name: homeassistant-config-setup
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
restartPolicy: Never
|
||||
containers:
|
||||
- name: config-setup
|
||||
image: busybox:1.35
|
||||
command: ['sh', '-c']
|
||||
args:
|
||||
- |
|
||||
# Wait for config file to exist
|
||||
while [ ! -f /config/configuration.yaml ]; do
|
||||
sleep 5
|
||||
done
|
||||
|
||||
# Add HTTP config if not present
|
||||
if ! grep -q "use_x_forwarded_for" /config/configuration.yaml; then
|
||||
echo "" >> /config/configuration.yaml
|
||||
echo "# HTTP configuration for reverse proxy support" >> /config/configuration.yaml
|
||||
echo "http:" >> /config/configuration.yaml
|
||||
echo " use_x_forwarded_for: true" >> /config/configuration.yaml
|
||||
echo " trusted_proxies:" >> /config/configuration.yaml
|
||||
echo " - 10.0.0.0/8" >> /config/configuration.yaml
|
||||
echo " - 172.16.0.0/12" >> /config/configuration.yaml
|
||||
echo " - 192.168.0.0/16" >> /config/configuration.yaml
|
||||
fi
|
||||
volumeMounts:
|
||||
- mountPath: /config
|
||||
name: homeassistant-config
|
||||
volumes:
|
||||
- name: homeassistant-config
|
||||
persistentVolumeClaim:
|
||||
claimName: homeassistant-pvc
|
@@ -1,88 +0,0 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: homeassistant
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
component: homeassistant
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
component: homeassistant
|
||||
spec:
|
||||
# hostNetwork: true
|
||||
dnsPolicy: ClusterFirstWithHostNet
|
||||
initContainers:
|
||||
- name: config-setup
|
||||
image: busybox:1.35
|
||||
command: ['sh', '-c']
|
||||
args:
|
||||
- |
|
||||
# Create initial config if it doesn't exist
|
||||
if [ ! -f /config/configuration.yaml ]; then
|
||||
cat > /config/configuration.yaml << 'EOF'
|
||||
# Loads default set of integrations. Do not remove.
|
||||
default_config:
|
||||
|
||||
# Load frontend themes from the themes folder
|
||||
frontend:
|
||||
themes: !include_dir_merge_named themes
|
||||
|
||||
automation: !include automations.yaml
|
||||
script: !include scripts.yaml
|
||||
scene: !include scenes.yaml
|
||||
|
||||
# HTTP configuration for reverse proxy support
|
||||
http:
|
||||
use_x_forwarded_for: true
|
||||
trusted_proxies:
|
||||
- 10.0.0.0/8
|
||||
- 172.16.0.0/12
|
||||
- 192.168.0.0/16
|
||||
EOF
|
||||
fi
|
||||
volumeMounts:
|
||||
- mountPath: /config
|
||||
name: homeassistant-config
|
||||
containers:
|
||||
- name: homeassistant
|
||||
image: "{{ .apps.homeassistant.image }}"
|
||||
ports:
|
||||
- containerPort: 8123
|
||||
protocol: TCP
|
||||
env:
|
||||
- name: TZ
|
||||
value: "{{ .apps.homeassistant.timezone }}"
|
||||
volumeMounts:
|
||||
- mountPath: /config
|
||||
name: homeassistant-config
|
||||
readOnly: false
|
||||
resources:
|
||||
requests:
|
||||
memory: "512Mi"
|
||||
cpu: "250m"
|
||||
limits:
|
||||
memory: "2Gi"
|
||||
cpu: "2"
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8123
|
||||
initialDelaySeconds: 30
|
||||
periodSeconds: 30
|
||||
timeoutSeconds: 10
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8123
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 15
|
||||
timeoutSeconds: 5
|
||||
volumes:
|
||||
- name: homeassistant-config
|
||||
persistentVolumeClaim:
|
||||
claimName: homeassistant-pvc
|
@@ -1,23 +0,0 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: homeassistant-public
|
||||
# annotations:
|
||||
# external-dns.alpha.kubernetes.io/target: "{{ .apps.homeassistant.domain }}"
|
||||
# external-dns.alpha.kubernetes.io/cloudflare-proxied: "false"
|
||||
spec:
|
||||
rules:
|
||||
- host: "{{ .apps.homeassistant.domain }}"
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: homeassistant
|
||||
port:
|
||||
number: 8123
|
||||
tls:
|
||||
- secretName: "{{ .apps.homeassistant.tlsKey }}"
|
||||
hosts:
|
||||
- "{{ .apps.homeassistant.domain }}"
|
@@ -1,13 +0,0 @@
|
||||
name: homeassistant
|
||||
install: true
|
||||
description: Home Assistant is an open source home automation platform that puts local control and privacy first.
|
||||
version: 2025.1.0
|
||||
icon: https://brands.home-assistant.io/homeassistant/logo.png
|
||||
requires: []
|
||||
defaultConfig:
|
||||
image: ghcr.io/home-assistant/home-assistant:stable
|
||||
timezone: UTC
|
||||
storage: 50Gi
|
||||
domain: hass.{{ .cloud.internalDomain }}
|
||||
tlsSecretName: wildcard-internal-wild-cloud-tls
|
||||
requiredSecrets: []
|
@@ -1,12 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: homeassistant
|
||||
spec:
|
||||
ports:
|
||||
- name: http
|
||||
port: 8123
|
||||
targetPort: 8123
|
||||
protocol: TCP
|
||||
selector:
|
||||
component: homeassistant
|
@@ -75,6 +75,8 @@ prompt_if_unset_config "cloud.domain" "Your public cloud domain" "cloud.${base_d
|
||||
domain=$(wild-config "cloud.domain")
|
||||
prompt_if_unset_config "cloud.internalDomain" "Your internal cloud domain" "internal.${domain}"
|
||||
prompt_if_unset_config "cloud.backup.root" "Existing path to save backups to" ""
|
||||
prompt_if_unset_secret "cloud.backupPassword" "Backup password (leave empty to generate a random one)" ""
|
||||
|
||||
|
||||
# Derive cluster name from domain if not already set
|
||||
current_cluster_name=$(wild-config "cluster.name")
|
||||
|
Reference in New Issue
Block a user