Cloud Commander Example

Example of how to deploy Cloud Commander, nodejs application with persistent storage in kubernetes.

Cloud Commander is a two-panel file manager for web.

How to run

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

Example Screenshot

cloudcmd.yaml

# persistant storage will used to keep data between restarts
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: cloudcmd-storage
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: "100Mi"

---
# deployment is a manager for running container
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: cloudcmd-pv
  labels:
    app: cloudcmd-pv
spec:
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: cloudcmd-pv
    spec:
      containers:
        - name: cloudcmd
          image: coderaiser/cloudcmd:latest-alpine
          env:
            - name: PORT
              value: "3000"
          resources:
            limits: { memory: "150Mi", cpu: "100m" }
          ports:
            - containerPort: 3000
          volumeMounts:
            - name: cloudcmd-pv
              mountPath: /storage
          readinessProbe:
            httpGet:
              path: /
              port: 3000
            initialDelaySeconds: 5
            periodSeconds: 5
      volumes:
        # storage object that we created earlier
        - name: cloudcmd-pv
          persistentVolumeClaim:
            claimName: cloudcmd-storage

---
# service is create internal DNS record for deployment
apiVersion: v1
kind: Service
metadata:
  name: cloudcmd
spec:
  ports:
    - port: 3000
  selector:
    app: cloudcmd-pv

---
# ingress is for handling traffic from outside
# this example will make HTTP and HTTPS endpoints with valid certificate
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: cloudcmd-ingress
  annotations:
    kubernetes.io/ingress.class: "nginx"
    certmanager.k8s.io/cluster-issuer: letsencrypt
spec:
  tls:
    - hosts:
      - myapp.kuber.host
      # domain certificate will be saved in secret called myapp-kuber-host
      secretName: myapp-kuber-host
  rules:
    - host: myapp.kuber.host # application domain name
      http:
        paths:
        - path: /
          backend:
            serviceName: cloudcmd
            servicePort: 3000

Run from command line

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