---
title: Charmhub | Deploy Mattermost using Charmhub - The Open Operator Collection
description: Deploy the latest version of Mattermost as a Kubernetes Operator on any
  cloud.
url: https://charmhub.io/mattermost-k8s/docs/tutorial-deploy-the-mattermost-charm-for-the-first-time
---

# Mattermost

[Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

* [Canonical IS DevOps](https://charmhub.io/publisher/canonical-is-devops "View all packages from Canonical IS DevOps")

Platform:

stable 18

```
juju deploy mattermost-k8s
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

---

#### Contacts

##### Maintainers

+ [Launchpad Team](https://launchpad.net/~canonical-is-sre)

---

Share your thoughts on this charm with the community on discourse.

[Join the discussion](https://discourse.charmhub.io/)

# Deploy the Mattermost charm for the first time

## [What you’ll do](https://charmhub.io/mattermost-k8s/docs/tutorial-deploy-the-mattermost-charm-for-the-first-time#p-26082-what-youll-do)

* Deploy the [Mattermost k8s charm](https://charmhub.io/mattermost-k8s)
* Integrate with [the PostgreSQL k8s charm](https://charmhub.io/postgresql-k8s).
* Login to Mattermost

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](https://charmhub.io/mattermost-k8s/docs/tutorial-deploy-the-mattermost-charm-for-the-first-time#p-26082-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](https://juju.is/docs/juju/set-up--tear-down-your-test-environment)
* NGINX Ingress Controller. If you’re using [MicroK8s](https://microk8s.io/), this can be done by running the command `microk8s enable ingress`. For more details, see [Addon: Ingress](https://microk8s.io/docs/addon-ingress).

For more information about how to install Juju, see [Get started with Juju](https://juju.is/docs/olm/get-started-with-juju).

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](https://charmhub.io/mattermost-k8s/docs/tutorial-deploy-the-mattermost-charm-for-the-first-time#p-26082-steps)

### [Shell into the Multipass VM](https://charmhub.io/mattermost-k8s/docs/tutorial-deploy-the-mattermost-charm-for-the-first-time#p-26082-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](https://charmhub.io/mattermost-k8s/docs/tutorial-deploy-the-mattermost-charm-for-the-first-time#p-26082-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](https://charmhub.io/mattermost-k8s/docs/tutorial-deploy-the-mattermost-charm-for-the-first-time#p-26082-deploy-the-mattermost-charm)

Since Mattermost requires connections to PostgreSQL, you’ll deploy it too. For more information, see [Charm Architecture](https://charmhub.io/mattermost-k8s/docs/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](https://charmhub.io/mattermost-k8s/docs/tutorial-deploy-the-mattermost-charm-for-the-first-time#p-26082-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](https://charmhub.io/mattermost-k8s/docs/tutorial-deploy-the-mattermost-charm-for-the-first-time#p-26082-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](https://charmhub.io/mattermost-k8s/docs/tutorial-deploy-the-mattermost-charm-for-the-first-time#p-26082-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.

---
