From 66750faf921205b4ccb54969cf89a6f8db9ba031 Mon Sep 17 00:00:00 2001 From: HeNine <> Date: Tue, 8 Feb 2022 14:34:42 +0100 Subject: [PATCH] Rewrite to jsonnet because reasons --- base/kustomization.yaml | 16 ---- base/postgres.yaml | 57 ------------ base/rabbitmq.yaml | 53 ------------ deployments/picc/picc.jsonnet | 4 + deployments/picc/picc_app.jsonnet | 71 +++++++++++++++ deployments/picc/picc_config.jsonnet | 12 +++ {base => deployments/postgres}/piccdb.sql | 86 +++++++++---------- deployments/postgres/postgres.jsonnet | 12 +++ deployments/postgres/postgres_app.jsonnet | 80 +++++++++++++++++ deployments/postgres/postgres_dbinit.jsonnet | 10 +++ .../postgres/postgres_password.jsonnet | 11 +++ .../rabbitmq}/etc/rabbitmq/enabled_plugins | 0 .../rabbitmq}/etc/rabbitmq/rabbitmq.conf | 40 ++++----- .../rabbitmq}/etc/rabbitmq/rmq_schema.json | 78 ++++++++--------- deployments/rabbitmq/rabbitmq.jsonnet | 11 +++ deployments/rabbitmq/rabbitmq_app.jsonnet | 60 +++++++++++++ deployments/rabbitmq/rabbitmq_config.jsonnet | 12 +++ lib/picc-k8s.libsonnet | 35 ++++++++ overlay/development/kustomization.yaml | 29 ------- overlay/development/namespace.yaml | 6 -- overlay/production/namespace.yaml | 6 -- profiles/development.jsonnet | 13 +++ profiles/production.jsonnet | 18 ++++ 23 files changed, 451 insertions(+), 269 deletions(-) delete mode 100644 base/kustomization.yaml delete mode 100644 base/postgres.yaml delete mode 100644 base/rabbitmq.yaml create mode 100644 deployments/picc/picc.jsonnet create mode 100644 deployments/picc/picc_app.jsonnet create mode 100644 deployments/picc/picc_config.jsonnet rename {base => deployments/postgres}/piccdb.sql (97%) create mode 100644 deployments/postgres/postgres.jsonnet create mode 100644 deployments/postgres/postgres_app.jsonnet create mode 100644 deployments/postgres/postgres_dbinit.jsonnet create mode 100644 deployments/postgres/postgres_password.jsonnet rename {base => deployments/rabbitmq}/etc/rabbitmq/enabled_plugins (100%) rename {base => deployments/rabbitmq}/etc/rabbitmq/rabbitmq.conf (88%) rename {base => deployments/rabbitmq}/etc/rabbitmq/rmq_schema.json (94%) create mode 100644 deployments/rabbitmq/rabbitmq.jsonnet create mode 100644 deployments/rabbitmq/rabbitmq_app.jsonnet create mode 100644 deployments/rabbitmq/rabbitmq_config.jsonnet create mode 100644 lib/picc-k8s.libsonnet delete mode 100644 overlay/development/kustomization.yaml delete mode 100644 overlay/development/namespace.yaml delete mode 100644 overlay/production/namespace.yaml create mode 100644 profiles/development.jsonnet create mode 100644 profiles/production.jsonnet diff --git a/base/kustomization.yaml b/base/kustomization.yaml deleted file mode 100644 index d05822b..0000000 --- a/base/kustomization.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -resources: - - postgres.yaml - - rabbitmq.yaml - -configMapGenerator: - - name: rabbitmq-config - files: - - enabled_plugins=etc/rabbitmq/enabled_plugins - - rabbitmq.conf=etc/rabbitmq/rabbitmq.conf - - rmq_schema.json=etc/rabbitmq/rmq_schema.json - - name: postgres-dbinit - files: - - piccdb.sql \ No newline at end of file diff --git a/base/postgres.yaml b/base/postgres.yaml deleted file mode 100644 index 41ec7e0..0000000 --- a/base/postgres.yaml +++ /dev/null @@ -1,57 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: postgres -spec: - type: LoadBalancer - selector: - app: postgres - ports: - - protocol: TCP - port: 5432 ---- -apiVersion: apps/v1 -kind: StatefulSet -metadata: - name: postgres -spec: - selector: - matchLabels: - app: postgres - serviceName: "postgres" - template: - metadata: - labels: - app: postgres - spec: - containers: - - name: postgres - image: docker.io/postgres:13 - ports: - - containerPort: 5432 - name: db - env: - - name: POSTGRES_DB - value: picc - - name: POSTGRES_PASSWORD - valueFrom: - secretKeyRef: - name: postgres-password - key: password - volumeMounts: - - name: postgres-data - mountPath: /var/lib/postgresql/data - - name: dbinit - mountPath: /docker-entrypoint-initdb.d - volumes: - - name: dbinit - configMap: - name: postgres-dbinit - volumeClaimTemplates: - - metadata: - name: postgres-data - spec: - accessModes: [ "ReadWriteOnce" ] - resources: - requests: - storage: 100Mi \ No newline at end of file diff --git a/base/rabbitmq.yaml b/base/rabbitmq.yaml deleted file mode 100644 index 0101e2f..0000000 --- a/base/rabbitmq.yaml +++ /dev/null @@ -1,53 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: rabbitmq -spec: - type: LoadBalancer - selector: - app: rabbitmq - ports: - - name: amqp - port: 5672 - - name: web - port: 15672 - - name: mqtt - port: 1883 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: rabbitmq - labels: - app: rabbitmq -spec: - replicas: 1 - selector: - matchLabels: - app: rabbitmq - template: - metadata: - labels: - app: rabbitmq - spec: - containers: - - name: rabbitmq - image: docker.io/rabbitmq:3 - ports: - - containerPort: 5672 - - containerPort: 15672 - - containerPort: 1883 - volumeMounts: - - mountPath: "/etc/rabbitmq" - name: config - volumes: - - name: config - configMap: - name: rabbitmq-config - items: - - key: "enabled_plugins" - path: "enabled_plugins" - - key: "rabbitmq.conf" - path: "rabbitmq.conf" - - key: "rmq_schema.json" - path: "rmq_schema.json" diff --git a/deployments/picc/picc.jsonnet b/deployments/picc/picc.jsonnet new file mode 100644 index 0000000..1cdb020 --- /dev/null +++ b/deployments/picc/picc.jsonnet @@ -0,0 +1,4 @@ +function(namespace){ + picc_app: import "picc_app.jsonnet", + picc_config: (import "picc_config.jsonnet")(namespace), +} \ No newline at end of file diff --git a/deployments/picc/picc_app.jsonnet b/deployments/picc/picc_app.jsonnet new file mode 100644 index 0000000..a853e22 --- /dev/null +++ b/deployments/picc/picc_app.jsonnet @@ -0,0 +1,71 @@ +{ + apiVersion: "apps/v1", + kind: "Deployment", + metadata: { + name: "picc", + labels: { + app: "picc" + } + }, + spec: { + replicas: 1, + selector: { + matchLabels: { + app: "picc" + } + }, + template: { + metadata: { + labels: { + app: "picc" + } + }, + spec: { + containers: [ + { + name: "picc", + image: "docker.raptorpond.com/picc", + env: [ + { + name: "RABBITMQ_HOST", + valueFrom: { + configMapKeyRef: { + name: "picc-config", + key: "rabbitmq_host" + } + } + }, + { + name: "RABBITMQ_PORT", + valueFrom: { + configMapKeyRef: { + name: "picc-config", + key: "rabbitmq_port" + } + } + }, + { + name: "POSTGRES_HOST", + valueFrom: { + configMapKeyRef: { + name: "picc-config", + key: "postgres_host" + } + } + }, + { + name: "POSTGRES_PASSWORD", + valueFrom: { + secretKeyRef: { + name: "postgres-password", + key: "password" + } + } + } + ] + } + ] + } + } + } +} \ No newline at end of file diff --git a/deployments/picc/picc_config.jsonnet b/deployments/picc/picc_config.jsonnet new file mode 100644 index 0000000..f2eb53e --- /dev/null +++ b/deployments/picc/picc_config.jsonnet @@ -0,0 +1,12 @@ +function(namespace){ + kind: "ConfigMap", + apiVersion: "v1", + metadata: { + name: "picc-config" + }, + data: { + rabbitmq_host: "rabbitmq.%s" % [namespace], + rabbitmq_port: "5672", + postgres_host: "postgres.%s" % [namespace] + } +} \ No newline at end of file diff --git a/base/piccdb.sql b/deployments/postgres/piccdb.sql similarity index 97% rename from base/piccdb.sql rename to deployments/postgres/piccdb.sql index af43743..21126a9 100644 --- a/base/piccdb.sql +++ b/deployments/postgres/piccdb.sql @@ -1,44 +1,44 @@ -BEGIN; - -DROP TABLE IF EXISTS picc_events; -DROP TABLE IF EXISTS picc_locations; - -CREATE TABLE picc_locations -( - id SERIAL PRIMARY KEY, - location_name TEXT NOT NULL - -- TODO: figure out PostGIS -); - -INSERT INTO picc_locations (id, location_name) -VALUES (0, 'Unknown'); -INSERT INTO picc_locations (id, location_name) -VALUES (1, 'Not Applicable'); - -DROP TABLE IF EXISTS picc_events; - -CREATE TABLE picc_events -( - id BIGSERIAL PRIMARY KEY, -- ID - log_time TIMESTAMP with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Time when event was logged - event_time TIMESTAMP with time zone, -- Optional: time when event was generated, can be different than log_time - event_location integer NOT NULL references picc_locations DEFAULT 0, -- Location associated with event --- sender text NOT NULL, -- Sender is implicit in whoever owns the endpoint - endpoint text - CONSTRAINT valid_endpoint CHECK ( endpoint ~ '^([A-Za-z0-9_-]+\.)*([A-Za-z0-9_-]+)$' ), -- Event endpoint - body jsonb NOT NULL -- Event body content -); - -CREATE INDEX idx_picc_events_endpoint ON picc_events (endpoint); - --- DROP TABLE IF EXISTS mqtt; --- --- CREATE TABLE picc_mqtt --- ( --- id BIGSERIAL PRIMARY KEY, --- receive_time TIMESTAMP, --- routing_key TEXT, --- payload TEXT --- ); - +BEGIN; + +DROP TABLE IF EXISTS picc_events; +DROP TABLE IF EXISTS picc_locations; + +CREATE TABLE picc_locations +( + id SERIAL PRIMARY KEY, + location_name TEXT NOT NULL + -- TODO: figure out PostGIS +); + +INSERT INTO picc_locations (id, location_name) +VALUES (0, 'Unknown'); +INSERT INTO picc_locations (id, location_name) +VALUES (1, 'Not Applicable'); + +DROP TABLE IF EXISTS picc_events; + +CREATE TABLE picc_events +( + id BIGSERIAL PRIMARY KEY, -- ID + log_time TIMESTAMP with time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, -- Time when event was logged + event_time TIMESTAMP with time zone, -- Optional: time when event was generated, can be different than log_time + event_location integer NOT NULL references picc_locations DEFAULT 0, -- Location associated with event +-- sender text NOT NULL, -- Sender is implicit in whoever owns the endpoint + endpoint text + CONSTRAINT valid_endpoint CHECK ( endpoint ~ '^([A-Za-z0-9_-]+\.)*([A-Za-z0-9_-]+)$' ), -- Event endpoint + body jsonb NOT NULL -- Event body content +); + +CREATE INDEX idx_picc_events_endpoint ON picc_events (endpoint); + +-- DROP TABLE IF EXISTS mqtt; +-- +-- CREATE TABLE picc_mqtt +-- ( +-- id BIGSERIAL PRIMARY KEY, +-- receive_time TIMESTAMP, +-- routing_key TEXT, +-- payload TEXT +-- ); + COMMIT; \ No newline at end of file diff --git a/deployments/postgres/postgres.jsonnet b/deployments/postgres/postgres.jsonnet new file mode 100644 index 0000000..b9b8fc7 --- /dev/null +++ b/deployments/postgres/postgres.jsonnet @@ -0,0 +1,12 @@ +local utils = import "../../lib/picc-k8s.libsonnet"; + +function(password=null, ip=null){ + postgres_app: import "postgres_app.jsonnet", + postgres_service: utils.service(name="postgres", ports=[{name: "postgres", protocol: "TCP", port:5432}], ip=ip), + postgres_password: + if password != null then + (import "postgres_password.jsonnet")(password) + else + (import "postgres_password.jsonnet")(), + postgres_dbinit: import "postgres_dbinit.jsonnet" +} \ No newline at end of file diff --git a/deployments/postgres/postgres_app.jsonnet b/deployments/postgres/postgres_app.jsonnet new file mode 100644 index 0000000..7126252 --- /dev/null +++ b/deployments/postgres/postgres_app.jsonnet @@ -0,0 +1,80 @@ +{ + apiVersion: "apps/v1", + kind: "StatefulSet", + metadata: { + name: "postgres" + }, + spec: { + selector: { + matchLabels: { + app: "postgres" + } + }, + serviceName: "postgres", + template: { + metadata:{ + labels: { + app: "postgres" + } + }, + spec: { + containers: [ + { + name: "postgres", + image: "docker.io/postgres:13", + ports: [ + {containerPort: 5432, + name: "db"} + ], + env: [ + { + name: "POSTGRES_DB", + value: "picc" + }, + { + name: "POSTGRES_PASSWORD", + valueFrom: { + secretKeyRef: { + name: "postgres-password", + key: "password" + } + } + } + ], + volumeMounts: [ + { + name: "postgres-data", + mountPath: "/var/lib/postgresql/data" + }, + { + name: "dbinit", + mountPath: "/docker-entrypoint-initdb.d" + } + ] + } + ], + volumes: [ + { + name: "dbinit", + configMap: { + name: "postgres-dbinit" + } + } + ] + } + }, + volumeClaimTemplates : [{ + metadata: { + name: "postgres-data" + }, + spec: { + accessModes: ["ReadWriteOnce"], + resources: { + requests: { + storage: "100Mi" + } + } + } + }] + } +} \ No newline at end of file diff --git a/deployments/postgres/postgres_dbinit.jsonnet b/deployments/postgres/postgres_dbinit.jsonnet new file mode 100644 index 0000000..5ebb556 --- /dev/null +++ b/deployments/postgres/postgres_dbinit.jsonnet @@ -0,0 +1,10 @@ +{ + kind: "ConfigMap", + apiVersion: "v1", + metadata: { + name: "postgres-dbinit" + }, + data: { + "piccdb.sql": importstr "piccdb.sql" + } +} \ No newline at end of file diff --git a/deployments/postgres/postgres_password.jsonnet b/deployments/postgres/postgres_password.jsonnet new file mode 100644 index 0000000..27f67de --- /dev/null +++ b/deployments/postgres/postgres_password.jsonnet @@ -0,0 +1,11 @@ +function(password = "piccpass") { + kind: "Secret", + apiVersion: "v1", + metadata: { + name: "postgres-password" + }, + data: { + "password": std.base64(password) + }, + type: "Opaque" +} \ No newline at end of file diff --git a/base/etc/rabbitmq/enabled_plugins b/deployments/rabbitmq/etc/rabbitmq/enabled_plugins similarity index 100% rename from base/etc/rabbitmq/enabled_plugins rename to deployments/rabbitmq/etc/rabbitmq/enabled_plugins diff --git a/base/etc/rabbitmq/rabbitmq.conf b/deployments/rabbitmq/etc/rabbitmq/rabbitmq.conf similarity index 88% rename from base/etc/rabbitmq/rabbitmq.conf rename to deployments/rabbitmq/etc/rabbitmq/rabbitmq.conf index 58ad217..c96b303 100644 --- a/base/etc/rabbitmq/rabbitmq.conf +++ b/deployments/rabbitmq/etc/rabbitmq/rabbitmq.conf @@ -1,21 +1,21 @@ -loopback_users.guest = false -listeners.tcp.default = 5672 -management.tcp.port = 15672 - -#mqtt.listeners.tcp.default = 1883 -## Default MQTT with TLS port is 8883 -# mqtt.listeners.ssl.default = 8883 - -# anonymous connections, if allowed, will use the default -# credentials specified here -#mqtt.allow_anonymous = true -#mqtt.default_user = guest -#mqtt.default_pass = guest - -#mqtt.vhost = / -mqtt.exchange = mqtt -# 24 hours by default -#mqtt.subscription_ttl = 86400000 -#mqtt.prefetch = 10 - +loopback_users.guest = false +listeners.tcp.default = 5672 +management.tcp.port = 15672 + +#mqtt.listeners.tcp.default = 1883 +## Default MQTT with TLS port is 8883 +# mqtt.listeners.ssl.default = 8883 + +# anonymous connections, if allowed, will use the default +# credentials specified here +#mqtt.allow_anonymous = true +#mqtt.default_user = guest +#mqtt.default_pass = guest + +#mqtt.vhost = / +mqtt.exchange = mqtt +# 24 hours by default +#mqtt.subscription_ttl = 86400000 +#mqtt.prefetch = 10 + load_definitions = /etc/rabbitmq/rmq_schema.json \ No newline at end of file diff --git a/base/etc/rabbitmq/rmq_schema.json b/deployments/rabbitmq/etc/rabbitmq/rmq_schema.json similarity index 94% rename from base/etc/rabbitmq/rmq_schema.json rename to deployments/rabbitmq/etc/rabbitmq/rmq_schema.json index 0c46e83..6662066 100644 --- a/base/etc/rabbitmq/rmq_schema.json +++ b/deployments/rabbitmq/etc/rabbitmq/rmq_schema.json @@ -1,40 +1,40 @@ -{ - "rabbit_version": "3.8.9", - "rabbitmq_version": "3.8.9", - "product_name": "RabbitMQ", - "product_version": "3.8.9", - "users": [ - { - "name": "guest", - "password_hash": "KzhdT8G04Hon/5BEAasW4KF9NVBpwo3MIKGBs0nJjz8KLBvq", - "hashing_algorithm": "rabbit_password_hashing_sha256", - "tags": "administrator" - } - ], - "vhosts": [ - { - "name": "/" - } - ], - "permissions": [ - { - "user": "guest", - "vhost": "/", - "configure": ".*", - "write": ".*", - "read": ".*" - } - ], - "policies": [], - "exchanges": [ - { - "name": "mqtt", - "vhost": "/", - "type": "topic", - "durable": true, - "auto_delete": false, - "internal": false, - "arguments": {} - } - ] +{ + "rabbit_version": "3.8.9", + "rabbitmq_version": "3.8.9", + "product_name": "RabbitMQ", + "product_version": "3.8.9", + "users": [ + { + "name": "guest", + "password_hash": "KzhdT8G04Hon/5BEAasW4KF9NVBpwo3MIKGBs0nJjz8KLBvq", + "hashing_algorithm": "rabbit_password_hashing_sha256", + "tags": "administrator" + } + ], + "vhosts": [ + { + "name": "/" + } + ], + "permissions": [ + { + "user": "guest", + "vhost": "/", + "configure": ".*", + "write": ".*", + "read": ".*" + } + ], + "policies": [], + "exchanges": [ + { + "name": "mqtt", + "vhost": "/", + "type": "topic", + "durable": true, + "auto_delete": false, + "internal": false, + "arguments": {} + } + ] } \ No newline at end of file diff --git a/deployments/rabbitmq/rabbitmq.jsonnet b/deployments/rabbitmq/rabbitmq.jsonnet new file mode 100644 index 0000000..c8ed8c6 --- /dev/null +++ b/deployments/rabbitmq/rabbitmq.jsonnet @@ -0,0 +1,11 @@ +local utils = import "../../lib/picc-k8s.libsonnet"; + +function(ip=null){ + rabbitmq_app: import "rabbitmq_app.jsonnet", + rabbitmq_service: utils.service(name="rabbitmq", + ports=[{name: "amqp", port: 5672}, + {name: "web", port: 15672}, + {name: "mqtt", port: 1883}], + ip=ip), + rabbitmq_conf: import "rabbitmq_config.jsonnet" +} \ No newline at end of file diff --git a/deployments/rabbitmq/rabbitmq_app.jsonnet b/deployments/rabbitmq/rabbitmq_app.jsonnet new file mode 100644 index 0000000..8d599bd --- /dev/null +++ b/deployments/rabbitmq/rabbitmq_app.jsonnet @@ -0,0 +1,60 @@ +{ + apiVersion: "apps/v1", + kind: "Deployment", + metadata: { + name: "rabbitmq", + labels: { + app: "rabbitmq" + } + }, + spec: { + replicas: 1, + selector: { + matchLabels: { + app: "rabbitmq" + } + }, + template: { + metadata: { + labels: { + app: "rabbitmq" + } + }, + spec: { + containers: [ + { + name: "rabbitmq", + image: "docker.io/rabbitmq:3", + ports: [ + {containerPort: 5672}, + {containerPort: 15672}, + {containerPort: 1883} + ], + volumeMounts: [ + { + mountPath: "/etc/rabbitmq", + name: "config" + } + ] + } + ], + volumes: [ + { + name: "config", + configMap: { + name: "rabbitmq-config", + items: [ + {key: "enabled_plugins", + path: "enabled_plugins"}, + {key: "rabbitmq.conf", + path: "rabbitmq.conf"}, + {key: "rmq_schema.json", + path: "rmq_schema.json"} + ] + } + } + ] + } + } + } +} \ No newline at end of file diff --git a/deployments/rabbitmq/rabbitmq_config.jsonnet b/deployments/rabbitmq/rabbitmq_config.jsonnet new file mode 100644 index 0000000..7ded969 --- /dev/null +++ b/deployments/rabbitmq/rabbitmq_config.jsonnet @@ -0,0 +1,12 @@ +{ + kind: "ConfigMap", + apiVersion: "v1", + metadata: { + name: "rabbitmq-config" + }, + data: { + "enabled_plugins": importstr "etc/rabbitmq/enabled_plugins", + "rabbitmq.conf": importstr "etc/rabbitmq/rabbitmq.conf", + "rmq_schema.json": importstr "etc/rabbitmq/rmq_schema.json" + } +} \ No newline at end of file diff --git a/lib/picc-k8s.libsonnet b/lib/picc-k8s.libsonnet new file mode 100644 index 0000000..2f8c7a5 --- /dev/null +++ b/lib/picc-k8s.libsonnet @@ -0,0 +1,35 @@ +{ + addNamespace(manifest, namespace):: + manifest + + { + metadata+: { + namespace: namespace + } + }, + + createNamespace(namespace):: + { + apiVersion: "v1", + kind: "Namespace", + metadata: { + name: namespace + } + }, + + service(name, ports, ip=null):: + { + apiVersion: "v1", + kind: "Service", + metadata: { + name: name + }, + spec: { + type: "LoadBalancer", + selector: { + app: name + }, + ports: ports, + [if ip != null then "loadBalancerIP"]: ip + } + } +} \ No newline at end of file diff --git a/overlay/development/kustomization.yaml b/overlay/development/kustomization.yaml deleted file mode 100644 index f6184c3..0000000 --- a/overlay/development/kustomization.yaml +++ /dev/null @@ -1,29 +0,0 @@ -apiVersion: kustomize.config.k8s.io/v1beta1 -kind: Kustomization - -namespace: picc-dev - -resources: - - namespace.yaml - - ../../base - -secretGenerator: - - name: postgres-password - literals: - - password=piccpass - -patches: - - patch: |- - - op: add - path: /spec/loadBalancerIP - value: 192.168.2.201 - target: - kind: Service - name: postgres - - patch: |- - - op: add - path: /spec/loadBalancerIP - value: 192.168.2.200 - target: - kind: Service - name: rabbitmq \ No newline at end of file diff --git a/overlay/development/namespace.yaml b/overlay/development/namespace.yaml deleted file mode 100644 index da37c65..0000000 --- a/overlay/development/namespace.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Namespace -apiVersion: v1 -metadata: - name: picc-dev - labels: - name: picc-dev \ No newline at end of file diff --git a/overlay/production/namespace.yaml b/overlay/production/namespace.yaml deleted file mode 100644 index 169f08f..0000000 --- a/overlay/production/namespace.yaml +++ /dev/null @@ -1,6 +0,0 @@ -kind: Namespace -apiVersion: v1 -metadata: - name: picc-prod - labels: - name: picc-prod diff --git a/profiles/development.jsonnet b/profiles/development.jsonnet new file mode 100644 index 0000000..2b8f30a --- /dev/null +++ b/profiles/development.jsonnet @@ -0,0 +1,13 @@ +local namespace="picc-dev"; + +local utils = import "../lib/picc-k8s.libsonnet"; + +local postgres = import "../deployments/postgres/postgres.jsonnet"; +local postgres_manifests = postgres(ip="192.168.2.201"); + +local rabbitmq = import "../deployments/rabbitmq/rabbitmq.jsonnet"; +local rabbitmq_manifests = rabbitmq(ip="192.168.2.200"); + +[utils.createNamespace(namespace),] + +[utils.addNamespace(postgres_manifests[manifest], namespace) for manifest in std.objectFields(postgres_manifests)] + +[utils.addNamespace(rabbitmq_manifests[manifest], namespace) for manifest in std.objectFields(rabbitmq_manifests)] diff --git a/profiles/production.jsonnet b/profiles/production.jsonnet new file mode 100644 index 0000000..7c8e736 --- /dev/null +++ b/profiles/production.jsonnet @@ -0,0 +1,18 @@ +local namespace="picc-prod"; + +local utils = import "../lib/picc-k8s.libsonnet"; + +local postgres = import "../deployments/postgres/postgres.jsonnet"; +local rabbitmq = import "../deployments/rabbitmq/rabbitmq.jsonnet"; +local picc = import "../deployments/picc/picc.jsonnet"; + +function(postgres_password) + +local postgres_manifests = postgres(password=postgres_password); +local rabbitmq_manifests = rabbitmq(); +local picc_manifests = picc(namespace); + +[utils.createNamespace(namespace),] + +[utils.addNamespace(postgres_manifests[manifest], namespace) for manifest in std.objectFields(postgres_manifests)] + +[utils.addNamespace(rabbitmq_manifests[manifest], namespace) for manifest in std.objectFields(rabbitmq_manifests)] + +[utils.addNamespace(picc_manifests[manifest], namespace) for manifest in std.objectFields(picc_manifests)]