Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahmedalaa14/devops-pipeline-python
Deploy Python App on K8s Cluster Using Jenkins Pipeline
https://github.com/ahmedalaa14/devops-pipeline-python
aws docker docker-compose eks-cluster jenkins kubernetes terraform
Last synced: about 1 month ago
JSON representation
Deploy Python App on K8s Cluster Using Jenkins Pipeline
- Host: GitHub
- URL: https://github.com/ahmedalaa14/devops-pipeline-python
- Owner: ahmedalaa14
- License: apache-2.0
- Created: 2024-07-15T18:27:03.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-22T15:40:00.000Z (3 months ago)
- Last Synced: 2024-09-30T17:43:06.484Z (about 1 month ago)
- Topics: aws, docker, docker-compose, eks-cluster, jenkins, kubernetes, terraform
- Language: Python
- Homepage:
- Size: 59.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Deploy Python App on K8s Cluster Using Jenkins Pipeline
- This project is to build Jenkins EC2 on AWS and use Jenkins to run 3 Jenkins files to create a cluster then deploy our python application on it, and Finally destroy all build resources
## Used tools:
- Terraform
- Jenkins
- K8s
- Docker
- Aws## Step 1: Jenkins EC2:
`NOTE: Make sure you have terraform installed, create terraform.tfvars file with the variables (ec2-ami, region & your public ssh key) then do the following:`
```
cd terraformterraform init
terraform apply -auto-approve
```## Step 2: Prerequisites:
`NOTE: replace the public-ip with the` **instance_public_ip** `that will showup in terraform output`
```
ssh ubuntu@public-ipvim install.sh
chmod +x install.sh
./install.sh
```## Step 3: Setup Jenkins:
1. Navigate to **Manage Jenkins** >> **Manage Plugins** >> **Available tab** >> search for **CloudBees AWS Credentials** >> **Install without Restart**
2. Navigate to **Manage Jenkins** >> **Manage Credentials** >> **global** >> **Global Credentials** >> **Add Credentials**
3. Add AWS Credentials, repeat step 2 again to add Github credentials
## Step 4: Create Jenkins Pipeline:
1. Navigate to **Dashboard** >> **Create a Job**
2. Give it a name >> Choose Pipeline
3. **Pipeline** Tab >> Choose **Pipeline Script from SCM** >> Choose **Git** >> Add **Repository URL** >> Add **Credentails** >> Specify the **Branch** >> Then the **Jenkinsfile** path inside the repository
4. Run the created job >> Create 2 similar jobs that navigate to **Jenkins-Deploy/Jenkinsfile** that will run automatically after Job one is done and **Jenkins-RM-EKS/Jenkinsfile** that you will use to remove your cluster
## Step 5: Access your application:
`Note: After the 2nd Jenkins job run and the application is deployed`
Navigate to the 2nd job >> **Console Output** >> Get your **Application URL** which you will found in the end next to **DNSNAME**.
It should look something like this (use the application port to access your app, we used here port _8000_ ):
```
a0e6e955cb648xxxxxxxxxxxx-xxxxxx025.REGION.elb.amazonaws.com:8000
```