Skip to content

Commit

Permalink
feat: announce replica ip using POD_IP
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunter Thompson committed Dec 20, 2021
1 parent e1abfb8 commit e6f7e1f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
13 changes: 13 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -31784,6 +31784,19 @@ The size of volume to use.

---

##### `annouceReplicaIp`<sup>Optional</sup> <a name="cdk8s-redis-cluster.RedisOptions.property.annouceReplicaIp"></a>

```typescript
public readonly annouceReplicaIp: boolean;
```

- *Type:* `boolean`
- *Default:* undefined

Annouce replica ip.

---

##### `announceIps`<sup>Optional</sup> <a name="cdk8s-redis-cluster.RedisOptions.property.announceIps"></a>

```typescript
Expand Down
20 changes: 20 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ export interface RedisOptions {
*
*/
readonly kumaMeshName?: string;
/**
* Annouce replica ip
* @default undefined
*/
readonly annouceReplicaIp?: boolean;
}

export class Redis extends Construct {
Expand Down Expand Up @@ -112,6 +117,12 @@ export class Redis extends Construct {

}

var b: string = '';

if (opts?.annouceReplicaIp) {
b = 'echo "replica-announce-ip $POD_IP" >> /opt/bitnami/redis/etc/redis.conf"';
}


const storageClass = new k8s.KubeStorageClass(this, 'storageClass', {
metadata: {
Expand Down Expand Up @@ -339,6 +350,7 @@ export class Redis extends Construct {
export REDIS_CLUSTER_CREATOR="yes"
export REDIS_CLUSTER_REPLICAS="1"
fi
${b}
/opt/bitnami/scripts/redis-cluster/entrypoint.sh /opt/bitnami/scripts/redis-cluster/run.sh`],
env: [
{
Expand Down Expand Up @@ -383,6 +395,14 @@ export class Redis extends Construct {
name: 'REDIS_PORT',
value: '6379',
},
{
name: 'POD_IP',
valueFrom: {
fieldRef: {
fieldPath: 'status.podIP',
},
},
},
],
ports: [
{
Expand Down
18 changes: 18 additions & 0 deletions test/__snapshots__/hello.test.ts.snap

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

1 change: 1 addition & 0 deletions test/hello.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test('with cm', () => {
volumeSize: '10Gi',
redisPassword: 'test',
kumaMesh: false,
annouceReplicaIp: true,
});

expect(Testing.synth(chart)).toMatchSnapshot();
Expand Down

0 comments on commit e6f7e1f

Please sign in to comment.