|
| 1 | +--- |
| 2 | + |
| 3 | +apiVersion: kustomize.config.k8s.io/v1alpha1 |
| 4 | +kind: Component |
| 5 | + |
| 6 | + |
| 7 | +resources: |
| 8 | + # - ../../base |
| 9 | + - Cluster-main-02.yaml |
| 10 | + - Service-main-r.yaml |
| 11 | + - Service-main-ro.yaml |
| 12 | + - Service-main-rw.yaml |
| 13 | + |
| 14 | + |
| 15 | +patches: |
| 16 | + |
| 17 | + # yamllint disable rule:indentation |
| 18 | + - patch: |- |
| 19 | +
|
| 20 | + - op: add |
| 21 | + path: /metadata/name |
| 22 | + value: main-01 |
| 23 | +
|
| 24 | + - op: replace |
| 25 | + path: /spec/replica |
| 26 | + value: |
| 27 | + primary: main-01 |
| 28 | + source: main-02 |
| 29 | +
|
| 30 | + # yamllint enable rule:indentation |
| 31 | + target: |
| 32 | + group: postgresql.cnpg.io |
| 33 | + version: v1 |
| 34 | + kind: Cluster |
| 35 | + name: main |
| 36 | +
|
| 37 | + # yamllint disable rule:indentation |
| 38 | + - patch: |- |
| 39 | +
|
| 40 | + - op: replace |
| 41 | + path: /spec/externalClusters |
| 42 | + value: |
| 43 | +
|
| 44 | + - name: main-01 |
| 45 | + connectionParameters: |
| 46 | + host: main-01-rw.updated_by_replacement.svc |
| 47 | + user: streaming_replica |
| 48 | + dbname: postgres |
| 49 | + sslmode: verify-full |
| 50 | + sslKey: |
| 51 | + name: main-01-replication |
| 52 | + key: tls.key |
| 53 | + sslCert: |
| 54 | + name: main-01-replication |
| 55 | + key: tls.crt |
| 56 | + sslRootCert: |
| 57 | + name: main-01-ca |
| 58 | + key: ca.crt |
| 59 | +
|
| 60 | + - name: main-02 |
| 61 | + connectionParameters: |
| 62 | + host: main-02-rw.updated_by_replacement.svc |
| 63 | + user: streaming_replica |
| 64 | + dbname: postgres |
| 65 | + sslmode: verify-full |
| 66 | + sslKey: |
| 67 | + name: main-02-replication |
| 68 | + key: tls.key |
| 69 | + sslCert: |
| 70 | + name: main-02-replication |
| 71 | + key: tls.crt |
| 72 | + sslRootCert: |
| 73 | + name: main-02-ca |
| 74 | + key: ca.crt |
| 75 | +
|
| 76 | + # yamllint enable rule:indentation |
| 77 | + target: |
| 78 | + group: postgresql.cnpg.io |
| 79 | + version: v1 |
| 80 | + kind: Cluster |
| 81 | +
|
| 82 | +
|
| 83 | +
|
| 84 | +replacements: |
| 85 | + # |
| 86 | + # Add to Top-most Kustomization.yaml |
| 87 | + # |
| 88 | + # Updates extenal cluster DNS name octet that contains the namespace |
| 89 | + # - source: |
| 90 | + # kind: Cluster |
| 91 | + # name: main-01 |
| 92 | + # fieldPath: metadata.namespace |
| 93 | + # targets: |
| 94 | + # - select: |
| 95 | + # kind: Cluster |
| 96 | + # fieldPaths: |
| 97 | + # - spec.externalClusters.[name=main-01].connectionParameters.host |
| 98 | + # - spec.externalClusters.[name=main-02].connectionParameters.host |
| 99 | + # options: |
| 100 | + # delimiter: "." |
| 101 | + # index: 1 |
| 102 | + |
| 103 | + |
| 104 | + # |
| 105 | + # Add to Top-most Kustomization.yaml, if primary has be changed |
| 106 | + # |
| 107 | + # Updates each of the services to point the cluster that is denoted as primary |
| 108 | + # within cluster main-02 |
| 109 | + - source: |
| 110 | + kind: Cluster |
| 111 | + name: main-02 |
| 112 | + fieldPath: spec.replica.primary |
| 113 | + targets: |
| 114 | + - select: |
| 115 | + kind: Service |
| 116 | + name: main-r |
| 117 | + fieldPaths: |
| 118 | + - spec.selector.[cnpg.io/cluster] |
| 119 | + - select: |
| 120 | + kind: Service |
| 121 | + name: main-ro |
| 122 | + fieldPaths: |
| 123 | + - spec.selector.[cnpg.io/cluster] |
| 124 | + - select: |
| 125 | + kind: Service |
| 126 | + name: main-rw |
| 127 | + fieldPaths: |
| 128 | + - spec.selector.[cnpg.io/cluster] |
| 129 | + |
| 130 | + # Dont change |
| 131 | + - source: |
| 132 | + kind: Cluster |
| 133 | + name: main-02 |
| 134 | + fieldPath: metadata.labels.[app.kubernetes.io/part-of] |
| 135 | + targets: |
| 136 | + - select: |
| 137 | + kind: Cluster |
| 138 | + fieldPaths: |
| 139 | + - metadata.labels.[app.kubernetes.io/part-of] |
| 140 | + - spec.inheritedMetadata.labels.[app.kubernetes.io/part-of] |
0 commit comments