cerc-io / stack-orchestrator

Read-only mirror of https://git.vdb.to/cerc-io/stack-orchestrator
https://git.vdb.to/cerc-io/stack-orchestrator
GNU Affero General Public License v3.0
20 stars 12 forks source link

Add ConfigMap support for k8s. #714

Closed telackey closed 5 months ago

telackey commented 5 months ago

Adds support for read-only ConfigMap-based volumes to be used with k8s deployments. This provides us a simple mechanism for supplying configuration files in remote k8s deployments. A regular volume will not do in that case, because we cannot bind to a host directory and any brand-new volume will be provisioned empty.

Note; An important limitation of ConfigMap volumes is that they only support files in a single directory. They do not descend recursively through the source directory.

The current mechanism for determining if a volume, as defined in a compose file, should be considered a ConfigMap rather than a regular volume is:

  1. Is the deploy-to type k8s or k8s-kind?
  2. And is the volume marked read-only (ro) everywhere it is used?
  3. And does it have "config" in its name?

If all are the above are true, it is placed in the spec file under the configmaps heading rather than volumes:

stack: package-registry
deploy-to: k8s
kube-config: /home/telackey/.kube/config-desktop
image-registry: localhost:5000
network:
  ports:
    server:
     - 3000
    runner:
     - '8088'
volumes:
  gitea-data: ./data/gitea-data
  postgres-data: ./data/postgres-data
  act-runner-data: ./data/act-runner-data
configmaps:
  act-runner-config: ./data/act-runner-config
❯ k get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                              STORAGECLASS   REASON   AGE
laconic-c69373e24c18fd31-act-runner-data   2Gi        RWO            Retain           Bound    default/laconic-c69373e24c18fd31-act-runner-data   manual                  11m
laconic-c69373e24c18fd31-gitea-data        2Gi        RWO            Retain           Bound    default/laconic-c69373e24c18fd31-gitea-data        manual                  11m
laconic-c69373e24c18fd31-postgres-data     2Gi        RWO            Retain           Bound    default/laconic-c69373e24c18fd31-postgres-data     manual                  11m
❯ k get cm
NAME                                         DATA   AGE
kube-root-ca.crt                             1      4d1h
laconic-c69373e24c18fd31-act-runner-config   1      11m