diff --git a/applications/higress/README.md b/applications/higress/README.md index 0dd740c86..79fa12d12 100644 --- a/applications/higress/README.md +++ b/applications/higress/README.md @@ -7,9 +7,16 @@ chmod a+x sealos mv sealos /usr/bin/ ``` +Under one sealos cluster, run the following command to deploy higress. +@Note: you must remove any other ingress controllers before you deploy higress. + ```shell -sealos run --masters 172.31.64.100 --nodes 172.31.64.101,172.31.64.102,172.31.64.103 labring/kubernetes:v1.23.0 labring/helm:v3.12.0 labring/calico:v3.24.1 labring/coredns:v0.0.1 --passwd 'Fanux#123' -sealos run labring/openebs:v3.4.0 -sealos run --env HELM_OPTS="--set higress-console.domain=console.8.218.172.255.nip.io" labring/higress:v1.1.0 +sealos run --env HELM_OPTS="--set higress-core.gateway.replicas=3 --set higress-core.controller.replicas=3 \ + --set higress-console.replicaCount=0 --set higress-console.domain=higress-console.svc.cluster.local \ + --set higress-core.gateway.resources.requests.cpu=256m --set higress-core.gateway.resources.requests.memory=256Mi \ + --set higress-console.resources.requests.cpu=256m --set higress-console.resources.requests.memory=256Mi \ + --set higress-core.controller.resources.requests.cpu=256m --set higress-core.controller.resources.requests.memory=256Mi" \ + --env ENABLE_GATEWAY=true --env ENABLE_ISTIO=true --env APPLY_DEFAULT_CR=true \ + labring/higress:v1.3.1 ``` diff --git a/applications/higress/latest/init.sh b/applications/higress/latest/init.sh old mode 100644 new mode 100755 index 575c9e3c4..b288cd06c --- a/applications/higress/latest/init.sh +++ b/applications/higress/latest/init.sh @@ -1,18 +1,129 @@ #!/bin/bash + cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 export readonly ARCH=${1:-amd64} export readonly NAME=${2:-$(basename "${PWD%/*}")} export readonly VERSION=${3:-$(basename "$PWD")} -rm -rf charts && mkdir -p charts -helm repo add higress.io https://higress.io/helm-charts -chart_version=`helm search repo --versions --regexp '\vhigress.io/higress\v' |grep ${VERSION#v} | awk '{print $2}' | sort -rn | head -n1` -helm pull higress.io/higress --version=${chart_version} -d charts/ --untar +function check_command() { + if ! command -v "$1" >/dev/null 2>&1; then + echo "$1 is required, exiting the script" + exit 1 + fi +} + +function prepare(){ + rm -rf charts plugins && mkdir -p charts plugins +} + +function init_gateway(){ + local gateway_api_version="v1.0.0" + wget -q -P plugins/ https://github.com/kubernetes-sigs/gateway-api/releases/download/${gateway_api_version}/standard-install.yaml +} + +function init_istio(){ + local repo_url="https://istio-release.storage.googleapis.com/charts" + local chart_name="istio" + local repo_name="istio/base" # just add istio crd + + helm repo add ${chart_name} ${repo_url} --force-update 1>/dev/null + + # Get latest version, as just for crd usage + local chart_latest_version=$(helm search repo --versions --regexp "\v"${repo_name}"\v" | awk '{print $2}' | grep -v VERSION | sort -rn | head -n1) + + helm pull ${repo_name} --version=${chart_latest_version} -d charts/ --untar +} + +function init_higress(){ + local repo_url="https://higress.io/helm-charts" + local chart_name="higress.io" + local repo_name="higress.io/higress" + + helm repo add ${chart_name} ${repo_url} --force-update 1>/dev/null -cat <<'EOF' >"Kubefile" + # Check version number exists + all_versions=$(helm search repo --versions --regexp "\v"${repo_name}"\v" | awk '{print $3}' | grep -v VERSION) + if ! echo "$all_versions" | grep -qw "${VERSION}"; then + echo "Error: Exit, the provided version "${VERSION}" does not exist in helm repo, get available version with: helm search repo "${repo_name}" --versions" + exit 1 + fi + + # Find the chart version through the app version + local chart_version=$(helm search repo --versions --regexp "\v"${repo_name}"\v" | grep ${VERSION} | awk '{print $2}' | sort -rn | head -n1) + + helm pull ${repo_name} --version=${chart_version} -d charts/ --untar +} + +function init_crd(){ + cat <<'EOF' >"plugins/crd.yaml" +apiVersion: networking.istio.io/v1alpha3 +kind: EnvoyFilter +metadata: + name: hcm-options + namespace: higress-system +spec: + configPatches: + - applyTo: NETWORK_FILTER + match: + context: GATEWAY + listener: + filterChain: + filter: + name: envoy.filters.network.http_connection_manager + patch: + operation: MERGE + value: + name: envoy.filters.network.http_connection_manager + typed_config: + '@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + max_request_headers_kb: 8192 +--- + +apiVersion: networking.istio.io/v1alpha3 +kind: EnvoyFilter +metadata: + name: global-route-config + namespace: higress-system +spec: + configPatches: + - applyTo: ROUTE_CONFIGURATION + match: + context: GATEWAY + patch: + operation: MERGE + value: + request_headers_to_add: + - append: false + header: + key: x-real-ip + value: '%REQ(X-ENVOY-EXTERNAL-ADDRESS)%' +EOF +} + +function init(){ + cat <<'EOF' >"Kubefile" FROM scratch COPY charts charts +COPY plugins plugins COPY registry registry COPY install.sh install.sh CMD ["bash install.sh"] EOF +} + +function main() { + if [ $# -ne 3 ]; then + echo "Usage: ./$0 " + exit 1 + else + check_command helm + prepare + init_gateway + init_istio + init_higress + init_crd + init + fi +} + +main $@ \ No newline at end of file diff --git a/applications/higress/latest/install.sh b/applications/higress/latest/install.sh index 1cd925ab1..c52a0e7b8 100644 --- a/applications/higress/latest/install.sh +++ b/applications/higress/latest/install.sh @@ -1,5 +1,26 @@ #!/bin/bash HELM_OPTS="${HELM_OPTS:-}" +ENABLE_ISTIO="${ENABLE_ISTIO:-}" +ENABLE_GATEWAY="${ENABLE_GATEWAY:-}" +APPLY_DEFAULT_CR="${APPLY_DEFAULT_CR:-}" -helm upgrade --install higress -n higress-system charts/higress --create-namespace --render-subchart-notes ${HELM_OPTS} +helm upgrade --install higress -n higress-system higress.io/higress \ + --create-namespace --render-subchart-notes \ + --set global.ingressClass=nginx --set global.enableStatus=false --set higress-core.gateway.hostNetwork=true \ + --set higress-core.gateway.service.type=NodePort --set global.disableAlpnH2=true \ + ${HELM_OPTS} + +if [[ "$ENABLE_ISTIO" == "true" ]]; then + helm upgrade --install istio-base istio/base -n istio-system --create-namespace + helm upgrade higress higress.io/higress -n higress-system --set global.enableIstioAPI=true --reuse-values +fi + +if [[ "$ENABLE_GATEWAY" == "true" ]]; then + kubectl apply -f plugins/standard-install.yaml + helm upgrade higress higress.io/higress -n higress-system --set global.enableGatewayAPI=true --reuse-values +fi + +if [[ "$APPLY_DEFAULT_CR" == "true" ]]; then + kubectl apply -f plugins/crd.yaml +fi