mirror of
https://github.com/notherealmarco/coredns-deployment.git
synced 2025-03-14 14:16:16 +01:00
kubernetes: Add optional DNS-IP paramater (#35)
* add opt dns ip param * make error msg better
This commit is contained in:
parent
23252c7c79
commit
84cd6fe922
1 changed files with 10 additions and 7 deletions
|
@ -4,18 +4,21 @@
|
|||
|
||||
SERVICE_CIDR=$1
|
||||
POD_CIDR=$2
|
||||
CLUSTER_DOMAIN=${3:-cluster.local}
|
||||
YAML_TEMPLATE=${4:-`pwd`/coredns.yaml.sed}
|
||||
CLUSTER_DNS_IP=$3
|
||||
CLUSTER_DOMAIN=${4:-cluster.local}
|
||||
YAML_TEMPLATE=${5:-`pwd`/coredns.yaml.sed}
|
||||
|
||||
if [[ -z $SERVICE_CIDR ]]; then
|
||||
echo "Usage: $0 SERVICE-CIDR [ POD-CIDR ] [ CLUSTER-DOMAIN ] [ YAML-TEMPLATE ]"
|
||||
echo "Usage: $0 SERVICE-CIDR [ POD-CIDR ] [ DNS-IP ] [ CLUSTER-DOMAIN ] [ YAML-TEMPLATE ]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CLUSTER_DNS_IP=$(kubectl get service --namespace kube-system kube-dns -o jsonpath="{.spec.clusterIP}")
|
||||
if [ $? -ne 0 ]; then
|
||||
>&2 echo "Error! The IP address for DNS service couldn't be determined by kubectl command"
|
||||
if [[ -z $CLUSTER_DNS_IP ]]; then
|
||||
CLUSTER_DNS_IP=$(kubectl get service --namespace kube-system kube-dns -o jsonpath="{.spec.clusterIP}")
|
||||
if [ $? -ne 0 ]; then
|
||||
>&2 echo "Error! The IP address for DNS service couldn't be determined automatically. Please specify the DNS-IP in paramaters."
|
||||
exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
sed -e s/CLUSTER_DNS_IP/$CLUSTER_DNS_IP/g -e s/CLUSTER_DOMAIN/$CLUSTER_DOMAIN/g -e s?SERVICE_CIDR?$SERVICE_CIDR?g -e s?POD_CIDR?$POD_CIDR?g $YAML_TEMPLATE
|
||||
|
|
Loading…
Reference in a new issue