Sharing the configuration

Remote development comes with many options allowing you to find the best fit for each component.

Managing these application specific settings with your team can be standardised:

  1. Within the environment configuration or the underlying template
  2. Within the application with a local file .bunnyshell/rdev.yaml

πŸ‘

Persist .bunnyshell/rdev.yaml within your repository

This ensures your team uses the same default configuration and allows the team to contribute modifications as the application naturally evolves.

1. Environment Configuration and Examples

Remote Development can be configured per component and container within bunnyshell.yaml

dev:
  [componentName]:
    - namespace: string # autowired for docker components
      kind: string      # autowired for docker components
      name: string      # autowired for docker components
      containers:
        [containerName]:
          command: [string, string]

          syncPaths:
            -
              remotePath: string
              localPath: string

          portForwards:
            - "int<int"
            - "int>int"

          environment:
            [name]: [value]
          
          # Values must respect kubernetes resource units
          # https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-units-in-kubernetes
          resources:
            limits:
              cpu: 123m
              memory: 751Mi
            requests:
              cpu: 101m
              memory: 749Mi

dev:
  api:
    - containers:
        api:
          command: ["php-fpm"]

          syncPaths:
            -
              remotePath: /var/www
              localPath: ..

          portForwards: ["9001<9001", "9002>9002"]

          environment:
            ENV: dev

          resources: &apiResources
            requests:
              cpu: 100m
              memory: 200Mi
            limits:
              cpu: 500m
              memory: 800Mi

dev:
  frontend:
    - containers:
        frontend:
          command: [yarn, start]

          syncPaths:
            -
              remotePath: /var/www/html
              localPath: ~/projects/frontend

          portForwards:
            - "8080<8080"

          environment:
            NODE_ENV: development

          resources:
            limits:
              cpu: 123m
              memory: 751Mi
            requests:
              cpu: 101m
              memory: 749Mi

dev:
  demo-books:
    - namespace: 'env-{{ env.unique }}'
      kind: Deployment
      name: backend
      containers:
        backend:
          command: [yarn, start:dev]
          syncPaths:
            -
              remotePath: /var/www
              localPath: ..
          portForwards:
            - 9229>9229
          environment:
            NODE_ENV: development
          resources:
            requests:
              cpu: '0.30'
              memory: 600M
            limits:
              cpu: '0.45'
              memory: 800M

2. Local Configuration and Examples

Projects can also manage these settings within a local .bunnyshell/rdev.yaml file:

profiles:
  [profileName]:
    command: [string, string]

    syncPaths:
      -
        remotePath: string
        localPath: string

    portForwards:
      - "int<int"

    environment:
      [name]: [value]

    # Values must respect kubernets resource units
    # https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#resource-units-in-kubernetes
    resources:
      limits:
        cpu: 123m
        memory: 751Mi
      requests:
        cpu: 101m
        memory: 749Mi

profiles:
  # using yaml anchors within rdev.yaml is supported
  api: &apiSettings
    command: ["php-fpm"]

    syncPaths:
      -
        remotePath: /var/www
        localPath: ..

    portForwards: ["9003<9003"]

    environment:
      APP_ENV: dev

    # yaml anchors must be unique within the same file
    resources: &apiResources
      requests:
        cpu: 100m
        memory: 200Mi
      limits:
        cpu: 500m
        memory: 800Mi

  workers:
    # the values behind yaml anchors can be imported and overriden
    <<: *apiSettings

    command: ["bin/console", "messenger:consume"]

    resources:
      # anchor keys are overriden, not merged
      # allowing you to make any changes to the imported configuration
      <<: *apiResources

      limits:
        cpu: 800m
        memory: 1200Mi

This can also be linked within bunnyshell.yaml by specifying a local profile instead of the full configuration:

dev:
  [componentName]:
    - namespace: string
      kind: string
      name: string
      containers:
        [containerName]:
          remoteDevProfile: [profileName]
dev:
  api:
    - containers:
        api:
          remoteDevProfile: api

  workers:
    - containers:
        workers:
          remoteDevProfile: workers
dev:
  demo-books:
    - namespace: 'env-{{ env.unique }}'
      kind: Deployment
      name: backend
      containers:
        backend:
          remoteDevProfile: backend

One time session overrides

All configuration settings can be overridden for the current remote development session within the CLI:

Usage:
  bns remote-development up [flags]

Flags:
      --component string                Filter by ServiceComponentID
      --container string                The container name to use for remote development
      --env stringArray                 Environment variables to set in the remote development container
      --environment string              Filter by EnvironmentID
  -h, --help                            Help for up
      --limit-cpu string                CPU resource limits for the remote development container
      --limit-memory string             Memory resource limits for the remote development container
  -l, --local-sync-path string          The folder on your machine that will be synced into the container on the path specified by --remote-sync-path
      --manual-select-single-resource   Do not skip interactive selectors when there is only one result
      --no-tty                          Start remote development with no SSH terminal
      --organization string             Filter by OrganizationID
  -f, --port-forward strings            Port forward: '8080>3000'
                                        Reverse port forward: '9003<9003'
                                        Comma separated: '8080>3000,9003<9003'
      --project string                  Filter by ProjectID
      --rdev-configDir string           Remote Dev config directory
                                        Using ... will look through all parent directories (default ".../.bunnyshell")
      --rdev-configFile string          Remote Dev config file
                                        An absolute path ignores --rdev-configDir (default "rdev.yaml")
      --rdev-profile string             Remote Dev profile name. Loaded from --rdev-configFile
  -r, --remote-sync-path string         The folder within the container where the source code of the application resides
                                        This will be used as a persistent volume to preserve your changes across multiple development sessions
                                        When using --sync-mode=none it will be used only as a workspace where changes to those files will be preserved
      --request-cpu string              CPU resource reservations for the remote development container
      --request-memory string           Memory resource reservations for the remote development container
  -s, --resource string                 The cluster resource to use (namespace/kind/name format).
      --sync-mode sync-mode             Mutagen sync mode.
                                        Available sync modes: none, two-way-safe, two-way-resolved, one-way-safe, one-way-replica
                                        "none" sync mode disables mutagen. (default two-way-resolved)
  -w, --wait-timeout duration           Time to wait for the pod to be ready (default 2m0s)

bns rdev up \
  --env DEBUG=true \
;
bns rdev up \
  --request-cpu 800M \
  --request-memory 1200Mi \
  --limit-cpu 1500M \
  --limit-memory 2400Mi \
;
bns rdev up -- yarn run:debug

πŸ“˜

Configuration Discovery

The value for --rdev-configDir uses the default value .../.bunnyshell.

The behaviour of bns rdev up with this value is to look for .bunnyshell within the current directory. If it's not found, it will continue to look through all parents until the file is found or error out.

Once found, this file acts as an anchor for any relative paths defined within the configuration.


What’s Next