From 1a18ef90e4f840b6e71ecd9f8c5983f17c9d0752 Mon Sep 17 00:00:00 2001 From: Swordsteel Date: Wed, 23 Jul 2025 13:03:34 +0200 Subject: [PATCH] k8s hlaeja device configuration --- doc/k8s-testing.md | 49 +++++++++++++++++++ .../03-device-configuration/01-secret.yaml | 12 +++++ .../03-device-configuration/02-configmap.yaml | 13 +++++ .../03-deployment.yaml | 32 ++++++++++++ .../03-device-configuration/04-service.yaml | 20 ++++++++ 5 files changed, 126 insertions(+) create mode 100644 kube/03-hlaeja/03-device-configuration/01-secret.yaml create mode 100644 kube/03-hlaeja/03-device-configuration/02-configmap.yaml create mode 100644 kube/03-hlaeja/03-device-configuration/03-deployment.yaml create mode 100644 kube/03-hlaeja/03-device-configuration/04-service.yaml diff --git a/doc/k8s-testing.md b/doc/k8s-testing.md index 0777fef..e81855b 100644 --- a/doc/k8s-testing.md +++ b/doc/k8s-testing.md @@ -30,6 +30,11 @@ * [Config Map](#config-map-2) * [Deployment](#deployment-1) * [Service](#service-3) + * [Device Configuration](#device-configuration) + * [Secret](#secret-3) + * [Config Map](#config-map-3) + * [Deployment](#deployment-2) + * [Service](#service-4) ---- @@ -223,6 +228,10 @@ kubectl apply -f .\kube\02-databases\02-cassandra\02-service.yaml ## Hlæja +To access service use `kubectl exec -it -n hlaeja -- /bin/sh` + +To tail a service log use `kubectl logs -f -n hlaeja` + ### Account Register This is only a ***concept*** and exist for testing rest of system. this need to be ***rewritten***. @@ -308,3 +317,43 @@ this service should not be accessible from world only open in testing ```bash kubectl apply -f .\kube\03-hlaeja\02-device-registry\04-service.yaml ``` + +--- + +### Device Configuration + +#### Secret + +```bash +kubectl apply -f .\kube\03-hlaeja\03-device-configuration\01-secret.yaml +``` + +Set values: + +- cassandra password (db have not turned this on yet) + +#### Config Map + +```bash +kubectl apply -f .\kube\03-hlaeja\03-device-configuration\02-configmap.yaml +``` + +Set values: + +- spring profile +- cassandra username (db have not turned this on yet) +- cassandra contact points + +#### Deployment + +```bash +kubectl apply -f .\kube\03-hlaeja\03-device-configuration\03-deployment.yaml +``` + +#### Service + +this service should not be accessible from world only open in testing + +```bash +kubectl apply -f .\kube\03-hlaeja\03-device-configuration\04-service.yaml +``` diff --git a/kube/03-hlaeja/03-device-configuration/01-secret.yaml b/kube/03-hlaeja/03-device-configuration/01-secret.yaml new file mode 100644 index 0000000..2350374 --- /dev/null +++ b/kube/03-hlaeja/03-device-configuration/01-secret.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Secret +metadata: + name: device-configuration + namespace: hlaeja + labels: + app: device-configuration + environment: testing + tier: backend +type: Opaque +stringData: + SPRING_CASSANDRA_PASSWORD: "password" diff --git a/kube/03-hlaeja/03-device-configuration/02-configmap.yaml b/kube/03-hlaeja/03-device-configuration/02-configmap.yaml new file mode 100644 index 0000000..94bd766 --- /dev/null +++ b/kube/03-hlaeja/03-device-configuration/02-configmap.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: device-configuration + namespace: hlaeja + labels: + app: device-configuration + environment: testing + tier: backend +data: + SPRING_PROFILES_ACTIVE: "testing" + SPRING_CASSANDRA_USERNAME: "cassandra" + SPRING_CASSANDRA_CONTACT_POINTS: "cassandra" diff --git a/kube/03-hlaeja/03-device-configuration/03-deployment.yaml b/kube/03-hlaeja/03-device-configuration/03-deployment.yaml new file mode 100644 index 0000000..31c3ebc --- /dev/null +++ b/kube/03-hlaeja/03-device-configuration/03-deployment.yaml @@ -0,0 +1,32 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: device-configuration + namespace: hlaeja + labels: + app: device-configuration + environment: testing + tier: backend +spec: + replicas: 1 + selector: + matchLabels: + app: device-configuration + template: + metadata: + labels: + app: device-configuration + spec: + imagePullSecrets: + - name: github + containers: + - name: device-configuration-app + image: ghcr.io/swordsteel/hlaeja-device-configuration:0.1.0 + imagePullPolicy: IfNotPresent + envFrom: + - configMapRef: + name: device-configuration + - secretRef: + name: device-configuration + ports: + - containerPort: 8080 diff --git a/kube/03-hlaeja/03-device-configuration/04-service.yaml b/kube/03-hlaeja/03-device-configuration/04-service.yaml new file mode 100644 index 0000000..9c6af03 --- /dev/null +++ b/kube/03-hlaeja/03-device-configuration/04-service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: device-configuration + namespace: hlaeja + annotations: + metallb.universe.tf/address-pool: default + labels: + app: device-configuration + environment: testing + tier: backend +spec: + type: LoadBalancer + loadBalancerIP: 10.0.3.113 + selector: + app: device-configuration + ports: + - protocol: TCP + port: 80 + targetPort: 8080