mirror of
https://github.com/notherealmarco/coredns-deployment.git
synced 2025-05-05 12:32:34 +02:00
Add kubeconfig option (#81)
This commit is contained in:
parent
5b8ae1cda0
commit
82742c778a
1 changed files with 13 additions and 3 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
show_help () {
|
show_help () {
|
||||||
cat << USAGE
|
cat << USAGE
|
||||||
usage: $0 [ -r REVERSE-CIDR ] [ -i DNS-IP ] [ -d CLUSTER-DOMAIN ] [ -t YAML-TEMPLATE ]
|
usage: $0 [ -r REVERSE-CIDR ] [ -i DNS-IP ] [ -d CLUSTER-DOMAIN ] [ -t YAML-TEMPLATE ] [ -k KUBECONFIG ]
|
||||||
|
|
||||||
-r : Define a reverse zone for the given CIDR. You may specifcy this option more
|
-r : Define a reverse zone for the given CIDR. You may specifcy this option more
|
||||||
than once to add multiple reverse zones. If no reverse CIDRs are defined,
|
than once to add multiple reverse zones. If no reverse CIDRs are defined,
|
||||||
|
@ -21,7 +21,7 @@ YAML_TEMPLATE=`pwd`/coredns.yaml.sed
|
||||||
|
|
||||||
|
|
||||||
# Get Opts
|
# Get Opts
|
||||||
while getopts "hr:i:d:t:" opt; do
|
while getopts "hr:i:d:t:k:" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
h) show_help
|
h) show_help
|
||||||
;;
|
;;
|
||||||
|
@ -33,16 +33,26 @@ while getopts "hr:i:d:t:" opt; do
|
||||||
;;
|
;;
|
||||||
t) YAML_TEMPLATE=$OPTARG
|
t) YAML_TEMPLATE=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
k) KUBECONFIG=$OPTARG
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Set kubeconfig flag if config specified
|
||||||
|
if [[ ! -z $KUBECONFIG ]]; then
|
||||||
|
if [[ -f $KUBECONFIG ]]; then
|
||||||
|
KUBECONFIG="--kubeconfig $KUBECONFIG"
|
||||||
|
else
|
||||||
|
KUBECONFIG=""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
# Conditional Defaults
|
# Conditional Defaults
|
||||||
if [[ -z $REVERSE_CIDRS ]]; then
|
if [[ -z $REVERSE_CIDRS ]]; then
|
||||||
REVERSE_CIDRS="in-addr.arpa ip6.arpa"
|
REVERSE_CIDRS="in-addr.arpa ip6.arpa"
|
||||||
fi
|
fi
|
||||||
if [[ -z $CLUSTER_DNS_IP ]]; then
|
if [[ -z $CLUSTER_DNS_IP ]]; then
|
||||||
# Default IP to kube-dns IP
|
# Default IP to kube-dns IP
|
||||||
CLUSTER_DNS_IP=$(kubectl get service --namespace kube-system kube-dns -o jsonpath="{.spec.clusterIP}")
|
CLUSTER_DNS_IP=$(kubectl get service --namespace kube-system kube-dns -o jsonpath="{.spec.clusterIP}" $KUBECONFIG)
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
>&2 echo "Error! The IP address for DNS service couldn't be determined automatically. Please specify the DNS-IP with the '-i' option."
|
>&2 echo "Error! The IP address for DNS service couldn't be determined automatically. Please specify the DNS-IP with the '-i' option."
|
||||||
exit 2
|
exit 2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue