Difference between revisions of "Chat"

From Fixme.ch
Jump to: navigation, search
(Upgrade)
(Mattermost (Current))
 
(20 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
* Initial goal was to get out of slack
 
* Initial goal was to get out of slack
 
* The other goal is to have a userfriendly chat, better than IRC (which still have its use cases of course)
 
* The other goal is to have a userfriendly chat, better than IRC (which still have its use cases of course)
 +
 +
[[File:Team chat.png]]
  
 
== Component  ==
 
== Component  ==
 
* Mattermost: http://www.mattermost.org/
 
* Mattermost: http://www.mattermost.org/
 
* Bot: https://hubot.github.com/
 
* Bot: https://hubot.github.com/
* Hosted on an Openstack cloud instance
+
* <s>Hosted on an Openstack cloud instance</s>
 +
* Hosted in [[Bellatrix]] on Kubernetes
  
 
== Upgrade ==
 
== Upgrade ==
 +
 +
=== Mattermost (Current) ===
 +
 +
IMPORTANT: Read the update notes before https://docs.mattermost.com/upgrade/important-upgrade-notes.html
  
 
<pre>
 
<pre>
ssh root@chat.fixme.ch
+
ssh ubunut@k8s.fixme.ch
systemctl stop mattermost
+
autopostgresqlbackup
+
ls -l /var/lib/autopostgresqlbackup/daily/mattermost/
+
  
su - chat
+
# Backup
# Download the TEAM edition (not the enterprise version) from http://about.mattermost.com/download/
+
ubuntu@k8s:~$ sudo rsync --exclude=data/ -av /srv/chat.fixme.ch/ /root/backup-chat-$(date +'%Y-%m-%d')/
VERSION=3.6.2
+
OLDVERSION=$(/home/chat/mattermost/bin/platform version 2>&1 | head -n 1 | awk '{print $2}')
+
wget https://releases.mattermost.com/$VERSION/mattermost-team-$VERSION-linux-amd64.tar.gz
+
mv mattermost mattermost-$OLDVERSION
+
tar xvf mattermost-team-$VERSION-linux-amd64.tar.gz
+
rsync -a ./mattermost-$OLDVERSION/config/ ./mattermost/config/
+
exit
+
  
setcap cap_net_bind_service=+ep /home/chat/mattermost/bin/platform
+
# Upgrade
systemctl start mattermost
+
ubuntu@k8s:~$ sudo docker pull mattermost/mattermost-prod-app:5.9.8
tail -F /home/chat/mattermost/logs/mattermost.log
+
ubuntu@k8s:~$ kubectl -n mattermost edit deployment.apps/mattermost-app
 +
 
 +
# Update the image tag to be to the last version (not latest!), ex:
 +
# image: mattermost/mattermost-prod-app:5.8.0
 +
# image: mattermost/mattermost-prod-app:5.9.8
 +
# save/quit
 +
 
 +
# Watch the pods being restarted
 +
 
 +
ubuntu@k8s:~$ kubectl get pods -n mattermost -w
 +
NAME                            READY  STATUS    RESTARTS  AGE
 +
mattermost-app-b68b5cdb-5jlhj    1/1    Running  5          308d
 +
postgresql-db-59ffdffd84-klkw2  1/1    Running  4          466d
 +
 
 +
# Watch the logs of the newly created pod
 +
ubuntu@k8s:~$ kubectl logs -n mattermost -f mattermost-app-b68b5cdb-5jlhj
 
</pre>
 
</pre>
 +
 +
=== PostgreSQL ===
 +
 +
Example d'update de postgresql
 +
 +
Creation d'un nouveau deployment avec la nouvelle version, en parallèle de l'actuelle dans objects.yaml
 +
<pre>
 +
apiVersion: v1
 +
kind: PersistentVolume
 +
metadata:
 +
  labels:
 +
    type: local
 +
  name: mattermost-postgresql-10
 +
  namespace: mattermost
 +
spec:
 +
  accessModes:
 +
  - ReadWriteOnce
 +
  capacity:
 +
    storage: 20Gi
 +
  hostPath:
 +
    path: /srv/chat.fixme.ch/postgresql-10
 +
 +
apiVersion: v1
 +
kind: PersistentVolumeClaim
 +
metadata:
 +
  name: mattermost-postgresql-10
 +
  namespace: mattermost
 +
spec:
 +
  accessModes:
 +
  - ReadWriteOnce
 +
  resources:
 +
    requests:
 +
      storage: 20Gi
 +
 +
apiVersion: apps/v1
 +
kind: Deployment
 +
metadata:
 +
  labels:
 +
    app: mattermost
 +
    tier: db
 +
  name: postgresql-10-db
 +
  namespace: mattermost
 +
spec:
 +
  replicas: 1
 +
  selector:
 +
    matchLabels:
 +
      app: mattermost
 +
      tier: db
 +
  template:
 +
    metadata:
 +
      creationTimestamp: null
 +
      labels:
 +
        app: mattermost
 +
        tier: db
 +
      name: mattermost-10-db
 +
    spec:
 +
      containers:
 +
      - image: postgres:10.16
 +
        imagePullPolicy: IfNotPresent
 +
        name: postgresql-10-db
 +
        ports:
 +
        - containerPort: 5432
 +
          protocol: TCP
 +
        resources: {}
 +
        terminationMessagePath: /dev/termination-log
 +
        terminationMessagePolicy: File
 +
        volumeMounts:
 +
        - mountPath: /var/lib/postgresql/data
 +
          name: db
 +
        env:
 +
        - name: POSTGRES_PASSWORD
 +
          valueFrom:
 +
            secretKeyRef:
 +
              key: db-root
 +
              name: mattermost.env
 +
      dnsPolicy: ClusterFirst
 +
      restartPolicy: Always
 +
      schedulerName: default-scheduler
 +
      securityContext: {}
 +
      terminationGracePeriodSeconds: 30
 +
      volumes:
 +
      - name: db
 +
        persistentVolumeClaim:
 +
          claimName: mattermost-postgresql-10
 +
</pre>
 +
 +
Creation des objets, backup de l'ancienne db et import dans la nouvelle
 +
<pre>
 +
mkdir /srv/chat.fixme.ch/postgresql-10
 +
kubectl create -n mattermost objects.yaml
 +
sudo docker exec k8s_postgresql-db_postgresql-db-59ffdffd84-pb2pg_mattermost_87151477-a5bf-11eb-bde2-525400731ac9_0 pg_dumpall -U postgres > dump-9.4.sql
 +
sudo cp dump-9.4.sql /srv/chat.fixme.ch/postgresql-10/.
 +
sudo docker exec -it k8s_postgresql-10-db_postgresql-10-db-558644f4fd-6g5lw_mattermost_bb97a762-a5c5-11eb-bde2-525400731ac9_0 /bin/bash
 +
pgsql -U postgres < /var/lib/postgresql/data/dump-9.4.sql
 +
</pre>
 +
 +
A terminer:
 +
- switch vers la nouvelle version
  
 
== Channel naming convention ==
 
== Channel naming convention ==

Latest revision as of 22:48, 3 December 2021

Description

Goal

  • Initial goal was to get out of slack
  • The other goal is to have a userfriendly chat, better than IRC (which still have its use cases of course)

Team chat.png

Component

Upgrade

Mattermost (Current)

IMPORTANT: Read the update notes before https://docs.mattermost.com/upgrade/important-upgrade-notes.html

ssh ubunut@k8s.fixme.ch

# Backup
ubuntu@k8s:~$ sudo rsync --exclude=data/ -av /srv/chat.fixme.ch/ /root/backup-chat-$(date +'%Y-%m-%d')/

# Upgrade
ubuntu@k8s:~$ sudo docker pull mattermost/mattermost-prod-app:5.9.8
ubuntu@k8s:~$ kubectl -n mattermost edit deployment.apps/mattermost-app

# Update the image tag to be to the last version (not latest!), ex:
# image: mattermost/mattermost-prod-app:5.8.0
# image: mattermost/mattermost-prod-app:5.9.8
# save/quit

# Watch the pods being restarted

ubuntu@k8s:~$ kubectl get pods -n mattermost -w
NAME                             READY   STATUS    RESTARTS   AGE
mattermost-app-b68b5cdb-5jlhj    1/1     Running   5          308d
postgresql-db-59ffdffd84-klkw2   1/1     Running   4          466d

# Watch the logs of the newly created pod
ubuntu@k8s:~$ kubectl logs -n mattermost -f mattermost-app-b68b5cdb-5jlhj

PostgreSQL

Example d'update de postgresql

Creation d'un nouveau deployment avec la nouvelle version, en parallèle de l'actuelle dans objects.yaml

apiVersion: v1
kind: PersistentVolume
metadata:
  labels:
    type: local
  name: mattermost-postgresql-10
  namespace: mattermost
spec:
  accessModes:
  - ReadWriteOnce
  capacity:
    storage: 20Gi
  hostPath:
    path: /srv/chat.fixme.ch/postgresql-10

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mattermost-postgresql-10
  namespace: mattermost
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: mattermost
    tier: db
  name: postgresql-10-db
  namespace: mattermost
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mattermost
      tier: db
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: mattermost
        tier: db
      name: mattermost-10-db
    spec:
      containers:
      - image: postgres:10.16
        imagePullPolicy: IfNotPresent
        name: postgresql-10-db
        ports:
        - containerPort: 5432
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
        volumeMounts:
        - mountPath: /var/lib/postgresql/data
          name: db
        env:
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              key: db-root
              name: mattermost.env
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - name: db
        persistentVolumeClaim:
          claimName: mattermost-postgresql-10

Creation des objets, backup de l'ancienne db et import dans la nouvelle

mkdir /srv/chat.fixme.ch/postgresql-10
kubectl create -n mattermost objects.yaml
sudo docker exec k8s_postgresql-db_postgresql-db-59ffdffd84-pb2pg_mattermost_87151477-a5bf-11eb-bde2-525400731ac9_0 pg_dumpall -U postgres > dump-9.4.sql
sudo cp dump-9.4.sql /srv/chat.fixme.ch/postgresql-10/.
sudo docker exec -it k8s_postgresql-10-db_postgresql-10-db-558644f4fd-6g5lw_mattermost_bb97a762-a5c5-11eb-bde2-525400731ac9_0 /bin/bash
pgsql -U postgres < /var/lib/postgresql/data/dump-9.4.sql

A terminer: - switch vers la nouvelle version

Channel naming convention

  • 10_* = general/association
  • 20_* = events
  • 30_* = projects/topics
  • 40_* = other
  • 99_* = archived channels

Participants