Naar de inhoud
imlostincode
ENNL
Deployment kit

symfony-k8s-deployment-kit

The same idea for Symfony apps: one shared deploy setup instead of a copy in every project.

examples / 0.1

overlay-staging/generator/kustomization.yaml.tmpl

Bekijk op GitHub ↗ (opent in een nieuw tabblad)
tmpl
# Per-branch staging kustomization — generated by deploy-staging workflow.
# Placeholders: ${BRANCH_SLUG}, ${COMMIT_SHA}
#
# Two consumption modes:
#
#   A. Cross-repo (template is a public git repo):
#      Resources reference the template by URL.
#
#   B. Single-repo (template is bundled into your fleet repo):
#      Resources reference ../../base (a copy synced by the deploy workflow).
#
# Pick whichever fits your setup and delete the other block.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: zcdb-staging
namePrefix: ${BRANCH_SLUG}-zcdb-

# --- Mode A: pull the template directly from GitHub ---
# resources:
#   - github.com/nickmous/symfony-k8s-deployment-kit//base?ref=v1.0.0
#   - ingress.yaml
#   - certificate.yaml
#   - middlewares.yaml
#   - secrets.yaml
#   - secrets-sops.yaml
# components:
#   - github.com/nickmous/symfony-k8s-deployment-kit//components/postgres?ref=v1.0.0
#   - github.com/nickmous/symfony-k8s-deployment-kit//components/redis?ref=v1.0.0
#   - github.com/nickmous/symfony-k8s-deployment-kit//components/messenger?ref=v1.0.0
#   - github.com/nickmous/symfony-k8s-deployment-kit//components/storage?ref=v1.0.0

# --- Mode B: use the base/components synced into the fleet repo ---
resources:
  - ../../base
  - ingress.yaml
  - certificate.yaml
  - middlewares.yaml
  - secrets.yaml
  - secrets-sops.yaml
components:
  - ../../base/components/postgres
  - ../../base/components/redis
  - ../../base/components/messenger
  - ../../base/components/storage

configurations:
  - kustomizeconfig.yaml

configMapGenerator:
  - name: app-config
    behavior: merge
    literals:
      - DEFAULT_URI=https://${BRANCH_SLUG}.staging.example.com
      - [email protected]
      - POSTGRES_DB=zcdb
      - SENTRY_RELEASE=sha-${COMMIT_SHA}

images:
  - name: app-image
    newName: ghcr.io/nickmous/zcdb
    newTag: sha-${COMMIT_SHA}
  - name: app-nginx-image
    newName: ghcr.io/nickmous/symfony-k8s-deployment-kit
    newTag: nginx-latest

labels:
  - pairs:
      app.kubernetes.io/part-of: zcdb
      app.kubernetes.io/instance: staging-${BRANCH_SLUG}
      branch: ${BRANCH_SLUG}
    includeSelectors: true

patches:
  - path: patches/deployment-patch.yaml
  - path: patches/configmap-patch.yaml

replacements:
  - source: { kind: Service, name: app, fieldPath: metadata.name }
    targets:
      - select: { kind: ConfigMap, name: app-config }
        fieldPaths: [data.APP_SERVICE_HOST]
  - source: { kind: Service, name: app-postgres, fieldPath: metadata.name }
    targets:
      - select: { kind: ConfigMap, name: app-config }
        fieldPaths: [data.POSTGRES_HOST, data.DATABASE_HOST]
        options: { create: true }
  - source: { kind: Service, name: app-redis, fieldPath: metadata.name }
    targets:
      - select: { kind: ConfigMap, name: app-config }
        fieldPaths: [data.REDIS_HOST]
        options: { create: true }