deploy on k8s
namespaces
- displeu-staging
- displeu-prod
(We have set up a dev environment for discourse https://git.fairkom.net/emb/displ.eu/fediverse/discourse/-/blob/main/README.md )
No ready made charts, see hosting/fairapps/portfolio#52 (comment 86679)
Designs
- Show closed items
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Roland Alton changed the description
changed the description
- Author Owner
ChatGPT k8s tutorial
Installing Discourse on Kubernetes using
kubectl
involves several steps, including creating the necessary Kubernetes resources (such as deployments, services, persistent volumes, and configuration secrets). Below is a guide to help you:
1. Prerequisites
- Kubernetes Cluster: Ensure you have a running Kubernetes cluster.
-
kubectl: Make sure you have
kubectl
configured to access your cluster. - PostgreSQL and Redis: Discourse requires a PostgreSQL database and a Redis instance.
- Persistent Storage: You need persistent volumes for Discourse data and its database.
2. Prepare Kubernetes Resources
Create the following resources:
a. Namespace
Create a namespace for Discourse:
apiVersion: v1 kind: Namespace metadata: name: discourse
Apply it:
kubectl apply -f namespace.yaml
b. Secrets
Create secrets for the PostgreSQL database, Redis, and Discourse configuration:
apiVersion: v1 kind: Secret metadata: name: discourse-secrets namespace: discourse type: Opaque data: DISCOURSE_DEVELOPER_EMAILS: <base64-encoded-email> DISCOURSE_SMTP_ADDRESS: <base64-encoded-smtp-address> DISCOURSE_SMTP_PORT: <base64-encoded-port> DISCOURSE_SMTP_USERNAME: <base64-encoded-username> DISCOURSE_SMTP_PASSWORD: <base64-encoded-password>
Replace placeholders and apply:
kubectl apply -f discourse-secrets.yaml
c. PostgreSQL
Use an existing PostgreSQL Helm chart or create a deployment and service:
apiVersion: apps/v1 kind: Deployment metadata: name: postgres namespace: discourse spec: replicas: 1 selector: matchLabels: app: postgres template: metadata: labels: app: postgres spec: containers: - name: postgres image: postgres:13 env: - name: POSTGRES_USER value: discourse - name: POSTGRES_PASSWORD value: discourse - name: POSTGRES_DB value: discourse volumeMounts: - mountPath: /var/lib/postgresql/data name: postgres-data volumes: - name: postgres-data persistentVolumeClaim: claimName: postgres-pvc --- apiVersion: v1 kind: Service metadata: name: postgres namespace: discourse spec: ports: - port: 5432 selector: app: postgres
d. Redis
Similarly, create a deployment and service for Redis:
apiVersion: apps/v1 kind: Deployment metadata: name: redis namespace: discourse spec: replicas: 1 selector: matchLabels: app: redis template: metadata: labels: app: redis spec: containers: - name: redis image: redis:6 ports: - containerPort: 6379 --- apiVersion: v1 kind: Service metadata: name: redis namespace: discourse spec: ports: - port: 6379 selector: app: redis
e. Discourse
Create the deployment and service for Discourse:
apiVersion: apps/v1 kind: Deployment metadata: name: discourse namespace: discourse spec: replicas: 1 selector: matchLabels: app: discourse template: metadata: labels: app: discourse spec: containers: - name: discourse image: discourse/base:2.0.20201221-1730 env: - name: DISCOURSE_DB_HOST value: postgres - name: DISCOURSE_DB_USERNAME value: discourse - name: DISCOURSE_DB_PASSWORD value: discourse - name: DISCOURSE_REDIS_HOST value: redis - name: DISCOURSE_HOSTNAME value: <your-discourse-hostname> volumeMounts: - mountPath: /shared name: discourse-data volumes: - name: discourse-data persistentVolumeClaim: claimName: discourse-pvc --- apiVersion: v1 kind: Service metadata: name: discourse namespace: discourse spec: ports: - port: 80 targetPort: 3000 selector: app: discourse
3. Persistent Volume Claims
Create Persistent Volume Claims (PVCs) for Discourse and PostgreSQL:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: postgres-pvc namespace: discourse spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: discourse-pvc namespace: discourse spec: accessModes: - ReadWriteOnce resources: requests: storage: 20Gi
Apply the PVCs:
kubectl apply -f pvc.yaml
4. Access Discourse
Once all resources are created:
- Use a LoadBalancer or Ingress to expose the Discourse service.
- Configure DNS to point to your Discourse hostname.
Let me know if you need help with specific YAML files or additional guidance!
- Roland Alton marked this issue as related to hosting/fairapps/portfolio#52
marked this issue as related to hosting/fairapps/portfolio#52
- Roland Alton assigned to @jan.krammer
assigned to @jan.krammer
- Author Owner
Domain
forum.displayeurope.eu
has been configured for lb1.I checked the term
forum
, it is used in nearly all European languages, so fits much better thandiscuss
ordiscourse
. - Author Owner
Issue to be continued on https://git.fairkom.net/emb/displ.eu/portal-application/k8s/-/issues/2 - closing this.
- Roland Alton closed
closed