chore: swap to valkey
This commit is contained in:
@@ -1,28 +0,0 @@
|
|||||||
import * as fs from "fs";
|
|
||||||
import { HelmProvider } from "@cdktf/provider-helm/lib/provider";
|
|
||||||
import { Release } from "@cdktf/provider-helm/lib/release";
|
|
||||||
import { Construct } from "constructs";
|
|
||||||
|
|
||||||
type RedisClusterOptions = {
|
|
||||||
provider: HelmProvider;
|
|
||||||
name: string;
|
|
||||||
namespace: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export class RedisCluster extends Construct {
|
|
||||||
constructor(scope: Construct, id: string, options: RedisClusterOptions) {
|
|
||||||
super(scope, id);
|
|
||||||
|
|
||||||
new Release(this, id, {
|
|
||||||
...options,
|
|
||||||
repository: "https://charts.bitnami.com/bitnami",
|
|
||||||
chart: "redis",
|
|
||||||
createNamespace: true,
|
|
||||||
values: [
|
|
||||||
fs.readFileSync("helm/values/redis.values.yaml", {
|
|
||||||
encoding: "utf8",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
120
valkey/index.ts
Normal file
120
valkey/index.ts
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
import { DeploymentV1 } from "@cdktf/provider-kubernetes/lib/deployment-v1";
|
||||||
|
import { KubernetesProvider } from "@cdktf/provider-kubernetes/lib/provider";
|
||||||
|
import { ServiceV1 } from "@cdktf/provider-kubernetes/lib/service-v1";
|
||||||
|
import { Construct } from "constructs";
|
||||||
|
|
||||||
|
type ValkeyClusterOptions = {
|
||||||
|
provider: KubernetesProvider;
|
||||||
|
name: string;
|
||||||
|
namespace: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export class ValkeyCluster extends Construct {
|
||||||
|
constructor(scope: Construct, id: string, options: ValkeyClusterOptions) {
|
||||||
|
super(scope, id);
|
||||||
|
|
||||||
|
// Labels used by both Deployment and Service
|
||||||
|
const labels = { app: "valkey" };
|
||||||
|
const { provider, name, namespace } = options;
|
||||||
|
|
||||||
|
new DeploymentV1(this, "valkeyDeployment", {
|
||||||
|
provider,
|
||||||
|
metadata: {
|
||||||
|
name,
|
||||||
|
namespace,
|
||||||
|
labels,
|
||||||
|
},
|
||||||
|
spec: {
|
||||||
|
replicas: "1",
|
||||||
|
strategy: {
|
||||||
|
type: "RollingUpdate",
|
||||||
|
rollingUpdate: {
|
||||||
|
maxSurge: "1",
|
||||||
|
maxUnavailable: "0",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
selector: { matchLabels: labels },
|
||||||
|
template: {
|
||||||
|
metadata: { labels },
|
||||||
|
spec: {
|
||||||
|
container: [
|
||||||
|
{
|
||||||
|
name: "valkey",
|
||||||
|
image: "docker.io/valkey/valkey:8.1.3",
|
||||||
|
port: [{ name: "client", containerPort: 6379 }],
|
||||||
|
env: [
|
||||||
|
{
|
||||||
|
name: "PASSWORD",
|
||||||
|
valueFrom: {
|
||||||
|
secretKeyRef: {
|
||||||
|
name: "valkey",
|
||||||
|
key: "password",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
command: ["/bin/sh", "-c"],
|
||||||
|
args: ['exec valkey-server --requirepass "$PASSWORD"'],
|
||||||
|
readinessProbe: {
|
||||||
|
tcpSocket: [
|
||||||
|
{
|
||||||
|
port: "6379",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
initialDelaySeconds: 5,
|
||||||
|
periodSeconds: 5,
|
||||||
|
timeoutSeconds: 3,
|
||||||
|
failureThreshold: 5,
|
||||||
|
},
|
||||||
|
livenessProbe: {
|
||||||
|
tcpSocket: [
|
||||||
|
{
|
||||||
|
port: "6379",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
initialDelaySeconds: 20,
|
||||||
|
periodSeconds: 10,
|
||||||
|
timeoutSeconds: 5,
|
||||||
|
failureThreshold: 5,
|
||||||
|
},
|
||||||
|
resources: {
|
||||||
|
requests: {
|
||||||
|
cpu: "100m",
|
||||||
|
memory: "128Mi",
|
||||||
|
},
|
||||||
|
limits: {
|
||||||
|
memory: "512Mi",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
new ServiceV1(this, "valkeyService", {
|
||||||
|
provider,
|
||||||
|
metadata: {
|
||||||
|
name,
|
||||||
|
namespace,
|
||||||
|
labels,
|
||||||
|
annotations: {
|
||||||
|
"external-dns.alpha.kubernetes.io/hostname": "valkey.dogar.dev",
|
||||||
|
"metallb.io/ip-allocated-from-pool": "pool",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
spec: {
|
||||||
|
type: "LoadBalancer",
|
||||||
|
selector: labels,
|
||||||
|
port: [
|
||||||
|
{
|
||||||
|
name: "client",
|
||||||
|
port: 6379,
|
||||||
|
targetPort: "client",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user