diff --git a/Devops_course.PNG b/Devops_course.PNG new file mode 100644 index 00000000..3ce2993d Binary files /dev/null and b/Devops_course.PNG differ diff --git a/Docker/Dockerfile_Instructions.md b/Docker/Dockerfile_Instructions.md new file mode 100644 index 00000000..463d4474 --- /dev/null +++ b/Docker/Dockerfile_Instructions.md @@ -0,0 +1,79 @@ + +DockerFile + +1. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. +2. The docker build command builds an image from a Dockerfile and a context. + ```sh + docker build . + docker build -f /path/to/a/Dockerfile . + docker build -t shykes/myapp . + ``` + +3. The Docker daemon runs the instructions in the Dockerfile one-by-one, committing the result of each instruction to a new image if necessary, before finally outputting the ID of your new image. +4. Whenever possible, Docker uses a build-cache to accelerate the docker build process significantly. +5. When you’re done with your build, you’re ready to look into scanning your image with docker scan + ```sh + docker scan hello-world + + ``` + +## Dockerfile Creation + + Docker file format + ```sh + # Comment + INSTRUCTION arguments + ``` + +1. A Dockerfile must begin with a FROM instruction. + +2. Docker distributes official versions of the images that can be used for building Dockerfiles under docker/dockerfile repository on Docker Hub. + +- `FROM` - A valid Dockerfile must start with a FROM instruction. + +- `RUN` - The RUN instruction will execute any commands in a new layer on top of the current image and commit the results. The resulting committed image will be used for the next step in the Dockerfile. + +- `CMD` - The main purpose of a CMD is to provide defaults for an executing container. + + `Note:` There can only be one CMD instruction in a Dockerfile. If you list more than one CMD then only the last CMD will take effect. + + `Note` - Do not confuse RUN with CMD. RUN actually runs a command and commits the result; CMD does not execute anything at build time, but specifies the intended command for the image. + +- `LABEL` -The LABEL instruction adds metadata to an image. A LABEL is a key-value pair. T + +- `EXPOSE` + 1. The EXPOSE instruction informs Docker that the container listens on the specified network ports at runtime. + 2. To set up port redirection on the host system, see using the -P flag. + 3. The docker network command supports creating networks for communication among containers without the need to expose or publish specific ports, because the containers connected to the network can communicate with each other over any port. + +- `ENV` - The ENV instruction sets the environment variable to the value . + +- `ADD` - The ADD instruction copies new files, directories or remote file URLs from and adds them to the filesystem of the image at the path . + + If is a local tar archive in a recognized compression format (identity, gzip, bzip2 or xz) then it is unpacked as a directory. + +- `COPY` - The COPY instruction copies new files or directories from and adds them to the filesystem of the container at the path . + +- `ENTRYPOINT` - An ENTRYPOINT allows you to configure a container that will run as an executable. + + 1. ENTRYPOINT will override all elements specified using CMD + 2. Both CMD and ENTRYPOINT instructions define what command gets executed when running a container. There are few rules that describe their co-operation. + + 3. Dockerfile should specify at least one of CMD or ENTRYPOINT commands. + + 4. ENTRYPOINT should be defined when using the container as an executable. + + 5. CMD should be used as a way of defining default arguments for an ENTRYPOINT command or for executing an ad-hoc command in a container. + + 6. CMD will be overridden when running the container with alternative arguments. + +- `VOLUME` - The VOLUME instruction creates a mount point with the specified name and marks it as holding externally mounted volumes from native host or other containers. + +- `USER` - The USER instruction sets the user name to use when running the image +- `WORKDIR` - The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions + +- `ARG` - The ARG instruction defines a variable that users can pass at build-time to the builder with the docker build command using the --build-arg = flag. + +- `SHELL` - The SHELL instruction allows the default shell used for the shell form of commands to be overridden. + + diff --git a/Docker/tomcat_dockerfile b/Docker/tomcat_dockerfile new file mode 100644 index 00000000..d4ffa84f --- /dev/null +++ b/Docker/tomcat_dockerfile @@ -0,0 +1,10 @@ +FROM centos +RUN yum install java -y +RUN mkdir /opt/tomcat/ +WORKDIR /opt/tomcat +ADD https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.54/bin/apache-tomcat-9.0.54.tar.gz /opt/tomcat +RUN tar xvfz apache*.tar.gz +RUN mv apache-tomcat-9.0.54/* /opt/tomcat +EXPOSE 8080 +CMD ["/opt/tomcat/bin/catalina.sh", "run"] + diff --git a/Jenkins/Jenkins_Installation.MD b/Jenkins/Jenkins_Installation.MD index 2a6adb9a..773a9790 100644 --- a/Jenkins/Jenkins_Installation.MD +++ b/Jenkins/Jenkins_Installation.MD @@ -1,46 +1,28 @@ # Install Jenkins on AWS EC2 Jenkins is a self-contained Java-based program, ready to run out-of-the-box, with packages for Windows, Mac OS X and other Unix-like operating systems. As an extensible automation server, Jenkins can be used as a simple CI server or turned into the continuous delivery hub for any project. +### Follow this artical [On YouTube Channel](https://youtu.be/ERR7cqW28FY) ### Prerequisites 1. EC2 Instance - With Internet Access - Security Group with Port `8080` open for internet -1. Java v1.8.x +1. Java 11 should be installed -## Install Java -1. We will be using open java for our demo, Get the latest version from http://openjdk.java.net/install/ - ```sh - yum install java-1.8* - #yum -y install java-1.8.0-openjdk-devel - ``` - -1. Confirm Java Version and set the java home - ```sh - java -version - find /usr/lib/jvm/java-1.8* | head -n 3 - JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk- - export JAVA_HOME - PATH=$PATH:$JAVA_HOME - # To set it permanently update your .bash_profile - vi ~/.bash_profile - ``` - _The output should be something like this,_ - ```sh - [root@~]# java -version - openjdk version "1.8.0_151" - OpenJDK Runtime Environment (build 1.8.0_151-b12) - OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode) - ``` ## Install Jenkins You can install jenkins using the rpm or by setting up the repo. We will set up the repo so that we can update it easily in the future. 1. Get the latest version of jenkins from https://pkg.jenkins.io/redhat-stable/ and install ```sh - yum -y install wget 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.key - yum -y install jenkins + amazon-linux-extras install epel + amazon-linux-extras install java-openjdk11 + + #on RedHat/CentOs + #yum install epel-release # repository that provides 'daemonize' + #yum install java-11-openjdk-devel + #yum install jenkins ``` ### Start Jenkins @@ -77,4 +59,3 @@ Jenkins is a self-contained Java-based program, ready to run out-of-the-box, wit 1. Save your job 1. Build job 1. Check "console output" - diff --git a/Kubernetes/Kubernetes-setup.MD b/Kubernetes/Kubernetes_Setup_using_kops.md similarity index 86% rename from Kubernetes/Kubernetes-setup.MD rename to Kubernetes/Kubernetes_Setup_using_kops.md index ff045ccf..080e19c7 100644 --- a/Kubernetes/Kubernetes-setup.MD +++ b/Kubernetes/Kubernetes_Setup_using_kops.md @@ -1,95 +1,101 @@ -# Setup Kubernetes (K8s) Cluster on AWS - - -1. Create Ubuntu EC2 instance -1. install AWSCLI - ```sh - curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-bundle.zip - apt install unzip python - unzip awscli-bundle.zip - #sudo apt-get install unzip - if you dont have unzip in your system - ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws - ``` - -1. Install kubectl on ubuntu instance - ```sh - curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl - chmod +x ./kubectl - sudo mv ./kubectl /usr/local/bin/kubectl - ``` - -1. Install kops on ubuntu instance - ```sh - curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64 - chmod +x kops-linux-amd64 - sudo mv kops-linux-amd64 /usr/local/bin/kops - ``` -1. Create an IAM user/role with Route53, EC2, IAM and S3 full access - -1. Attach IAM role to ubuntu instance - ```sh - # Note: If you create IAM user with programmatic access then provide Access keys. Otherwise region information is enough - aws configure - ``` - -1. Create a Route53 private hosted zone (you can create Public hosted zone if you have a domain) - ```sh - Routeh53 --> hosted zones --> created hosted zone - Domain Name: valaxy.net - Type: Private hosted zone for Amzon VPC - ``` - -1. create an S3 bucket - ```sh - aws s3 mb s3://demo.k8s.valaxy.net - ``` -1. Expose environment variable: - ```sh - export KOPS_STATE_STORE=s3://demo.k8s.valaxy.net - ``` - -1. Create sshkeys before creating cluster - ```sh - ssh-keygen - ``` - -1. Create kubernetes cluster definitions on S3 bucket - ```sh - kops create cluster --cloud=aws --zones=ap-south-1b --name=demo.k8s.valaxy.net --dns-zone=valaxy.net --dns private - ``` - -1. Create kubernetes cluser - ```sh - kops update cluster demo.k8s.valaxy.net --yes - ``` - -1. Validate your cluster - ```sh - kops validate cluster - ``` - -1. To list nodes - ```sh - kubectl get nodes - ``` - -1. To delete cluster - ```sh - kops delete cluster demo.k8s.valaxy.net --yes - ``` - -#### Deploying Nginx pods on Kubernetes -1. Deploying Nginx Container - ```sh - kubectl run sample-nginx --image=nginx --replicas=2 --port=80 - # kubectl run simple-devops-project --image=yankils/simple-devops-image --replicas=2 --port=8080 - kubectl get pods - kubectl get deployments - ``` - -1. Expose the deployment as service. This will create an ELB in front of those 2 containers and allow us to publicly access them. - ```sh - kubectl expose deployment sample-nginx --port=80 --type=LoadBalancer - # kubectl expose deployment simple-devops-project --port=8080 --type=LoadBalancer - kubectl get services -o wide - ``` +# Setup Kubernetes (K8s) Cluster on AWS + + +1. Create Ubuntu EC2 instance +1. install AWSCLI + ```sh + curl https://s3.amazonaws.com/aws-cli/awscli-bundle.zip -o awscli-bundle.zip + sudo apt update + sudo apt install unzip python + unzip awscli-bundle.zip + #sudo apt-get install unzip - if you dont have unzip in your system + ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws + ``` + +1. Install kubectl on ubuntu instance + ```sh + curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl + chmod +x ./kubectl + sudo mv ./kubectl /usr/local/bin/kubectl + ``` + +1. Install kops on ubuntu instance + ```sh + curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64 + chmod +x kops-linux-amd64 + sudo mv kops-linux-amd64 /usr/local/bin/kops + ``` +1. Create an IAM user/role with Route53, EC2, IAM and S3 full access + +1. Attach IAM role to ubuntu instance + ```sh + # Note: If you create IAM user with programmatic access then provide Access keys. Otherwise region information is enough + aws configure + ``` + +1. Create a Route53 private hosted zone (you can create Public hosted zone if you have a domain) + ```sh + Routeh53 --> hosted zones --> created hosted zone + Domain Name: valaxy.net + Type: Private hosted zone for Amzon VPC + ``` + +1. create an S3 bucket + ```sh + aws s3 mb s3://demo.k8s.valaxy.net + ``` +1. Expose environment variable: + ```sh + export KOPS_STATE_STORE=s3://demo.k8s.valaxy.net + ``` + +1. Create sshkeys before creating cluster + ```sh + ssh-keygen + ``` + +1. Create kubernetes cluster definitions on S3 bucket + ```sh + kops create cluster --cloud=aws --zones=ap-south-1b --name=demo.k8s.valaxy.net --dns-zone=valaxy.net --dns private + ``` + +1. If you wish to update the cluster worker node sizes use below command + ```sh + kops edit ig --name=CHANGE_TO_CLUSTER_NAME nodes + ``` + +1. Create kubernetes cluser + ```sh + kops update cluster demo.k8s.valaxy.net --yes + ``` + +1. Validate your cluster + ```sh + kops validate cluster + ``` + +1. To list nodes + ```sh + kubectl get nodes + ``` + +1. To delete cluster + ```sh + kops delete cluster demo.k8s.valaxy.net --yes + ``` + +#### Deploying Nginx pods on Kubernetes +1. Deploying Nginx Container + ```sh + kubectl create deploy sample-nginx --image=nginx --replicas=2 --port=80 + # kubectl deploy simple-devops-project --image=yankils/simple-devops-image --replicas=2 --port=8080 + kubectl get all + kubectl get pod + ``` + +1. Expose the deployment as service. This will create an ELB in front of those 2 containers and allow us to publicly access them. + ```sh + kubectl expose deployment sample-nginx --port=80 --type=LoadBalancer + # kubectl expose deployment simple-devops-project --port=8080 --type=LoadBalancer + kubectl get services -o wide + ``` diff --git a/Kubernetes/Kubernetes_Setup_using_kubeadm.md b/Kubernetes/Kubernetes_Setup_using_kubeadm.md new file mode 100644 index 00000000..633d062b --- /dev/null +++ b/Kubernetes/Kubernetes_Setup_using_kubeadm.md @@ -0,0 +1,125 @@ +# Kubernetes Cluster installation using kubeadm +Follow this documentation to set up a Kubernetes cluster on __CentOS__ 7 machines. + +This documentation guides you in setting up a cluster with one master node and two worker nodes. + +## Prerequisites: +1. System Requirements + >Master: t2.medium (2 CPUs and 2GB Memory) + >Worker Nodes: t2.micro + +1. Open Below ports in the Security Group. + #### Master node: + `6443 + 32750 + 10250 + 4443 + 443 + 8080 ` + + ##### On Master node and Worker node: + `179` + + ### `On Master and Worker:` +1. Perform all the commands as root user unless otherwise specified + + Install, Enable and start docker service. + Use the Docker repository to install docker. + > If you use docker from CentOS OS repository, the docker version might be old to work with Kubernetes v1.13.0 and above + + ```sh + yum install -y -q yum-utils device-mapper-persistent-data lvm2 > /dev/null 2>&1 + yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo > /dev/null 2>&1 + yum install -y -q docker-ce >/dev/null 2>&1 + ``` +1. Start Docker services + ```sh + systemctl enable docker + systemctl start docker + ``` +1. Disable SELinux + ```sh + setenforce 0 + sed -i --follow-symlinks 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux + ``` +1. Disable Firewall + ```sh + systemctl disable firewalld + systemctl stop firewalld + ``` +1. Disable swap + ```sh + sed -i '/swap/d' /etc/fstab + swapoff -a + ``` +1. Update sysctl settings for Kubernetes networking + ```sh + cat >> /etc/sysctl.d/kubernetes.conf <>/etc/yum.repos.d/kubernetes.repo< --pod-network-cidr=192.168.0.0/16 + ``` +1. Create a user for kubernetes administration and copy kube config file. + ``To be able to use kubectl command to connect and interact with the cluster, the user needs kube config file.`` + In this case, we are creating a user called `kubeadmin` + ```sh + useradd kubeadmin + mkdir /home/kubeadmin/.kube + cp /etc/kubernetes/admin.conf /home/kubeadmin/.kube/config + chown -R kubeadmin:kubeadmin /home/kubeadmin/.kube + ``` +1. Deploy Calico network as a __kubeadmin__ user. + > This should be executed as a user (heare as a __kubeadmin__ ) + + ```sh + sudo su - kubeadmin + kubectl create -f https://docs.projectcalico.org/v3.9/manifests/calico.yaml + ``` + +1. Cluster join command + ```sh + kubeadm token create --print-join-command + ``` +## `On Worker Node:` +1. Add worker nodes to cluster + > Use the output from __kubeadm token create__ command in previous step from the master server and run here. + +1. Verifying the cluster + To Get Nodes status + ```sh + kubectl get nodes + ``` + To Get component status + ```sh + kubectl get cs + ``` + diff --git a/Kubernetes/create_image_regapp.yml b/Kubernetes/create_image_regapp.yml new file mode 100644 index 00000000..910aedbc --- /dev/null +++ b/Kubernetes/create_image_regapp.yml @@ -0,0 +1,15 @@ +--- +- hosts: ansible + + tasks: + - name: create docker image + command: docker build -t regapp:latest . + args: + chdir: /opt/docker + + - name: create tag to push image onto dockerhub + command: docker tag regapp:latest valaxy/regapp:latest + + - name: push docker image + command: docker push valaxy/regapp:latest + diff --git a/Kubernetes/firstpod.yml b/Kubernetes/firstpod.yml new file mode 100644 index 00000000..48c7fd81 --- /dev/null +++ b/Kubernetes/firstpod.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Pod +metadata: + name: nginx-pod + labels: + app: demo-app + +spec: + containers: + - name: nginx-container + image: nginx + ports: + - name: nginx + containerPort: 80 diff --git a/Kubernetes/firstrs.yml b/Kubernetes/firstrs.yml new file mode 100644 index 00000000..9021aff9 --- /dev/null +++ b/Kubernetes/firstrs.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: ReplicaSet +metadata: + name: demo-app +spec: + replicas: 1 + template: + metadata: + labels: + app: demo-app + + spec: + containers: + - name: demo-app + image: nginx + + diff --git a/Kubernetes/firstservice.yml b/Kubernetes/firstservice.yml new file mode 100644 index 00000000..59db6d7c --- /dev/null +++ b/Kubernetes/firstservice.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: demo-service + +spec: + ports: + - name: demo-service + port: 80 + targetPort: 80 + + selector: + app: demo-app + + type: LoadBalancer + + kubectl expose webapp --type=NodePort --targerPort=80 -- \ No newline at end of file diff --git a/Kubernetes/kube_deploy.yml b/Kubernetes/kube_deploy.yml new file mode 100644 index 00000000..ac403464 --- /dev/null +++ b/Kubernetes/kube_deploy.yml @@ -0,0 +1,15 @@ +--- +- hosts: kubernetes +# become: ture + user: root + + tasks: + - name: deploy regapp on kubernetes + command: kubectl apply -f regapp-deployment.yml + + - name: create service for regapp + command: kubectl apply -f regapp-service.yml + + - name: update deployment with new pods if image updated in docker hub + command: kubectl rollout restart deployment.apps/valaxy-regapp + diff --git a/Kubernetes/kubernetes-valaxy-deployment.yml b/Kubernetes/kubernetes-valaxy-deployment.yml index 9efc3e57..974c4f7f 100644 --- a/Kubernetes/kubernetes-valaxy-deployment.yml +++ b/Kubernetes/kubernetes-valaxy-deployment.yml @@ -1,8 +1,8 @@ --- - name: Create pods using deployment hosts: kubernetes - become: true - user: root + # become: true + user: ubuntu tasks: - name: create a deployment diff --git a/Kubernetes/kubernetes-valaxy-service.yml b/Kubernetes/kubernetes-valaxy-service.yml index 363dec51..027ba5f6 100644 --- a/Kubernetes/kubernetes-valaxy-service.yml +++ b/Kubernetes/kubernetes-valaxy-service.yml @@ -1,8 +1,8 @@ --- - name: create service for deployment hosts: kubernetes - become: true - user: root + # become: true + user: ubuntu tasks: - name: create a service diff --git a/Kubernetes/kubernetes_setup_using_eksctl.md b/Kubernetes/kubernetes_setup_using_eksctl.md new file mode 100644 index 00000000..a58df311 --- /dev/null +++ b/Kubernetes/kubernetes_setup_using_eksctl.md @@ -0,0 +1,81 @@ +# Setup Kubernetes on Amazon EKS + +You can follow same procedure in the official AWS document [Getting started with Amazon EKS – eksctl](https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html) + +#### Pre-requisites: + - an EC2 Instance + - Install AWSCLI latest verison + +1. Setup kubectl + a. Download kubectl version 1.21 + b. Grant execution permissions to kubectl executable + c. Move kubectl onto /usr/local/bin + d. Test that your kubectl installation was successful + + ```sh + curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.21.2/2021-07-05/bin/linux/amd64/kubectl + chmod +x ./kubectl + mv ./kubectl /usr/local/bin + kubectl version --short --client + ``` +2. Setup eksctl + a. Download and extract the latest release + b. Move the extracted binary to /usr/local/bin + c. Test that your eksclt installation was successful + + ```sh + curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp + sudo mv /tmp/eksctl /usr/local/bin + eksctl version + ``` + +3. Create an IAM Role and attache it to EC2 instance + `Note: create IAM user with programmatic access if your bootstrap system is outside of AWS` + IAM user should have access to + IAM + EC2 + CloudFormation + Note: Check eksctl documentaiton for [Minimum IAM policies](https://eksctl.io/usage/minimum-iam-policies/) + +4. Create your cluster and nodes + ```sh + eksctl create cluster --name cluster-name \ + --region region-name \ + --node-type instance-type \ + --nodes-min 2 \ + --nodes-max 2 \ + --zones , + + example: + eksctl create cluster --name valaxy-cluster \ + --region ap-south-1 \ + --node-type t2.small \ + ``` + +5. To delete the EKS clsuter + ```sh + eksctl delete cluster valaxy --region ap-south-1 + ``` + +6. Validate your cluster using by creating by checking nodes and by creating a pod + ```sh + kubectl get nodes + kubectl run tomcat --image=tomcat + ``` + + #### Deploying Nginx pods on Kubernetes +1. Deploying Nginx Container + ```sh + kubectl create deployment demo-nginx --image=nginx --replicas=2 --port=80 + # kubectl deployment regapp --image=valaxy/regapp --replicas=2 --port=8080 + kubectl get all + kubectl get pod + ``` + +1. Expose the deployment as service. This will create an ELB in front of those 2 containers and allow us to publicly access them. + ```sh + kubectl expose deployment demo-nginx --port=80 --type=LoadBalancer + # kubectl expose deployment regapp --port=8080 --type=LoadBalancer + kubectl get services -o wide + ``` + diff --git a/Kubernetes/nginx-deploy.yaml b/Kubernetes/nginx-deploy.yaml new file mode 100644 index 00000000..303e4013 --- /dev/null +++ b/Kubernetes/nginx-deploy.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment + labels: + app: nginx +spec: + replicas: 2 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 diff --git a/Kubernetes/regapp-deploy.yml b/Kubernetes/regapp-deploy.yml new file mode 100644 index 00000000..6ef59cef --- /dev/null +++ b/Kubernetes/regapp-deploy.yml @@ -0,0 +1,29 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: valaxy-regapp + labels: + app: regapp + +spec: + replicas: 2 + selector: + matchLabels: + app: regapp + + template: + metadata: + labels: + app: regapp + spec: + containers: + - name: regapp + image: valaxy/regapp + imagePullPolicy: Always + ports: + - containerPort: 8080 + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 + maxUnavailable: 1 \ No newline at end of file diff --git a/Kubernetes/regapp-service.yml b/Kubernetes/regapp-service.yml new file mode 100644 index 00000000..3fe9e051 --- /dev/null +++ b/Kubernetes/regapp-service.yml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: valaxy-service + labels: + app: regapp +spec: + selector: + app: regapp + + ports: + - port: 8080 + targetPort: 8080 + + type: LoadBalancer \ No newline at end of file diff --git a/README.md b/README.md index a77ac220..f4b020d9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Simple DevOps Project +[![Image](https://github.com/yankils/Simple-DevOps-Project/blob/master/Devops_course.PNG "DevOps Project - CI/CD with Jenkins Ansible Docker Kubernetes ")](https://www.udemy.com/course/valaxy-devops/?referralCode=8147A5CF4C8C7D9E253F) + This Repository is a collection of Implementation documents. ### Purpose: diff --git a/Tomcat/tomcat_installation.MD b/Tomcat/tomcat_installation.MD index e37c21cc..5c39848b 100644 --- a/Tomcat/tomcat_installation.MD +++ b/Tomcat/tomcat_installation.MD @@ -1,26 +1,28 @@ # Tomcat installation on EC2 instance - +- Follow this video lecture in Valaxy Technologies **[YouTube Channel](https://youtu.be/68WNroQBUts)** +- Complete DevOps Project course on [Udemy](https://www.udemy.com/course/valaxy-devops/?referralCode=8147A5CF4C8C7D9E253F) ### Pre-requisites -1. EC2 instance with Java v1.8.x - +1. EC2 instance with Java 11 ### Install Apache Tomcat 1. Download tomcat packages from https://tomcat.apache.org/download-80.cgi onto /opt on EC2 instance + > Note: Make sure you change `` with the tomcat version which you download. ```sh # Create tomcat directory cd /opt wget http://mirrors.fibergrid.in/apache/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.tar.gz - tar -xvzf /opt/apache-tomcat-8.5.35.tar.gz + tar -xvzf /opt/apache-tomcat-.tar.gz ``` 1. give executing permissions to startup.sh and shutdown.sh which are under bin. ```sh - chmod +x /opt/apache-tomcat-8.5.35/bin/startup.sh - shutdown.sh + chmod +x /opt/apache-tomcat-/bin/startup.sh + chmod +x /opt/apache-tomcat-/bin/shutdown.sh ``` - + > Note: you may get below error while starting tomcat incase if you dont install Java + `Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program` 1. create link files for tomcat startup.sh and shutdown.sh ```sh - ln -s /opt/apache-tomcat-8.5.35/bin/startup.sh /usr/local/bin/tomcatup - ln -s /opt/apache-tomcat-8.5.35/bin/shutdown.sh /usr/local/bin/tomcatdown + ln -s /opt/apache-tomcat-/bin/startup.sh /usr/local/bin/tomcatup + ln -s /opt/apache-tomcat-/bin/shutdown.sh /usr/local/bin/tomcatdown tomcatup ``` #### Check point : @@ -29,7 +31,7 @@ access tomcat application from browser on port 8080 Using unique ports for each application is a best practice in an environment. But tomcat and Jenkins runs on ports number 8080. Hence lets change tomcat port number to 8090. Change port number in conf/server.xml file under tomcat home ```sh - cd /opt/apache-tomcat-8.5.35/conf + cd /opt/apache-tomcat-/conf # update port number in the "connecter port" field in server.xml # restart tomcat after configuration update tomcatdown @@ -45,13 +47,18 @@ Access tomcat application from browser on port 8090 find / -name context.xml ``` 1. above command gives 3 context.xml files. comment () `Value ClassName` field on files which are under webapp directory. -After that restart tomcat services to effect these changes +After that restart tomcat services to effect these changes. +At the time of writing this lecture below 2 files are updated. ```sh - tomcatdown + /opt/tomcat/webapps/host-manager/META-INF/context.xml + /opt/tomcat/webapps/manager/META-INF/context.xml + + # Restart tomcat services + tomcatdown tomcatup ``` 1. Update users information in the tomcat-users.xml file -goto tomcat home directory and Add below users to conf/tomcat-user.xml file +goto tomcat home directory and Add below users to conf/tomcat-users.xml file ```sh