diff --git a/k8s/main.ts b/k8s/main.ts index fcaab6a3f..e16443043 100644 --- a/k8s/main.ts +++ b/k8s/main.ts @@ -1,6 +1,8 @@ import { Construct } from 'constructs'; import { App } from 'cdk8s'; import { CronJob, DjangoApplication, PennLabsChart, ReactApplication, RedisApplication } from '@pennlabs/kittyhawk'; +import { KubeConfigMap } from '@pennlabs/kittyhawk/lib/imports/k8s'; +import dedent from "ts-dedent"; const cronTime = require('cron-time-generator'); @@ -16,6 +18,20 @@ export class MyChart extends PennLabsChart { const clubsSecret = 'penn-clubs'; const clubsDomain = 'pennclubs.com'; + /** Redis ConfigMap */ + new KubeConfigMap(this, 'redis-config', { + data: { + 'redis.conf': dedent` + apiVersion: v1 + kind: ConfigMap + metadata: + name: redis-config + data: + redis-config: "" + `, + } + }); + /** Ingress HTTPS Enforcer */ const ingressProps = { annotations: { @@ -26,13 +42,23 @@ export class MyChart extends PennLabsChart { new RedisApplication(this, 'redis', { deployment: { + cmd: ['redis-server', '/redis-master/redis.conf'], secretMounts: [ { - name: 'redis-data', - mountPath: '/data', + name: 'config', + mountPath: '/redis-master', }, + { + name: 'data', + mountPath: 'redis-master-data', + } ], - } + env: [{ + name: "MASTER", + value: "true", + }], + }, + }); new DjangoApplication(this, 'django-wsgi', { diff --git a/k8s/package.json b/k8s/package.json index 5c3b26544..da08504c4 100644 --- a/k8s/package.json +++ b/k8s/package.json @@ -18,7 +18,8 @@ "dependencies": { "@pennlabs/kittyhawk": "^1.1.8", "cdk8s": "^2.2.63", - "constructs": "^10.0.119" + "constructs": "^10.0.119", + "ts-dedent": "^2.2.0" }, "devDependencies": { "@types/jest": "^26.0.24", @@ -27,4 +28,4 @@ "ts-jest": "^26.5.6", "typescript": "^4.6.3" } -} \ No newline at end of file +} diff --git a/k8s/yarn.lock b/k8s/yarn.lock index c9b52d3e9..dc254f0e4 100644 --- a/k8s/yarn.lock +++ b/k8s/yarn.lock @@ -4463,6 +4463,11 @@ triple-beam@^1.3.0: resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.4.1.tgz#6fde70271dc6e5d73ca0c3b24e2d92afb7441984" integrity sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg== +ts-dedent@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/ts-dedent/-/ts-dedent-2.2.0.tgz#39e4bd297cd036292ae2394eb3412be63f563bb5" + integrity sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ== + ts-jest@^26.5.6: version "26.5.6" resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.5.6.tgz#c32e0746425274e1dfe333f43cd3c800e014ec35"