Skip to content

Commit 27d6e97

Browse files
authored
Merge pull request #44 from oracle-devrel/stagparams
Deploy stage level paramters
2 parents c6ca2b3 + 8a8c086 commit 27d6e97

18 files changed

+190
-3
lines changed

AIO.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
All in One reference for samples - In Alphabetical (A to Z) order.
2-
-----
1+
## All in One reference for samples - In Alphabetical (A to Z) order.
32

43
- A way (workaround) to execute commands on to a Windows machine using OCI Run command agent from OCI Build pipeline. - https://github.com/oracle-devrel/oci-devops-examples/tree/main/oci-build-examples/oci-devops-connect-to-windows-from-buildmachines
54
- 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
@@ -11,6 +10,7 @@ All in One reference for samples - In Alphabetical (A to Z) order.
1110
- Build and deploy a JAVA - Graal EE - Micronaut application on to Instances - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-pipeline-examples/oci-devops-graal-micronaut-deploy-to-instances
1211
- Build and run a OCI devops pipeline with JAVA and Graal VM framework. - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-pipeline-examples/oci-java-graalvm-devops-example
1312
- Build and run a OCI devops pipeline with Java-Micronaut framework. - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-pipeline-examples/oci-java-micronaut-devops-example
13+
- Cascade delete of OCI Project - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-config-examples/oci-project-cascadedelete
1414
- Cascaded Pipelines - With in the Region - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-pipeline-examples/oci-cascaded-pipelines/same-region
1515
- Container image scan before deploy - https://github.com/oracle-devrel/oci-devops-examples/tree/main/oci-build-examples/oci_imagescan_before_deploy
1616
- Deploy to Instances following OCI Devops blue-green deployment strategy - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-deployment-examples/oci-devops-deploy-instances-with-blue-green-model
@@ -27,7 +27,7 @@ All in One reference for samples - In Alphabetical (A to Z) order.
2727
- Integrate sonarqube with OCI devops build runner. - https://github.com/oracle-devrel/oci-devops-examples/tree/main/oci-build-examples/oci_buildrunner_with_sonarqube
2828
- 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
2929
- OCI Policy management using terraform - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-config-examples/oci_devops_policy_dg_terraform
30-
- Cascade delete of OCI Project - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-config-examples/oci-project-cascadedelete
30+
- Sample illustration of OCI DevOps deployment pipeline with *STAGE LEVEL PARAMETERS* - https://github.com/oracle-devrel/oci-devops-examples/blob/main/oci-deployment-examples/oci-deployment-stagelevelparams
3131
- 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
3232
- 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
3333
- 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
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
Sample illustration of OCI DevOps deployment pipeline with *STAGE LEVEL PARAMETERS*
2+
------------
3+
4+
Objective
5+
---
6+
- Create an OCI Deployment pipeline with a default OKE deployment stage.
7+
- Provide default parameters for the stage.
8+
- Do executions and demonstrate how can the parameters can override using stage-level parameters.
9+
10+
Specific instructions to download only this sample.
11+
---
12+
13+
```
14+
$ git init oci-deployment-stagelevelparams
15+
$ cd oci-deployment-stagelevelparams
16+
$ git remote add origin https://github.com/oracle-devrel/oci-devops-examples
17+
$ git config core. sparsecheckout true
18+
$ echo "oci-deployment-examples/oci-deployment-stagelevelparams/*">>.git/info/sparse-checkout
19+
$ git pull --depth=1 origin main
20+
21+
```
22+
23+
⚠️ Stage level parameter option is now available `ONLY` for `OCI deployment pipeline` and `NOT` available for deployment when invoked from `OCI Buildpipeline` using the `Invoke deployment` stage.
24+
25+
Procedure
26+
---
27+
- The procedure requires an active OKE (Oracle Container Engine for Kubernetes).
28+
29+
- If you do not have an OKE cluster, please create one (It can be private or public hosted nodes /API endpoints) - https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengcreatingclusterusingoke_topic-Using_the_Console_to_create_a_Quick_Cluster_with_Default_Settings.htm#create-quick-cluster
30+
31+
- Access the OKE Cluster and create two namespaces as `nginx16` and `nginx14`.
32+
- Create an OCI dynamic group with the below rules.
33+
34+
```java
35+
ALL {resource.type = 'devopsdeploypipeline', resource.compartment.id = 'COMPARTMENT OCID'}
36+
```
37+
38+
- Create an OCI policy with the below statements.
39+
40+
```java
41+
Allow dynamic-group <NAME of the DG> to manage ons-topics in compartment <NAME Of the COMPARTMENT>
42+
Allow dynamic-group <NAME of the DG> to manage cluster-family in compartment <NAME Of the COMPARTMENT>
43+
```
44+
45+
- Create an OCI Notification topic - https://docs.oracle.com/en-us/iaas/Content/Notification/Tasks/create-topic.htm#top
46+
- Create a DevOps project and associate it with the notification. - https://docs.oracle.com/en-us/iaas/Content/devops/using/create_project.htm#create_a_project
47+
48+
49+
![](images/oci-devops-project.png)
50+
51+
- Ensure enable to logs for the DevOps project.
52+
53+
- Create a DevOps environment of type `Oracle Kubernetes Engine`.
54+
55+
![](images/oci-devops-env.png)
56+
57+
- Select the appropriate OKE Cluster and save.
58+
59+
- Create a deployment artifact of type `Kubernetes manifest`.
60+
61+
![](images/oci-artifact-type.png)
62+
63+
- Select the source type as `inline` and paste the content from [file here.](deployment. yaml)
64+
65+
- Ensure to select the option `Allow parameterization` and add.
66+
67+
![](images/oci-artifact-inline.png)
68+
69+
- We are using a sample Nginx deployment file for this procedure.
70+
71+
- Create a `deployment pipeline` - https://docs.oracle.com/en-us/iaas/Content/devops/using/deployment_pipelines.htm
72+
73+
![](images/oci-deployment-pipeline.png)
74+
75+
- We will be adding `two OKE deployment stages` within the deployment pipeline to illustrate the procedure.
76+
77+
- Use `+` and add first deployment stage of type `OKE Rolling`.
78+
- Name the stage as `Nginx16` and select the `environment and DevOps artifact created.
79+
- Use namespace as `nginx16` for the deployment.
80+
81+
![](images/oci-deploystage-ngnx16.png)
82+
83+
84+
- Use `+` add another stage of type `OKE Rolling`.
85+
86+
- Name the stage as `Nginx14` and select the `environment and DevOps artifact created
87+
88+
- Use the namespace as `nginx16` for the deployment.
89+
90+
![](images/oci-deploy-stage-ngnx14.png)
91+
92+
- Set the below parameters for the pipeline (these are global parameters for the pipeline)
93+
94+
![](images/oci-deploy-params.png)
95+
96+
```java
97+
- port: 80
98+
- version: 1.14.2
99+
```
100+
101+
- Use `Run pipeline` and run the pipeline for both stages.
102+
- Wait for all the stages to complete.
103+
104+
![](images/oci-deployment-default.png)
105+
106+
- Once all the steps are completed, connect to the OKE cluster (preferably using cloud shell and kubectl) and run the below commands and validate the version of the image.
107+
108+
```java
109+
kubectl describe deployment.apps/nginx-deployment -n nginx16|grep Image
110+
kubectl describe deployment.apps/nginx-deployment -n nginx14|grep Image
111+
```
112+
113+
- It should show the version as the default version values from `deployment parameters
114+
115+
![](images/oci-oke-default-image.png)
116+
117+
- Let us do a `value override` with another deployment, where we will provide different versions for one of the stages.
118+
119+
- Click on `Run pipeline` > Select `stages` from option `Stage parameters override`
120+
- Select stage `Nginx16` and provide `Name` as `version` and
121+
`Value` as `1.16.1`.
122+
123+
![](images/oci-deploymet-stage-param.png)
124+
125+
- Re-run the commands using kubectl to validate the changes.
126+
127+
![](images/oci-deploy-override-values.png)
128+
129+
130+
- As you may verify from the above that the override is effective, let us do one last test wherein we will try to parse a param which is not defined in the global pipeline parameters.
131+
132+
- Delete the parameter `port` from the `pipeline parameters`
133+
134+
![](images/oci-deploy-param-deleted.png)
135+
136+
- Re-run the deployment where we will be giving different values for stages as ports.
137+
138+
![](images/oci-deploy-param-ports.png)
139+
140+
- Wait for all the steps to complete and validate the changes by connecting to the OKE cluster.
141+
142+
```java
143+
kubectl describe deployment.apps/nginx-deployment -n nginx16|grep Port
144+
kubectl describe deployment.apps/nginx-deployment -n nginx14|grep Port
145+
```
146+
147+
![](images/oci-multi-override.png)
148+
149+
- Ensure to delete OKE resources and devops project related resources once completed . You can use `Cascade deletion` option with in `Devops project` to clean all the devops related resources.
150+
151+
Read more
152+
----
153+
154+
- OCI DevOps - https://docs.oracle.com/en-us/iaas/Content/devops/using/home.htm.
155+
- OCI Reference architectures - https://docs.oracle.com/solutions/
156+
- OCI DevOps samples - https://github.com/oracle-devrel/oci-devops-examples
157+
158+
Contributors
159+
===========
160+
161+
- Author: Rahul M R.
162+
- Collaborators : NA
163+
- Last release: January 2023
164+
165+
### Back to examples.
166+
----
167+
- 🍿 [Back to OCI Devops Deployment sample](./../README.md)
168+
- 🏝️ [Back to OCI Devops sample](./../../README.md)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: nginx-deployment
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: nginx
9+
replicas: 2
10+
template:
11+
metadata:
12+
labels:
13+
app: nginx
14+
spec:
15+
containers:
16+
- name: nginx
17+
image: nginx:${version}
18+
ports:
19+
- containerPort: ${port}
145 KB
Loading
58.3 KB
Loading
38.2 KB
Loading
121 KB
Loading
146 KB
Loading
119 KB
Loading
163 KB
Loading

0 commit comments

Comments
 (0)