|
| 1 | +--- |
| 2 | +title: "Create and commit resources for application" |
| 3 | +description: "" |
| 4 | +group: getting-started |
| 5 | +sub-group: quick-start |
| 6 | +toc: true |
| 7 | +--- |
| 8 | + |
| 9 | +Now that you have created an application, you need to deploy the application. Let's deploy the `codefresh-guestbook` application by creating and commiting resources. |
| 10 | +You will create and commit the following resources: |
| 11 | +1. A folder in Git to save resources for the application |
| 12 | +1. `Rollout` resource defining the deployment strategy |
| 13 | +1. `Service` resource to expose the application to external traffic |
| 14 | + |
| 15 | +### Before you begin |
| 16 | +* [Create an application]({{site.baseurl}}/docs/getting-started/quick-start/create-app-ui) |
| 17 | +* Make sure [Argo Rollouts is installed]({{site.baseurl}}/docs/deployment/install-argo-rollouts) on the target cluster |
| 18 | + |
| 19 | +### Create folder in Git for application resources |
| 20 | +Create a folder in the Git repo in which to save all the resources for the `codefresh-guestbook` application. |
| 21 | + |
| 22 | +* In your Git repo, create a folder to store the resources needed to deploy the application. |
| 23 | + For example, `/quick-start/` |
| 24 | + |
| 25 | +### Create rollout.yaml |
| 26 | + |
| 27 | +Create a rollout resource for the application you want to deploy. |
| 28 | + |
| 29 | + |
| 30 | +To leverage Argo Rollouts' deployment capabilities, we are using the Argo's `rollout` resource instead of the native Kubernetes Deployment object. |
| 31 | +For detailed information on the fields you can define, see [Argo Rollout specification](https://argoproj.github.io/argo-rollouts/features/specification/){:target="\_blank"}. |
| 32 | + |
| 33 | + |
| 34 | +* In the Git repository create the `rollout.yaml` file, as in the example below. |
| 35 | + |
| 36 | + |
| 37 | +```yaml |
| 38 | +apiVersion: argoproj.io/v1alpha1 |
| 39 | +kind: Rollout |
| 40 | +metadata: |
| 41 | + name: codefresh-guestbook-rollout |
| 42 | +spec: |
| 43 | + replicas: 4 |
| 44 | + revisionHistoryLimit: 2 |
| 45 | + selector: |
| 46 | + matchLabels: |
| 47 | + app: codefresh-guestbook |
| 48 | + template: |
| 49 | + metadata: |
| 50 | + labels: |
| 51 | + app: codefresh-guestbook |
| 52 | + spec: |
| 53 | + containers: |
| 54 | + - image: gcr.io/heptio-images/ks-guestbook-demo:0.1 |
| 55 | + name: codefresh-guestbook |
| 56 | + ports: |
| 57 | + - name: http |
| 58 | + containerPort: 80 |
| 59 | + protocol: TCP |
| 60 | + minReadySeconds: 30 |
| 61 | + strategy: |
| 62 | + canary: |
| 63 | + steps: |
| 64 | + - setWeight: 25 |
| 65 | + - pause: {duration: 20s} |
| 66 | + - setWeight: 75 |
| 67 | + - pause: {duration: 15s} |
| 68 | +``` |
| 69 | +
|
| 70 | +#### Fields in `rollout.yaml` |
| 71 | + |
| 72 | +{: .table .table-bordered .table-hover} |
| 73 | +| Rollout Field | Notes | |
| 74 | +| -------------- | -------------| |
| 75 | +| `replicas` | When deployed, the rollout creates four replicas of the `codefresh-guestbook` application.| |
| 76 | +| `revisionHistoryLimit` | The number of replica sets to retain. | |
| 77 | +| `matchLabels` | The pods to select for this rollout. In our example, all pods with the label `codefresh-guestbook` are selected.| |
| 78 | +| `image` | The container image for the application with the version tag, `gcr.io/heptio-images/ks-guestbook-demo:0.1` in our example.| |
| 79 | +| `name` | The name of the application, `codefresh-guestbook` in our example. | |
| 80 | +| `canary` | The deployment strategy, `canary` meaning that the traffic is gradually routed to the new application. Starting with `setWeight` of `25%` followed by a `pause` of 20 seconds, and the remaining `75%` after verification.| |
| 81 | +| `templateName` | The analysis template used to validate the application metrics. Our example has the `background-analysis` template, and interfaces with Prometheus to monitor and validate metric thresholds.| |
| 82 | + |
| 83 | + |
| 84 | +### Create a service resource |
| 85 | +Create a service resource to expose your application to external traffic. |
| 86 | + |
| 87 | +* Create a `service.yaml` resource for the application you want to deploy, as in the example below. |
| 88 | + > Create it in the same folder in which you saved `rollout.yaml`. |
| 89 | + |
| 90 | +```yaml |
| 91 | +apiVersion: v1 |
| 92 | +kind: Service |
| 93 | +metadata: |
| 94 | + name: codefresh-guestbook-svc |
| 95 | +spec: |
| 96 | + ports: |
| 97 | + - port: 8080 |
| 98 | + targetPort: 80 |
| 99 | + selector: |
| 100 | + app: codefresh-guestbook # must be the same as the selector defined in rollouts.yaml |
| 101 | + type: LoadBalancer |
| 102 | +``` |
| 103 | + |
| 104 | +#### Fields in `service.yaml` |
| 105 | + |
| 106 | +{: .table .table-bordered .table-hover} |
| 107 | +| Service field | Notes | |
| 108 | +| -------------- | -------------- | |
| 109 | +| `spec.ports` | The internal `port`, 8080 in our example, and external `targetPort`, 80 in our example.| |
| 110 | +| `selector.app` | The pods to select, and MUST be identical to that defined in `rollouts.yaml`, `codefresh-guestbook` in our example.| |
| 111 | + |
| 112 | +### View application resources in Codefresh |
| 113 | +Once you create and commit the `rollout` and `service` resources, return to the Applications dashboard. The Current State to see these resources. |
| 114 | + |
| 115 | +1. In the Codefresh UI, go to the [Applications dashboard](https://g.codefresh.io/2.0/applications-dashboard?sort=desc-lastUpdated){:target="\_blank"}. |
| 116 | +1. Select the application. |
| 117 | + The Current State tab is now populated with the `rollout` and `service` resources you added. |
| 118 | + |
| 119 | + {% include |
| 120 | + image.html |
| 121 | + lightbox="true" |
| 122 | + file="/images/getting-started/quick-start/cdops-app-current-state.png" |
| 123 | + url="/images/getting-started/quick-start/cdops-app-current-state.png" |
| 124 | + alt="Current State with resources for application" |
| 125 | + caption="Current State with resources for application" |
| 126 | + max-width="70%" |
| 127 | + %} |
| 128 | + |
| 129 | +### What to do next |
| 130 | +<!---[Create Jira and Docker Hub integrations ]({{site.baseurl}}/docs/getting-started/quick-start/create-app-ui)---> |
| 131 | +[(Optional) Update image tag for application]({{site.baseurl}}/docs/getting-started/quick-start/create-rollout) |
0 commit comments