Skip to content

Commit 9f35df2

Browse files
author
odx-pipelines/[email protected]
committed
stage level params
1 parent df3e003 commit 9f35df2

17 files changed

+203
-0
lines changed
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+
Read more
150+
----
151+
152+
- OCI DevOps - https://docs.oracle.com/en-us/iaas/Content/devops/using/home.htm.
153+
- OCI Reference architectures - https://docs.oracle.com/solutions/
154+
- OCI DevOps samples - https://github.com/oracle-devrel/oci-devops-examples
155+
156+
Contributors
157+
===========
158+
159+
- Author: Rahul M R.
160+
- Collaborators : NA
161+
- Last release: January 2023
162+
163+
### Back to examples.
164+
----
165+
166+
- 🍿 [Back to OCI Devops Deployment sample](./../README.md)
167+
- 🏝️ [Back to OCI Devops sample](./../../README.md)
168+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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}
20+
21+
---
22+
apiVersion: v1
23+
kind: Service
24+
metadata:
25+
name: sample-nginx
26+
annotations:
27+
service.beta.kubernetes.io/oci-load-balancer-shape: "10Mbps"
28+
spec:
29+
type: LoadBalancer
30+
ports:
31+
- port: 80
32+
protocol: TCP
33+
targetPort: 80
34+
selector:
35+
app: nginx
145 KB
Loading
58.3 KB
Loading
38.2 KB
Loading
121 KB
Loading
146 KB
Loading
119 KB
Loading
163 KB
Loading
155 KB
Loading

0 commit comments

Comments
 (0)