diff --git a/Project-15_Deploying MS Architecture with Kubernetes /README.md b/Project-15_Deploying MS Architecture with Kubernetes /README.md deleted file mode 100644 index d76dde2..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /README.md +++ /dev/null @@ -1,164 +0,0 @@ -# Project-15: Deploying MS Architecture with Kubernetes and Terraform - -![](images/Project-15.png) - -## Pre-requisites - -* AWS Account -* Terraform installed locally (you can also create an Ec2 instance and install terraform onto ec2) or use CFN template -* DockerHub account - -### Step-1: Create K8s cluster with Terraform or CloudFormation - -#### With Terraform - -We will create a 1 Master Node & 1 Worker Node K8s cluster with Terraform files given under `terraform-files-to-create-K8s-cluster` directory. While we are inside of this directory, we will run below commands: -```sh -terraform init -terraform validate -terraform plan -terraform apply -``` - -#### With Cloudformation - -If we dont want to install Terraform, we can create K8s cluster using cfn template given under `cfn-template-to-create-K8s-cluster`. We need to go to AWS Console and upload this file to create our stack. It can be also done with awscli command. - -### Step-2: Write Dockerfile for WebServer - -Go to `image_for_web_server` directory and create a Dockerfile with below content. -```sh -FROM python:alpine -COPY . /app -WORKDIR /app -RUN pip install -r requirements.txt -EXPOSE 80 -CMD python app.py -``` - -### Step-3: Write Dockerfile for ResultServer - -Go to `image_for_web_server` directory and create a Dockerfile with below content. -```sh -FROM python:alpine -COPY . /app -WORKDIR /app -RUN pip install -r requirements.txt -EXPOSE 80 -CMD python app.py -``` - -### Step-4: Create Docker images and push to DockerHub - -#### Create Image -SSH into your K8s master node. Move the `image_for_result_server` and `image_for_web_server` folders to master node. (You can use VSCode remote SSH extension and drag/drop the files or create repo with those files and clone it ) - -Go to `image_for_web_server` directory, run below command -```bash -docker build -t /phonebook-webserver . -``` - -Create Docker image from Dockerfile under result_server/create_image/ directory with below command -```bash -docker build -t /phonebook-resultserver . -``` - -![](images/images-created.png) - -#### Push images - -First login to your dockerHub account -```bash -docker login -Username: -Password: -``` - -Then push your images to DockerHub -```bash -docker push /phonebook-webserver -docker push /phonebook-resultserver -``` - -![](images/images-pushed.png) - -### Step-5: Change image names - -Go to `resultserver_deployment.yml` change image name to you have pushed to DockerHub -```sh - spec: - containers: - - name: result-app - image: rumeysakdogan/phonebook-resultserver -``` - -Go to `webserver_deployment.yml` change image name to you have pushed to DockerHub -```sh - spec: - containers: - - name: result-app - image: rumeysakdogan/phonebook-webserver -``` - -### Step-6: Create secret/configMap - -We will create a secret manifest to store DB_passwords. Before we create Secret we need to encode passwords by using base64. - -I will use Clarusway_1 as my `mysql-admin-password` and `R1234r` `mysql-root-password`. So I need to encode it with below command, and use it in secret file. -```sh -echo -n 'CLarusway_1' | base64 -> Q2xhcnVzd2F5XzE= -echo -n 'R1234r' | base64 -> UjEyMzRy -``` - -We can also decode the secrets with below command: -```sh -echo -n 'UjEyMzRy' | base64 --decode -echo -n 'Q2xhcnVzd2F5XzE=' | base64 -``` - -Go to `kubernetes-manifests/secrets_configMap` directory, and create secret and configmap: -```sh -kubectl apply -f mysql_secret.yaml -kubectl apply -f database_configmap.yaml -kubectl apply -f servers_configmap.yaml -``` - -### Step-6: Create my_sql database - -Go to `kubernetes-manifests/mysql_deployment` directory,and create manifests with below command: -```sh -kubectl apply -f . -``` - -### Step-7: Create webserver - -Go to `kubernetes-manifests/mysql_deployment` directory,and create manifests with below command: -```sh -kubectl apply -f . -``` -Now we can see our deployments, services, pods and replicasets with `kubectl get all` command: - -![](images/kube-apply-complete.png) - -### Step-8: Add Nodeports to security group of Worker Node - -Resultserver is running on NodePort: 30002 -Webserver is running on NodePort: 30001 - -We will add these ports to SecGrp of Worker Node. - -![](images/nodeports-added-to-sg.png) - -### Step-9: Check your application is up and running - -Check your application from browser with below urls: - -* Webserver: :30001 - -![](images/phonebook-web-server.png) - -* Resultserver: :30002 - -![](images/phonebook-resullt-server.png) diff --git a/Project-15_Deploying MS Architecture with Kubernetes /cfn-template-to-create-K8s-cluster/kubernetes-env-cf.yaml b/Project-15_Deploying MS Architecture with Kubernetes /cfn-template-to-create-K8s-cluster/kubernetes-env-cf.yaml deleted file mode 100644 index 2b585b5..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /cfn-template-to-create-K8s-cluster/kubernetes-env-cf.yaml +++ /dev/null @@ -1,229 +0,0 @@ -AWSTemplateFormatVersion: 2010-09-09 - -Description: | - This Cloudformation Template creates a Kubernetes Cluster on Ubuntu 20.04 of EC2 Instances. - Kubernetes cluster comprises of one master node and one worker node. - Once the Master node is up and running, Worker node automatically joins the Cluster. - Managers security group allows all protocols from all ports within itself and from the Workers. - Workers security group allows all protocols from all ports within itself and from the Managers. - Both Security groups allows SSH (22) connections from anywhere. - User needs to select appropriate key name when launching the template. - This template is designed for us-east-1 (N. Virginia) region. If you work on another region, do not forget to change instances imageId - -Parameters: - KeyPairName: - Description: Enter the name of your Key Pair for SSH connections. - Type: AWS::EC2::KeyPair::KeyName - ConstraintDescription: Must be one of the existing EC2 KeyPair - -Resources: - InstanceConnectPolicy: - Type: "AWS::IAM::ManagedPolicy" - Properties: - PolicyDocument: #required - Version: 2012-10-17 - Statement: - - Effect: Allow - Action: - - ec2-instance-connect:SendSSHPublicKey - Resource: - - !Sub arn:aws:ec2:${AWS::Region}:${AWS::AccountId}:instance/* - Condition: {"StringEquals": {"ec2:osuser": "ubuntu"}} - - Effect: Allow - Action: - - ec2:DescribeInstances - Resource: "*" - - EC2InstanceConnect: - Type: "AWS::IAM::Role" - Properties: - AssumeRolePolicyDocument: - Statement: - - Effect: Allow - Principal: - Service: - - ec2.amazonaws.com - Action: - - 'sts:AssumeRole' - ManagedPolicyArns: - - !Ref InstanceConnectPolicy - EC2ConnectProfile: - Type: "AWS::IAM::InstanceProfile" - Properties: - Roles: #required - - !Ref EC2InstanceConnect - ManagersSecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - GroupDescription: Enable SSH for Kube Masters - SecurityGroupIngress: - - IpProtocol: tcp - FromPort: 22 - ToPort: 22 - CidrIp: 0.0.0.0/0 - WorkersSecurityGroup: - Type: AWS::EC2::SecurityGroup - Properties: - GroupDescription: Enable SSH for Kube Workers - SecurityGroupIngress: - - IpProtocol: tcp - FromPort: 22 - ToPort: 22 - CidrIp: 0.0.0.0/0 - ManagersSGIngress1: - Type: "AWS::EC2::SecurityGroupIngress" - Properties: - GroupId: !GetAtt ManagersSecurityGroup.GroupId - IpProtocol: -1 #required - SourceSecurityGroupId: !GetAtt ManagersSecurityGroup.GroupId - ManagersSGIngress2: - Type: "AWS::EC2::SecurityGroupIngress" - Properties: - GroupId: !GetAtt ManagersSecurityGroup.GroupId - IpProtocol: -1 #required - SourceSecurityGroupId: !GetAtt WorkersSecurityGroup.GroupId - WorkersSGIngress1: - Type: "AWS::EC2::SecurityGroupIngress" - Properties: - GroupId: !GetAtt WorkersSecurityGroup.GroupId - IpProtocol: -1 #required - SourceSecurityGroupId: !GetAtt WorkersSecurityGroup.GroupId - WorkersSGIngress2: - Type: "AWS::EC2::SecurityGroupIngress" - Properties: - GroupId: !GetAtt WorkersSecurityGroup.GroupId - IpProtocol: -1 #required - SourceSecurityGroupId: !GetAtt ManagersSecurityGroup.GroupId - - KubeMaster1: - Type: AWS::EC2::Instance - Properties: - ImageId: ami-08d4ac5b634553e16 - InstanceType: t3a.medium - KeyName: !Ref KeyPairName - IamInstanceProfile: !Ref EC2ConnectProfile - SecurityGroupIds: - - !GetAtt ManagersSecurityGroup.GroupId - Tags: - - - Key: Name - Value: !Sub Kube Master 1st on Ubuntu 20.04 of ${AWS::StackName} - UserData: - Fn::Base64: - !Sub | - #! /bin/bash - apt-get update -y - apt-get upgrade -y - hostnamectl set-hostname kube-master - chmod 777 /etc/sysctl.conf - echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf - sysctl -p - chmod 644 /etc/sysctl.conf - apt install -y docker.io - systemctl start docker - mkdir /etc/docker - cat <> /etc/sysctl.conf - sysctl -p - chmod 644 /etc/sysctl.conf - apt install -y docker.io - systemctl start docker - cat </dev/null | openssl dgst -sha256 -hex | sed 's/^.* //') --ignore-preflight-errors=All - -Outputs: - 1stKubeMasterPublicDNSName: - Description: Kube Master 1st Public DNS Name - Value: !Sub - - ${PublicAddress} - - PublicAddress: !GetAtt KubeMaster1.PublicDnsName - 1stKubeMasterPrivateDNSName: - Description: Kube Master 1st Private DNS Name - Value: !Sub - - ${PrivateAddress} - - PrivateAddress: !GetAtt KubeMaster1.PrivateDnsName - 1stKubeWorkerPublicDNSName: - Description: Kube Worker 1st Public DNS Name - Value: !Sub - - ${PublicAddress} - - PublicAddress: !GetAtt KubeWorker1.PublicDnsName - 1stKubeWorkerPrivateDNSName: - Description: Kube Worker 1st Private DNS Name - Value: !Sub - - ${PrivateAddress} - - PrivateAddress: !GetAtt KubeWorker1.PrivateDnsName diff --git a/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/Dockerfile b/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/Dockerfile deleted file mode 100644 index dca7550..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM python:alpine -COPY . /app -WORKDIR /app -RUN pip install -r requirements.txt -EXPOSE 80 -CMD python app.py diff --git a/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/app.py b/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/app.py deleted file mode 100644 index 9b72e7b..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/app.py +++ /dev/null @@ -1,52 +0,0 @@ -# Import Flask modules -from flask import Flask, request, render_template -from flaskext.mysql import MySQL -import os - -# Create an object named app -app = Flask(__name__) - -# Configure mysql database -app.config['MYSQL_DATABASE_HOST'] = os.getenv('MYSQL_DATABASE_HOST') -app.config['MYSQL_DATABASE_PASSWORD'] = os.getenv('MYSQL_PASSWORD') -app.config['MYSQL_DATABASE_DB'] = os.getenv('MYSQL_DATABASE') -app.config['MYSQL_DATABASE_USER'] = os.getenv('MYSQL_USER') -#app.config['MYSQL_DATABASE_PORT'] = 3306 -mysql = MySQL() -mysql.init_app(app) -connection = mysql.connect() -connection.autocommit(True) -cursor = connection.cursor() - -# Write a function named `find_persons` which finds persons' record using the keyword from the phonebook table in the db, -# and returns result as list of dictionary -# `[{'id': 1, 'name':'XXXX', 'number': 'XXXXXX'}]`. -def find_persons(keyword): - query = f""" - SELECT * FROM phonebook WHERE name like '%{keyword.strip().lower()}%'; - """ - cursor.execute(query) - result = cursor.fetchall() - persons =[{'id':row[0], 'name':row[1].strip().title(), 'number':row[2]} for row in result] - if len(persons) == 0: - persons = [{'name':'No Result', 'number':'No Result'}] - return persons - - -# Write a function named `find_records` which finds phone records by keyword using `GET` and `POST` methods, -# using template files named `index.html` given under `templates` folder -# and assign to the static route of ('/') -@app.route('/', methods=['GET', 'POST']) -def find_records(): - if request.method == 'POST': - keyword = request.form['username'] - persons = find_persons(keyword) - return render_template('index.html', persons=persons, keyword=keyword, show_result=True, developer_name='Rumeysa') - else: - return render_template('index.html', show_result=False, developer_name='Rumeysa') - - -# Add a statement to run the Flask application which can be reached from any host on port 80. -if __name__== '__main__': - #app.run(debug=True) - app.run(host='0.0.0.0', port=80) diff --git a/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/requirements.txt b/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/requirements.txt deleted file mode 100644 index e7a444c..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -flask -flask-mysql \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/templates/index.html b/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/templates/index.html deleted file mode 100644 index 24d30b5..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /image_for_result_server/templates/index.html +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - Kubernetes Deployment of MicroServices Project - - - - - -
- -

Project : Phonebook Application

-

Welcome to {{developer_name}}'s Phonebook Application

-

Enter a name to search

- -
- - - - {% if show_result %} -

Result for '{{ keyword }}'

-
    - {% for person in persons %} -
  • Name: {{ person['name'] }} ---- Phone Number: {{ person['number'] }}
  • - {% endfor %} -
- {% endif %} -
- -

This app is developed in Python by {{ developer_name }} and deployed with Flask on AWS Cloud using Kubernetes.

- - - diff --git a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/Dockerfile b/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/Dockerfile deleted file mode 100644 index dca7550..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM python:alpine -COPY . /app -WORKDIR /app -RUN pip install -r requirements.txt -EXPOSE 80 -CMD python app.py diff --git a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/app.py b/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/app.py deleted file mode 100644 index b2f6494..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/app.py +++ /dev/null @@ -1,170 +0,0 @@ -# Import Flask modules -from flask import Flask, request, render_template -from flaskext.mysql import MySQL -import os - -# Create an object named app -app = Flask(__name__) - -# Configure mysql database -app.config['MYSQL_DATABASE_HOST'] = os.getenv('MYSQL_DATABASE_HOST') -app.config['MYSQL_DATABASE_PASSWORD'] = os.getenv('MYSQL_PASSWORD') -app.config['MYSQL_DATABASE_DB'] = os.getenv('MYSQL_DATABASE') -app.config['MYSQL_DATABASE_USER'] = os.getenv('MYSQL_USER') -#app.config['MYSQL_DATABASE_PORT'] = 3306 -mysql = MySQL() -mysql.init_app(app) -connection = mysql.connect() -connection.autocommit(True) -cursor = connection.cursor() - -# Write a function named `init_todo_db` which initializes the todo db -# Create P table within sqlite db. - - -def init_phonebook_db(): - phonebook_table = """ - CREATE TABLE IF NOT EXISTS phonebook.phonebook( - id INT NOT NULL AUTO_INCREMENT, - name VARCHAR(100) NOT NULL, - number VARCHAR(100) NOT NULL, - PRIMARY KEY (id) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - """ - cursor.execute(phonebook_table) - -# Write a function named `insert_person` which inserts person into the phonebook table in the db, -# and returns text info about result of the operation - - -def insert_person(name, number): - query = f""" - SELECT * FROM phonebook WHERE name like '{name.strip().lower()}'; - """ - cursor.execute(query) - row = cursor.fetchone() - if row is not None: - return f'Person with name {row[1].title()} already exits.' - - insert = f""" - INSERT INTO phonebook (name, number) - VALUES ('{name.strip().lower()}', '{number}'); - """ - cursor.execute(insert) - result = cursor.fetchall() - return f'Person {name.strip().title()} added to Phonebook successfully' - -# Write a function named `update_person` which updates the person's record in the phonebook table, -# and returns text info about result of the operation - - -def update_person(name, number): - query = f""" - SELECT * FROM phonebook WHERE name like '{name.strip().lower()}'; - """ - cursor.execute(query) - row = cursor.fetchone() - if row is None: - return f'Person with name {name.strip().title()} does not exist.' - - update = f""" - UPDATE phonebook - SET name='{row[1]}', number = '{number}' - WHERE id= {row[0]}; - """ - cursor.execute(update) - - return f'Phone record of {name.strip().title()} is updated successfully' - - -# Write a function named `delete_person` which deletes person record from the phonebook table in the db, -# and returns returns text info about result of the operation -def delete_person(name): - query = f""" - SELECT * FROM phonebook WHERE name like '{name.strip().lower()}'; - """ - cursor.execute(query) - row = cursor.fetchone() - if row is None: - return f'Person with name {name.strip().title()} does not exist, no need to delete.' - - delete = f""" - DELETE FROM phonebook - WHERE id= {row[0]}; - """ - cursor.execute(delete) - return f'Phone record of {name.strip().title()} is deleted from the phonebook successfully' - - -# Write a function named `add_record` which inserts new record to the database using `GET` and `POST` methods, -# using template files named `add-update.html` given under `templates` folder -# and assign to the static route of ('add') -@app.route('/add', methods=['GET', 'POST']) -def add_record(): - if request.method == 'POST': - name = request.form['username'] - if name is None or name.strip() == "": - return render_template('add-update.html', not_valid=True, message='Invalid input: Name can not be empty', show_result=False, action_name='save', developer_name='Rumeysa') - elif name.isdecimal(): - return render_template('add-update.html', not_valid=True, message='Invalid input: Name of person should be text', show_result=False, action_name='save', developer_name='Rumeysa') - - phone_number = request.form['phonenumber'] - if phone_number is None or phone_number.strip() == "": - return render_template('add-update.html', not_valid=True, message='Invalid input: Phone number can not be empty', show_result=False, action_name='save', developer_name='Rumeysa') - elif not phone_number.isdecimal(): - return render_template('add-update.html', not_valid=True, message='Invalid input: Phone number should be in numeric format', show_result=False, action_name='save', developer_name='Rumeysa') - - result = insert_person(name, phone_number) - return render_template('add-update.html', show_result=True, result=result, not_valid=False, action_name='save', developer_name='Rumeysa') - else: - return render_template('add-update.html', show_result=False, not_valid=False, action_name='save', developer_name='Rumeysa') - -# Write a function named `update_record` which updates the record in the db using `GET` and `POST` methods, -# using template files named `add-update.html` given under `templates` folder -# and assign to the static route of ('update') - - -@app.route('/update', methods=['GET', 'POST']) -def update_record(): - if request.method == 'POST': - name = request.form['username'] - if name is None or name.strip() == "": - return render_template('add-update.html', not_valid=True, message='Invalid input: Name can not be empty', show_result=False, action_name='update', developer_name='Rumeysa') - phone_number = request.form['phonenumber'] - if phone_number is None or phone_number.strip() == "": - return render_template('add-update.html', not_valid=True, message='Invalid input: Phone number can not be empty', show_result=False, action_name='update', developer_name='Rumeysa') - elif not phone_number.isdecimal(): - return render_template('add-update.html', not_valid=True, message='Invalid input: Phone number should be in numeric format', show_result=False, action_name='update', developer_name='Rumeysa') - - result = update_person(name, phone_number) - return render_template('add-update.html', show_result=True, result=result, not_valid=False, action_name='update', developer_name='Rumeysa') - else: - return render_template('add-update.html', show_result=False, not_valid=False, action_name='update', developer_name='Rumeysa') - -# Write a function named `delete_record` which updates the record in the db using `GET` and `POST` methods, -# using template files named `delete.html` given under `templates` folder -# and assign to the static route of ('delete') - - -@app.route('/delete', methods=['GET', 'POST']) -def delete_record(): - if request.method == 'POST': - name = request.form['username'] - if name is None or name.strip() == "": - return render_template('delete.html', not_valid=True, message='Invalid input: Name can not be empty', show_result=False, developer_name='Rumeysa') - result = delete_person(name) - return render_template('delete.html', show_result=True, result=result, not_valid=False, developer_name='Rumeysa') - else: - return render_template('delete.html', show_result=False, not_valid=False, developer_name='Rumeysa') - - -@app.route('/', methods=['GET', 'POST']) -def find_records(): - return render_template('index.html', show_result=False, developer_name='Rumeysa') - - -# Add a statement to run the Flask application which can be reached from any host on port 80. -if __name__ == '__main__': - init_phonebook_db() - # app.run(debug=True) - app.run(host='0.0.0.0', port=80) diff --git a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/requirements.txt b/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/requirements.txt deleted file mode 100644 index e7a444c..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/requirements.txt +++ /dev/null @@ -1,2 +0,0 @@ -flask -flask-mysql \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/templates/add-update.html b/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/templates/add-update.html deleted file mode 100644 index 36a648f..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/templates/add-update.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - Kubernetes Deployment of MicroServices Project - - - - - -
- -

Project : Phonebook Application

-

Welcome to {{developer_name}}'s Phonebook Application

-

Enter a name and phone number to {{action_name}}

- -
- - - - - - {% if not_valid %} -

{{ message }}

- {% endif %} - {% if show_result %} -

{{ result }}

- {% endif %} -
- -

This app is developed in Python by {{ developer_name }} and deployed with Flask on AWS Cloud using Kubernetes.

- - - - \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/templates/delete.html b/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/templates/delete.html deleted file mode 100644 index 9ecb122..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/templates/delete.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - Kubernetes Deployment of MicroServices Project - - - - - -
- -

Project : Phonebook Application

-

Welcome to {{developer_name}}'s Phonebook Application

-

Enter a name to delete

- -
- - - - {% if not_valid %} -

{{ message }}

- {% endif %} - {% if show_result %} -

{{ result }}

- {% endif %} -
- -

This app is developed in Python by {{ developer_name }} and deployed with Flask on AWS Cloud using Clouldformation Service.

- - - - \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/templates/index.html b/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/templates/index.html deleted file mode 100644 index f70e7c6..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /image_for_web_server/templates/index.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - Kubernetes Deployment of MicroServices Project - - - - - -
- -

Project : Phonebook Application

-

Welcome to {{developer_name}}'s Phonebook Application

-

Please select operation:

- -
- -
- -
- -
- -
- -
- -

This app is developed in Python by {{ developer_name }} and deployed with Flask on AWS EC2 using Kubernetes.

- - - diff --git a/Project-15_Deploying MS Architecture with Kubernetes /images/Project-15.png b/Project-15_Deploying MS Architecture with Kubernetes /images/Project-15.png deleted file mode 100644 index 1999a43..0000000 Binary files a/Project-15_Deploying MS Architecture with Kubernetes /images/Project-15.png and /dev/null differ diff --git a/Project-15_Deploying MS Architecture with Kubernetes /images/images-created.png b/Project-15_Deploying MS Architecture with Kubernetes /images/images-created.png deleted file mode 100644 index 90894df..0000000 Binary files a/Project-15_Deploying MS Architecture with Kubernetes /images/images-created.png and /dev/null differ diff --git a/Project-15_Deploying MS Architecture with Kubernetes /images/images-pushed.png b/Project-15_Deploying MS Architecture with Kubernetes /images/images-pushed.png deleted file mode 100644 index 09560f6..0000000 Binary files a/Project-15_Deploying MS Architecture with Kubernetes /images/images-pushed.png and /dev/null differ diff --git a/Project-15_Deploying MS Architecture with Kubernetes /images/kube-apply-complete.png b/Project-15_Deploying MS Architecture with Kubernetes /images/kube-apply-complete.png deleted file mode 100644 index 4bf6225..0000000 Binary files a/Project-15_Deploying MS Architecture with Kubernetes /images/kube-apply-complete.png and /dev/null differ diff --git a/Project-15_Deploying MS Architecture with Kubernetes /images/nodeports-added-to-sg.png b/Project-15_Deploying MS Architecture with Kubernetes /images/nodeports-added-to-sg.png deleted file mode 100644 index 2acdc36..0000000 Binary files a/Project-15_Deploying MS Architecture with Kubernetes /images/nodeports-added-to-sg.png and /dev/null differ diff --git a/Project-15_Deploying MS Architecture with Kubernetes /images/phonebook-resullt-server.png b/Project-15_Deploying MS Architecture with Kubernetes /images/phonebook-resullt-server.png deleted file mode 100644 index 44f31d4..0000000 Binary files a/Project-15_Deploying MS Architecture with Kubernetes /images/phonebook-resullt-server.png and /dev/null differ diff --git a/Project-15_Deploying MS Architecture with Kubernetes /images/phonebook-web-server.png b/Project-15_Deploying MS Architecture with Kubernetes /images/phonebook-web-server.png deleted file mode 100644 index 8af18dd..0000000 Binary files a/Project-15_Deploying MS Architecture with Kubernetes /images/phonebook-web-server.png and /dev/null differ diff --git a/Project-15_Deploying MS Architecture with Kubernetes /images/secret-created.png b/Project-15_Deploying MS Architecture with Kubernetes /images/secret-created.png deleted file mode 100644 index 1928040..0000000 Binary files a/Project-15_Deploying MS Architecture with Kubernetes /images/secret-created.png and /dev/null differ diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/.DS_Store b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/.DS_Store deleted file mode 100644 index 5dce1fb..0000000 Binary files a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/.DS_Store and /dev/null differ diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/mysql_deployment.yaml b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/mysql_deployment.yaml deleted file mode 100644 index b68ccfd..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/mysql_deployment.yaml +++ /dev/null @@ -1,44 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: mysql-deploy - labels: - name: mysql-deploy -spec: - replicas: 1 - selector: - matchLabels: - name: mysql-pod - template: - metadata: - name: mysql-pod - labels: - name: mysql-pod - spec: - containers: - - image: mysql:5.7 - name: mysql - imagePullPolicy: Always #https://kubernetes.io/docs/concepts/configuration/overview/ - env: - - name: MYSQL_PASSWORD - valueFrom: - secretKeyRef: - name: mysql-secret - key: mysql-admin-password - - name: MYSQL_ROOT_PASSWORD - valueFrom: - secretKeyRef: - name: mysql-secret - key: mysql-root-password - envFrom: - - configMapRef: - name: database-configmap - ports: - - containerPort: 3306 - volumeMounts: - - name: mysql-persistent-storage - mountPath: /var/lib/mysql - volumes: - - name: mysql-persistent-storage - persistentVolumeClaim: - claimName: mysql-pv-claim \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/mysql_service.yaml b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/mysql_service.yaml deleted file mode 100644 index fed2fe6..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/mysql_service.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: mysql-service - labels: - name: mysql-service -spec: - ports: - - port: 3306 - targetPort: 3306 - selector: - name: mysql-pod \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/persistent_volume.yaml b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/persistent_volume.yaml deleted file mode 100644 index a888f0a..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/persistent_volume.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: PersistentVolume -metadata: - name: mysql-pv-volume - labels: - type: local -spec: - storageClassName: manual - capacity: - storage: 20Gi - accessModes: - - ReadWriteOnce - hostPath: - path: "/mnt/data" \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/persitent_volume_claim.yaml b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/persitent_volume_claim.yaml deleted file mode 100644 index 5de9a2a..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/mysql_deployment/persitent_volume_claim.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: mysql-pv-claim -spec: - storageClassName: manual - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 20Gi \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/result_server/result_server_deployment.yaml b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/result_server/result_server_deployment.yaml deleted file mode 100644 index 6b74fd9..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/result_server/result_server_deployment.yaml +++ /dev/null @@ -1,33 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: result-app-deploy - labels: - name: result-app-deploy -spec: - replicas: 1 - selector: - matchLabels: - name: result-app-pod - template: - metadata: - name: result-app-pod - labels: - name: result-app-pod - spec: - containers: - - name: result-app - image: rumeysakdogan/phonebook-resultserver - ports: - - containerPort: 80 - env: - - name: MYSQL_PASSWORD - valueFrom: - secretKeyRef: - name: mysql-secret - key: mysql-admin-password - envFrom: - - configMapRef: - name: servers-configmap - - diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/result_server/result_server_service.yaml b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/result_server/result_server_service.yaml deleted file mode 100644 index 666e41b..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/result_server/result_server_service.yaml +++ /dev/null @@ -1,14 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: result-service - labels: - name: result-service -spec: - type: NodePort - ports: - - port: 80 - targetPort: 80 - nodePort: 30002 - selector: - name: result-app-pod diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/secrets_configMap/database_configmap.yaml b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/secrets_configMap/database_configmap.yaml deleted file mode 100644 index 75a6446..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/secrets_configMap/database_configmap.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: database-configmap -data: - MYSQL_USER: clarus - MYSQL_DATABASE: phonebook \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/secrets_configMap/mysql_secret.yaml b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/secrets_configMap/mysql_secret.yaml deleted file mode 100644 index 18a5a53..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/secrets_configMap/mysql_secret.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: v1 -kind: Secret -metadata: - name: mysql-secret -type: Opaque -data: - mysql-admin-password: Q2xhcnVzd2F5XzE= - mysql-root-password: UjEyMzRy - diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/secrets_configMap/servers_configmap.yaml b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/secrets_configMap/servers_configmap.yaml deleted file mode 100644 index 657d585..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/secrets_configMap/servers_configmap.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: servers-configmap -data: - MYSQL_DATABASE_HOST: mysql-service.default.svc.cluster.local - MYSQL_USER: clarus - MYSQL_DATABASE: phonebook - - diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/web_server/web_server_deployment.yaml b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/web_server/web_server_deployment.yaml deleted file mode 100644 index 32cc929..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/web_server/web_server_deployment.yaml +++ /dev/null @@ -1,31 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: phonebook-app-deploy - labels: - app: phonebook-app-deploy -spec: - replicas: 1 - selector: - matchLabels: - name: phonebook-app-pod - template: - metadata: - name: phonebook-app-pod - labels: - name: phonebook-app-pod - spec: - containers: - - name: phonebook-app - image: rumeysakdogan/phonebook-webserver - ports: - - containerPort: 80 - env: - - name: MYSQL_PASSWORD - valueFrom: - secretKeyRef: - name: mysql-secret - key: mysql-admin-password - envFrom: - - configMapRef: - name: servers-configmap \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/web_server/web_server_service.yaml b/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/web_server/web_server_service.yaml deleted file mode 100644 index 4bf85f0..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /kubernetes-manifests/web_server/web_server_service.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: phonebook-service - labels: - name: phonebook-service -spec: - #type: LoadBalancer # --> not working for now... - type: NodePort - ports: - - port: 80 - targetPort: 80 - nodePort: 30001 - selector: - name: phonebook-app-pod \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /terraform-files-to-create-K8s-cluster/main.tf b/Project-15_Deploying MS Architecture with Kubernetes /terraform-files-to-create-K8s-cluster/main.tf deleted file mode 100644 index 7699121..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /terraform-files-to-create-K8s-cluster/main.tf +++ /dev/null @@ -1,169 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 4.0" - } - } -} - -provider "aws" { - region = "us-east-1" -} - -data "aws_caller_identity" "current" {} - -data "aws_region" "current" {} - -variable "key-name" { - default = "FirstKey" # change here -} - -locals { - name = "rd" # change here, optional -} - -resource "aws_instance" "master" { - ami = "ami-08d4ac5b634553e16" - instance_type = "t3a.medium" - key_name = var.key-name - iam_instance_profile = aws_iam_instance_profile.ec2connectprofile.name - vpc_security_group_ids = [ aws_security_group.tf-k8s-master-sec-gr.id ] - user_data = data.template_file.master.rendered - tags = { - Name = "${local.name}-kube-master" - } -} - -resource "aws_instance" "worker" { - ami = "ami-08d4ac5b634553e16" - instance_type = "t3a.medium" - key_name = var.key-name - iam_instance_profile = aws_iam_instance_profile.ec2connectprofile.name - vpc_security_group_ids = [ aws_security_group.tf-k8s-master-sec-gr.id ] - user_data = data.template_file.worker.rendered - tags = { - Name = "${local.name}-kube-worker" - } - depends_on = [aws_instance.master] -} - -resource "aws_iam_instance_profile" "ec2connectprofile" { - name = "ec2connectprofile" - role = aws_iam_role.ec2connectcli.name -} - -resource "aws_iam_role" "ec2connectcli" { - name = "ec2connectcli" - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Action = "sts:AssumeRole" - Effect = "Allow" - Sid = "" - Principal = { - Service = "ec2.amazonaws.com" - } - }, - ] - }) - - inline_policy { - name = "my_inline_policy" - - policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - "Effect" : "Allow", - "Action" : "ec2-instance-connect:SendSSHPublicKey", - "Resource" : "arn:aws:ec2:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:instance/*", - "Condition" : { - "StringEquals" : { - "ec2:osuser" : "ubuntu" - } - } - }, - { - "Effect" : "Allow", - "Action" : "ec2:DescribeInstances", - "Resource" : "*" - } - ] - }) - } -} - -data "template_file" "worker" { - template = file("worker.sh") - vars = { - region = data.aws_region.current.name - master-id = aws_instance.master.id - master-private = aws_instance.master.private_ip - } - -} - -data "template_file" "master" { - template = file("master.sh") -} - -resource "aws_security_group" "tf-k8s-master-sec-gr" { - name = "${local.name}-k8s-master-sec-gr" - tags = { - Name = "${local.name}-k8s-master-sec-gr" - } - - ingress { - from_port = 0 - protocol = "-1" - to_port = 0 - self = true - } - - ingress { - from_port = 22 - to_port = 22 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 80 - to_port = 80 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 30000 - to_port = 32767 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } - - egress { - from_port = 0 - protocol = "-1" - to_port = 0 - cidr_blocks = ["0.0.0.0/0"] - } -} - - -output "master_public_dns" { - value = aws_instance.master.public_dns -} - -output "master_private_dns" { - value = aws_instance.master.private_dns -} - -output "worker_public_dns" { - value = aws_instance.worker.public_dns -} - -output "worker_private_dns" { - value = aws_instance.worker.private_dns -} \ No newline at end of file diff --git a/Project-15_Deploying MS Architecture with Kubernetes /terraform-files-to-create-K8s-cluster/master.sh b/Project-15_Deploying MS Architecture with Kubernetes /terraform-files-to-create-K8s-cluster/master.sh deleted file mode 100644 index e706cf7..0000000 --- a/Project-15_Deploying MS Architecture with Kubernetes /terraform-files-to-create-K8s-cluster/master.sh +++ /dev/null @@ -1,38 +0,0 @@ -#! /bin/bash -apt-get update -y -apt-get upgrade -y -hostnamectl set-hostname kube-master -chmod 777 /etc/sysctl.conf -echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf -sysctl -p -chmod 644 /etc/sysctl.conf -apt install -y docker.io -systemctl start docker -mkdir /etc/docker -cat <> /etc/sysctl.conf -sysctl -p -chmod 644 /etc/sysctl.conf -apt install -y docker.io -systemctl start docker -cat </dev/null | openssl dgst -sha256 -hex | sed 's/^.* //') --ignore-preflight-errors=All \ No newline at end of file