messing with kustomize and emqx

This commit is contained in:
Joseph Hanson 2024-09-22 21:10:53 -05:00
parent 2a8c569ce9
commit a1edec07ed
Signed by: jahanson
SSH key fingerprint: SHA256:vy6dKBECV522aPAwklFM3ReKAVB086rT3oWwiuiFG7o
4 changed files with 78 additions and 20 deletions

View file

@ -35,7 +35,34 @@ spec:
engineVersion: v2
data:
init-user.json: |
[{"user_id": "{{ .X_EMQX_MQTT_USERNAME }}", "password": "{{ .X_EMQX_MQTT_PASSWORD }}", "is_superuser": true}]
[
{
"user_id": "{{ .X_EMQX_MQTT_USERNAME }}",
"password": "{{ .X_EMQX_MQTT_PASSWORD }}",
"is_superuser": true
},
{
username = "tasmota"
password = "{{ .X_EMQX_TASMOTA_PASSWORD }}"
},
{
username = "homeassistant"
password = "{{ .X_EMQX_HOMEASSISTANT_PASSWORD }}"
}
]
dataFrom:
- extract:
key: emqx
- extract:
key: "emqx - [tasmota]"
rewrite:
- regexp:
source: "(.*)"
target: "X_EMQX_TASMOTA_$1"
- extract:
key: "emqx - [homeassistant]"
rewrite:
- regexp:
source: "(.*)"
target: "X_EMQX_HOMEASSISTANT_$1"

View file

@ -7,26 +7,9 @@ metadata:
spec:
image: public.ecr.aws/emqx/emqx:5.8.0
config:
mode: Merge
data: |
authentication {
backend = "built_in_database"
mechanism = "password_based"
password_hash_algorithm {
name = "bcrypt",
}
user_id_type = "username"
bootstrap_file = "/opt/init-user.json"
bootstrap_type = "plain"
}
authorization {
sources = [
{
type = built_in_database
enable = true
}
]
no_match: "deny"
}
$(emqx-conf)
coreTemplate:
metadata:
annotations:

View file

@ -6,3 +6,24 @@ resources:
- ./cluster.yaml
- ./ingress.yaml
- ./podmonitor.yaml
patchesStrategicMerge:
- cluster.yaml
configMapGenerator:
- name: emqx-conf
files:
- resources/emqx.conf
replacements:
- source:
kind: ConfigMap
name: emqx-conf
fieldPath: data.emqx.conf
targets:
- select:
kind: EMQX
name: emqx
fieldPaths:
- spec.config.data
options:
delimiter: |
generatorOptions:
disableNameSuffixHash: true

View file

@ -0,0 +1,27 @@
authentication {
backend = "built_in_database"
mechanism = "password_based"
password_hash_algorithm {
name = "bcrypt",
}
user_id_type = "username"
bootstrap_file = "/opt/init-user.json"
bootstrap_type = "plain"
}
authorization {
sources = [
{
type = built_in_database
enable = true
}
]
no_match: "deny"
}
authorization.sources.built_in_database.rules = [
{allow, {user, "jahanson"}, all, ["#"]},
{allow, {user, "tasmota"}, publish, ["tasmota/discovery/#", "tele/tasmota_+/+", "cmnd/tasmota_+/+"]},
{allow, {user, "homeassistant"}, subscribe, ["stat/tasmota_+/+", "tele/tasmota_+/+"]},
{deny, all}
]