Rocket.Chat Example

Example of how to deploy Rocket.Chat, nodejs application with persistent storage in kubernetes.

Rocket.Chat is free, unlimited and open source Slack alternative. Replace email, HipChat & Slack with the ultimate team chat software solution.

How to run

  • Save this example to file, e.g rocketchat.yaml
  • Change host names myapp.kuber.host to domain of your namespace (see your domains)
  • Run with kubectl apply -f rocketchat.yaml

Example Screenshot

rocketchat.yaml

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: rocket-storage
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 300Mi

---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: mongodb-storage
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 300Mi

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: mongodb
  labels:
    app: mongodb
spec:
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: mongodb
    spec:
      containers:
        - name: mongodb
          image: mongo:latest
          env:
            - name: MONGO_INITDB_ROOT_USERNAME
              value: root
            - name: MONGO_INITDB_ROOT_PASSWORD
              value: ""
            - name: MONGO_INITDB_DATABASE
              value: rocketchat
          command: ["mongod", "--smallfiles", "--nojournal", "--bind_ip_all"]
          resources:
            limits: { memory: "100Mi", cpu: "100m" }
          ports:
            - containerPort: 27017
          volumeMounts:
            - name: mongodb-storage
              mountPath: /data/db
          readinessProbe:
            exec:
              command:
              - mongo
              - --eval
              - "db.adminCommand('ping')"
            timeoutSeconds: 5
      volumes:
      - name: mongodb-storage
        persistentVolumeClaim:
          claimName: mongodb-storage

---
apiVersion: v1
kind: Service
metadata:
  name: mongodb
spec:
  type: LoadBalancer
  selector:
    app: mongodb
  ports:
    - port: 27017

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: rocket-chat
  labels:
    app: rocket-chat
spec:
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: rocket-chat
    spec:
      containers:
        - name: rocket-chat
          image: rocket.chat:latest
          env:
            - name: PORT
              value: "3000"
            - name: MONGO_URL
              value: mongodb://root@mongodb:27017/rocketchat
            - name: ROOT_URL
              value: https://myapp.kuber.host
            - name: INSTANCE_IP
              valueFrom:
                fieldRef:
                  fieldPath: status.podIP
          resources:
            requests: { memory: "190Mi", cpu: "190m" }
            limits: { memory: "600Mi", cpu: "190m" }
          ports:
            - containerPort: 3000
          volumeMounts:
          - name: rocket-storage
            mountPath: /app/uploads
          readinessProbe:
            httpGet:
              path: /
              port: 3000
            initialDelaySeconds: 5
            timeoutSeconds: 5
            periodSeconds: 15
      volumes:
      - name: rocket-storage
        persistentVolumeClaim:
          claimName: rocket-storage

---
apiVersion: v1
kind: Service
metadata:
  name: rocket-chat
spec:
  ports:
    - port: 3000
  selector:
    app: rocket-chat

---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: rocket-chat-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    certmanager.k8s.io/cluster-issuer: letsencrypt
spec:
  tls:
    - hosts:
      - myapp.kuber.host
      secretName: myapp-kuber-host
  rules:
  - host: myapp.kuber.host
    http:
      paths:
      - path: /
        backend:
          serviceName: rocket-chat
          servicePort: 3000

Run from command line

kubectl apply -f https://kuber.host/docs/examples/rocketchat.yaml