Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs and CI to support rabbitmq-external chart #655

Merged
merged 23 commits into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5a36bf6
fix the system containers seeding group
amitsagtani97 Sep 27, 2023
a0e9e39
add more storage to vms in test env
amitsagtani97 Sep 27, 2023
dc7dd76
ci.sh: Add rabbitmq-external chart to artifact
supersven Sep 29, 2023
610378f
Use `rabbitmq` Helm chart (instead of `rabbitmq-external`)
supersven Sep 29, 2023
d35442d
Document RabbitMQ installation
supersven Sep 29, 2023
889ddb2
offline-cluster.sh: Don't use rabbitmq and helm_external playbooks
supersven Sep 29, 2023
7e4618a
add helm_external playbook installation step in offline-helm.sh
amitsagtani97 Sep 28, 2023
f3e7170
use k8s based rabbitmq by default
amitsagtani97 Sep 28, 2023
d047978
Point restund_allowed_private_network_cidrs to 172.16.0.1/24
supersven Sep 29, 2023
d77f1bd
offline-cluster.sh: Run restund Ansible playbook last
supersven Sep 29, 2023
8f49bd7
[temp] use mandarian release to build the artifact
amitsagtani97 Sep 28, 2023
9fbf5b7
pickup valid changes from #656
amitsagtani97 Oct 14, 2023
05ee989
[temp] debug the failing CI
amitsagtani97 Oct 16, 2023
e82a025
use the main wire-server chart repo
amitsagtani97 Oct 30, 2023
6096d61
pass the ssh-agent path and remove verbosity
amitsagtani97 Dec 13, 2023
ec0bbed
use fixed inventory path for CI
amitsagtani97 Dec 14, 2023
1a8d701
pass correct ssh_auth_sock
amitsagtani97 Dec 14, 2023
19251c4
Revert "use fixed inventory path for CI"
amitsagtani97 Dec 18, 2023
6ffdc96
fix indentation and if-else statements
amitsagtani97 Dec 19, 2023
0be790d
update helm_external playbook to add tag to rabbitmq specific croles
amitsagtani97 Dec 19, 2023
3ba71f7
fix documentation and CI with rabbitmq chart
amitsagtani97 Jan 3, 2024
8c2385b
add note for adding etcd groups
amitsagtani97 Jan 3, 2024
6a6de1e
add more details to rabbitmq configuration steps
amitsagtani97 Jan 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions ansible/helm_external.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
server_type: cassandra
network_interface: "{{ cassandra_network_interface }}"

- hosts: "rmq-cluster"
become: false
tasks:
- name: Generate rabbitmq IPs for helm
include_tasks: tasks/helm_external.yml
vars:
external_dir_name: rabbitmq-external
server_type: rmq-cluster
network_interface: "{{ rabbitmq_network_interface }}"
# - hosts: "rmq-cluster"
Copy link
Contributor

@supersven supersven Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is commenting out the best way to not execute this task? Wouldn't it be better to rely on some conditional (e.g. when: rabbitmq_cluster.is_internal == false (these value names likely don't exist yet, I made them up))?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a tag for the rabbimq role and added --skip-tags and --tags to install as required.

# become: false
# tasks:
# - name: Generate rabbitmq IPs for helm
# include_tasks: tasks/helm_external.yml
# vars:
# external_dir_name: rabbitmq-external
# server_type: rmq-cluster
# network_interface: "{{ rabbitmq_network_interface }}"
4 changes: 2 additions & 2 deletions ansible/inventory/offline/99-static
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@
# restund_allowed_private_network_cidrs = a.b.c.d/24
# If you install restund together with other services on the same machine
# you need to restund_allowed_private_network_cidrs to allow these services
# to communicate on the private network. E.g. If your private network is 172.16.0.1/24
# restund_allowed_private_network_cidrs = 172.16.0/24
# to communicate on the private network. E.g. If your private network is 172.16.0.0/24
# restund_allowed_private_network_cidrs = '["172.16.0.0/24"]'

# Explicitely specify the restund user id to be "root" to override the default of "997"
restund_uid = root
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles-external/sft
2 changes: 1 addition & 1 deletion ansible/seed-offline-containerd.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- name: Seed system containers
hosts: k8s-cluster:etcd
hosts: k8s-cluster
tags: system-containers
tasks:
- name: load containers
Expand Down
48 changes: 36 additions & 12 deletions bin/offline-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,60 @@ set -x

ls $ANSIBLE_DIR/inventory/offline

if [ -f "$ANSIBLE_DIR/inventory/offline/hosts.ini" ]
then
INVENTORY_FILE="$ANSIBLE_DIR/inventory/offline/hosts.ini"
else
if [ -f "$ANSIBLE_DIR/inventory/offline/inventory.yml" ]
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved
then
INVENTORY_FILE="$ANSIBLE_DIR/inventory/offline/inventory.yml"
else
{
echo "no inventory file in ansible/inventory/offline/. please supply an inventory.yml or hosts.ini."
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved
exit -1
}
fi
fi

if [ -f "$ANSIBLE_DIR/inventory/offline/hosts.ini" ] && [ -f "$ANSIBLE_DIR/inventory/offline/inventory.ymp" ]
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved
then
{
echo "both hosts.ini and inventory.yml provided in ansible/inventory/offline! pick only one."
exit -1
}
fi

echo "using ansible inventory: $INVENTORY_FILE"
cat $INVENTORY_FILE
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved

# Populate the assethost, and prepare to install images from it.
#
# Copy over binaries and debs, serves assets from the asset host, and configure
# other hosts to fetch debs from it.
#
# If this step fails partway, and you know that parts of it completed, the `--skip-tags debs,binaries,containers,containers-helm,containers-other` tags may come in handy.
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/setup-offline-sources.yml
ansible-playbook -i $INVENTORY_FILE $ANSIBLE_DIR/setup-offline-sources.yml

# Run kubespray until docker is installed and runs. This allows us to preseed the docker containers that
# are part of the offline bundle
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/kubernetes.yml --tags bastion,bootstrap-os,preinstall,container-engine
ansible-playbook -i $INVENTORY_FILE $ANSIBLE_DIR/kubernetes.yml --tags bastion,bootstrap-os,preinstall,container-engine

# Install docker on the restund nodes
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/restund.yml --tags docker
ansible-playbook -i $INVENTORY_FILE $ANSIBLE_DIR/restund.yml --tags docker

# With ctr being installed on all nodes that need it, seed all container images:
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/seed-offline-containerd.yml
ansible-playbook -i $INVENTORY_FILE $ANSIBLE_DIR/seed-offline-containerd.yml

# Install NTP
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/sync_time.yml -v
ansible-playbook -i $INVENTORY_FILE $ANSIBLE_DIR/sync_time.yml -v

# Run the rest of kubespray. This should bootstrap a kubernetes cluster successfully:
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/kubernetes.yml --skip-tags bootstrap-os,preinstall,container-engine
ansible-playbook -i $INVENTORY_FILE $ANSIBLE_DIR/kubernetes.yml --skip-tags bootstrap-os,preinstall,container-engine

./bin/fix_default_router.sh

# Deploy all other services which don't run in kubernetes.
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/cassandra.yml
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/elasticsearch.yml
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/restund.yml
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/minio.yml
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/rabbitmq.yml
ansible-playbook -i $ANSIBLE_DIR/inventory/offline $ANSIBLE_DIR/helm_external.yml
ansible-playbook -i $INVENTORY_FILE $ANSIBLE_DIR/cassandra.yml
ansible-playbook -i $INVENTORY_FILE $ANSIBLE_DIR/elasticsearch.yml
ansible-playbook -i $INVENTORY_FILE $ANSIBLE_DIR/minio.yml
ansible-playbook -i $INVENTORY_FILE $ANSIBLE_DIR/restund.yml
3 changes: 1 addition & 2 deletions bin/offline-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ WSD_CONTAINER=$(sudo docker load -i $SCRIPT_DIR/../containers-adminhost/containe

./bin/offline-secrets.sh


sudo docker run --network=host -v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent -v $PWD:/wire-server-deploy $WSD_CONTAINER ./bin/offline-cluster.sh
sudo docker run --network=host -v $PWD:/wire-server-deploy $WSD_CONTAINER ./bin/offline-helm.sh
sudo docker run --network=host -v $SSH_AUTH_SOCK:/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent -v $PWD:/wire-server-deploy $WSD_CONTAINER ./bin/offline-helm.sh
5 changes: 5 additions & 0 deletions bin/offline-helm.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/usr/bin/env bash

set -euo pipefail
set -x
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ANSIBLE_DIR="$( cd "$SCRIPT_DIR/../ansible" && pwd )"
ansible-playbook -i "$ANSIBLE_DIR"/inventory/offline "$ANSIBLE_DIR"/helm_external.yml -vv

helm upgrade --install --wait cassandra-external ./charts/cassandra-external --values ./values/cassandra-external/values.yaml
helm upgrade --install --wait elasticsearch-external ./charts/elasticsearch-external --values ./values/elasticsearch-external/values.yaml
Expand Down
2 changes: 1 addition & 1 deletion bin/offline-vm-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ create_node () {
sudo virt-install \
--name "$name" \
--ram 8192 \
--disk path=/var/kvm/images/"$name".img,size=80 \
--disk path=/var/kvm/images/"$name".img,size=100 \
--vcpus 6 \
--network bridge=br0 \
--graphics none \
Expand Down
1 change: 1 addition & 0 deletions offline/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ charts=(
wire/sftd
wire/restund
wire/rabbitmq
wire/rabbitmq-external
# Has a weird dependency on curl:latest. out of scope
# wire-server-metrics
# fluent-bit
Expand Down
70 changes: 31 additions & 39 deletions offline/docs_ubuntu_22.04.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,19 +280,6 @@ the `wire.com/external-ip` annotation to the public IP of the node.

In order to automatically generate deeplinks, Edit the minio variables in `[minio:vars]` (`prefix`, `domain` and `deeplink_title`) by replacing `example.com` with your own domain.

### Configuring rabbitmq

Add the nodes in which you want to run rabbitmq to the `[rmq-cluster]` group. Also, update the `ansible/roles/rabbimq-cluster/defaults/main.yml` file with the correct configurations for your environment.

Important: RabbitMQ nodes address each other using a node name, for e.g rabbitmq@ansnode1
Please refer to official doc and configure your DNS based on the setup - https://www.rabbitmq.com/clustering.html#cluster-formation-requirements

For adding entries to local host file(/etc/hosts), run
```
d ansible-playbook -i ansible/inventory/offline/hosts.ini ansible/roles/rabbitmq-cluster/tasks/configure_dns.yml
```



### Example hosts.ini

Expand Down Expand Up @@ -327,7 +314,10 @@ deeplink_title = "wire demo environment, example.com"

[restund:vars]
restund_uid = root
restund_allowed_private_network_cidrs=172.16.0.1/24
restund_allowed_private_network_cidrs='["172.16.0.0/24"]'

[rmq-cluster:vars]
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved
rabbitmq_network_interface = enp1s0

[kube-master]
kubenode1
Expand Down Expand Up @@ -394,14 +384,6 @@ Minio and restund services have shared secrets with the `wire-server` helm chart

This should generate two files. `./ansible/inventory/group_vars/all/secrets.yaml` and `values/wire-server/secrets.yaml`.

## Deploying Kubernetes, Restund and stateful services

In order to deploy all the services run:
```
d ./bin/offline-cluster.sh
```
In case any of the steps in this script fail, see the notes in the comments that accompany each step.
Comment out steps that have already completed when re-running the scripts.

#### Ensuring kubernetes is healthy.

Expand Down Expand Up @@ -460,6 +442,25 @@ Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
```

## Deploying Kubernetes, Restund and stateful services

In order to deploy all mentioned services, run:
```
d ./bin/offline-cluster.sh
```
In case any of the steps in this script fail, see the notes in the comments that accompany each step.
Comment out steps that have already completed when re-running the scripts.

#### Ensuring Kubernetes is healthy.

Ensure the cluster comes up healthy. The container also contains `kubectl`, so check the node status:

```
d kubectl get nodes -owide
```
They should all report ready.


#### Troubleshooting restund

In case the restund firewall fails to start. Fix
Expand Down Expand Up @@ -507,41 +508,32 @@ ufw allow 25672/tcp;
'
```

### Preparation for Federation
For enabling Federation, we need to have RabbitMQ in place. Please follow the instructions in [offline/federation_preparation.md](./federation_preparation.md) for setting up RabbitMQ.

After that continue to the next steps below.


### Preparing helm values for external services
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved
Afterwards, run the following playbook to create helm values that tell our helm charts
what the IP addresses of cassandra, elasticsearch, minio and rabbitmq are.

```
d ansible-playbook -i ./ansible/inventory/offline/hosts.ini ansible/helm_external.yml
```

#### Installing Rabbitmq

To install the rabbitmq,
First copy the value and secret file:
```
cp ./values/rabbitmq/prod-values.example.yaml ./values/rabbitmq/values.yaml
cp ./values/rabbitmq/prod-secrets.example.yaml ./values/rabbitmq/secrets.yaml
```

Now, update the `./values/rabbitmq/values.yaml` and `./values/rabbitmq/secrets.yaml` with correct values as per needed.

Deploy the rabbitmq helm chart -
```
d helm upgrade --install rabbitmq ./charts/rabbitmq --values ./values/rabbitmq/values.yaml --values ./values/rabbitmq/secrets.yaml
```

### Deploying Wire

It's now time to deploy the helm charts on top of kubernetes, installing the Wire platform.

#### Finding the stateful services
First. Make kubernetes aware of where alll the external stateful services are by running:
First, setup interfaces from Kubernetes to external services by running:

```
d helm install cassandra-external ./charts/cassandra-external --values ./values/cassandra-external/values.yaml
d helm install elasticsearch-external ./charts/elasticsearch-external --values ./values/elasticsearch-external/values.yaml
d helm install minio-external ./charts/minio-external --values ./values/minio-external/values.yaml
d helm install rabbitmq-external ./charts/rabbitmq-external --values ./values/rabbitmq-external/values.yaml
```

#### Deploying stateless dependencies
Expand Down
85 changes: 85 additions & 0 deletions offline/federation_preparation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
## RabbitMQ

There are two methods to deploy the RabbitMQ cluster:

### Method 1: Install RabbitMQ inside kubernetes cluster with the help of helm chart

To install the RabbitMQ service, first copy the value and secret files:
```
cp ./values/rabbitmq/prod-values.example.yaml ./values/rabbitmq/values.yaml
cp ./values/rabbitmq/prod-secrets.example.yaml ./values/rabbitmq/secrets.yaml
```
By default this will create a RabbitMQ deployment with ephemeral storage. To use the local persistence storage of Kubernetes nodes, please refer to the related documentation in [offline/local_persistent_storage_k8s.md](./local_persistent_storage_k8s.md).

Now, update the `./values/rabbitmq/values.yaml` and `./values/rabbitmq/secrets.yaml` with correct values as needed.

Deploy the `rabbitmq` helm chart:
```
d helm upgrade --install rabbitmq ./charts/rabbitmq --values ./values/rabbitmq/values.yaml --values ./values/rabbitmq/secrets.yaml
```

### Method 2: Install RabbitMQ outside of the Kubernetes cluster with an Ansible playbook

Add the nodes on which you want to run rabbitmq to the `[rmq-cluster]` group in the `ansible/inventory/offline/hosts.ini` file. Also, update the `ansible/roles/rabbitmq-cluster/defaults/main.yml` file with the correct configurations for your environment.

If you need RabbitMQ to listen on a different interface than the default gateway, set `rabbitmq_network_interface`

You should have following entries in the `/ansible/inventory/offline/hosts.ini` file. For example:
```
[rmq-cluster:vars]
rabbitmq_network_interface = enp1s0

[rmq-cluster]
ansnode1
ansnode2
ansnode3
```

**Important:** RabbitMQ nodes address each other using a node name, for e.g rabbitmq@ansnode1
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved
Please refer to the official documentation and configure your DNS based on the setup - https://www.rabbitmq.com/clustering.html#cluster-formation-requirements


For adding entries to local host file(`/etc/hosts`), run
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved
```
d ansible-playbook -i ansible/inventory/offline/hosts.ini ansible/roles/rabbitmq-cluster/tasks/configure_dns.yml
```

Create the rabbitmq cluster:

```
d ansible-playbook -i ansible/inventory/offline/hosts.ini ansible/rabbitmq.yml
```

Uncomment the following section, in the `ansible/helm_external.yml` file:
```
# - hosts: "rmq-cluster"
# become: false
# tasks:
# - name: Generate rabbitmq IPs for helm
# include_tasks: tasks/helm_external.yml
# vars:
# external_dir_name: rabbitmq-external
# server_type: rmq-cluster
# network_interface: "{{ rabbitmq_network_interface }}"

```

and run the following playbook to create values file for helm charts to look for RabbitMQ IP addresses -

```
d ansible-playbook -i ./ansible/inventory/offline/hosts.ini ansible/helm_external.yml
```

Make Kubernetes aware of where RabbitMQ external stateful service is running:
```
d helm install rabbitmq-external ./charts/rabbitmq-external --values ./values/rabbitmq-external/values.yaml
```

Configure wire-server to use the external RabbitMQ service:

Edit the `/values/wire-server/prod-values.yaml` file to update the RabbitMQ host
Under `brig` and `galley` section, you will find the `rabbitmq` config, update the host to `rabbitmq-external`, it should look like this:
```
rabbitmq:
host: rabbitmq-external
```
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions values/wire-server/prod-values.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ brig:
elasticsearch:
host: elasticsearch-external
rabbitmq:
host: rabbitmq-external
host: rabbitmq
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved
useSES: false
# Set to false if you want to hand out DynamoDB to store prekeys
randomPrekeys: true
Expand Down Expand Up @@ -141,7 +141,7 @@ galley:
cassandra:
host: cassandra-external
rabbitmq:
host: rabbitmq-external
host: rabbitmq
amitsagtani97 marked this conversation as resolved.
Show resolved Hide resolved
settings:
# prefix URI used when inviting users to a conversation by link
conversationCodeURI: https://account.example.com/conversation-join/ # change this
Expand Down
Loading