Skip to content

Commit e13392d

Browse files
authored
Merge pull request #39 from oracle-devrel/env
Dynamic ENV with Instance Query
2 parents 56199a0 + 075aaa2 commit e13392d

File tree

10 files changed

+143
-2
lines changed

10 files changed

+143
-2
lines changed

AIO.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
All in One reference for samples - In Alphabetical (A to Z) order.
22
-----
3-
43
- Access resource with Private IP from OCI Build runner - https://github.com/oracle-devrel/oci-devops-examples/tree/main/oci-build-examples/oci-devops-pa-with-private-oke
54
- Build Caching - https://github.com/oracle-devrel/oci-devops-examples/tree/main/oci-build-examples/oci-build-caching
65
- Build Native image with Graal VM Enterprise edition - https://github.com/oracle-devrel/oci-devops-examples/tree/main/oci-build-examples/oci_devops_build_with_graalenterprise
@@ -26,6 +25,6 @@ All in One reference for samples - In Alphabetical (A to Z) order.
2625
- Integrate sonarqube with OCI devops build runner. - https://github.com/oracle-devrel/oci-devops-examples/tree/main/oci-build-examples/oci_buildrunner_with_sonarqube
2726
- Invoke deployment pipeline on a container image upload - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-deployment-examples/oci-devops-deploy-on-imageupload
2827
- OCI Policy management using terraform - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-config-examples/oci_devops_policy_dg_terraform
28+
- Sample illustration of OCI Devops deployment pipeline to update the deployment environment - Instances dynamically - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-deployment-examples/oci-devops-instance-env-dynamic-update
2929
- Scanning code for vulnerabilities for Maven packages - https://github.com/oracle-devrel/oci-devops-examples/tree/main/oci-build-examples/oci-devops-vulnerability-audit-management
3030
- Trigger build-pipeline from OCI Code repo on file modifications . - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-coderepo-examples/oci-devops-coderepo-filebasedtrigger
31-
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
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+
![](images/oci-devops-env-static.png)
43+
44+
- Here we manually pick the instances based on our desired choice.
45+
46+
![](images/oci-devops-env-static-2.png)
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+
![](images/oci-devops-env-query.png)
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+
![](images/oci-instance-tag.png)
63+
64+
```java
65+
freeformTags.key = 'env' && freeformTags.value = 'prod'
66+
```
67+
68+
![](images/oci-query-tag.png)
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+
![](images/oci-query-ad.png)
84+
85+
- Using `displayName`
86+
87+
```java
88+
displayName =~ 'instance' && lifecycleState= 'RUNNING'
89+
```
90+
91+
![](images/oci-query-displayname.png)
92+
93+
94+
- Using `shape`
95+
96+
```java
97+
shape='VM.Standard.E3.Flex'
98+
```
99+
100+
![](images/oci-query-shape.png)
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+
87.6 KB
Loading
254 KB
Loading
59.3 KB
Loading
67.7 KB
Loading
99.8 KB
Loading
85.9 KB
Loading
74.1 KB
Loading
124 KB
Loading

0 commit comments

Comments
 (0)