mirror of
https://github.com/notherealmarco/coredns-deployment.git
synced 2025-05-05 12:32:34 +02:00
deploy.sh and rollback.sh fixes (#99)
* Don't overwrite KUBECONFIG. kubectl already knows to look in $HOME/.kube or use $KUBECONFIG. https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/#set-the-kubeconfig-environment-variable * Use $DIR instead of pwd. https://stackoverflow.com/a/246128/1881379 * chmod +x kubernetes/rollback.sh
This commit is contained in:
parent
2022b220fd
commit
a6c087005f
2 changed files with 11 additions and 16 deletions
|
@ -2,9 +2,11 @@
|
|||
|
||||
# Deploys CoreDNS to a cluster currently running Kube-DNS.
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
show_help () {
|
||||
cat << USAGE
|
||||
usage: $0 [ -r REVERSE-CIDR ] [ -i DNS-IP ] [ -d CLUSTER-DOMAIN ] [ -t YAML-TEMPLATE ] [ -k KUBECONFIG ]
|
||||
usage: $0 [ -r REVERSE-CIDR ] [ -i DNS-IP ] [ -d CLUSTER-DOMAIN ] [ -t YAML-TEMPLATE ]
|
||||
|
||||
-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,
|
||||
|
@ -18,8 +20,9 @@ exit 0
|
|||
}
|
||||
|
||||
# Simple Defaults
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
CLUSTER_DOMAIN=cluster.local
|
||||
YAML_TEMPLATE=`pwd`/coredns.yaml.sed
|
||||
YAML_TEMPLATE="$DIR/coredns.yaml.sed"
|
||||
STUBDOMAINS=""
|
||||
UPSTREAM=\\/etc\\/resolv\.conf
|
||||
FEDERATIONS=""
|
||||
|
@ -100,26 +103,16 @@ while getopts "hsr:i:d:t:k:" opt; do
|
|||
;;
|
||||
t) YAML_TEMPLATE=$OPTARG
|
||||
;;
|
||||
k) KUBECONFIG=$OPTARG
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Set kubeconfig flag if config specified
|
||||
if [[ ! -z $KUBECONFIG ]]; then
|
||||
if [[ -f $KUBECONFIG ]]; then
|
||||
KUBECONFIG="--kubeconfig $KUBECONFIG"
|
||||
else
|
||||
KUBECONFIG=""
|
||||
fi
|
||||
fi
|
||||
# Conditional Defaults
|
||||
if [[ -z $REVERSE_CIDRS ]]; then
|
||||
REVERSE_CIDRS="in-addr.arpa ip6.arpa"
|
||||
fi
|
||||
if [[ -z $CLUSTER_DNS_IP ]]; then
|
||||
# Default IP to kube-dns IP
|
||||
CLUSTER_DNS_IP=$(kubectl get service --namespace kube-system kube-dns -o jsonpath="{.spec.clusterIP}" $KUBECONFIG)
|
||||
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 with the '-i' option."
|
||||
exit 2
|
||||
|
|
8
kubernetes/rollback.sh
Normal file → Executable file
8
kubernetes/rollback.sh
Normal file → Executable file
|
@ -2,6 +2,8 @@
|
|||
|
||||
# Roll back kube-dns to the cluster which has CoreDNS installed.
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
show_help () {
|
||||
cat << USAGE
|
||||
usage: $0 [ -i DNS-IP ] [ -d CLUSTER-DOMAIN ]
|
||||
|
@ -14,12 +16,12 @@ exit 0
|
|||
}
|
||||
|
||||
|
||||
curl -L https://raw.githubusercontent.com/kubernetes/kubernetes/master/cluster/addons/dns/kube-dns/kube-dns.yaml.base > `pwd`/kube-dns.yaml.sed
|
||||
|
||||
# Simple Defaults
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
CLUSTER_DOMAIN=cluster.local
|
||||
YAML_TEMPLATE=`pwd`/kube-dns.yaml.sed
|
||||
YAML_TEMPLATE="$DIR/kube-dns.yaml.sed"
|
||||
|
||||
curl -L https://raw.githubusercontent.com/kubernetes/kubernetes/master/cluster/addons/dns/kube-dns/kube-dns.yaml.base > "$YAML_TEMPLATE"
|
||||
|
||||
# Get Opts
|
||||
while getopts "hi:d:" opt; do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue