|
| 1 | + |
| 2 | + |
| 3 | + |
| 4 | +# Sample illustration of OCI Devops deployment pipeline to update the `deployment environment - Instances dynamically` . |
| 5 | + |
| 6 | + |
| 7 | +### Audience: Experience and Experts of OCI Devops. |
| 8 | + |
| 9 | +### Objective |
| 10 | + |
| 11 | +The sample here focuses on updating the deployment environment - instance group dynamically. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +Specific instructions to download only this sample. |
| 16 | +--- |
| 17 | + |
| 18 | +``` |
| 19 | + $ git init oci-devops-instance-env-dynamic-update |
| 20 | + $ cd oci-devops-instance-env-dynamic-update |
| 21 | + $ git remote add origin https://github.com/oracle-devrel/oci-devops-examples |
| 22 | + $ git config core. sparsecheckout true |
| 23 | + $ echo "oci-deployment-examples/oci-devops-instance-env-dynamic-update/*">>.git/info/sparse-checkout |
| 24 | + $ git pull --depth=1 origin main |
| 25 | +
|
| 26 | +``` |
| 27 | + |
| 28 | + |
| 29 | +Procedure |
| 30 | +--- |
| 31 | + |
| 32 | +- A **devops environment** is the target platform for your software. You create references to different destination environments for DevOps deployment. |
| 33 | + |
| 34 | +- There will be use cases where you may want to fetch the instances within a defined devops environment based on dynamic add/deletion of new instances. |
| 35 | +- Read more about `Managing Environments` [here](https://docs.oracle.com/en-us/iaas/Content/devops/using/environments.htm). |
| 36 | + |
| 37 | +### Using static declaration of Devops Instance Environment. |
| 38 | + |
| 39 | +- In this case, we will be using the `Filter` method and where in the instances are manually picked. |
| 40 | +- Filter mode will not update dynamically against instance addition/deletion. |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | +- Here we manually pick the instances based on our desired choice. |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +### Using dynamic declaration of devops Instance Environment. |
| 50 | + |
| 51 | +- In this case, we will be using `Query` and adding the desired condition against the possible keys. |
| 52 | +- In this way, the instances will be added /updated dynamically. |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | +- Let us see some of the common instance queries. |
| 57 | + |
| 58 | +#### Using a tag |
| 59 | + |
| 60 | +- Add a free form tag to instances and use the same within the query. |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +```java |
| 65 | +freeformTags.key = 'env' && freeformTags.value = 'prod' |
| 66 | +``` |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | +- When using the tag always prefer to use the `lifecycleState` to avoid a delay in holding the deployment against a not running instance. As you may know, we can have many instances with the same tag with different stages. |
| 71 | + |
| 72 | +```java |
| 73 | +freeformTags.key = 'env' && freeformTags.value = 'prod' && lifecycleState= 'RUNNING' |
| 74 | +``` |
| 75 | +#### Using most common compute instance attributes. |
| 76 | + |
| 77 | +- Using `availabilityDomain` |
| 78 | + |
| 79 | +```java |
| 80 | +availabilityDomain = 'xxxx-AD-X' && lifecycleState = 'RUNNING' |
| 81 | +``` |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | +- Using `displayName` |
| 86 | + |
| 87 | +```java |
| 88 | +displayName =~ 'instance' && lifecycleState= 'RUNNING' |
| 89 | +``` |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | +- Using `shape` |
| 95 | + |
| 96 | +```java |
| 97 | +shape='VM.Standard.E3.Flex' |
| 98 | +``` |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | +- You may also use various other parameters of instances like `definedTags`, `lifecycleState`, |
| 104 | + |
| 105 | +#### Operators supports |
| 106 | + |
| 107 | +- All the below operators are supported with instance query syntax. |
| 108 | + |
| 109 | +```java |
| 110 | +'.', '=', '!=', '==', '!==', '=~', '!=~', '>', '>=', '<', '<='} |
| 111 | +``` |
| 112 | + |
| 113 | +- Refer [here](https://docs.oracle.com/en-us/iaas/Content/Search/Concepts/querysyntax.htm#conditions) for more . |
| 114 | + |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | +## Read more |
| 123 | + |
| 124 | + |
| 125 | +- OCI Devops - https://docs.oracle.com/en-us/iaas/Content/devops/using/home.htm. |
| 126 | +- OCI Reference architectures - https://docs.oracle.com/solutions/ |
| 127 | +- OCI Devops samples - https://github.com/oracle-devrel/oci-devops-examples |
| 128 | + |
| 129 | +Contributors |
| 130 | +=========== |
| 131 | + |
| 132 | +- Author: [Rahul M R](https://github.com/RahulMR42). |
| 133 | +- Collaborators : NA |
| 134 | +- Last release: October 2022 |
| 135 | + |
| 136 | +### Back to examples. |
| 137 | +---- |
| 138 | + |
| 139 | +- 🍿 [Back to OCI Devops Deployment sample](./../README.md) |
| 140 | +- 🏝️ [Back to OCI Devops sample](./../../README.md) |
| 141 | + |
| 142 | + |
0 commit comments