Skip to content

Commit

Permalink
Fix Redis Persistence (for real) (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
esinx authored Feb 5, 2024
1 parent 281d2f6 commit bd91989
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 47 deletions.
2 changes: 1 addition & 1 deletion cdk/kittyhawk/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 11 additions & 15 deletions cdk/kittyhawk/src/application/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { Construct } from "constructs";
import { DeploymentProps } from "../deployment";
import {
KubeConfigMap,
KubePersistentVolume,
KubePersistentVolumeClaim,
KubeStorageClass,
Quantity,
} from "../imports/k8s";
import { Application } from "./base";
Expand Down Expand Up @@ -52,7 +52,6 @@ export class RedisApplication extends Application {

// Persistence constants
const storageClassName = `${releaseName}-${appname}-storage`;
const pvName = `${releaseName}-${appname}-pv`;
const pvcName = `${releaseName}-${appname}-pvc`;

if (redisProps.redisConfigMap) {
Expand All @@ -65,30 +64,27 @@ export class RedisApplication extends Application {
},
});
}

if (redisProps.persistData) {
new KubePersistentVolume(scope, pvName, {
new KubeStorageClass(scope, storageClassName, {
metadata: {
name: pvName,
},
spec: {
storageClassName,
accessModes: ["ReadWriteMany"], // TODO: ask Redis folks
capacity: {
storage: Quantity.fromString("1Gi"),
},
hostPath: {
path: `/${releaseName}/redis`,
name: storageClassName,
annotations: {
"storageclass.kubernetes.io/is-default-class": "true",
},
},
provisioner: "ebs.csi.aws.com",
volumeBindingMode: "WaitForFirstConsumer",
parameters: {
type: "gp3",
},
});
new KubePersistentVolumeClaim(scope, pvcName, {
metadata: {
name: pvcName,
},
spec: {
storageClassName,
accessModes: ["ReadWriteMany"], // TODO: ask Redis folks
accessModes: ["ReadWriteOnce"], // AWS EBS only supports RWO
resources: {
requests: {
storage: Quantity.fromString("1Gi"),
Expand Down
52 changes: 22 additions & 30 deletions cdk/kittyhawk/test/application/__snapshots__/redis.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cdk/kittyhawk/test/deployment.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Construct } from "constructs";
import { Container, Deployment } from "../src";
import { chartTest, failingTestNoGitSha } from "./utils";
import { KubeServiceAccount } from "../src/imports/k8s";
import { chartTest, failingTestNoGitSha } from "./utils";

export function buildDeploymentDefault(scope: Construct) {
new Deployment(scope, "container", {
Expand Down

0 comments on commit bd91989

Please sign in to comment.