Skip to content
Open

test #10

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1dbab50
ansadmin corrected instead of dockeradmin
ffdavis Dec 8, 2018
e24b33a
updated git info
ValaxyTech Dec 22, 2018
c00ed21
Delete testfile3
ValaxyTech Feb 12, 2019
613e418
Delete testfile2
ValaxyTech Feb 12, 2019
0a8b7d4
Delete testfile
ValaxyTech Feb 12, 2019
6f0305a
Create S3_Artifact_for_Jenkins
ValaxyTech Feb 12, 2019
ad96402
Rename S3_Artifact_for_Jenkins to S3_Artifact_for_Jenkins.md
ValaxyTech Feb 12, 2019
646b9f9
Update S3_Artifact_for_Jenkins.md
ValaxyTech Feb 12, 2019
d3ae534
Update S3_Artifact_for_Jenkins.md
ValaxyTech Feb 12, 2019
0642731
Update S3_Artifact_for_Jenkins.md
ValaxyTech Feb 12, 2019
182ba2d
Update S3_Artifact_for_Jenkins.md
ValaxyTech Feb 13, 2019
9dbb69b
Update S3_Artifact_for_Jenkins.md
ValaxyTech Feb 13, 2019
7ff2903
Highlighting commands
miztiik Mar 4, 2019
53577e6
Highlighting Command Syntax
miztiik Mar 4, 2019
606aaf9
Merge pull request #1 from ffdavis/patch-1
ValaxyTech Mar 6, 2019
1c018c6
Merge pull request #3 from miztiik/master
ValaxyTech Mar 6, 2019
0841776
Create K8s-setup initial commit
ValaxyTech Mar 12, 2019
c16da67
Rename k8s-setup to k8s-setup.md
ValaxyTech Mar 12, 2019
328647f
Update k8s-setup.md
ValaxyTech Mar 12, 2019
692bf65
initial commit
ValaxyTech Jul 23, 2019
1dc59cd
Modified ansible file
ValaxyTech Jul 24, 2019
87bed86
title updated
ValaxyTech Jul 24, 2019
55a0e0c
Ansible Dynamic Inventory
ValaxyTech Aug 10, 2019
3352f1b
Update Dynamic_Inventory.MD
ValaxyTech Aug 19, 2019
c7f8bf1
Update Dynamic_Inventory.MD
ValaxyTech Aug 19, 2019
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
64 changes: 64 additions & 0 deletions Ansible/Ansible_installation_on_RHEL8.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Ansible Installation on RHEL 8.x server

1. Install Python latest version (on Control node and Managed host)
```sh
yum install python3 -y
```

1. By default, python3 is the command to run python commands. to use just python, use "alternatives" command. (on Control node and Managed host)
```sh
alternatives --set python /usr/bin/python3
```

1. Check for Python version
```sh
python --version
```
1. Install python-pip package manager (on Control node)
```sh
yum -y install python3-pip
```

1. Create a new user for ansible administration & grant admin access to the user (on Control node and Managed host)
```sh
useradd ansadmin
passwd ansadmin
```
1. Below command adds ansadmin to sudoers file. But we strongly recommended using "visudo" command if you are aware vi or nano editor. (on Control node and Managed host)
```sh
echo "ansadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
```
1. Using key-based authentication is advised. If you are still at the learning stage use password-based authentication (on Control node and Managed host)
```sh
# sed command replaces "PasswordAuthentication no to yes" without editing file
sed -ie 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
sudo service sshd reload
```

#### Install Ansible as a ansadmin user (on Control node)
```sh
su - ansadmin
pip3 install ansible --user
```
Note: Ansible must be installed as a user (here ansadmin)
1. check for ansible version
```sh
ansible --version
```

1. Log in as a ansadmin user on master and generate ssh key (on Control node)
```sh
ssh-keygen
```
1. Copy keys onto all ansible managed hosts (on Control node)
```sh
ssh-copy-id ansadmin@<target-server>
```
### Validation test

1. Create a directory /etc/ansible and create an inventory file called "hosts" add control node IP address in it.

1. Run ansible command as ansadmin user it should be successful (Master)
```sh
ansible all -m ping
```
36 changes: 36 additions & 0 deletions Ansible/Dynamic_Inventory.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Ansible Dynamic Inventory

### Pre-requisites:
1. Ansible Server - Get [Click here](https://www.youtube.com/watch?v=-Y8Oatd49qA) to install on RHEL 8 and [click here](https://www.youtube.com/watch?v=79xFyOc_eEY) to install on Amazon Linux


### Setup

To get help on dynamic inventory please follow [Ansible Official Document](https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html#inventory-script-example-aws-ec2)

1. Download [ec2.py](https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.py) and [ec2.ini](https://raw.githubusercontent.com/ansible/ansible/devel/contrib/inventory/ec2.ini) files

1. Create IAM Programmatic access user with EC2 full access on AWS console

`IAM` --> `users` --> `Add user`

1. Export IAM user credentials on Ansible server.

```bash
export AWS_ACCESS_KEY_ID='1bc123'
export AWS_SECRET_ACCESS_KEY='abc123'
```
1. To export keys permanently make sure that you have installed pip and boto and add credentials ~/.boto file

1. add executing permissions to ec2.py script
```sh
chmod 755 ec2.py
```
1. test the script
```
./ec2.py --list
```
1. List out servers which are running on ap-south-1a AZ
```
ansible -i ec2.py ap-south-1a --list-hosts
```
6 changes: 3 additions & 3 deletions Jenkins/Git_plugin_install.MD
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Install git packages on jenkins server
yum install git -y
```

#### Setup maven on jenkins console
- Install maven plugin without restart
#### Setup Git on jenkins console
- Install git plugin without restart
- `Manage Jenkins` > `Jenkins Plugins` > `available` > `github`

- Configure java path
- Configure git path
- `Manage Jenkins` > `Global Tool Configuration` > `git`

#### Next Steps
Expand Down
35 changes: 35 additions & 0 deletions Jenkins/S3_Artifact_for_Jenkins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# S3 as a artifact for Jenkins

Follow this in **[YouTube](https://youtu.be/GQZYpIRxi-g)**

### Prerequisites
1. Create Jenkins Server
Jenkins server **[Get Help here](https://www.youtube.com/watch?v=M32O4Yv0ANc)**

### Setup steps
1. Create a S3 bucket to store artifacts
`S3 --> Create bucket `
```sh
Bucket name: valaxy-s3-artifact
Region: Singapore
```
1. Create new IAM role with "S3 full access" and assign it to jenkins server
`IAM --> Create role --> EC2`
```ssh
Permission: AmazonS3FullAccess
Tags: key - Name, Value - S3FullAccess Role
name: S3_Full_Access
```

1. Install "S3 Publisher" plugin on Jenkins
`Manage Jenkins --> Manage Plugins --> Availabe --> S3 publisher`

1. Configure S3 profile on Jenkins
`Manage Jenkins --> Configure Systems --> Amazon S3 profiles`
```sh
Profile name : s3-artifact-repository
Use IAM Role : chose
```

1. Create a job to store artifacts under S3.
81 changes: 81 additions & 0 deletions Kubernetes/k8s-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

#### 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
```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. Create an IAM user/role with Route53, EC2, IAM and S3 full access
1. Attach IAM role to ubuntu server

#### Note: If you create IAM user with programmatic access then provide Access keys.
```sh
aws configure
```
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 a Route53 private hosted zone (you can create Public hosted zone if you have a domain)
1. create an S3 bucket
```sh
aws s3 mb s3://dev.k8s.valaxy.in
```
1. Expose environment variable:
```sh
export KOPS_STATE_STORE=s3://dev.k8s.valaxy.in
```
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-southeast-1b --name=dev.k8s.valaxy.in --dns-zone=valaxy.in --dns private
```
1. Create kubernetes cluser
```sh
kops update cluster dev.k8s.valaxy.in --yes
```
1. Validate your cluster
```sh
kops validate cluster
```

1. To list nodes
```sh
kubectl get nodes
```

#### Deploying Nginx container on Kubernetes
1. Deploying Nginx Container
```sh
kubectl run sample-nginx --image=nginx --replicas=2 --port=80
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 get services -o wide
```
1. To delete cluster
```sh
kops delete cluster dev.k8s.valaxy.in --yes
```
23 changes: 16 additions & 7 deletions SimpeDevOpsProjects/Project-3.MD
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mkdir /opt/docker
From tomcat:8-jre8

# Maintainer
MAINTAINER "valaxytech@gmail.com"
MAINTAINER "valaxytech"

# copy war file on to container
COPY ./webapp.war /usr/local/tomcat/webapps
Expand All @@ -47,14 +47,21 @@ B) Build

C) send files or execute commands over SSH
Name: docker_host
Source files : webapp/target/*.war
Remove prefix : webapp/target
Remote directory : //opt//docker
Exec command : docker stop valaxy_demo; docker rm -f valaxy_demo; docker image rm -f valaxy_demo; cd /opt/docker; docker build -t valaxy_demo .
Source files : `webapp/target/*.war`
Remove prefix : `webapp/target`
Remote directory : `//opt//docker`
Exec command[s] :
```sh
docker stop valaxy_demo;
docker rm -f valaxy_demo;
docker image rm -f valaxy_demo;
cd /opt/docker;
docker build -t valaxy_demo .
```

D) send files or execute commands over SSH
Name: docker_host
Exec command : docker run -d --name valaxy_demo -p 8090:8080 valaxy_demo
Name: `docker_host`
Exec command : `docker run -d --name valaxy_demo -p 8090:8080 valaxy_demo`

7. Login to Docker host and check images and containers. (no images and containers)

Expand All @@ -63,4 +70,6 @@ D) send files or execute commands over SSH
9. check images and containers again on Docker host. This time an image and container get creates through Jenkins job

10. Access web application from browser which is running on container
```
<docker_host_Public_IP>:8090
```
2 changes: 1 addition & 1 deletion SimpeDevOpsProjects/Project-4.MD
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ In *part-01* we create Docker image on ansible server through Jenkins job and pu
#### Troubleshooting:
1. Docker should be installed on ansible server
1. Should login to "docker hub" on ansible server
1. Docker admin user should be part of `docker` group
1. ansadmin user should be part of `docker` group

In *Part-02* we create *create_docker_container.yml* playbook. this get intiated by jenkins job, run by ansible and exected on dokcer_host

Expand Down
1 change: 0 additions & 1 deletion testfile

This file was deleted.

1 change: 0 additions & 1 deletion testfile2

This file was deleted.

2 changes: 0 additions & 2 deletions testfile3

This file was deleted.