Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"FSharp.suggestGitignore": false,
"java.configuration.updateBuildConfiguration": "interactive",
"java.compile.nullAnalysis.mode": "automatic"
}
50 changes: 50 additions & 0 deletions DEVOPS-main/DOCKER/Mini_Project/Docker_commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
=====================
# Build image (from Dockerfile)
=====================
docker build -t project/myapp:v1 .
# 'project/myapp' is user-defined name

=====================
# Create container (from Image)
=====================
docker run -dt --name container1 -p 80:80 project/myapp
# here 80:80 means <local_machine_port>:<container_port>
# 'container1' is user-defined name

=====================
# Access the content
=====================
# Open browser & use <ec2_publicIP> to access the content

------------------------------------------------------------
--- END ---
------------------------------------------------------------
=====================
# OTHER COMMANDS
=====================

=====================
# Go inside container
=====================
docker exec -it /bin/bash

=====================
# Stop & remove all containers
=====================
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)

=====================
# Delete all docker images
=====================
docker image prune -af

=====================
# To delete all content from text file using 'vi'
# use 'Esc:%d'
=====================

=====================
# To check which directories are consuming space in Linux
=====================
du -h /usr | sort -rh | head -n 10
20 changes: 20 additions & 0 deletions DEVOPS-main/DOCKER/Mini_Project/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu

# Install Apache & Git
RUN apt-get update && \
apt-get install -y apache2 git

# Pull content from Github
RUN git clone https://github.com/iotbands1train/DevopsProject1.git
# Add content inside html directory
RUN cd DevopsProject/ && \
cp -R * /var/www/html/

# Delete the Project directory after copying the files
RUN rm -rf DevopsProject

# Start Apache
CMD ["apache2ctl", "-D", "FOREGROUND"]

# Expose port 80 of container
EXPOSE 80
25 changes: 25 additions & 0 deletions DEVOPS-main/DOCKER/Mini_Project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
# **DOCKER MINI PROJECT**
---

![image](https://github.com/pandacloud1/DEVOPS/assets/134182273/e7a14622-fc73-4036-b64c-e41f0f175b07)

## Objective:
Pulling content from Github & exposing through container

## Instructions:
1. Create EC2 instance & enable required ports (eg. 22, 80, 8080) in the security group
2. Install Docker
* *(https://github.com/pandacloud1/DEVOPS/tree/main/Installation_Scripts/Docker)*
3. Create Dockerfile as below:
* Install Git, Apache
* Pull content from Github
* Copy the content to /var/www/html/ location
* Start Apache service
4. Create Docker image from 'Dockerfile'
5. Create Container from Docker image exposing required port of the container with the local machine
6. Access the content from the browser using <ec2_public_IP>

- *Dockerfile:* *(https://github.com/pandacloud1/DEVOPS/blob/main/DOCKER/Mini_Project/Dockerfile)*
- *Docker_Commands:* *(https://github.com/pandacloud1/DEVOPS/blob/main/DOCKER/Mini_Project/Docker_commands)*

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

vi ansible.sh

#!/bin/bash
sudo yum update -y
sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y
sudo yum install git python python-devel python-pip openssl ansible -y



chmod a+x ansible.sh
./ansible.sh


19 changes: 19 additions & 0 deletions DEVOPS-main/Installation_Scripts/Docker/Amazon_Linux2/docker.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# REF: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-docker.html
#!/bin/bash
sudo yum update -y
sudo yum install docker -y
sudo systemctl start docker
sudo systemctl enable docker
# Add ec2-user to the docker group so that Docker commands can be run w/o using sudo.
sudo usermod -aG docker $USER && newgrp docker #(add normal user 'docker')
# sudo usermod -aG docker ec2-user
# To avoid below permission error
# Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
sudo chmod 777 /var/run/docker.sock


# chmod a+x docker.bash
# ./docker.bash

chmod a+x docker.bash
./docker.bash
3 changes: 3 additions & 0 deletions DEVOPS-main/Installation_Scripts/Git/Amazon_Linux2/git.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
sudo yum update -y
sudo yum install git -y
35 changes: 35 additions & 0 deletions DEVOPS-main/Installation_Scripts/Jenkins/Amazon_Linux/jenkins.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# jenkins.sh
vi jenkins.sh

#!/bin/bash
# REF: (https://www.jenkins.io/doc/tutorials/tutorial-for-installing-jenkins-on-AWS/)
# NOTE:
# 1. Jenkins works on port 8080, so keep the port open while creating EC2 instance
# 2. Jenkins also requires Java & supports versions 11,17 & 21

sudo yum update -y
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo yum install java-17-amazon-corretto -y
sudo yum install jenkins -y
sudo /usr/sbin/alternatives --config java
sudo /usr/sbin/alternatives --config javac
sudo systemctl enable jenkins
sudo systemctl start jenkins

# Get Jenkins_Public_IP
ip=$(curl ifconfig.me)
port=8080
echo "Access your Jenkins here --> http://$ip:$port"

# Generate Jenkins initial login password
pass=$(sudo cat /var/lib/jenkins/secrets/initialAdminPassword)
echo "Your Jenkins Initial Password: $pass"

# In case if Jenkins fails to starts, try to set Java version to 11,17,21 using below command
# sudo /usr/sbin/alternatives --config java
# (Select the relevant Java version: 11,17 or 21)

chmod a+x jenkins.sh
./jenkins.sh
23 changes: 23 additions & 0 deletions DEVOPS-main/Installation_Scripts/Kubernetes/03-k8s.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

vi k8s.bash


# install kubectl

# k8s.bash

#!/bin/bash
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
sudo chmod +x kubectl
sudo mkdir -p ~/.local/bin
sudo mv ./kubectl ~/.local/bin/kubectl
kubectl version

# execute bash
chmod a+x k8s.bash
./k8s.bash

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -------------------
# Install Docker
# -------------------
# REF: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-docker.html
#!/bin/bash
sudo yum update -y
sudo yum install docker -y
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER && newgrp docker

# -------------------
# Install K8S (Kubeadm)
# -------------------
# REF: https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config

cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.29/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.29/rpm/repodata/repomd.xml.key
exclude=kubelet kubeadm kubectl cri-tools kubernetes-cni
EOF

sudo yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
sudo systemctl enable --now kubelet

# Initialize Master (Control) Plane
# Reference link: https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/#considerations-about-apiserver-advertise-address-and-controlplaneendpoint
sudo kubeadm init --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=NumCPU --ignore-preflight-errors=Mem

# Configure K8s
sudo mkdir -p $HOME/.kube
sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f https://docs.projectcalico.org/v3.18/manifests/calico.yaml
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.27.0/manifests/tigera-operator.yaml
kubectl taint nodes --all node-role.kubernetes.io/control-plane-
kubectl get pods -A
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Install Docker
sudo yum update -y
sudo yum install docker -y
sudo systemctl start docker
sudo systemctl enable docker
# Add user to Docker group
sudo usermod -aG docker $USER && newgrp docker
sudo usermod -aG docker ec2-user
# To avoid below permission error
# Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
sudo chmod 777 /var/run/docker.sock

# Install Minikube
# REF: https://minikube.sigs.k8s.io/docs/start/ (Select 'Linux - RPM')
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-latest.x86_64.rpm
sudo rpm -Uvh minikube-latest.x86_64.rpm
sudo minikube start

# Install kubectl
# REF: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
sudo chmod +x kubectl
sudo mkdir -p ~/.local/bin
sudo mv ./kubectl ~/.local/bin/kubectl
kubectl version
56 changes: 56 additions & 0 deletions DEVOPS-main/Installation_Scripts/Kubernetes/Ubuntu20.04/k8s.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# ====================================
# INSTALLING MINIKUBE IN UBUNTU 20.04
# ====================================
# Reference: https://minikube.sigs.k8s.io/docs/start/

# ------------------------
# PRE-REQUISITE
# ------------------------
# Docker
# Min 2GB Memory, Min 2CPU's, Min 20GB Storage space (Use Instance_type: t2.medium)
# Ports: 22, 80, 443, 6443, 10250, 30000-32767 (Keep all ports open for practise)


# ------------------------
# INSTALL DOCKER
# ------------------------
sudo apt update -y #(update the OS)
sudo apt install docker.io -y #(install docker)
sudo service docker start #(start docker service)
sudo usermod -aG docker $USER && newgrp docker #(add normal user 'docker')
# sudo usermod -aG docker ec2-user
# To avoid below permission error
# Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock
sudo chmod 777 /var/run/docker.sock

# ------------------------
# INSTALL MINKUBE
# ------------------------
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb
sudo dpkg -i minikube_latest_amd64.deb
minikube start

# ------------------------
# INSTALL KUBECTL
# ------------------------

# Install package for Kubernetes apt repository
sudo apt-get install -y apt-transport-https ca-certificates curl gpg

# In older release less than Ubuntu 22.04 below directory must be created
sudo mkdir -m 755 /etc/apt/keyrings

# Download the public signing key for the Kubernetes package repositories
curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.29/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg

# Add the appropriate Kubernetes apt repository
# This overwrites any existing configuration in /etc/apt/sources.list.d/kubernetes.list
echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.29/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list

# Update the apt package index, install kubectl
sudo apt-get update -y
sudo apt-get install -y kubectl


# Open the below command in new tab when exposing ports
minikube tunnel
18 changes: 18 additions & 0 deletions DEVOPS-main/Installation_Scripts/Maven/Amazon_Linux2/maven.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
vi maven.bash



# REF: https://docs.aws.amazon.com/neptune/latest/userguide/iam-auth-connect-prerq.html
sudo wget https://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
sudo sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
sudo yum install -y apache-maven
sudo yum install java-1.8.0-devel -y
sudo /usr/sbin/alternatives --config java
sudo /usr/sbin/alternatives --config javac
# (When prompted, enter the number for Java 1.8)

# chmod a+x docker.bash
# ./docker.bash

chmod a+x maven.bash
./maven.bash
16 changes: 16 additions & 0 deletions DEVOPS-main/Installation_Scripts/Trivy/Amazon_Linux2/trivy.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@


vi trivy.sh

#!/bin/bash
# REF: https://aquasecurity.github.io/trivy/v0.18.3/installation/
sudo rpm -ivh https://github.com/aquasecurity/trivy/releases/download/v0.18.3/trivy_0.18.3_Linux-64bit.rpm



chmod a+x trivy.sh
./trivy.sh




14 changes: 14 additions & 0 deletions DEVOPS-main/Installation_Scripts/java/jdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# java.sh
vi java.sh

#!/bin/bash
sudo yum update -y
sudo yum install java-1.8.0-openjdk -y
sudo yum install git -y
java -version

# chmod a+x java.sh
# ./java.sh

chmod a+x java.sh
./java.sh
Loading