Skip to content

Commit 4e9ec7d

Browse files
committed
Final draft of automating with CLI
Added new article outlines as well.
1 parent 25061e3 commit 4e9ec7d

File tree

3 files changed

+143
-3
lines changed

3 files changed

+143
-3
lines changed

ci-automation/2-automated-deployment-cli.md

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Automation Basics
2+
title: Automated deployment with CLI
33
parent:
44
- tutorials
55
- ci-automation
@@ -20,7 +20,7 @@ author: eli-schilling
2020
redirect_from: "/collections/tutorials/1-automation-basics/"
2121
mrm:
2222
xredirect: https://developer.oracle.com/tutorials/ci-automation/1-automation-basics/
23-
slug: 1-automation-basics
23+
slug: 2-automated-deployment-cli
2424
---
2525
{% imgx aligncenter assets/ci-automation.png 400 400 "Automating Container Instances" "Container Instances Automation Tutorial Series" %}
2626

@@ -129,6 +129,81 @@ Copy that and use it to run one more command:
129129

130130
The output of the command will have the details of the VNIC, including the Public IP address. Copy that, navigate to it in a web browser and you should see the WordPress setup page.
131131

132+
![Screenshot of: Wordpress setup page][9]
133+
134+
### Leveraging Command Parameter JSON for complex input
135+
136+
As you can see in the **CREATE** command that was just run, several of the command parameters require complex JSON input. While it is possible to pass directly into the CLI, a preferred approach is to leverage JSON command parameter input. Generating the outline is simple enough and can be done for each of the more complex parameters. It looks like this:
137+
138+
oci container-instances container-instance create --generate-param-json-input containers >> containers.json
139+
140+
This will create a JSON file with all of the paramaters available (optional and required) when defining one or more containers for your resource. You can do the same for *shape-config* and *vnics*, resulting in 3 JSON files to pass through the CLI command. The following examples illustrate the minimum configuration required within each file to complete this tutorial. You can, of course, experiment with additional parameter input once you get the hang of this.
141+
142+
1. **containers.json**
143+
144+
[
145+
{
146+
"displayName": "appContainer",
147+
"environmentVariables": {
148+
"WORDPRESS_DB_HOST": "127.0.0.1",
149+
"WORDPRESS_DB_USER": "wordpress",
150+
"WORDPRESS_DB_PASSWORD": "wordpress",
151+
"WORDPRESS_DB_NAME": "wordpress"
152+
},
153+
"imageUrl": "docker.io/library/wordpress:latest",
154+
"isResourcePrincipalDisabled": true,
155+
"resourceConfig": {
156+
"memoryLimitInGBs": 4.0,
157+
"vcpusLimit": 1.0
158+
}
159+
},
160+
{
161+
"arguments": [
162+
"--default-authentication-plugin=mysql_native_password"
163+
],
164+
"displayName": "dbContainer",
165+
"environmentVariables": {
166+
"MYSQL_ROOT_PASSWORD": "wordpressonmysql",
167+
"MYSQL_DATABASE": "wordpress",
168+
"MYSQL_USER": "wordpress",
169+
"MYSQL_PASSWORD": "wordpress"
170+
},
171+
"imageUrl": "docker.io/library/mysql:8.0.31",
172+
"isResourcePrincipalDisabled": true,
173+
"resourceConfig": {
174+
"memoryLimitInGBs": 4.0,
175+
"vcpusLimit": 1.0
176+
}
177+
}
178+
]
179+
180+
2. **vnics.json**
181+
[
182+
{
183+
"displayName": "ContainerInstance-Demo",
184+
"freeformTags": {
185+
"Details": "Resource created using CLI"
186+
},
187+
"isPublicIpAssigned": true,
188+
"skipSourceDestCheck": true,
189+
"subnetId": "ocid1.subnet.oc1.phx.<the rest of your subnet OCID here>"
190+
}
191+
]
192+
193+
3. **shape-config.json**
194+
{
195+
"memoryInGBs": 16.0,
196+
"ocpus": 4.0
197+
}
198+
199+
Once you have created and populated the three files, you can simply pass the JSON file as input to your command parameters, resulting in a much cleaner command.
200+
201+
oci container-instances container-instance create --display-name CLI-ContainerInstance-Demo --availability-domain $adName --compartment-id $compOcid --containers file://containers.json --shape-config file://shape-config.json --vnics file://vnics.json --shape CI.Standard.E4.Flex
202+
203+
### Conclusion
204+
205+
There you have it, and well done! You've just completely provisioned OCI Container Instances with related network resources, all from the command line interface! When you're ready to try something a little different, check out the next article on automating Container Instances using Terraform.
206+
132207

133208

134209
[1]: https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/cliinstall.htm
@@ -138,4 +213,5 @@ The output of the command will have the details of the VNIC, including the Publi
138213
[5]: assets/ci-automation-cli-03.png
139214
[6]: assets/ci-automation-cli-04.png
140215
[7]: assets/ci-automation-cli-05.png
141-
[8]: assets/ci-automation-cli-06.png
216+
[8]: assets/ci-automation-cli-06.png
217+
[9]: assets/ci-automation-cli-07.png
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Automated Deployment with Terraform
3+
parent:
4+
- tutorials
5+
- ci-automation
6+
sidebar: series
7+
tags:
8+
- open-source
9+
- iac
10+
- terraform
11+
- devops
12+
- get-started
13+
categories:
14+
- iac
15+
- opensource
16+
thumbnail: assets/ci-automation.png
17+
date: 2023-02-01 12:00
18+
description: Now that you've seen the CLI in action, let's take a look at how to perform similar resource provisioning using Terraform.
19+
toc: true
20+
author: eli-schilling
21+
redirect_from: "/collections/tutorials/1-automation-basics/"
22+
mrm:
23+
xredirect: https://developer.oracle.com/tutorials/ci-automation/1-automation-basics/
24+
slug: 3-automated-deployment-tf.md
25+
---
26+
{% imgx aligncenter assets/ci-automation.png 400 400 "Automating Container Instances" "Container Instances Automation Tutorial Series" %}

ci-automation/5-container-testing.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: Automated Deployment and Testing with Container Instances
3+
parent:
4+
- tutorials
5+
- ci-automation
6+
sidebar: series
7+
tags:
8+
- open-source
9+
- iac
10+
- devops
11+
- get-started
12+
categories:
13+
- iac
14+
- opensource
15+
thumbnail: assets/ci-automation.png
16+
date: 2023-02-01 12:00
17+
description: With the critical components of automated provisioning securely embedded in your brain, its time to put this knowledge into practice. This article will walk through the process of leveraging Container Instances within your CI/CD pipeline for automated testing activities.
18+
toc: true
19+
author: eli-schilling
20+
redirect_from: "/collections/tutorials/1-automation-basics/"
21+
mrm:
22+
xredirect: https://developer.oracle.com/tutorials/ci-automation/1-automation-basics/
23+
slug: 5-container-testing.md
24+
---
25+
{% imgx aligncenter assets/ci-automation.png 400 400 "Automating Container Instances" "Container Instances Automation Tutorial Series" %}
26+
27+
28+
29+
Basic idea:
30+
1. Push code to DevOps Repo
31+
2. Trigger Build Pipeline
32+
3. Deliver image to Artifact Repository
33+
4. Create new CI resource
34+
5. Automated validation
35+
6. Destroy CI resource
36+
37+
Consider writing this from the perspective of moving from manual to automated.
38+
At first we did it all by hand, seemed insurmountable to move to DevOps, taking one bite at a time it was feasible.

0 commit comments

Comments
 (0)