-
Notifications
You must be signed in to change notification settings - Fork 29
/
aro4-getcreds.sh
executable file
·53 lines (38 loc) · 1.83 KB
/
aro4-getcreds.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
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Written by Stuart Kirk
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
################################################################################################## Initialize
echo " "
echo "Display ARO Credentials & Endpoints"
echo "==================================="
echo " "
if [ $# -ne 1 ]; then
echo "Usage: $BASH_SOURCE <name of cluster>"
exit 1
fi
if [ -z "$(az aro list -o table |grep -i $1)" ]; then
echo "$1 doesn't seem to exist. Review the output of 'az aro list'"
exit 1
fi
clusterName="$(az aro list -o table |grep -i $1 | awk '{print $1}')"
clusterResourceGroup="$(az aro list -o table |grep -i $1 | awk '{print $2}')"
echo "Cluster name: $clusterName"
echo " "
az aro show -n $clusterName -g $clusterResourceGroup -o jsonc --query '[apiserverProfile , consoleProfile , ingressProfiles]'
echo " "
az aro list-credentials -o table -n $clusterName -g $clusterResourceGroup
declare apiServer="$(az aro show -n $clusterName -g $clusterResourceGroup -o tsv --query '[apiserverProfile.url]')"
declare kubePW="$(az aro list-credentials -n $clusterName -g $clusterResourceGroup -o tsv --query '[kubeadminPassword]')"
echo " "
echo "To log in to CLI:"
echo "oc login $apiServer -u kubeadmin -p $kubePW"
echo " "
echo "To delete cluster:"
echo "az aro delete -n $clusterName -g $clusterResourceGroup -y ; az group delete -n $clusterResourceGroup -y"
echo " "