This page shows you how to deploy a new version of your App and migrate
traffic over from an old to a new version.

## Pushing the initial App

Use the Kf CLI to push the initial version of your App with any Routes:

```bash
$ kf push app-v1 --route my-app.my-space.example.com
```

## Pushing the updated App

Use the Kf CLI to push a new version of your App without any Routes:

```bash
$ kf push app-v2 --no-route
```

## Adding Routes to the updated App

Use the Kf CLI to bind all existing Routes to the updated App with a weight of 0
to ensure they don't get any requests.

```bash
$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 0
```

## Shifting traffic

Start shifting traffic from the old App to the updated App by updating the
weights on the Routes.

```bash
$ kf map-route app-v1 my-space.example.com --hostname my-app --weight 80
$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 20
```

If the deployment is going well, you can shift more traffic by updating the weights
again:

```bash
$ kf map-route app-v1 my-space.example.com --hostname my-app --weight 50
$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 50
```

> [!NOTE]
> **Note:** Weights split traffic proportionally to the sum of the weights of all Apps mapped to the Route. It's common practice to treat weights as percentages.

## Completing traffic shifting

Once you're satisfied that the new service hasn't introduced regressions,
complete the rollout by shifting all traffic to the new instance:

```bash
$ kf map-route app-v1 my-space.example.com --hostname my-app --weight 0
$ kf map-route app-v2 my-space.example.com --hostname my-app --weight 100
```

## Turning down the original App

Once you're satisfied that quick rollbacks aren't needed, remove the original
route and stop the App:

```bash
$ kf unmap-route app-v1 myspace.example.com --hostname my-app
$ kf stop app-v1
```

Or delete the App and all associated Route mappings:

```bash
$ kf delete app-v1
```