Try out Mattermost on Minikube in Less Than 5 Minutes
Want to try out Mattermost, but don’t have sufficient infrastructure or the time? Here is a guide on how to deploy Mattermost using minikube in five minutes.
Pre-requisites
You’ll need to do the following four things before starting off with minikube:
- Enable virtualization in your BIOS. Note that every installation may have a different approach for this.
- Install minikube.
- Install a supported driver from the minikube site. I used VirtualBox.
- Install helm using the supported install method.
Create your own minikube Cluster
In this step, we’ll create a minikube cluster in order to have a local Kubernetes installation, and enable ingress on it (so we can access Mattermost later).
minikube start --driver=virtualbox --kubernetes-version 1.23.10 --cpus=6
minikube addons enable ingress
Create your own Mattermost instance
For this process, we have a few steps to accomplish. Please note that this setup process is used for demonstration purposes only and shouldn’t be used in a production environment
1. Create a new mattermost-operator namespace.
minikube kubectl create ns mattermost-operator
2. Create a custom values file for helm and save it as values.yaml. Replace <my-hostname> with the desired name that we’ll access later via a browser.
# Default values for mattermost-operator.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
# The values below are for mattermost Custom Resource
# Full spec example can be found here: https://github.com/mattermost/mattermost-operator/blob/master/docs/examples/mattermost_full.yaml
# Examples for mattermost spec can be found here: https://github.com/mattermost/mattermost-operator/tree/master/docs/examples
# Enable the database, file storage operatorManaged below to run with in cluster database and file storage (not recommended for production scenario).
mattermostCR:
enabled: true
name: mattermost-example
spec:
version: 7.2.0
replicas: 1
ingress:
enabled: true
host:
database:
operatorManaged: # Operator managed database allows configuration of replicas, storage size and resource requirements. If the `size` is specified, it will override those values.
replicas: 1
resources:
requests:
cpu: 250m
memory: 512Mi
storageSize: 20Gi
type: mysql
fileStore:
operatorManaged: # Operator managed file store allows configuration of replicas, storage size and resource requirements. If the `size` is specified, it will override those values.
replicas: 1
resources:
requests:
cpu: 150m
memory: 512Mi
storageSize: 20Gi
# The values below are for the mattermost operator
mattermostOperator:
enabled: true
replicas: 1
rbac:
create: true
serviceAccount:
create: true
env:
maxReconcilingInstallations: 20
requeuOnLimitDelay: 20s
image:
repository: mattermost/mattermost-operator
tag: v1.18.0
pullPolicy: IfNotPresent
args:
- --enable-leader-election
## Specify image pull secret for private repository
##
privateRegistry:
enabled: false
imagePullSecret:
### IMPORTANT: Below operators should be deployed separately in production environments. ###
minioOperator:
enabled: true
replicas: 1
appName: minio
namespace: minio-operator
rbac:
create: true
serviceAccount:
create: true
image:
repository: minio/k8s-operator
tag: 1.0.7
pullPolicy: IfNotPresent
mysqlOperator:
enabled: true
replicas: 1
appName: mysql
namespace: mysql-operator
rbac:
create: true
serviceAccount:
create: true
image:
repository: quay.io/presslabs/mysql-operator
tag: 0.4.0
pullPolicy: IfNotPresent
## Configuration for Mysql operator fs group
##
fsGroup: 777
## Configuration for Mysql operator extra args
##
extraArgs: []
## Configuration for Mysql operator service
##
service:
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
## Configuration for Mysql operator statefulset
##
statefulSet:
annotations:
checksum/config: 4b7db0b6281fab87fd1fe282fa4f2f521dbcb5a9486a7589396701e825a9fbb9
checksum/secret: cf656f56e9efe9eaab93bc378aa1783d4ac5585ec82b5a5f5380c1c228cb5f02
## Configuration for Mysql operator sidecar
##
sidecar:
image:
repository: quay.io/presslabs/mysql-operator-sidecar
tag: 0.4.0
## Configuration for Probes
##
readinessProbeTimeout: 10
readinessProbeInitialDelay: 0
livenessProbeTimeout: 10
livenessProbeInitialDelay: 200
## Configuration for Mysql operator orchestrator
##
orchestrator:
config:
ApplyMySQLPromotionAfterMasterFailover: false
Debug: false
BackendDB: sqlite
DetachLostReplicasAfterMasterFailover: true
DetectClusterAliasQuery: "SELECT CONCAT(SUBSTRING(@@hostname, 1, LENGTH(@@hostname) - 1 - LENGTH(SUBSTRING_INDEX(@@hostname,'-',-2))),'.',SUBSTRING_INDEX(@@report_host,'.',-1))"
DetectInstanceAliasQuery: "SELECT @@hostname"
DiscoverByShowSlaveHosts: false
FailMasterPromotionIfSQLThreadNotUpToDate: true
HTTPAdvertise: "https://{{ .Env.HOSTNAME }}-svc:80"
HostnameResolveMethod: none
InstancePollSeconds: 5
ListenAddress: ":3000"
MasterFailoverDetachReplicaMasterHost: true
MySQLHostnameResolveMethod: "@@report_host"
MySQLTopologyCredentialsConfigFile: "/etc/orchestrator/orc-topology.cnf"
ProcessesShellCommand: "sh"
RecoverMasterClusterFilters: ['.*']
RecoverIntermediateMasterClusterFilters: ['.*']
RecoveryPeriodBlockSeconds: 300
RemoveTextFromHostnameDisplay: ":3306"
RecoveryIgnoreHostnameFilters: []
RaftNodes: []
SQLite3DataFile: "/var/lib/orchestrator/orc.db"
SlaveLagQuery: "SELECT TIMESTAMPDIFF(SECOND,ts,NOW()) as drift FROM sys_operator.heartbeat ORDER BY drift ASC LIMIT 1"
UnseenInstanceForgetHours: 1
OnFailureDetectionProcesses:
- "/usr/local/bin/orc-helper event -w '{failureClusterAlias}' 'OrcFailureDetection' 'Failure: {failureType}, failed host: {failedHost}, lost replcas: {lostReplicas}' || true"
- "/usr/local/bin/orc-helper failover-in-progress '{failureClusterAlias}' '{failureDescription}' || true"
PostIntermediateMasterFailoverProcesses:
- "/usr/local/bin/orc-helper event '{failureClusterAlias}' 'OrcPostIntermediateMasterFailover' 'Failure type: {failureType}, failed hosts: {failedHost}, slaves: {countSlaves}' || true"
PostMasterFailoverProcesses:
- "/usr/local/bin/orc-helper event '{failureClusterAlias}' 'OrcPostMasterFailover' 'Failure type: {failureType}, new master: {successorHost}, slaves: {slaveHosts}' || true"
PostUnsuccessfulFailoverProcesses:
- "/usr/local/bin/orc-helper event -w '{failureClusterAlias}' 'OrcPostUnsuccessfulFailover' 'Failure: {failureType}, failed host: {failedHost} with {countSlaves} slaves' || true"
PreFailoverProcesses:
# as backup in case the first request fails
- "/usr/local/bin/orc-helper failover-in-progress '{failureClusterAlias}' '{failureDescription}' || true"
image:
repository: quay.io/presslabs/mysql-operator-orchestrator
tag: 0.4.0
pullPolicy: IfNotPresent
## Configuration for Mysql operator persistent volume
##
persistentVolume:
accessModes: [ReadWriteOnce]
size: 10Gi
topology:
user: "b3JjaGVzdHJhdG9y"
password: "Nnc2NHBhaGJzUA=="
3. Add a Mattermost Helm chart repository.
helm repo add mattermost https://helm.mattermost.com
helm repo update
4. Install Mattermost using the mattermost-operator, mysql-operator and minio-operator with Helm.
helm install mattermost -n mattermost-operator -f values.yaml mattermost/mattermost-operator
5. Wait for the pods to spin up. You can press CTRL+C to exit the command at any time.
minikube kubectl get pods -n mattermost-operator -w
After a few minutes (depending on internet speed and hardware) you should be able to see the following result.
6. Retrieve the IP address and add it to your local host file.
(linux) echo "$(minikube kubectl get endpoints kubernetes -ojsonpath={.subsets[0].addresses[0].ip}) " > /etc/hosts
(windows) edit the C:\windows\system32\drivers\etc\hosts and paste the ip address with the relavent hostname
(retrieve ip address of the cluster) minikube kubectl get endpoints kubernetes -ojsonpath={.subsets[0].addresses[0].ip}
7. Access the <hostname> with a web browser and view your freshly installed Mattermost instance.
8. When you’re done testing your Mattermost instance, you can delete the cluster with a single command.
minikube delete
Try Mattermost on minikube
Ready to try it out for yourself? Grab a cup of coffee and head to our deployment page for everything you need to get started with Mattermost on minikube — you’ll be up and running before your drink is cool.
This post was adapted from its original version on Medium.