Kubernetes上にmattermostを構築する
本文讲述的内容。
mattermostをkubernetes上に構築する方法のまとめ。
1. githubからmanifestとかを取ってくる
vagrant@vagrant:~$ git clone https://github.com/mattermost/mattermost-docker.git
2. 部署PostgreSQL
vagrant@vagrant:~$ kubectl run postgres --image=postgres:9 \
--env="POSTGRES_PASSWORD=mmuser_password" \
--env="POSTGRES_DB=mattermost" \
--env="POSTGRES_USER=mmuser"
vagrant@vagrant:~$ kubectl expose deployment postgres \
--name=db \
--port 5432 \
--target-port 5432
3. 部署秘密
vagrant@vagrant:~/mattermost-docker/contrib/kubernetes$ kubectl apply -f mattermost.secret.yaml
4. mattermostのdeploymentをdeployする
### manifestの書き方が古いので最新化する
vagrant@vagrant:~/mattermost-docker/contrib/kubernetes$ git diff
diff --git a/contrib/kubernetes/mattermost.deployment.yaml b/contrib/kubernetes/mattermost.deployment.yaml
index 8c14390..20ea85d 100644
--- a/contrib/kubernetes/mattermost.deployment.yaml
+++ b/contrib/kubernetes/mattermost.deployment.yaml
@@ -1,4 +1,4 @@
-apiVersion: extensions/v1beta1
+apiVersion: apps/v1
kind: Deployment
metadata:
name: mattermost-app
@@ -7,7 +7,12 @@ metadata:
tier: app
namespace: default
spec:
- replicas: 1
+ selector:
+ matchLabels:
+ app: mattermost
+ tier: app
+ strategy:
+ type: Recreate
template:
metadata:
name: mattermost-app
### deplyする
vagrant@vagrant:~/mattermost-docker/contrib/kubernetes$ kubectl apply -f mattermost.deployment.yaml
deployment.apps/mattermost-app created
5.mattermostのserviceをdeployする
vagrant@vagrant:~/mattermost-docker/contrib/kubernetes$ kubectl create -f mattermost.svc.yaml
service/mattermost created
vagrant@vagrant:~/mattermost-docker/contrib/kubernetes$ kubectl get svc mattermost
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
mattermost NodePort 10.99.213.175 <none> 80:32383/TCP 38m
vagrant@vagrant:~/mattermost-docker/contrib/kubernetes$