This pattern shows how to deploy a cloud native website on Oracle Cloud Infrastructure (OCI) Container Engine for Kubernetes (OKE) via Continuos Integration and Continuos Deployment (CICD) pipeline using OCI DevOps service and integrate with fully managed MySQL Database Service (MDS)
- The website is built using Nginx and PHP as microservices and access MySQL Database Service.
- Nginx is exposed as a service of type Load Balancer and it's listening on TCP port 5000. PHP and MySQL will not be exposed for external connectivity to reduce external attack surface.
- Upon code commit to "main" branch, build pipeline will be triggered automatically to build and test the applications.
- Deployment pipeline will be triggered automatically once build pipeline runs successfully to deploy application to test OKE cluster, test it, and deploy it to production OKE cluster.
OCI provides one-click cluster deployment and will take care of creation of VCN, subnets, security list, Kubernetes Master and Worker Nodes.
Steps Here
Steps Here
Steps Here
Steps Here
Steps Here
Steps Here
Steps Here
Steps Here
Steps Here
-
Access MDS host using Bastion
a. Create Bastion session to MDS host
b. Create port forwarding using Bastion
ssh -i <privateKey> -N -L <localPort>:10.0.10.79:3306 -p 22 ocid1.bastionsession.oc1.uk-london-1.amaaaaaay5l3z3yadxxhqb2uyivjxudpvdielpfx6bsejxe2oz25wypxx7fq@host.bastion.uk-london-1.oci.oraclecloud.com
c. Install mysql shell from https://dev.mysql.com/downloads/shell/
d. Connect to MDS host
mysqlsh -h 127.0.0.1 -p '<MDS password>' -u <MDS user>
e. Create database. Switch to SQL mode by entering \sql.
\sql CREATE DATABASE webappdb;
f. List all databases
show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | webappdb | +--------------------+
-
Create db schema in MDS a. Switch to the right database.
use webappdb;
a. Insert the following SQL statement in mysql shell to create table.
CREATE TABLE `employee_data`( `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, `first_name` VARCHAR(50) NOT NULL, `last_name` VARCHAR(50) NOT NULL, `gender` VARCHAR(50) NOT NULL, `email` VARCHAR(50) NOT NULL, `hire_date` VARCHAR(50) NOT NULL, `department` VARCHAR(50) NOT NULL, `job` VARCHAR(50) NOT NULL, `salary` DECIMAL(10,2) NOT NULL )AUTO_INCREMENT=1;
b. Check the tables
show tables;