Mattermost

  • By Canonical IS DevOps
Channel Revision Published Runs on
latest/stable 27 22 Nov 2023
Ubuntu 20.04
latest/edge 18 14 Jun 2021
Ubuntu 20.04
juju deploy mattermost-k8s
Show information

Platform:

Deploy the Mattermost charm for the first time

What you’ll do

The Mattermost k8s charm helps deploy a horizontally scalable Mattermost application with ease. This tutorial will walk you through each step of deployment to get a basic Mattermost deployment.

Requirements

  • A working station, e.g., a laptop, with amd64 architecture.
  • Juju 3 installed and bootstrapped to a MicroK8s controller. You can accomplish this process by using a Multipass VM as outlined in this guide: Set up / Tear down your test environment
  • NGINX Ingress Controller. If you’re using MicroK8s, this can be done by running the command microk8s enable ingress. For more details, see Addon: Ingress.

For more information about how to install Juju, see Get started with Juju.

:warning: When using a Multipass VM, make sure to replace 127.0.0.1 IP addresses with the VM IP in steps that assume you’re running locally. To get the IP address of the Multipass instance run multipass info my-juju-vm.

Steps

Shell into the Multipass VM

NOTE: If you’re working locally, you can skip this step.

To be able to work inside the Multipass VM first you need to log in with the following command:

multipass shell my-juju-vm

Add a Juju model for the tutorial

To manage resources effectively and to separate this tutorial’s workload from your usual work, create a new model in the MicroK8s controller using the following command:

juju add-model mattermost-tutorial

Deploy the Mattermost charm

Since Mattermost requires connections to PostgreSQL, you’ll deploy it too. For more information, see Charm Architecture.

Deploy the charms:

juju deploy mattermost-k8s
juju deploy postgresql-k8s --trust

Deploy and enable TLS certificates for PostgreSQL connections:

juju deploy tls-certificates-operator

Integrate with the TLS Cerfiticates k8s charm the PostgreSQL k8s charm

You need to configure TLS Certificates Charm to use a self-signed certificates. We will use self-signed certificates for the purposes of this tutorial.

juju config tls-certificates-operator generate-self-signed-certificates="true" ca-common-name="Test CA"

You need to integrate PostgreSQL k8s charm with TLS Certificates charm and Mattermost k8s charm.

juju integrate postgresql-k8s tls-certificates-operator
juju integrate mattermost-k8s postgresql-k8s:db

Run juju status to see the current status of the deployment. The output will look similar to the following:

Model                Controller          Cloud/Region        Version  SLA          Timestamp
mattermost-tutorial  microk8s-localhost  microk8s/localhost  3.5.3    unsupported  20:19:24Z

App                        Version                         Status  Scale  Charm                      Channel        Rev  Address         Exposed  Message
mattermost-k8s             .../mattermost:v8.1.3-20.04...  active      1  mattermost-k8s             latest/stable   27  10.152.183.136  no
postgresql-k8s             14.12                           active      1  postgresql-k8s             14/stable      381  10.152.183.108  no
tls-certificates-operator                                  active      1  tls-certificates-operator  latest/stable   22  10.152.183.192  no

Unit                          Workload  Agent  Address       Ports     Message
mattermost-k8s/0*             active    idle   10.1.200.151  8065/TCP
postgresql-k8s/0*             active    idle   10.1.200.149            Primary
tls-certificates-operator/0*  active    idle   10.1.200.150

The deployment is finished when the Application status shows “Active”.

Login to Mattermost

We should now edit /etc/hosts so that the IP address of your ingress controller resolves to the name of the deployed application. Add the following to that file:

127.0.0.1 mattermost-k8s

Once the deployment has completed and the mattermost-k8s workload state in juju status has changed to active you can then visit http://mattermost-k8s in a browser and log in to your Mattermost instance, and you’ll be presented with a screen to create an initial admin account. Further accounts must be created using this admin account, or by setting up an external authentication source, such as SAML.

Clean up the environment

Congratulations! You have successfully finished the Mattermost K8s tutorial. You can now remove the model environment that you’ve created using the following command.

juju destroy-model mattermost-tutorial --destroy-storage

If you used Multipass, to remove the Multipass instance you created for this tutorial, use the following command.

multipass delete --purge my-juju-vm

Finally, remove the 127.0.0.1 mattermost-k8s line from the /etc/hosts file.