UncleNUC Wiki

Second chance for NUCs

User Tools

Site Tools


lab:stack_-_install_haproxy

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
lab:stack_-_install_haproxy [2023/05/01 01:38] – updated userlab:stack_-_install_haproxy [2023/05/01 19:48] (current) – replaced user
Line 1: Line 1:
-====== Install HAProxy ====== 
-In our previous step we deployed a web app to Kubernetes on our [[Stack of NUCs]]. 
- 
-Now we are going to install HAProxy. 
- 
-Purpose: 
-  * Demonstrate a using HAProxy in front of a web application on Kubernetes 
- 
-References 
-  * [[https://28gauravkhore.medium.com/how-to-configure-the-haproxy-using-the-ansible-and-also-how-to-configure-haproxy-dynamically-f18a55de3a66]] 
- 
-====== Step 1 - Connect to the Ansible control node ====== 
-From [[stack - nuc 1|NUC 1]], log in to the Ansible control node, [[stack -  nuc 2|NUC 2]]. 
- 
-====== Step 2 - Set Up a Folder for Configuration and Playbooks ====== 
-  - Create folder ''/home/ansible/my-project/haproxy'' and change directory to it 
-  - Copy the ''hosts'' file we created early in the lab 
-    * ''cp /home/ansible/my-project/hosts /home/ansible/my-project/haproxy/'' 
-  - Create the file ''/home/ansible/my-project/haproxy/ansible.cfg'' 
-    * <file yaml ansible.cfg> 
-[defaults] 
-inventory         = hosts 
-</file> 
-  - Create the file ''/home/ansible/my-project/haproxy/haproxy.cfg.j2'' 
-    * <file yaml haproxy.cfg.j2> 
-# ------------------------ 
-# main frontend which proxys to the backends 
-# ------------------------ 
-frontend main 
-    bind *:8080 
-    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 
-{% for ip in groups['nodes'] %} 
-    server app{{ loop.index}} {{ ip }}:80 check 
-{% endfor %} 
-</file> 
-====== Step 3 - Install HAProxy ====== 
- 
-<file yaml haproxy-install.yml> 
---- 
-- hosts: nodes 
-  tasks: 
-    - name: Install haproxy 
-      package: 
-        name: haproxy 
-        state: present 
-    - name: Configure haproxy.cfg file 
-      template: 
-        src: "/home/ansible/my-project/haproxy/haproxy.cfg.j2" 
-        dest: "/etc/haproxy/haproxy.cfg" 
-    - name: "haproxy service start" 
-      service: 
-        name: haproxy 
-        state: restarted 
-</file> 
- 
-''ansible-playbook haproxy-install.yml'' 
- 
  
lab/stack_-_install_haproxy.1682905101.txt.gz · Last modified: 2023/05/01 01:38 by user