hey How would I specify which application I want ...
# 🤖|ask-kapa
m
Please stand by @swift-spring-8620 as I search the knowledge base. I normally take about 20 seconds or so. :wave:
---------------------- You can specify which application to deploy using the
--local
flag followed by the name of the application. For example, if you want to deploy only the 'example-application', you would use the following command:
Copy code
bash
garden deploy --local=example-application
This command will only deploy the 'example-application' and not the others in your project. For more information, you can refer to the Running Service in Local Mode () guide in the Garden documentation. ----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon: ----------------------
s
hey @microscopic-river-74022 if instead I wanted to assign a specific namespace for example 'application-1' and use that namespace in my relevant deploys, can I use this method to select which application i want to run?
m
Let me check the knowledge base for you. One moment! :books:
---------------------- Yes, you can use namespaces to partition your environment in Garden. This is particularly useful if you want to split a shared development or testing environment between different users or branches of code. To assign a specific namespace to an environment, you can set the
namespace
field in the respective provider configuration. For example, you can set
namespace: ${environment.namespace}
. By default, the
kubernetes
and
local-kubernetes
providers set the Kubernetes namespace to
<project name>-<Garden namespace>
. Here's an example of how you can define environments and namespaces in your
project.garden.yml
file:
Copy code
yaml
apiVersion: garden.io/v1
kind: Project
name: my-project
defaultEnvironment: dev
environments:
- name: local # local development environment
- name: dev # remote/shared development environment
  defaultNamespace: user-${local.username}
- name: staging
  production: true
- name: prod
  production: true
In this example, the
dev
environment uses a namespace that includes the current username, effectively partitioning the environment between different users. To specify the environment and namespace when running a Garden command, you can use the
--env
flag followed by
<namespace>.<env>
. For example:
Copy code
bash
garden deploy --env=application-1.dev
This command will deploy the services in the 'dev' environment under the 'application-1' namespace. For more information, you can refer to the Projects () guide in the Garden documentation. ----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon: ----------------------
Let me check the knowledge base for you. One moment! :books:
s
@microscopic-river-74022 Does localmode function the same way as the sync command, by which the changes that are made in the source code would reflect to the live application? If so, how do you specify the target and source path to the code files?
m
---------------------- Yes, the
localMode
function in Garden does work similarly to the
sync
command in that it allows changes made in your local source code to be reflected in the running application. However, the
localMode
function is specifically designed for running services locally while still being able to interact with other services in your stack that are running in a remote cluster. To use
localMode
, you need to specify it in your service configuration. Here's an example:
Copy code
yaml
kind: Module
type: container
services:
  - name: my-service
    localMode:
      command: ["npm", "start"]
      hotReloadCommand: ["npm", "run", "dev"]
      target: my-service
In this example, the
command
field specifies the command to run the service locally, and the
hotReloadCommand
field specifies the command to run when the service is hot-reloaded. The
target
field specifies the remote Kubernetes resource to proxy traffic from. On the other hand, the
sync
command is used to synchronize files between your local machine and the running service. You can use the
--sync
flag followed by a sync spec to specify which files to sync. For example:
Copy code
bash
garden deploy --sync=*
This command will deploy all applicable services with sync enabled, and any changes you make that fall under one of the sync specs you've defined will be automatically synced between your local machine and the running service. For more information, you can refer to the Running Service in Local Mode () guide and the Code Synchronization () guide in the Garden documentation. ----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon: ----------------------