802 字
4 分钟
helm 架设 mattermost 踩坑

工作#

却说社畜以来,做了兼职 半吊子 运维,用 k8s 部署些前后端。现在疫情影响,大家广泛应用远程办公工具,这公务交流显然要用专业工具。先前试用 slack,但毕竟在美帝受墙干扰,且免费版限制多,于是决定切换到自架 mattermost

matternost#

Mattermost is a flexible, open source messaging platform that enables secure team collaboration

根据官网 吹逼 宣传,mattermost 是个开源的团队交流工具,看 UI 也和 slack 相近,用起来应该没有问题,甚至还用中文。注意到还有 helm 版 。有了这个可部署方便多了

踩坑#

于是按照文档开始部署,坑就来了。

1. toyaml error#

首先按所需变量一填,没想到报 toYaml error。原本以为 github 撞墙,下回来 tgz 在🐧☁️上开 darkhttpd ,没想到不是这个问题。没办法看下 yaml,原来是 resource 要填。原以为是 mattermost 的变量,没想到是 k8s 的 resource。以前创的时候用🐧☁️图形化没注意到😓

2. pod has unbound PersistentVolumeClaims#

填上 resource 后接着来,这下没报错了。跑去集群一看,没启动起来,报pod has unbound PersistentVolumeClaims。以为硬盘不够,一看也还有空间。跑去集群——存储看看,没想到🐧☁️开存储最少开 10G,而 mattermost plugins 开 1G。是 1G 开不出来

3. read only file system#

再改配置开 10G,终于跑起来了。想着终于部署完了,进入后台开始配置,一点保存没想到又报错,看 log 发现报open /mattermost/config/config.json: read-only file system。配置是只读,这就没道理。逛下 github issue 发现 mattermost/mattermost-helm#100 有报这个问题,原来 matternost 把配置做 secret 而只读,总不能改个配置就重新部署一下。按照评论使用extraInitContainers把 config.json 拷去 data 空间,就可以读了。

extraInitContainers 使用了一个 alpine 来执行 cp 命令,这些配置

extraInitContainers:
- name: copy-config
image: "alpine:latest"
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /mattermost/config/config.json
name: config-json
subPath: config.json
- mountPath: /mattermost/data
name: mattermost-data
command: ["/bin/ash", "-c", "cp -f /mattermost/config/config.json /mattermost/data/config.json"]
extraEnvVars:
- name: MM_CONFIG
value: "/mattermost/data/config.json"

按🐧☁️ key-value 写显然要命,就得想想用其他方法。这种写作 yaml 最方便,看 helm 可以用 -f 指定文件,按🐧☁️文档 可以用 helm 客户端连进去,于是先开 kubectl 内网访问,后开 helm 连接进去。

4.permission denied#

这次用 yaml 创出来了再去配置又报 open /mattermost/data/config.json: permission denied,我寻思 mattermost 还能对自己 data 空间没权限,再逛逛 issue 发现 mattermost/mattermost-helm#120 使用 busybox 来赋予权限。按照这样先赋权后拷贝,应该就可以有权限更改了。

终章#

经过这些配置后发现在 5.13.2 版本下没问题,估计 tgz 只适配 5.13.2 版本。列出示例配置:

resources:
limits:
cpu: 500m
memory: 1Gi
requests:
cpu: 100m
memory: 512Mi
persistence:
plugins:
size: 10Gi
extraEnvVars:
- name: MM_CONFIG
value: "/mattermost/data/config.json"
extraInitContainers:
- name: set-plugins-owner
command:
- sh
- -c
- chown -R 2000:2000 /mattermost/plugins
- chgrp 2000 /mattermost/plugins
image: busybox:1.29.2
imagePullPolicy: IfNotPresent
resources: {}
securityContext:
privileged: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /mattermost/plugins
name: mattermost-plugins
- name: set-data-owner
command:
- sh
- -c
- chown -R 2000:2000 /mattermost/data
- chgrp 2000 /mattermost/data
image: busybox:1.29.2
imagePullPolicy: IfNotPresent
resources: {}
securityContext:
privileged: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /mattermost/data
name: mattermost-data
- name: copy-config
image: "alpine:latest"
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /mattermost/config/config.json
name: config-json
subPath: config.json
- mountPath: /mattermost/data
name: mattermost-data
command: ["/bin/ash", "-c", "cp -f /mattermost/config/config.json /mattermost/data/config.json"]
helm 架设 mattermost 踩坑
https://blog.ckyol.moe/posts/mattermosthelmpitfalls/
作者
ckyOL
发布于
2020-02-29
许可协议
CC BY-NC-SA 4.0

分享文章

生成精美分享图或复制链接,与更多人分享本文。

继续阅读

沿着主题读

基于共同的标签与分类

换条路线

从其他文章中稳定抽取

评论

正在加载评论...

最后更新于 ,距今已过 2386

部分内容可能已过时