-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path02-create-nginx-ingress-controller.sh
39 lines (32 loc) · 1.48 KB
/
02-create-nginx-ingress-controller.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Variables
source ./00-variables.sh
# Check if the NGINX ingress controller Helm chart is already installed
result=$(helm list -n $NGINX_NAMESPACE | grep $NGINX_RELEASE_NAME | awk '{print $1}')
if [[ -n $result ]]; then
echo "[$NGINX_RELEASE_NAME] NGINX ingress controller release already exists in the [$NGINX_NAMESPACE] namespace"
else
# Check if the NGINX ingress controller repository is not already added
result=$(helm repo list | grep $NGINX_REPO_NAME | awk '{print $1}')
if [[ -n $result ]]; then
echo "[$NGINX_REPO_NAME] Helm repo already exists"
else
# Add the NGINX ingress controller repository
echo "Adding [$NGINX_REPO_NAME] Helm repo..."
helm repo add $NGINX_REPO_NAME $NGINX_REPO_URL
fi
# Update your local Helm chart repository cache
echo 'Updating Helm repos...'
helm repo update
# Deploy NGINX ingress controller
echo "Deploying [$NGINX_RELEASE_NAME] NGINX ingress controller to the [$NGINX_NAMESPACE] namespace..."
helm install $NGINX_RELEASE_NAME $NGINX_REPO_NAME/$nginxChartName \
--create-namespace \
--namespace $NGINX_NAMESPACE \
--set controller.nodeSelector."kubernetes\.io/os"=linux \
--set controller.replicaCount=$NGINX_REPLICA_COUNT \
--set defaultBackend.nodeSelector."kubernetes\.io/os"=linux \
--set controller.service.annotations."service\.beta\.kubernetes\.io/azure-load-balancer-health-probe-request-path"=/healthz
fi
# Get values
helm get values $NGINX_RELEASE_NAME --namespace $NGINX_NAMESPACE