Mattermost docs - Tutorial - Getting Started

Getting Started

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.

Prerequisites

To deploy mattermost-k8s charm, you will need a juju bootstrapped with any kubernetes controller. To see how to bootstrap your juju installation with microk8s, please refer to the documentation on microk8s installation.

Setting up the tutorial model

To easily clean up the resources and to separate your workload from the contents of this tutorial, it is recommended to set up a new model with the following command.

juju add-model mattermost-tutorial

Deploy the mattermost-k8s charm

Deployment of Mattermost requires a relational database. The integration with the pgsql interface is required by the mattermost-k8s charm and hence, postgresql-k8s charm will be used.

Start off by deploying the mattermost charm. By default it will deploy the latest stable release of the mattermost-k8s charm.

juju deploy mattermost-k8s

Deploy and relate database

The following commands deploys the postgresql-k8s charm with TLS and relates mattermost-k8s charm through its db interface.

juju deploy postgresql-k8s
# If your k8s cluster has RBAC enabled, you'll then need to run this:
juju trust postgresql-k8s --scope=cluster
# Deploy and enable TLS certificates for PostgreSQL connections.
juju deploy tls-certificates-operator
# Using self-signed certificates for demonstration purposes only.
juju config tls-certificates-operator generate-self-signed-certificates="true" ca-common-name="Test CA"
juju relate postgresql-k8s tls-certificates-operator
# And now relate postgresql-k8s to mattermost-k8s
juju relate mattermost-k8s postgresql-k8s:db

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.

Cleaning 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 -y --release-storage

Nice tutorial - Found it really useful and got me up and running in no time.

Some comments/Feedback on this page (part of my onboarding tasks):

Deploy and relate database

  • Database relation subtitle is possibly not needed/doesn’t add anything.
  • Comments in the code snippet are possibly more detail than needed for a Getting Started Tutorial?

Login to Mattermost

  • Is the /etc/hosts use really required (and the use of 127.0.0.1)? Wouldn’t it be simpler to show IP in juju status output and then show using this and port as the URL. (Possibly there’s a reason for adding this step that I’m not appreciating).

Cleaning up the environment

  • juju destroy model => juju destroy-model
1 Like

Thanks for the feedback!

I’ve removed the “Database relation” heading as suggested and fixed the destroy-model command.

I think the comments in the database relations code snippet are possibly more detail than needed in a getting started tutorial, but I think they help give context on why each command is needed rather than just following them.

In terms of hitting the IP in juju status vs. hitting 127.0.0.1 the reason for that is the IP in juju status is the IP of the workload unit, and while that’s reachable directly when deploying via MicroK8s it wouldn’t be reachable on any large scale kubernetes cluster. People familiar with Kubernetes but not yet familiar with Juju would want to know how to connect via ingress I think rather than hitting the workload pod directly.

4 Likes

Hint: do not miss port 8065 to access Mattermost WEB:

firefox http://<juju_mattermost_k8s_app_ip>:8065

Hi Alex,

I don’t believe that’s needed? This is a pod spec charm, so it defines an ingress resource, and assuming you follow the instructions and add the IP of your ingress controller to /etc/hosts you can reach the site without having to hit the pod directly (i.e. using ingress).

Can you confirm if that works for you?

Thanks, Tom

My post was to highlight the non-standard port “8065” (as no forwarder on 80/443 ports).

I didn’t mention to use pod IP, the application IP should be used with a proper port:

Sure, /etc/hosts trick with localhost will work if (Micro)K8s is nearby… but it can be running on a different host/cloud. :slight_smile:

I hope it helps. Tnx!

Hi Alex,

This charm requires the cluster to have the nginx-ingress controller deployed (which Charmed Kubernetes does, for instance, and MicroK8s does when the “ingress” add on is enabled), and will configure an ingress resource for that, so this is why we’re advising people to connect on port 80 to the ingress controller’s IP. The ingress resource will forward connections to the kubernetes service on port 8065.

Thanks, Tom

1 Like