Skip to content

Commit 567aac0

Browse files
authored
Two Tier Grabdish (#436)
* Test 1 * test2 * test3 * test3 * test4 * test5 * test6 * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test js loader * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * Update setup_functions.env * test * test * test * test * test * test * test * test * test * test * test * Revert Changes Outside of Workshop Folder
1 parent 8ff3de9 commit 567aac0

File tree

543 files changed

+138922
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

543 files changed

+138922
-2
lines changed

grabdish/config/db/common/apply/order-object-scripts.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,4 @@ EXCEPTION
169169

170170
END;
171171
/
172-
show errors
172+
show errors

grabdish/docs/Provisioning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The code that provisions the Grabdish application is located in the grabdish/con
99
## Prerequisites
1010

1111
The following are required before provisioning Grabdish:
12-
1. Kubernetes cluster with kuebctl configured
12+
1. Kubernetes cluster with kubectl configured
1313
2. One or two databases
1414
3. An OCI object store bucket (ATP 2DB only)
1515
4. get_secret bash function (available in infra/vault/folder)

workshops/dcms-db/config/apply.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
5+
6+
# Fail on error
7+
set -eu
8+
9+
if ! provisioning-helper-pre-apply; then
10+
exit 1
11+
fi
12+
13+
QUEUE_TYPE=$(state_get QUEUE_TYPE)
14+
OCI_REGION="$(state_get OCI_REGION)"
15+
16+
# Generate the ssh keys
17+
if ! test -d $MY_STATE/ssh; then
18+
mkdir -p $MY_STATE/ssh
19+
ssh-keygen -t rsa -N "" -b 2048 -C "db" -f $MY_STATE/ssh/dcmsdb
20+
state_set SSH_PUBLIC_KEY_FILE $"$MY_STATE/ssh/dcmsdb.pub"
21+
state_set SSH_PRIVATE_KEY_FILE "$MY_STATE/ssh/dcmsdb"
22+
fi
23+
24+
# Copy terraform to my state
25+
if ! test -d $MY_STATE/terraform; then
26+
rm -rf $MY_STATE/terraform
27+
cp -r $MSDD_WORKSHOP_CODE/$DCMS_WORKSHOP/config/terraform $MY_STATE
28+
fi
29+
30+
# Start the provisioning apply
31+
cd $MY_STATE/terraform
32+
source terraform-env.sh
33+
34+
if ! terraform init; then
35+
echo 'ERROR: terraform init failed!'
36+
exit 1
37+
fi
38+
39+
if ! terraform apply -auto-approve; then
40+
echo 'ERROR: terraform apply failed!'
41+
exit 1
42+
fi
43+
44+
# Get the load balancer public IP
45+
state_set LB_ADDRESS `terraform output -raw lb_address`
46+
47+
# Get the ORDS instance public IP
48+
state_set ORDS_ADDRESS `terraform output -raw ords_address`
49+
50+
# Get the ORDS instance public IP
51+
state_set DB_OCID `terraform output -raw db_ocid`
52+
53+
state_set TNS_ADMIN_ZIP_FILE $MY_STATE/terraform/uploads/adb_wallet.zip
54+
TNS_ADMIN=$MY_STATE/tns_admin
55+
mkdir -p $TNS_ADMIN
56+
unzip $(state_get TNS_ADMIN_ZIP_FILE) -d $TNS_ADMIN
57+
cat >$TNS_ADMIN/sqlnet.ora <<- !
58+
WALLET_LOCATION = (SOURCE = (METHOD = file) (METHOD_DATA = (DIRECTORY="$TNS_ADMIN")))
59+
SSL_SERVER_DN_MATCH=yes
60+
!
61+
62+
state_set TNS_ADMIN $TNS_ADMIN
63+
64+
# Write the output
65+
cat >$OUTPUT_FILE <<!
66+
export LB_ADDRESS='$(state_get LB_ADDRESS)'
67+
export ORDS_ADDRESS='$(state_get ORDS_ADDRESS)'
68+
export TNS_ADMIN='$(state_get TNS_ADMIN)'
69+
!

workshops/dcms-db/config/destroy.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
5+
# Fail on error
6+
set -e
7+
8+
9+
if ! provisioning-helper-pre-destroy; then
10+
exit 1
11+
fi
12+
13+
cd $MY_STATE/terraform
14+
15+
# Workaround for issue where terraform fails in OCI cloud shell after a few days
16+
rm -rf .terraform
17+
rm -f .terraform.lock.hcl
18+
19+
# Start the provisioning destroy
20+
source terraform-env.sh
21+
22+
if ! terraform init; then
23+
echo 'ERROR: terraform init failed!'
24+
exit 1
25+
fi
26+
27+
if ! terraform destroy -auto-approve; then
28+
echo 'ERROR: terraform apply failed!'
29+
exit 1
30+
fi
31+
32+
rm -f $STATE_FILE
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# Copyright (c) 2021 Oracle and/or its affiliates.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4+
5+
REQ_UTILS="touch rm mkdir"
6+
REQ_INPUT_PARAMS=""
7+
REQ_OUTPUT_PARAMS="LB_ADDRESS ORDS_ADDRESS TNS_ADMIN"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright © 2020, Oracle and/or its affiliates.
2+
# All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
3+
4+
data "oci_identity_availability_domains" "availability_domains" {
5+
compartment_id = var.tenancy_ocid
6+
}
7+
8+
// If this is ALF, need to determine which AD can create CI's in
9+
data "oci_limits_limit_values" "limits_limit_values" {
10+
compartment_id = var.tenancy_ocid
11+
service_name = "compute"
12+
scope_type = "AD"
13+
name = "vm-standard-e2-1-micro-count"
14+
filter {
15+
name = "value"
16+
values = ["2"]
17+
}
18+
}
19+
20+
// If we have a value from limits, use that as ALF, otherwise use AD-1
21+
locals {
22+
availability_domain = length(data.oci_limits_limit_values.limits_limit_values.limit_values.*.availability_domain) != 0 ? data.oci_limits_limit_values.limits_limit_values.limit_values[0].availability_domain : data.oci_identity_availability_domains.availability_domains.availability_domains[0]["name"]
23+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright © 2020, Oracle and/or its affiliates.
2+
# All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
3+
4+
// Get the latest Oracle Linux image
5+
data "oci_core_images" "images" {
6+
compartment_id = var.compartment_ocid
7+
operating_system = var.compute_os
8+
operating_system_version = var.linux_os_version
9+
shape = local.compute_shape
10+
11+
filter {
12+
name = "display_name"
13+
values = ["^.*Oracle[^G]*$"]
14+
regex = true
15+
}
16+
}
17+
18+
resource "oci_core_instance" "instance" {
19+
compartment_id = var.compartment_ocid
20+
display_name = format("%s-ords-core", var.proj_abrv)
21+
availability_domain = local.availability_domain
22+
shape = local.compute_shape
23+
dynamic "shape_config" {
24+
for_each = local.is_flexible_shape ? [1] : []
25+
content {
26+
baseline_ocpu_utilization = "BASELINE_1_2"
27+
ocpus = var.compute_flex_shape_ocpus[var.size]
28+
// Memory OCPU * 16GB
29+
memory_in_gbs = var.compute_flex_shape_ocpus[var.size] * 16
30+
}
31+
}
32+
source_details {
33+
source_type = "image"
34+
source_id = data.oci_core_images.images.images[0].id
35+
}
36+
agent_config {
37+
are_all_plugins_disabled = false
38+
is_management_disabled = false
39+
is_monitoring_disabled = false
40+
plugins_config {
41+
desired_state = "ENABLED"
42+
name = "Bastion"
43+
}
44+
}
45+
// If this is ALF, we can't place in the private subnet as need access to the cloud agent/packages
46+
create_vnic_details {
47+
subnet_id = local.is_always_free ? oci_core_subnet.subnet_public.id: oci_core_subnet.subnet_private[0].id
48+
assign_public_ip = local.is_always_free
49+
nsg_ids = [oci_core_network_security_group.security_group_ssh.id, oci_core_network_security_group.security_group_ords.id]
50+
}
51+
metadata = {
52+
ssh_authorized_keys = file(var.ssh_public_key_file)
53+
}
54+
lifecycle {
55+
ignore_changes = all
56+
}
57+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# Copyright © 2020, Oracle and/or its affiliates.
2+
# All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl
3+
4+
#####################################################################
5+
## Always Free + Paid Resources
6+
#####################################################################
7+
// Security Group for SSH
8+
resource "oci_core_network_security_group" "security_group_ssh" {
9+
compartment_id = var.compartment_ocid
10+
vcn_id = oci_core_vcn.vcn.id
11+
display_name = format("%s-security-group-ssh", var.proj_abrv)
12+
}
13+
// Security Group for SSH - EGRESS
14+
resource "oci_core_network_security_group_security_rule" "security_group_ssh_egress" {
15+
network_security_group_id = oci_core_network_security_group.security_group_ssh.id
16+
direction = "EGRESS"
17+
protocol = "6"
18+
destination = "0.0.0.0/0"
19+
destination_type = "CIDR_BLOCK"
20+
}
21+
// Security Group for SSH - INGRES
22+
resource "oci_core_network_security_group_security_rule" "security_group_ssh_ingress_TCP22" {
23+
network_security_group_id = oci_core_network_security_group.security_group_ssh.id
24+
direction = "INGRESS"
25+
protocol = "6"
26+
source = "0.0.0.0/0"
27+
source_type = "CIDR_BLOCK"
28+
tcp_options {
29+
destination_port_range {
30+
max = 22
31+
min = 22
32+
}
33+
}
34+
}
35+
36+
// Security Group for Load Balancer (lb)
37+
resource "oci_core_network_security_group" "security_group_lb" {
38+
compartment_id = var.compartment_ocid
39+
vcn_id = oci_core_vcn.vcn.id
40+
display_name = format("%s-security-group-lb", var.proj_abrv)
41+
}
42+
// Security Group for Load Balancer (lb) - EGRESS
43+
resource "oci_core_network_security_group_security_rule" "security_group_lb_egress" {
44+
network_security_group_id = oci_core_network_security_group.security_group_lb.id
45+
direction = "EGRESS"
46+
protocol = "6"
47+
destination = "0.0.0.0/0"
48+
destination_type = "CIDR_BLOCK"
49+
}
50+
// Security Group for Load Balancer (lb) - INGRESS
51+
resource "oci_core_network_security_group_security_rule" "security_group_lb_inress_TCP80" {
52+
network_security_group_id = oci_core_network_security_group.security_group_lb.id
53+
direction = "INGRESS"
54+
protocol = "6"
55+
source = "0.0.0.0/0"
56+
source_type = "CIDR_BLOCK"
57+
tcp_options {
58+
destination_port_range {
59+
max = 80
60+
min = 80
61+
}
62+
}
63+
}
64+
resource "oci_core_network_security_group_security_rule" "security_group_lb_inress_TCP443" {
65+
network_security_group_id = oci_core_network_security_group.security_group_lb.id
66+
direction = "INGRESS"
67+
protocol = "6"
68+
source = "0.0.0.0/0"
69+
source_type = "CIDR_BLOCK"
70+
tcp_options {
71+
destination_port_range {
72+
max = 443
73+
min = 443
74+
}
75+
}
76+
}
77+
78+
// Security Group for ORDS
79+
resource "oci_core_network_security_group" "security_group_ords" {
80+
compartment_id = var.compartment_ocid
81+
vcn_id = oci_core_vcn.vcn.id
82+
display_name = format("%s-security-group-ords", var.proj_abrv)
83+
}
84+
// Security Group for ORDS - EGRESS
85+
resource "oci_core_network_security_group_security_rule" "security_group_ords_egress_grp" {
86+
network_security_group_id = oci_core_network_security_group.security_group_ords.id
87+
direction = "EGRESS"
88+
protocol = "6"
89+
destination = oci_core_network_security_group.security_group_ords.id
90+
destination_type = "NETWORK_SECURITY_GROUP"
91+
}
92+
resource "oci_core_network_security_group_security_rule" "security_group_ords_egress" {
93+
network_security_group_id = oci_core_network_security_group.security_group_ords.id
94+
direction = "EGRESS"
95+
protocol = "6"
96+
destination = "0.0.0.0/0"
97+
destination_type = "CIDR_BLOCK"
98+
}
99+
// Security Group for ORDS - INGRESS
100+
resource "oci_core_network_security_group_security_rule" "security_group_ords_ingress_TCP8080" {
101+
network_security_group_id = oci_core_network_security_group.security_group_ords.id
102+
direction = "INGRESS"
103+
protocol = "6"
104+
source = var.public_subnet_cidr
105+
source_type = "CIDR_BLOCK"
106+
tcp_options {
107+
destination_port_range {
108+
max = 8080
109+
min = 8080
110+
}
111+
}
112+
}
113+
114+
#####################################################################
115+
## Paid Resources
116+
#####################################################################
117+
resource "oci_core_network_security_group" "security_group_adb" {
118+
count = local.is_always_free ? 0 : 1
119+
compartment_id = var.compartment_ocid
120+
vcn_id = oci_core_vcn.vcn.id
121+
display_name = format("%s-security-group-adb", var.proj_abrv)
122+
}
123+
// Security Group for ADB - EGRESS
124+
resource "oci_core_network_security_group_security_rule" "security_group_adb_egress" {
125+
count = local.is_always_free ? 0 : 1
126+
network_security_group_id = oci_core_network_security_group.security_group_adb[0].id
127+
direction = "EGRESS"
128+
protocol = "6"
129+
destination = var.private_subnet_cidr
130+
destination_type = "CIDR_BLOCK"
131+
}
132+
// Security Group for ADB - INGRESS
133+
resource "oci_core_network_security_group_security_rule" "security_group_adb_ingress_TCP1522" {
134+
count = local.is_always_free ? 0 : 1
135+
network_security_group_id = oci_core_network_security_group.security_group_adb[0].id
136+
direction = "INGRESS"
137+
protocol = "6"
138+
source = var.private_subnet_cidr
139+
source_type = "CIDR_BLOCK"
140+
tcp_options {
141+
destination_port_range {
142+
max = 1522
143+
min = 1522
144+
}
145+
}
146+
}

0 commit comments

Comments
 (0)