blob: 81533b9b4c11210bd7ba5e7951683b4209f44bd6 [file] [log] [blame]
Lucjan Bryndzae604acd2020-02-06 15:20:24 +01001#!/bin/bash -e
2#
3# Copyright 2020 Samsung Electronics Co., Ltd.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17DNS_PORT=31555
18CLUSTER_CONTROL=$( kubectl get no -l node-role.kubernetes.io/controlplane=true -o jsonpath='{.items..metadata.name}')
19CLUSTER_IP=$(kubectl get no $CLUSTER_CONTROL -o jsonpath='{.metadata.annotations.rke\.cattle\.io/external-ip }')
20SPATH="$( dirname "$( which "$0" )" )"
21
22
23
24usage() {
25cat << ==usage
26$0 [cluster_domain] [helm_chart_args ...]
27 [cluster_domain] Default value simpledemo.onap.org
28 [helm_chart_args...] Optional arguments passed to helm install command
Lucjan Bryndzaf2208122020-03-12 10:02:56 +010029$0 --help This message
30$0 --info Display howto configure target machine
Lucjan Bryndzae604acd2020-02-06 15:20:24 +010031==usage
32}
33
34
35target_machine_notice_info() {
36cat << ==infodeploy
37Extra DNS server already deployed:
381. You can add the DNS server to the target machine using following commands:
39 sudo iptables -t nat -A OUTPUT -p tcp -d 192.168.211.211 --dport 53 -j DNAT --to-destination $CLUSTER_IP:$DNS_PORT
40 sudo iptables -t nat -A OUTPUT -p udp -d 192.168.211.211 --dport 53 -j DNAT --to-destination $CLUSTER_IP:$DNS_PORT
41 sudo sysctl -w net.ipv4.conf.all.route_localnet=1
42 sudo sysctl -w net.ipv4.ip_forward=1
432. Update /etc/resolv.conf file with nameserver 192.168.211.211 entry on your target machine
44==infodeploy
45}
46
47deploy() {
48 pushd "$SPATH/bind9dns" > /dev/null
49 if [ $# -eq 0 ]; then
50 local cl_domain="simpledemo.onap.org"
51 else
52 local cl_domain=$1
53 shift
54 fi
55 helm install . --set dnsconf.wildcard="$cl_domain=$CLUSTER_IP" $@
56 popd > /dev/null
57 target_machine_notice_info
58}
59
60if [[ $# -eq 1 ]] && [[ $1 == "-h" || $1 == "--help" ]]; then
61 usage
Lucjan Bryndzaf2208122020-03-12 10:02:56 +010062elif [[ $# -eq 1 ]] && [[ $1 == "--info" ]]; then
63 target_machine_notice_info
Lucjan Bryndzae604acd2020-02-06 15:20:24 +010064else
65 deploy $@
66fi