Skip to content

mehmetsungur/Kubernetes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Certainly! Here's an updated version of the README file that includes code snippets for the Jenkins pipeline, application code, and Terraform configuration:

Blogging Platform CI/CD

This repository contains the code and configuration for the Blogging Platform CI/CD pipeline, application code, and infrastructure provisioning using Terraform.

Jenkins Pipeline

The Jenkins pipeline automates the continuous integration and continuous deployment process for the Blogging Platform application. It consists of the following stages:

  1. Clone: This stage clones the source code repository for the Blogging Platform application.
stage('Clone') {
    steps {
        git 'https://github.com/yourusername/blogging-platform.git'
    }
}
  1. Build: This stage installs the required dependencies for the application.
stage('Build') {
    steps {
        container('python') {
            sh 'pip install -r requirements.txt'
        }
    }
}
  1. Test: This stage runs the unit tests for the application.
stage('Test') {
    steps {
        container('python') {
            sh 'python -m unittest discover'
        }
    }
}
  1. Deploy: This stage deploys the application to a Kubernetes cluster.
stage('Deploy') {
    environment {
        KUBECONFIG = credentials('kubeconfig')
        IMAGE = 'yourusername/blogging-app'
    }
    steps {
        container('kubectl') {
            sh 'kubectl --kubeconfig=$KUBECONFIG apply -f deployment.yaml'
            sh 'kubectl --kubeconfig=$KUBECONFIG apply -f service.yaml'
            sh "kubectl --kubeconfig=$KUBECONFIG set image deployment/blogging-app-deployment blogging-app-container=$IMAGE"
        }
    }
}

The Jenkins pipeline is configured to trigger automatically on every commit to the repository, ensuring that changes are built, tested, and deployed consistently.

Blogging Platform Application

The Blogging Platform application is a web application built using Python. It provides a platform for users to create and publish blog posts. The application code can be found in the blogging-platform directory.

To run the application locally, follow these steps:

  1. Install Python 3.x and ensure it is available in your system's PATH.
  2. Navigate to the blogging-platform directory.
  3. Install the required dependencies by running the command: pip install -r requirements.txt.
  4. Start the application by running the command: python app.py.
  5. Access the application by opening a web browser and navigating to http://localhost:5000.

Terraform Infrastructure Provisioning

The Terraform configuration in this repository allows for provisioning the infrastructure required to host the Blogging Platform application on AWS.

The main Terraform files are as follows:

  • main.tf: Defines the AWS provider and resources such as EC2 instances.
provider "aws" {
  region = "us-east-1"  # Replace with your desired region
}

resource "aws_instance" "blogging_instance" {
  ami           = "ami-0123456789"  # Replace with the desired AMI ID
  instance_type = "t2.micro"        # Replace with the desired instance type
  key_name      = "your-keypair"    # Replace with your key pair name

  tags = {
    Name = "Blogging Instance"
  }

  # Add any additional configuration for the instance, such as security groups, subnet, etc.
}
  • variables.tf: Defines input variables used in the Terraform configuration.
variable "aws_access_key" {
  description = "AWS access key"
}

variable "aws_secret_key

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors