Skip to content

Commit 8cbf41e

Browse files
authored
Update _index.md
Suggest adding a disclaimer due to the age of this pattern. Also copied the README from the pattern repo to add some content. Please review and accept or deny. I've copied Jonny on a comment to see if this would be acceptable.
1 parent 6f604e2 commit 8cbf41e

1 file changed

Lines changed: 196 additions & 0 deletions

File tree

content/patterns/cockroachdb/_index.md

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,203 @@ links:
1414
---
1515

1616
# Cockroach
17+
## About Multi-Region CockroachDB Gitops
18+
19+
**Disclaimer: This pattern was last reviewed in 2022. Your experience may vary. If you successfully deploy this pattern, please consider contributing an update.**
20+
1721

1822
A multicloud pattern using cockroachdb and submariner, deployed via RHACM.
1923

2024
[Repo](https://github.com/validatedpatterns/cockroachdb-pattern)
25+
26+
# Multi-Region CockroachDB Gitops
27+
28+
The pattern deploys CockroachDB across multi OpenShift clusters that are spread across different geographic regions and hosted on clouds like [Azure](https://portal.azure.com/), [AWS](https://aws.amazon.com/) or [GKE](https://cloud.google.com/kubernetes-engine). It deploys a CockroachDB [StatefulSet](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/)
29+
into each separate cluster, and links them by deploying [Submariner add-on](https://access.redhat.com/documentation/en-us/red_hat_advanced_cluster_management_for_kubernetes/2.5/html/add-ons/add-ons-overview#submariner) on the hub cluster.
30+
31+
If you've followed a link to this repository, but are not really sure what it contains
32+
or how to use it, head over to [Multicloud GitOps](http://validatedpatterns.io/multicloud-gitops/)
33+
for additional context and installation instructions.
34+
35+
## Prerequisites
36+
37+
1. An OpenShift cluster (Go to [the OpenShift console](https://console.redhat.com/openshift/create)). See also [sizing your cluster](../cluster-sizing).
38+
1. A GitHub account (and, optionally, a token for it with repositories permissions, to read from and write to your forks)
39+
1. The helm binary, see [here](https://helm.sh/docs/intro/install/)
40+
1. Atleast two OpenShift clusters deployed in different regions or across different clouds. Clusters should be deployed with different IP CIDR ranges.
41+
42+
| Cluster | Pod CIDR | Service CIDR |
43+
|---|---|---|
44+
| cluster1 | 10.128.0.0/14 | 172.30.0.0/16 |
45+
| cluster2 | 10.132.0.0/14 | 172.31.0.0/16 |
46+
| cluster3 | 10.140.0.0/14 | 172.32.0.0/16 |
47+
48+
ACM does not support configuring Submariner add-on for OpenShift clusters deployed in Azure cloud. Additonal steps are required to configure Submariner on Azure cluster. Before deploying cockroachdb-pattern ensure the following steps have been completed for Azure clusters.
49+
50+
### Prepare Azure Clusters for Submariner
51+
52+
Submariner Gateway nodes need to be able to accept traffic over UDP ports (4500 and 4490 by default). Submariner also uses UDP port 4800 to encapsulate traffic from the worker and master nodes to the Gateway nodes, and TCP port 8080 to retrieve metrics from the Gateway nodes. Additionally, the default OpenShift deployment does not allow assigning an elastic public IP to existing worker nodes, which may be necessary on one end of the tunnel connection.
53+
54+
subctl cloud prepare is a command designed to update your OpenShift installer provisioned infrastructure for Submariner deployments, handling the requirements specified above.
55+
56+
Run the command for cluster1:
57+
58+
```sh
59+
az ad sp create-for-rbac --sdk-auth > my.auth
60+
export KUBECONFIG=cluster1/auth/kubeconfig
61+
subctl cloud prepare azure --ocp-metadata cluster1/metadata.json --auth-file my.auth
62+
```
63+
64+
For more information on how to prepare Azure OpenShift cluster for Submariner deployment, refer to the [submariner](https://submariner.io/getting-started/quickstart/openshift/azure/#prepare-azure-clusters-for-submariner) documentation.
65+
66+
If you do not have a running Red Hat OpenShift cluster, you can start one on a
67+
public or private cloud by using [Red Hat's cloud
68+
service](https://console.redhat.com/openshift/create).
69+
70+
## How to deploy
71+
72+
1. Fork the [cockroachdb-pattern](https://github.com/validatedpatterns/cockroachdb-pattern) repository on GitHub. It is necessary to fork because your fork will be updated as part of the GitOps and DevOps processes.
73+
74+
1. Clone the forked copy of this repository.
75+
76+
```sh
77+
git clone git@github.com:your-username/cockroachdb-pattern.git
78+
```
79+
80+
1. Create a local copy of the Helm values file that can safely include credentials
81+
82+
DO NOT COMMIT THIS FILE
83+
84+
You do not want to push personal credentials to GitHub.
85+
86+
```sh
87+
cp values-secret.yaml.template ~/values-secret.yaml
88+
vi ~/values-secret.yaml
89+
```
90+
91+
1. Customize the deployment for your cluster
92+
93+
```sh
94+
git checkout -b my-branch
95+
vi values-global.yaml
96+
git add values-global.yaml
97+
git commit values-global.yaml
98+
git push origin my-branch
99+
```
100+
101+
1. You can deploy the pattern using the [validated pattern operator](/infrastructure/using-validated-pattern-operator/). If you do use the operator then skip to Validating the Environment below.
102+
103+
1. Preview the changes
104+
105+
```sh
106+
make show
107+
```
108+
109+
1. Login to your hub cluster using oc login or exporting the KUBECONFIG
110+
111+
```sh
112+
oc login
113+
```
114+
115+
or set KUBECONFIG to the path to your `kubeconfig` file. For example:
116+
117+
```sh
118+
export KUBECONFIG=~/my-ocp-env/hub/auth/kubconfig
119+
```
120+
121+
1. Apply the changes to your cluster
122+
123+
```sh
124+
make install
125+
```
126+
127+
1. Check the operators have been installed
128+
129+
```text
130+
OpenShift Console Web UI -> Installed Operators
131+
```
132+
133+
1. Check all applications are synchronised
134+
Under the project `cockroachdb-pattern-hub` click on the URL for the `hub`gitops`server`. The Vault application is not synched.
135+
136+
1. Check all the managed clusters have been imported.
137+
Go to the routes and search for `multi` within `All Projects`. Click the link to launch ACM console. Under the clusters verify if all the managed clusters have been imported. Click on Cluster add-ons and verify if the Submariner add-on has been installed.
138+
139+
1. Login to your managed cluster `cluster1` using oc login or exporting the KUBECONFIG as described in step 1.
140+
141+
1. Select the project cockroachdb
142+
143+
```sh
144+
oc project cockroachdb
145+
```
146+
147+
1. Check the pods are running and the crete-certs and init-cockroachdb-xxxxx have completed.
148+
149+
```sh
150+
NAME READY STATUS RESTARTS AGE
151+
cockroachdb-0 1/1 Running 0 77s
152+
cockroachdb-1 1/1 Running 0 77s
153+
cockroachdb-2 1/1 Running 0 77s
154+
cockroachdb-client-secure 1/1 Running 0 77s
155+
create-certs 0/1 Completed 0 77s
156+
init-cockroachdb-jhnns 0/1 Completed 0 77s
157+
```
158+
159+
1. Verify if the cockroach db is replicated across clusters.
160+
161+
a. Launch cockroachdb cmdLine
162+
163+
```sh
164+
kubectl exec -it cockroachdb-client-secure -- ./cockroach sql --certs-dir=/cockroach-certs --host=cockroachdb-public
165+
```
166+
167+
b. Create DB, tables and populate data
168+
169+
```sh
170+
CREATE DATABASE IF NOT EXISTS foo;
171+
CREATE TABLE IF NOT EXISTS foo.bar (k STRING PRIMARY KEY, v STRING);
172+
UPSERT INTO foo.bar VALUES ('Kuber', 'netes'), ('Cockroach', 'DB');
173+
SELECT CONCAT(k, v) FROM foo.bar;
174+
```
175+
176+
Output:
177+
178+
```sh
179+
root@cockroachdb-public:26257/defaultdb> SELECT CONCAT(k, v) FROM foo.bar;
180+
concat
181+
---------------
182+
CockroachDB
183+
Kubernetes
184+
(2 rows)
185+
```
186+
187+
c. Login to second managed cluster `cluster2` using oc login or exporting the KUBECONFIG as described above.
188+
189+
d. Select the project cockroachdb
190+
191+
```sh
192+
oc project cockroachdb
193+
```
194+
195+
e. Launch cockroachdb cmdLine
196+
197+
```sh
198+
kubectl exec -it cockroachdb-client-secure -- ./cockroach sql --certs-dir=/cockroach-certs --host=cockroachdb-public
199+
```
200+
201+
f. Verify the table and data is replicated
202+
203+
```sh
204+
SELECT CONCAT(k, v) FROM foo.bar;
205+
```
206+
207+
Output:
208+
209+
```sh
210+
root@cockroachdb-public:26257/defaultdb> SELECT CONCAT(k, v) FROM foo.bar;
211+
concat
212+
---------------
213+
CockroachDB
214+
Kubernetes
215+
(2 rows)
216+
```

0 commit comments

Comments
 (0)