Last active
July 12, 2022 07:04
-
-
Save halvards/dc854f16d76bcc86ec59d846aa2011a0 to your computer and use it in GitHub Desktop.
NGINX Ingress Controller with Standalone Network Endpoint Group (NEG)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# Copyright 2020 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
# | |
# Disclaimer: This is not an officially supported Google product. | |
set -euf -o pipefail | |
INGRESS_NGINX_VERSION=${INGRESS_NGINX_VERSION:-0.32.0} | |
curl -sSLO "https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-${INGRESS_NGINX_VERSION}/deploy/static/provider/cloud/deploy.yaml" | |
cat << EOF > patch-deployment.yaml | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
name: ingress-nginx-controller | |
namespace: ingress-nginx | |
spec: | |
replicas: 2 | |
template: | |
spec: | |
containers: | |
- name: controller | |
ports: | |
- containerPort: 10254 | |
name: health | |
EOF | |
cat << EOF > patch-service.yaml | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
name: ingress-nginx-controller | |
namespace: ingress-nginx | |
annotations: | |
cloud.google.com/neg: '{"exposed_ports": {"80": {}, "443": {}}}' | |
spec: | |
externalTrafficPolicy: '' | |
type: ClusterIP | |
EOF | |
cat << EOF > kustomization.yaml | |
apiVersion: kustomize.config.k8s.io/v1beta1 | |
kind: Kustomization | |
resources: | |
- deploy.yaml | |
patchesStrategicMerge: | |
- patch-deployment.yaml | |
- patch-service.yaml | |
EOF | |
kubectl apply --kustomize . | |
echo | |
echo 'ingress-nginx successfully installed.' | |
echo | |
echo 'Read how to add external HTTP(S) load balancing:' | |
echo 'https://cloud.google.com/kubernetes-engine/docs/how-to/standalone-neg#attach_load_balancers_to_standalone_negs' | |
echo | |
echo 'If you have multiple ingress controllers in your cluster, add this' | |
echo 'annotation to your ingress objects to use ingress-nginx:' | |
echo ' kubernetes.io/ingress.class: nginx' | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, it fails for me with this error:
Running on GCP GKE version 1.22.8-gke.202
INGRESS_NGINX_VERSION=0.32.0
Do you have any advice please? Thank you