From 26906c657f607f347e7d1dcef175ec073366bc91 Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Sat, 18 May 2024 18:14:25 -0500 Subject: [PATCH 1/5] Add EasyHAProxy --- stacks/easyhaproxy/README.md | 53 +++++++++++++++++++++++++++++++++ stacks/easyhaproxy/deploy.sh | 48 +++++++++++++++++++++++++++++ stacks/easyhaproxy/uninstall.sh | 13 ++++++++ stacks/easyhaproxy/upgrade.sh | 42 ++++++++++++++++++++++++++ stacks/easyhaproxy/values.yml | 1 + 5 files changed, 157 insertions(+) create mode 100644 stacks/easyhaproxy/README.md create mode 100755 stacks/easyhaproxy/deploy.sh create mode 100755 stacks/easyhaproxy/uninstall.sh create mode 100755 stacks/easyhaproxy/upgrade.sh create mode 100644 stacks/easyhaproxy/values.yml diff --git a/stacks/easyhaproxy/README.md b/stacks/easyhaproxy/README.md new file mode 100644 index 00000000..42a5855f --- /dev/null +++ b/stacks/easyhaproxy/README.md @@ -0,0 +1,53 @@ +# EasyHAProxy + +[EasyHAProxy](https://easyhaproxy.com/) is an Ingress and Auto Discover service based on HAProxy. + +HAProxy is an open-source, high-performance load balancer and reverse proxy designed for TCP and HTTP-based applications. Renowned for its stability, reliability, and performance, it is widely adopted in production environments. + +EasyHAProxy combines HAProxy's robustness with seamless service discovery and exposure within Kubernetes clusters. It offers a straightforward method to configure Ingress rules for services. +Key Features + +- Handles and routes HTTP, HTTPS, and TCP traffic (e.g., MySQL server). +- Supports custom error messages. +- Integrates Let's Encrypt SSL certificate functionality. +- Automatically discovers services within the Kubernetes cluster. +- Facilitates the configuration of Ingress rules for services. +- Provides load balancing capabilities. + +## How to set up your application for EasyHAProxy + +You need to add to your application ingress annotations to expose your service to the internet. + +```yaml +kind: Ingress +metadata: + annotations: + kubernetes.io/ingress.class: easyhaproxy-ingress + . + . + . +``` + +If you want to try a simple example, you can deploy the following application: + +```shell +helm repo add byjg https://opensource.byjg.com/helm +helm repo update +helm upgrade --install mysite byjg/static-httpserver \ + --namespace default \ + --set "ingress.hosts={www.example.org,example.org}" \ + --set parameters.title=Welcome +``` + +## Additional Resources + +For further details about EasyHAProxy, please refer to the [documentation](https://easyhaproxy.com/). + +## Troubleshooting + +Due to limitations in the HAProxy community edition, EasyHAProxy functions solely as a standalone service, regardless of the number of nodes present. + +If the node hosting EasyHAProxy experiences downtime, the service will remain unavailable until the node is operational again. + +To restore connectivity, you have the option to deploy or upgrade the EasyHAProxy service. + diff --git a/stacks/easyhaproxy/deploy.sh b/stacks/easyhaproxy/deploy.sh new file mode 100755 index 00000000..4192aa4e --- /dev/null +++ b/stacks/easyhaproxy/deploy.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +set -e + +################################################################################ +# repo +################################################################################ +helm repo add byjg https://opensource.byjg.com/helm +helm repo update > /dev/null + +################################################################################ +# Pre-requisites +################################################################################ + +# Check if there is any node with the label "easyhaproxy/node=master" +master_node_exists=$(kubectl get nodes --selector=easyhaproxy/node=master -o jsonpath='{.items[*].metadata.name}') + +# If there is no node with the label, then label the first node +if [ -z "$master_node_exists" ]; then + masternode=$(kubectl get nodes -o jsonpath='{.items[0].metadata.name}') + kubectl label nodes $(masternode) "easyhaproxy/node=master" --overwrite +fi + +################################################################################ +# chart +################################################################################ +STACK="easyhaproxy" +CHART="byjg/easyhaproxy" +CHART_VERSION="0.1.7" +NAMESPACE="easyhaproxy" + +if [ -z "${MP_KUBERNETES}" ]; then + # use local version of values.yml + ROOT_DIR=$(git rev-parse --show-toplevel) + values="$ROOT_DIR/stacks/easyhaproxy/values.yml" +else + # use github hosted master version of values.yml + values="https://raw.githubusercontent.com/digitalocean/marketplace-kubernetes/master/stacks/easyhaproxy/values.yml" +fi + +helm upgrade "$STACK" "$CHART" \ + --atomic \ + --create-namespace \ + --install \ + --timeout 8m0s \ + --namespace "$NAMESPACE" \ + --values "$values" \ + --version "$CHART_VERSION" diff --git a/stacks/easyhaproxy/uninstall.sh b/stacks/easyhaproxy/uninstall.sh new file mode 100755 index 00000000..45c465ed --- /dev/null +++ b/stacks/easyhaproxy/uninstall.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +set -e + +################################################################################ +# chart +################################################################################ +STACK="easyhaproxy" +NAMESPACE="easyhaproxy" + + +helm uninstall "$STACK" \ + --namespace "$NAMESPACE" diff --git a/stacks/easyhaproxy/upgrade.sh b/stacks/easyhaproxy/upgrade.sh new file mode 100755 index 00000000..d95cb4e3 --- /dev/null +++ b/stacks/easyhaproxy/upgrade.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +set -e + +################################################################################ +# repo +################################################################################ +helm repo add byjg https://opensource.byjg.com/helm +helm repo update > /dev/null + +################################################################################ +# Pre-requisites +################################################################################ + +# Check if there is any node with the label "easyhaproxy/node=master" +master_node_exists=$(kubectl get nodes --selector=easyhaproxy/node=master -o jsonpath='{.items[*].metadata.name}') + +# If there is no node with the label, then label the first node +if [ -z "$master_node_exists" ]; then + masternode=$(kubectl get nodes -o jsonpath='{.items[0].metadata.name}') + kubectl label nodes $(masternode) "easyhaproxy/node=master" --overwrite +fi + +################################################################################ +# chart +################################################################################ +STACK="easyhaproxy" +CHART="byjg/easyhaproxy" +NAMESPACE="easyhaproxy" + +if [ -z "${MP_KUBERNETES}" ]; then + # use local version of values.yml + ROOT_DIR=$(git rev-parse --show-toplevel) + values="$ROOT_DIR/stacks/easyhaproxy/values.yml" +else + # use github hosted master version of values.yml + values="https://raw.githubusercontent.com/digitalocean/marketplace-kubernetes/master/stacks/easyhaproxy/values.yml" +fi + +helm upgrade "$STACK" "$CHART" \ +--namespace "$NAMESPACE" \ +--values "$values" \ diff --git a/stacks/easyhaproxy/values.yml b/stacks/easyhaproxy/values.yml new file mode 100644 index 00000000..6f5865ca --- /dev/null +++ b/stacks/easyhaproxy/values.yml @@ -0,0 +1 @@ +# byjg/easyhaproxy From 61e28f7c02b6086e402e9e6c94ea6d53d24ffdc6 Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Sat, 18 May 2024 18:26:30 -0500 Subject: [PATCH 2/5] Minor adjusts. --- stacks/easyhaproxy/uninstall.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stacks/easyhaproxy/uninstall.sh b/stacks/easyhaproxy/uninstall.sh index 45c465ed..66fb4f88 100755 --- a/stacks/easyhaproxy/uninstall.sh +++ b/stacks/easyhaproxy/uninstall.sh @@ -8,6 +8,13 @@ set -e STACK="easyhaproxy" NAMESPACE="easyhaproxy" +# Check if there is any node with the label "easyhaproxy/node=master" +master_node_exists=$(kubectl get nodes --selector=easyhaproxy/node=master -o jsonpath='{.items[*].metadata.name}') + +# If there is a node with the label, then remove the label +if [ -n "$master_node_exists" ]; then + kubectl label nodes "$master_node_exists" "easyhaproxy/node-" +fi helm uninstall "$STACK" \ --namespace "$NAMESPACE" From 49bf355e5e83492c8c553a5ca2bb8ac78c8370fb Mon Sep 17 00:00:00 2001 From: Joao Gilberto Magalhaes Date: Sat, 18 May 2024 18:30:53 -0500 Subject: [PATCH 3/5] Fix error --- stacks/easyhaproxy/deploy.sh | 2 +- stacks/easyhaproxy/upgrade.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stacks/easyhaproxy/deploy.sh b/stacks/easyhaproxy/deploy.sh index 4192aa4e..f6ae7a70 100755 --- a/stacks/easyhaproxy/deploy.sh +++ b/stacks/easyhaproxy/deploy.sh @@ -18,7 +18,7 @@ master_node_exists=$(kubectl get nodes --selector=easyhaproxy/node=master -o jso # If there is no node with the label, then label the first node if [ -z "$master_node_exists" ]; then masternode=$(kubectl get nodes -o jsonpath='{.items[0].metadata.name}') - kubectl label nodes $(masternode) "easyhaproxy/node=master" --overwrite + kubectl label nodes "$masternode" "easyhaproxy/node=master" --overwrite fi ################################################################################ diff --git a/stacks/easyhaproxy/upgrade.sh b/stacks/easyhaproxy/upgrade.sh index d95cb4e3..b0716925 100755 --- a/stacks/easyhaproxy/upgrade.sh +++ b/stacks/easyhaproxy/upgrade.sh @@ -18,7 +18,7 @@ master_node_exists=$(kubectl get nodes --selector=easyhaproxy/node=master -o jso # If there is no node with the label, then label the first node if [ -z "$master_node_exists" ]; then masternode=$(kubectl get nodes -o jsonpath='{.items[0].metadata.name}') - kubectl label nodes $(masternode) "easyhaproxy/node=master" --overwrite + kubectl label nodes "$masternode" "easyhaproxy/node=master" --overwrite fi ################################################################################ From cfa165139f92d991acd4b92a94dd057680a7c4a7 Mon Sep 17 00:00:00 2001 From: Joao M Date: Sun, 19 May 2024 21:07:23 -0500 Subject: [PATCH 4/5] Update README.md --- stacks/easyhaproxy/README.md | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/stacks/easyhaproxy/README.md b/stacks/easyhaproxy/README.md index 42a5855f..bbf80afb 100644 --- a/stacks/easyhaproxy/README.md +++ b/stacks/easyhaproxy/README.md @@ -14,6 +14,11 @@ Key Features - Facilitates the configuration of Ingress rules for services. - Provides load balancing capabilities. +## Install + +- Enable the EasyHAProxy in the Digital Ocean marketplace +- Create a Digital Ocean Load Balance pointing to your Kubernetes Cluster. + ## How to set up your application for EasyHAProxy You need to add to your application ingress annotations to expose your service to the internet. @@ -28,7 +33,15 @@ metadata: . ``` -If you want to try a simple example, you can deploy the following application: +## Additional Resources + +For further details about EasyHAProxy, please refer to the [documentation](https://easyhaproxy.com/). + +## Troubleshooting + +### Check if the EasyHAProxy is running properly + +You can install the "Static Http Server" and define the domain you want to validate as the example below: ```shell helm repo add byjg https://opensource.byjg.com/helm @@ -39,11 +52,8 @@ helm upgrade --install mysite byjg/static-httpserver \ --set parameters.title=Welcome ``` -## Additional Resources - -For further details about EasyHAProxy, please refer to the [documentation](https://easyhaproxy.com/). -## Troubleshooting +### EasyHAProxy Container not Starting Due to limitations in the HAProxy community edition, EasyHAProxy functions solely as a standalone service, regardless of the number of nodes present. From 633bdd7640a186447dc76ff0ec946b1f238af87a Mon Sep 17 00:00:00 2001 From: Joao M Date: Wed, 29 May 2024 09:03:19 -0500 Subject: [PATCH 5/5] Setting default resources for easyhaproxy --- stacks/easyhaproxy/values.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stacks/easyhaproxy/values.yml b/stacks/easyhaproxy/values.yml index 6f5865ca..3a729bf8 100644 --- a/stacks/easyhaproxy/values.yml +++ b/stacks/easyhaproxy/values.yml @@ -1 +1,5 @@ # byjg/easyhaproxy +resources: + requests: + cpu: "100m" + memory: "128Mi"