discourse 安装_如何使用Discourse在半天之内建立内部团队论坛
discourse 安裝
by Ben Cheng
通過本誠
如何使用Discourse在半天之內建立內部團隊論壇 (How to set up an internal team forum in half a day using Discourse)
TL;DR: I’ve deployed Discourse on Kubernetes (K8s) for my company’s internal discussion platform. Because I couldn’t find a simple tutorial, I documented my steps to help other developers do it too.
TL; DR:我已經在公司內部討論平臺的Kubernetes(K8s)上部署了Discourse 。 因為找不到簡單的教程,所以我記錄了我的步驟以幫助其他開發人員也這樣做。
我為什么要在Kubernetes上部署Discourse? (Why would I want to deploy Discourse on Kubernetes?)
本教程快速概述 (A quick overview of this tutorial)
The tutorial and the sample config below shows how to deploy a single Discourse web-server. This server needs to connect to a PostgreSQL and Redis server. We are using Google Cloud Registry and gcePersistentDisk for storage. So let's begin:
下面的教程和示例配置顯示了如何部署單個Discourse Web服務器 。 該服務器需要連接到PostgreSQL和Redis服務器 。 我們正在使用Google Cloud Registry和gcePersistentDisk進行存儲。 因此,讓我們開始:
創建Discourse應用程序Docker映像 (Create Discourse app Docker image)
We will “misuse” the launcher provided by discourse_docker to create the docker image for the Discourse web server. And by “misuse” I mean that we have over-used the launcher script to create docker images for production use.
我們將“濫用” discourse_docker提供的啟動器,以為Discourse Web服務器創建docker映像。 “濫用”是指我們過度使用了啟動程序腳本來創建用于生產的docker映像。
1. Clone from https://github.com/discourse/discourse_docker to your local environment.
1.從https://github.com/discourse/discourse_docker克隆到您的本地環境。
2. Setup a temporary Redis server and PostgresSQL database in the local environment.
2.在本地環境中設置一個臨時的Redis服務器和PostgresSQL數據庫 。
3. Create a containers/web_only.yml (as shown below)
3.創建一個containers/web_only.yml (如下所示)
- The env var is not relevant to K8s. It’s just for building the local image, so let’s fill in something that works for your local environment. env var與K8無關。 它僅用于構建本地圖像,因此讓我們填寫適用于您本地環境的內容。
- Determine the plugins you want to install with your Discourse setting here. 在此處使用“話語”設置確定要安裝的插件。
4. Tip: The local Redis instances might be in protected-mode, and won’t allow a Docker guest to host the connection. For this case, you should start your Redis server with the protected-mode turned off: redis-server --protected-mode no
4。 提示 :本地Redis實例可能處于保護模式,并且不允許Docker guest虛擬機托管連接。 在這種情況下,應在關閉保護模式的情況下啟動Redis服務器: redis-server --protected-mode no
5. Create the Docker images and upload the images to your K8s Docker registry. In this case, we are using Google Cloud Registry:
5.創建Docker映像并將映像上傳到您的K8s Docker注冊表。 在這種情況下,我們使用的是Google Cloud Registry:
Create Docker image with Discourse’s launcher: ./launcher bootstrap web_only
使用Discourse的啟動器創建Docker映像: ./launcher bootstrap web_only
Verify that the image is created: docker images. You should see the Discourse image in the list if successful.
確認已創建映像: docker images 。 如果成功,您應該在列表中看到“話語”圖像。
- Upload the image to the registry with this command: 使用以下命令將圖像上傳到注冊表:
Sample config in web_only.yml :
web_only.yml示例配置:
現在我們準備部署到K8 (Now we’re ready to deploy to K8s)
1. Prepare a persistent volume
1.準備一個持久卷
We will need a persistent volume as the database to store the user info and the discussion items. We are using GCEPersistentDisk for the persistent disk on the K8s cluster. Now, let’s create two 10GB disks for the app and database respectively. You may consider your Discourse usage to adjust the disk size configuration.
我們將需要一個永久卷作為數據庫來存儲用戶信息和討論項。 我們正在將GCEPersististentDisk用于K8s集群上的永久磁盤。 現在,讓我們分別為應用程序和數據庫創建兩個10GB磁盤。 您可以考慮使用Discourse來調整磁盤大小配置。
2. Deploy to Kubernetes
2.部署到Kubernetes
Next, we will configure the deployment settings of the K8s cloud. Customize the sample K8s file. Here are some variables you probably want to tweak:
接下來,我們將配置K8s云的部署設置。 自定義示例K8s文件。 以下是您可能需要調整的一些變量:
volumes.yaml
volumes.yaml
For both persistent volumes:
對于兩個持久卷:
- metadata.name
-元數據名稱
- spec.capacity.storage
-規格容量存儲
- spec.gcePersistentDisk.pdName (for the persistent disk name above)
-spec.gcePersistentDisk.pdName(用于上面的永久磁盤名稱)
- spec.claimRef.namespace (for the namespace you’re using in K8s)
-spec.claimRef.namespace(用于您在K8s中使用的名稱空間)
The sample file here assumes you are using gcePersistentDisk. volumes.yaml needs to change heavily depending on what type of persistent disk you plan to use.
這里的樣本文件假定您正在使用gcePersistentDisk 。 volume.yaml需要根據計劃使用的永久磁盤類型進行大量更改。
redis.yaml
redis.yaml
Redis Deployment:
Redis部署:
- spec.template.spec.containers.resources.* (CPU and Memory resources for cache server)
-spec.template.spec.containers.resources。*(高速緩存服務器的CPU和內存資源)
pgsql.yaml
pgsql.yaml
PersistentVolumeClaim (pgsql-pv-claim):
PersistentVolumeClaim( pgsql-pv-claim ):
-
--
spec.resources.requests.storage (storage of DB server)
spec.resources.requests.storage (數據庫服務器的存儲)
discourse.yaml
discourse.yaml
PersistentVolumeClaim (discourse-pv-claim)
PersistentVolumeClaim( discourse-pv-claim )
- spec.resources.requests.storage (storage of web-server disk for logs and backups)
-spec.resources.requests.storage(用于記錄和備份的Web服務器磁盤的存儲)
Deployment (web-server)
部署( web-server )
-
--
spec.template.spec.containers.image (Set the URL to point to your Docker image)
spec.template.spec.containers.image (設置URL指向您的Docker映像)
-
--
spec.template.spec.containers.env
spec.template.spec.containers.env
DISCOURSE_DEVELOPER_EMAILS
DISCOURSE_DEVELOPER_EMAILS
DISCOURSE_DEVELOPER_EMAILSDISCOURSE_HOSTNAME
DISCOURSE_DEVELOPER_EMAILS DISCOURSE_HOSTNAME
DISCOURSE_DEVELOPER_EMAILSDISCOURSE_HOSTNAMEDISCOURSE_SMTP_ADDRESS
DISCOURSE_DEVELOPER_EMAILS DISCOURSE_HOSTNAME DISCOURSE_SMTP_ADDRESS
DISCOURSE_DEVELOPER_EMAILSDISCOURSE_HOSTNAMEDISCOURSE_SMTP_ADDRESSDISCOURSE_SMTP_PORT
DISCOURSE_DEVELOPER_EMAILS DISCOURSE_HOSTNAME DISCOURSE_SMTP_ADDRESS DISCOURSE_SMTP_PORT
- spec.template.spec.containers.resources.* (CPU and Memory resources for your web-server)
-spec.template.spec.containers.resources。*(Web服務器的CPU和內存資源)
ingress.yaml
ingress.yaml
spec.rules.host
spec.rules.host
spec.tls.hosts
spec.tls.hosts
Recommended: From there, you might want to create your own namespace for the deployment. Also assume you have set the right context to run the kubectl command in the namespace. (For details, read Kubernetes documentation). Otherwise, you should rename most of the names in the config files above to unique names and add some labels. Apply secrets. dbUsername and dbPassword can be anything you want. Please set the right smtpUsername and smtpPassword for the mail delivery services you use. Another note on HTTPS for Ingress: you should read this document and the Ingress controllers specific to your cluster and update ingress.yaml accordingly.
推薦:從那里,您可能要為部署創建自己的名稱空間。 還要假設您設置了正確的上下文以在名稱空間中運行kubectl命令。 (有關詳細信息,請閱讀Kubernetes文檔 )。 否則,您應該將上述配置文件中的大多數名稱重命名為唯一名稱,并添加一些標簽。 應用秘密。 dbUsername和dbPassword可以是您想要的任何內容。 請為您使用的郵件傳遞服務設置正確的smtpUsername和smtpPassword 。 關于HTTPS for Ingress的另一個說明:您應該閱讀本文檔以及特定于集群的Ingress控制器,并相應地更新ingress.yaml 。
Apply all config files:
應用所有配置文件:
Before starting the app, run the following on PostgreSQL instance to initialize the database properly. You can find your pod name by running kubectl get pods.
在啟動應用程序之前,請在PostgreSQL實例上運行以下命令以正確初始化數據庫。 您可以通過運行kubectl get pods來找到您的pod名稱。
Create Discourse deployment and Ingress with these commands:
使用以下命令創建Discourse部署和Ingress:
From here, your Discourse instance should be up and running. Below are some useful commands in case things don't work and require debugging:
從這里開始,您的Discourse實例應已啟動并正在運行。 以下是一些有用的命令,以防萬一無法正常工作并需要調試:
設置S3備份和文件上傳 (Setup S3 backup and file upload)
Discourse can use AWS S3 for backup and file upload. Here are the steps to enable it:
Discourse可以使用AWS S3進行備份和文件上傳。 以下是啟用它的步驟:
1. Create two S3 buckets: one for backup and one for file upload. Set them as private.
1.創建兩個S3存儲桶:一個用于備份,一個用于文件上傳。 將它們設置為私人。
2. Create an IAM user with API access only and attach the AWS inline policy below:
2.創建僅具有API訪問權限的IAM用戶,并在下面附加AWS嵌入式策略:
3. Fill in the Access Key and Key ID in Discourse Setting.
3.在“ 話語設置”中填寫訪問密鑰和密鑰ID。
Then Discourse can upload files to the S3 bucket you’ve specified, so you can attach image and file attachments in each post.
然后Discourse可以將文件上傳到您指定的S3存儲桶中,因此您可以在每個帖子中附加圖像和文件附件。
而已! (That’s it!)
I hope this piece is helpful for you to set up your own Discourse platform. It’s also a practical exercise for me to try deploying an app on K8s.
希望本文對您建立自己的Discourse平臺有所幫助。 對我來說,嘗試在K8s上部署應用程序也是一種實踐練習。
潛在的改進和擴大規模: (Potential improvement and scaling up:)
- It’s possible to run multiple replicas for Discourse web-server for scaling up. It should work, but I haven’t tried yet. 可以為Discourse Web服務器運行多個副本以進行擴展。 它應該可以工作,但是我還沒有嘗試過。
We could also deploy Primary-Replica PostgreSQL for scaling up. We’re using Bitnami’s PostgreSQL docker image and you can read the relevant instructions here.
我們還可以部署Primary-Replica PostgreSQL以進行擴展。 我們正在使用Bitnami的PostgreSQL docker鏡像,您可以在此處閱讀相關說明。
Building an app? Our free developer tools and open source backend will make your job easier.
建立應用程式? 我們免費的開發人員工具和開源后端將使您的工作更加輕松。
翻譯自: https://www.freecodecamp.org/news/how-to-set-up-an-internal-team-forum-in-half-a-day-using-discourse-b13588d907fe/
discourse 安裝
總結
以上是生活随笔為你收集整理的discourse 安装_如何使用Discourse在半天之内建立内部团队论坛的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 联想微型计算机c365,联想C365一体
- 下一篇: 微信小程序---授权保存图片或视频,拒绝