------------------------
Kubernetes basic concept
------------------------
1. Create a namespace called frontend
ns-> namespace
[root@master kube]# kc create ns fronend
# kc get ns
2. Create a pod name nginx in frontend namespace. usig nginx image
# kc run nginx --image=nginx -n frontend
[root@master kube]# kc create ns frontend
namespace/frontend created
[root@master kube]# kc run nginx --image=nginx -n frontend
pod/nginx created
[root@master kube]# kc get ns | grep frontend
frontend Active 2m2s
[root@master kube]# kc get pods | grep nginx
nginx-f89759699-hxfnp 0/1 Pending 0 24d
[root@master kube]#
3. Get list of al lpods in kibe-system namespace and write the output to /root/kube-system-pods.txt
[root@master kube]# kc get pods -n kube-system
[root@master kube]# kc get pods -n kube-system > /root/kube/kube-system-pods.txt
4. Get list of all services across all namespaces and write the output to /root/all-services.txt
[root@master kube]# kc get svc -A
[root@master kube]# kc get svc -A > /root/kube/all-services.txt
Note: -A is shirtcut for --all-namespaces
5. Create a pod named hello with iage busybox and command echo "Hello Workd". Make sure the pod do not restart automatically
[root@master kube]# kc run hello --image=busybox --restart=Never -- echo "HelloWorld kc delete pod pod!"
[root@master kube]# kc get pod
6. Generate a pod manifest file at /root/mypodx.yaml. Pod name should be mypodx with image redis. Make sure you only generate the pod manifest file, you do not have to create the pod.
[root@master kube]# kc run mypod --image=redis --dry-run=client -o yaml >/root/kube/mypodx.yaml
-------------------
Configuration Part
-------------------
1. Create a config map called my-config in namespace called datatab. Use value confa=exvalue. Yo umay want to create namespac if it does not exists.
[root@master kube]# kc create ns datatab
[root@master kube]# kc create cm my-config --from-literal=confa=exvalue --namespace=datatab
2. A configmap al-conf has been created. Expose the value of al-user to a pod named al-pod as AL_USER environment variable. Use redis image for the pod.
cat << EOF > al-pod.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: al-pod
name: al-pod
spec:
containers:
- image: redis
name: al-pod
env:
- name: AL_USER
valueFrom:
configMapKeyRef:
name: al-conf
key: al-user
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
EOF
[root@master kube]# kc apply -f al-pod.yaml
3. Create a Pod named secure-pod. Use redis image. Run pod as user 1000 and group 2000
create a spec file:
cat << EOF > secure-pod.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: secure-pod
name: secure-pod
spec:
securityContext:
runAsUser: 1000
runAsGroup: 2000
containers:
- image: redis
name: secure-pod
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
EOF
[root@master kube]# kc apply -f secure-pod.yaml
[root@master kube]# kc get pods | grep secure
4. Create a pod mainfest file at /root/kube/limitd-pod.yaml with name limited-pod and busybox image. Set memory request at 100Mi and limit at 200 Mi. You do not need to create the pod
[root@master kube]# kc run limited-pod --image=busybox --requests='memory=100Mi' --limits='memory=200Mi' --dry-run=client -o yaml > /root/kube/limited-pod.yaml
[root@master kube]# more /root/kube/limited-pod.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: limited-pod
name: limited-pod
spec:
containers:
- image: busybox
name: limited-pod
resources:
limits:
memory: 200Mi
requests:
memory: 100Mi
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
[root@master kube]#
5. Complete the following tasks
a. Create a secret db-secret with value MYSQL_ROOT_PASSWORD=YoYoSecret and MYSQL_PASSWORD=X0X0Password
[root@master kube]# kubectl create secret generic db-secret --from-literal='MYSQL_ROOT_PASSWORD=YoYoSecret' --from-literal='MYSQL_PASSWORD=XoXoPassword'
b. Create a configmap db-config with value MYSQL_USER=k8s and MYSQL_DATABASE=newdb
[root@master kube]# kc create configmap db-config --from-literal='MYSQL_USER=k8s' --from-literal='MYSQL_DATABASE=mewdb'
c. Create a pod named mydb with image mysql:5.7 and expose all values of db-secret and db-config as environment variable to pod.
Create a spec file
cat << EOF > mydb.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: mydb
name: mydb
spec:
containers:
- image: mysql:5.7
name: mydb
envFrom:
- configMapRef:
name: db-config
- secretRef:
name: db-secret
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
EOF
[root@master kube]# kc apply -f mydb.yaml
pod/mydb created
6. Create a service account named namaste. Use the service account to create a pod yo-namaste with image nginx
[root@master kube]# kc create sa namaste
serviceaccount/namaste created
[root@master kube]# kc run yo-namaste --image=nginx --serviceaccount=namaste
pod/yo-namaste created
[root@master kube]# kc get pods
--------------------------------
Multi-Container PODs
Complete the following tasks
1. Create a pod mp-hello with image alpine, nginx and consul:1.8.
Use command sleep infinity for alpine comtainer.
# kc run mp-hello --image=alpine --command sleep=infinity
# cat << EOF > np-hello.yaml
[root@master kube]# cat <<EOF > mp-hello.yaml
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: null
labels:
run: mp-hellp
name: mp-hellp
spec:
containers:
- args:
- sleep
- infinity
- image: alpine
name: mp-hellp
- image: nginx
name: nginx
- image: consul:1.8
name: consul
resources: {}
dnsPolicy: ClusterFirst
restartPolicy: Always
status: {}
EOF
[root@master kube]# kc apply -f mp-hello.yaml
error: error validating "mp-hello.yaml": error validating data: ValidationError(Pod.spec.containers[0]): missing required field "name" in io.k8s.api.core.v1.Container; if you choose to ignore these errors, turn validation off with --validate=false
[root@master kube]# kc apply -f mp-hello.yaml
pod/mp-hellp created
[root@master kube]#
$ sleep 5 && upgrade.sh
Tuesday, December 8, 2020
Kubernetes - hands on practice
Monday, December 7, 2020
Ansible - update / copy file using jinja template
Copy name server info to all web servers
1. Disable NetworkManager service
[root@master ~]# systemctl status/stop/disable NetworkManager
2. Update your config file with correct dns entry
[root@master ~]# cat mydns.conf
nameserver {{ dnsip }}
3. Write your yaml file
[root@master ~]# cat mydns.yaml
- hosts: myweb
vars:
- dnsip: "8.8.8.8"
tasks:
- template:
src: mydns.conf
dest: /etc/resolv.conf
4. Check your ansible config file
[root@master ~]# ansible --version
config file = /etc/ansible/ansible.cfg
5. Find your inventory file
[root@master ~]# cat /etc/ansible/ansible.cfg | more
[defaults]
inventory = /root/myhosts
host_key_checking=false
6. Check your inventory record. Set up passwordless authentication (ssh-keygen)
[root@master ~] # cat myhosts
[myweb]
worker1 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
worker2 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
7. Run your playbook
[root@master ~]# ansible-playbook mydns.yaml
Ansible - File copy - update DNS record on client machines
Copy name server info to all web servers
1. Disable NetworkManager service
[root@master ~]# systemctl status/stop/disable NetworkManager
2. Update your config file with correct dns entry
[root@master ~]# cat mydns.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 10.0.2.2
3. Write your yaml file
[root@master ~]# cat mydns.yaml
- hosts: myweb
tasks:
- copy:
src: dns.conf
dest: /etc/resolv.conf
4. Check your ansible config file
[root@master ~]# ansible --version
config file = /etc/ansible/ansible.cfg
5. Find your inventory file
[root@master ~]# cat /etc/ansible/ansible.cfg | more
[defaults]
inventory = /root/myhosts
host_key_checking=false
6. Check your inventory record. Set up passwordless authentication (ssh-keygen)
[root@master ~] # cat myhosts
[myweb]
worker1 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
worker2 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
7. Run your playbook
[root@master ~]# ansible-playbook mydns.yaml
Thursday, December 3, 2020
Ansible - task automation, install, start service and configure web service
Day6- ansible
Ansible
- Control Node
- Managed node
- Web Server (IP)
- hosts: myweb # myweb comes from
tasks:
- package:
name: "httpd"
- copy:
dest: "/var/www/html/index.html"
content: " for lb testing"
- service:
name: "httpd"
state: restarted
- hosts: mylb
tasks:
- name: "Install LB software"
package:
name: "haproxy"
~
add template
go to haproxy server and copy this file to your ansible controller node.
For me, I used same server for controller node and proxy.
[root@master ~]# cat lb.yaml
- hosts: myweb # myweb comes from
tasks:
- package:
name: "httpd"
- copy:
dest: "/var/www/html/index.html"
content: " for lb testing"
- service:
name: "httpd"
state: restarted
- hosts: mylb
tasks:
- name: "Install LB software"
package:
name: "haproxy"
- template:
dest: "/etc/haproxy/haproxy.cfg"
src: "haproxy.cfg"
- service:
name: "haproxy"
state: restarted
[root@master ~]# ansible-playbook lb.yaml
Go to your LB and check if you can access the sites...
if you have new host, just add it to ansible inventory and lb, run the play, it will configure..
one click, web server is ready and added to lb
Note: if you forget to update LB, adding new server does not work at all.
This concept is call scale -> horizontal scaling.. adding node
veritcal scaling - > adding cpu/ram/disk
go to load balancer, and check the config file...
check under baclend and add new host and rerun the lb.yml file.
add new host (horizontal scaling)
Challanges in terms of management
1. Knowing config file of every software is challanging
2. everytime, we have to go to control node and update new host
if there is a new IP address, update the config file and upload automatically..
we want new IP will be added to haproxy.conf automatically
or say we have old IP and we no longer using and need to be removed..
Task:
On controller node, when you have new IP is detected, configure web server, update the template file for haproxy and upload it to haproxy server?
=======================================================
How to configure docker using ansible
Steps
Note: docker-ce does not come on redhat iso.
1. Configure yum repo for docker
Get url from internet
2. Install docker
docker-ce
3. Start service
4. docker images
5. Run comtainers
Masternode: .50
Managed node: .51/.52
[root@master ~]# ping goo.gl
[root@master ~]# yum list docker-cd
go to your controller node.
# ansible-docs yumrepositry
- hosts: 192.168.10.50
tasks:
- name: setting up docker yum confuration
yum_repository:
name: df
description: EPEL yum repo
file: external_repo
baseurl: https://download ....
gpgcheck: no
# install the package
- package:
name: "docker-ce"
state: present
We got error
Now, go to the system and try to install manually.
# yum install docker-ce
error: use '--nobest'
# yum install docker-ce --nobest
It installs successfully
but we want to perform this task using ansible.
google ansible package module
and go to docs.ansible
read the doc, we didn't find anything under package
google ansible yum module
ad-hoc commands,
[root@master ~]# ansible all -m command -a date
worker1 | CHANGED | rc=0 >>
Thu Dec 3 11:40:44 EST 2020
worker2 | CHANGED | rc=0 >>
Thu Dec 3 11:40:44 EST 2020
master | CHANGED | rc=0 >>
Thu Dec 3 11:40:44 EST 2020
Reboot all the machines
[root@master ~]# ansible all -m command -a reboot
reboot web servers
[root@master ~]# ansible myweb -m command -a reboot
rather than package module, use ad-hoc command
- hosts: 192.168.10.50
tasks:
- name: setting up docker yum confuration
yum_repository:
name: df
description: EPEL yum repo
file: external_repo
baseurl: https://download.docker.con/linux/centos/7/x86_64/stable/
gpgcheck: no
# install the package
# - package:
# name: "docker-ce"
# state: present
- command: "yum install docker-ce --nobest -v"
you will encounter same kind of problem on hadoop as well.
yum comand does not work with --force
need flag --force
For that you have to use command module and os specific command.
# rpm -ivh hadoop --force
Write a playbook that goes to aws-cloud and create an ec2 instance
LAB2 - Running ansible ad-hoc commands
Running ansible ad-hoc commands
1. Get ansible version
# ansible --version
- Get ansible/python version
- Get the config file location
- and get the inventory file location
2. Check the communication with managed nodes
# ansible all -m ping
3. Copying files to worker node
- Lets google for copy module: ansible copy file module
- search for ansible service module and review the doc and review the example as well.
4. Lets install httpd manually first on one of the worker node
# yum install httpd
# systemctl start httpd
# cd /var/www/html
# cat > index.html
Welcome to my web site !!!
5. go to browser and test it. You should have access to the page.
If you encounter proble, disable firewall, selinux for testing purpose.
6. Now, remove httpd
# systemctl stop httpd
# yum remove httpd -y
# rpm -q httpd # verify
# ls -ld /var/www/html # you can't list this dir
7. Now, go to control node and run ad-hoc command
# ansible --version
# ansible all --list-hosts
# cat > index.html
Welcome to ansible pushed page !!!
# ansible all -m package -a "name=httpd state=present"
# ansible all -m copy -a "src=index.html dest=/var/www/html/"
# ansible all -m service -a "name=httpd state=started"
# ansible worker2 -m service -a "name=httpd state=started"
# ansible worker2 -m copy -a "src=copyme.html dest=/var/www/html/"
go to worker2 node and check
# systemctl status httpd
[root@master ~]# cat copyme.html
Copied from ctrl node
[root@worker2 html]# cat copyme.html
Copied from ctrl node
# ansible 192.169.10.51 -m service -a "name=httpd state=started
-------------------------------
Now, lets go ahead and setup web server.
1. Install httpd package
# ansible all -m package -a "name=httpd state=present"
We are using package module here.
2. Copy webpage to web server
# ansible all -m copy -a "src=copyme.html dest=/var/www/html/"
3. Start web server httpd on managed node from control node
# ansbile all -m service -a "name=httpd state=started"
8. Lets automate this manu task by writing a config file
# cat webpage.yaml
- hosts: myweb
tasks:
- package: "name: "httpd state=present"
- copy: "src=copyme.html dest=/var/www/html/"
- service: "name=httpd state=started"
# ansible-playbook webpage.yaml
[root@master ~]# cat webserver.yaml
- hosts: all
tasks:
- file:
state: directory
path: "/dvd1"
- mount:
src: "/dev/cdrom"
path: "/dvd1"
state: mounted
fstype: "iso9660"
# add entry to fstab
# task is a list of three task such as file, mount and yum.
# these belongs to same block of code, so same space..
- yum_repository:
baseurl: "/dvd1/AppStream"
name: "mydvd1"
description: "My yum repo"
gpgcheck: no
- yum_repository:
baseurl: "/dvd1/BaseOS"
name: "mydvd2"
description: "My yum repo 2"
gpgcheck: no
- package:
name: "httpd"
state: present
- copy:
dest: "/var/www/html/index.html"
content: "Welcome to my web page. Enjoy !!!"
- firewalld:
port: "80/tcp"
state: enabled
permanent: yes
immediate: yes
[root@master ~]#
[root@master ~]# cat myhosts
#[masterserver]
#master ansible_user=sam
#[WebServer]
#worker1
#worker1 ansible_user=sam
#worker2 ansible_user=sam
[mylb]
master ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
[myweb]
worker1 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
worker2 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
[root@master ~]#
[root@master ~]# cat lb.yaml
- hosts: myweb # myweb comes from
tasks:
- package:
name: "httpd"
- copy:
dest: "/var/www/html/index.html"
content: " for lb testing"
- service:
name: "httpd"
state: restarted
- hosts: mylb
tasks:
- name: "Install LB software"
package:
name: "haproxy"
- template:
dest: "/etc/haproxy/haproxy.cfg"
src: "haproxy.cfg"
- service:
name: "haproxy"
state: restarted
[root@master ~]#
[root@master ~]# cat repo.docker.repo
- hosts: 192.168.10.50
tasks:
- name: setting up docker yum confuration
yum_repository:
name: df
description: EPEL yum repo
file: external_repo
baseurl: https://download.docker.con/linux/centos/7/x86_64/stable/
gpgcheck: no
# install the package
- package:
name: "docker-ce"
state: present
- command: "yum install docker-ce --nobest -v"
[root@master ~]#
[root@master ~]# cat copyme.txt
Copied from ctrl node
[root@master ~]#
[root@master ~]# cat web.html
Welcome to my page for ansible
[root@master ~]#
[root@master ~]# cat pod-definition.yml
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
labels:
app: myapp
spec:
containers:
- name: nginx-container
image: nginx
[root@master ~]#
Wednesday, December 2, 2020
Lab1 - Install and configure ansible, and install package on worker node using ansible
1. Check if ansible is installed on your system.
# rpm -q ansible
# rpm -qa grep ansible
2. Check/setup your repo
# yum repolist
# yum install ansible
No match for argument: ansible
3. Install ansible using pip
# python -V
# pip3 install ansible
# ansible -version # Note the config file location
4. List your ansible hosts
# ansible all --list-hosts
5. Define your inventory of hosts
# vi /root/myhosts
w1 192.168.10.51
w2 192.168.10.51
google for ansible inventory, read through it...
# vi /etc/ansible/ansible.cfg
# add the following contents
[defaults]
inventory = /root/myhosts
wq!
# ansible all --list-hosts
# ansible all -m ping
6. Now, lets go ahead and install one software package on worker node.
- Login to worker node and check if firefox is installed, If yes, remove it.
# rpm -q firefox
# rp remove firefox
7. Google for ansible package module
go to docs.ansible and read through, look at the example.
check state -> present/absent
# ansible all -m package -a "name=firefox state=present"
error: install sshpass program
# rpm -q sshpass
# yum install sshpass
# pip3 install sshpass
still failed to install.
Google for epel release package, download and install
# wget <http://path-to-epel>
# rpm -ivh epel-release-latest-8.noarch.rpm
# yum repolist
# yum install sshpass
# ansible all -m package -a "name=firefox state=present"
[root@master ~]# ansible all -m package -a "name=firefox state=present"
[root@worker1 html]# rpm -q firefox
package firefox is not installed
[root@worker1 html]# rpm -q firefox
firefox-68.7.0-2.el8_1.x86_64
[root@worker2 html]# rpm -q firefox
package firefox is not installed
[root@worker2 html]# rpm -q firefox
firefox-68.7.0-2.el8_1.x86_64
[root@master ~]# ansible --version
ansible 2.9.14
config file = /etc/ansible/ansible.cfg
[root@master ~]# more /etc/ansible/ansible.cfg
[defaults]
inventory = /root/myhosts
[root@master ~]# cat myhosts
#[masterserver]
#master ansible_user=sam
#[WebServer]
#worker1
[mylb]
master ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
[myweb]
worker1 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
worker2 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
[root@master ~]# cat /etc/hosts
192.168.56.5 master master.expanor.local
192.168.56.6 worker1 worker1.expanor.local
192.168.56.7 worker2 worker2.expanor.local
Ansible-Install and configure HA-Proxy using ansible
Ansible Notesday 5
-------------------------
LB and reverse proxy
--------------------
how to configure load balancer and reverse proxy
webserver
Apache (http) -> webserver:80 -> web page -html
-> we have apache web server running on port 80.
use case,
so, user within the organization or from remote site access the site.
one server has limited resources such as cpu/mem and it can handle certain number of load/connection.
so, if user keep growing, you have to upgrade server power. what if you have millions of users/visitors to your site?
this is a big challange. we have on single server and it is working on its full capcacity.
what can we do to increase the limit?
we already increase the max limit. how can we solve it?
we can launch a new server instances (VM, container) with new IP and configure the web server the same way as the first one.
Challanges?
You have two servers with two IP. so, you have to let your user to connect to new IP. so, you have two different IP to access it. again, your user growth increase and you have new IPs. this sounds not logical.
say, you have 1000s of computer, you can't give all IP to your users. it will be hectic for user so, to get ride of this problem, we will have one server with say ip of .100.
so user will connect to .100. now, any request comes to .100, it will forward request to web server.
And web server thinks .100 is client and returns the request to .100. And .100 forward user request.
IP .100 is never a web server or a client. This is a proxy, so it behaves proxy and reverse proxy.
server serving on other's behave,
firewall
in the web server, you don't have to allow all IP address, you can only allow .100 since request always comes through .100.
so you can enable .100 on firewall.
we have extra level of security here.
.100 [ Proxy server]
-- Webserver1
-- webserver2
-- webserver3
- all the request comes to .100, pass traffic to webserver1
- when load increase add new web server to reverse proxy.
- as soon as first request comes, it goes to w1 and second goes to s2.
- So, it is balancing the load between the servers.
- if load increases, we can add new web server and register with prxy and it is available for service.
For this kind of setup, we can use ansible to configure.
in real scenario, the .100 server we give them name such as host or domain.
so, these names might not be the real physical server. these may be just load balancer and they don't go down.
====================
# yum install php
systemctl status httpd
# cd /var/www/html
<pre>
<?php>
print `ifconfig`;
</php>
</pre>
========================
Configure LB and proxy
Step1. Install haproxy - comes on DVD
# yum install haproxy
Step2. Configure haproxy
# /etc/haproxy/haproxy.cfg
frontend main
bind *:5000
change it to port 8080
frontend main
#bind *:5000
bind *:8080
go down you will see backend
default_backend app
backend app
balance roundrobin
server webserver1 192.168.56.6:80 check
server webserver2 192.168.56.7:80 check
here you will define list of all backend servers.
[root@master ~]# systemctl start haproxy
systemctl start/enable haproxy
Now, go to web server and create test page.
get your IP address and try to access
http://192.168.56.5:8080/
keep refreshing the page, you will see different content.
We manually configured the page.
- hosts: 192.168.56.6,192.168.56.6 # all to install software on all or define individually
tasks:
There is one option available in inventory to group them. and give them group name say web or load balancer.
[mylb]
master ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
[myweb]
worker1 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
worker2 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
# cat lb.yaml
- hosts: myweb # myweb comes from
tasks:
- package:
name: "httpd"
- hosts: mylb
tasks:
- package:
name: "haproxy"
# ap lb.yaml
# ansible-playbook lb.yaml
# cat lb.yaml
- hosts: myweb # myweb comes from
tasks:
- package:
name: "httpd"
- hosts: mylb
tasks:
- package:
name: "haproxy"
-step2: config
step3. service haproxy
lets say you configure load balancer: .5
webserver: .6/.7
say, we have load come up, and need to configure new web server.
only thing you have to do is, on inventory, add new IP address under web, it will be configured a web server.
the chanllange is to go to load balancer, and add entry to backend app with new IP.
with the help of ansible, when new ip added to inventory, the config of haproxy will be updated.
Accessing HAProxy stats page
---------------------------
Configuration of haproxy config file
[root@master ~]# cat /etc/haproxy/haproxy.cfg
#---------------------------------------------------------------------
# Example configuration for a possible web application. See the
# full configuration options online.
#
# https://www.haproxy.org/download/1.8/doc/configuration.txt
#
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
# to have these messages end up in /var/log/haproxy.log you will
# need to:
#
# 1) configure syslog to accept network log events. This is done
# by adding the '-r' option to the SYSLOGD_OPTIONS in
# /etc/sysconfig/syslog
#
# 2) configure local2 events to go to the /var/log/haproxy.log
# file. A line like the following can be added to
# /etc/sysconfig/syslog
#
# local2.* /var/log/haproxy.log
#
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
# utilize system-wide crypto-policies
ssl-default-bind-ciphers PROFILE=SYSTEM
ssl-default-server-ciphers PROFILE=SYSTEM
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend main
bind *:8080
#bind *:5000
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js
use_backend static if url_static
default_backend app
#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
balance roundrobin
server static 127.0.0.1:4331 check
#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
balance roundrobin
server webserver1 192.168.56.6:80 check
server webserver2 192.168.56.7:80 check
frontend stats
bind *:8084
stats enable
stats uri /stats
stats refresh 10s
stats admin if LOCALHOST
[root@master ~]#
Now access the STATS page by going to masternode (proxy server) IP:8084/stats
http://master:8084/stats
you will see web interface.
-----------------------------------------------
[root@master ~]# ansible --version
ansible 2.9.14
config file = /etc/ansible/ansible.cfg
[root@master ~]# more /etc/ansible/ansible.cfg
[defaults]
inventory = /root/myhosts
[root@master ~]# cat myhosts
#[masterserver]
#master ansible_user=sam
#[WebServer]
#worker1
[mylb]
master ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
[myweb]
worker1 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
worker2 ansible_user=root ansible_ssh_pass=changeme ansible_connection=ssh
[root@master ~]# cat /etc/hosts
192.168.56.5 master master.expanor.local
192.168.56.6 worker1 worker1.expanor.local
192.168.56.7 worker2 worker2.expanor.local
[root@master ~]# cat lb.yaml
- hosts: myweb # myweb comes from
tasks:
- package:
name: "httpd"
- hosts: mylb
tasks:
- package:
name: "haproxy"
Git branch show detached HEAD
Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03) 00 2. Run re-set hard $ git reset --hard 3. ...
-
snmpconfig command allow you to managge snmpv1/v3 agent configuration on SAN switch. Event trap level is mapped with event severity level....
-
Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03) 00 2. Run re-set hard $ git reset --hard 3. ...
-
SQS Simple Queue Service - 2-28-2021 Class Notes Tightly couple A (Program) --> data info ---> B (Program) tightly coupled (sync( A --...