環境
- Kubernetes 1.26
やりたいこと
GROWIの最大の特徴は、マークダウン記法でかけることだ。これにより、シンプルで見やすい文書を簡単に作成できる。
さて、今回の本題は、GROWIをKubernetesにデプロイする方法だ。Kubernetesは、複数のコンテナを管理するオープンソースのシステムであり、スケーラビリティや可用性の高いアプリケーションを構築することができる。
おおよそのひな壇は公式が出しているdocker-compose.yml これをKomposeを使ってk8sの構成ファイルに変換していく。
https://github.com/weseek/growi-docker-compose
Deployment
app-deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: labels: io.kompose.service: app name: app spec: replicas: 1 selector: matchLabels: io.kompose.service: app template: metadata: labels: io.kompose.service: app spec: containers: - image: weseek/growi:6.0.15 name: app ports: - containerPort: 3000 resources: {} imagePullPolicy: IfNotPresent env: - name: ELASTICSEARCH_URI value: http://elasticsearch:9200/growi - name: MONGO_URI value: mongodb://mongo:27017/growi - name: PASSWORD_SEED value: changeme volumes: - name: growi-data persistentVolumeClaim: claimName: growi-data
es-deployment.yaml
apiVersion: apps/v1 kind: Deployment metadata: labels: io.kompose.service: elasticsearch name: elasticsearch spec: replicas: 1 selector: matchLabels: io.kompose.service: elasticsearch template: metadata: labels: io.kompose.service: elasticsearch spec: containers: - image: thr3a/growi-es name: elasticsearch env: - name: ES_JAVA_OPTS value: -Xms512m -Xmx512m - name: LOG4J_FORMAT_MSG_NO_LOOKUPS value: "true" - name: bootstrap.memory_lock value: "true" resources: {} imagePullPolicy: IfNotPresent volumeMounts: - mountPath: /usr/share/elasticsearch/data name: es-data volumes: - name: es-data persistentVolumeClaim: claimName: es-data
mongo-deployment
apiVersion: apps/v1 kind: Deployment metadata: labels: io.kompose.service: mongo name: mongo spec: replicas: 1 selector: matchLabels: io.kompose.service: mongo template: metadata: labels: io.kompose.service: mongo spec: containers: - image: mongo:4.4 name: mongo resources: {} imagePullPolicy: IfNotPresent volumeMounts: - mountPath: /data name: mongo-db volumes: - name: mongo-db persistentVolumeClaim: claimName: mongo-db
PVC
データの永続化が必要なのでPVCを作る。今回はstorageClassNameは「nfs-production」とする
app-pvc.yaml
apiVersion: v1 kind: PersistentVolumeClaim metadata: labels: io.kompose.service: growi-data name: growi-data spec: storageClassName: nfs-production accessModes: - ReadWriteOnce resources: requests: storage: 100G
es-pvc.yaml
apiVersion: v1 kind: PersistentVolumeClaim metadata: labels: io.kompose.service: es-data name: es-data spec: storageClassName: nfs-production accessModes: - ReadWriteOnce resources: requests: storage: 100G
mongo-pvc.yaml
apiVersion: v1 kind: PersistentVolumeClaim metadata: labels: io.kompose.service: mongo-db name: mongo-db spec: storageClassName: nfs-production accessModes: - ReadWriteOnce resources: requests: storage: 10G
ソースコードまとめ
https://github.com/thr3a/kubernetes-manifests/tree/master/argo/growi