You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
echo -e "${GREEN}-h, --help${RESET}\t\t\t Display help for the given command. When no command is given display help for the ${GREEN}list${RESET} command"
32
32
echo -e "${GREEN}-c, --create-token${RESET}\t\t Create a new bearer token for the default kubernetes account"
33
33
echo -e "${GREEN}-r, --retrieve-token${RESET}\t\t Retrieve the existing bearer token for the default kubernetes account"
34
34
echo -e "${GREEN}-p, --permissions${RESET}\t\t Grant the necessary permissions for the default kubernetes user to access the REST API"
35
-
echo -e "${GREEN}-m, --master-node [name]${RESET}\t Create a k3s master node with a dynamic name passed through an argument"
35
+
echo -e "${GREEN}-m, --master-token${RESET}\t\t Retrieve the existing master token for the current node master"
36
36
echo -e "\n${BROWN}Available commands:${RESET}"
37
37
echo -e "${GREEN}about${RESET}\t\t\t\t Shows a short information about Maestro"
38
38
echo -e "${GREEN}list${RESET}\t\t\t\t List all the commands and usefull information"
39
+
echo -e "${GREEN}master${RESET}\t\t\t Create a k3s master node with a given name"
40
+
echo -e "${GREEN}worker${RESET}\t\t\t Create a k3s worker node with a given name, master node address and token"
39
41
}
40
42
41
43
about() {
@@ -52,8 +54,12 @@ fi
52
54
create_token=false
53
55
retrieve_token=false
54
56
permissions=false
55
-
master_node_flag=false
56
-
master_node_name=""
57
+
master_token=false
58
+
master_flag=false
59
+
worker_flag=false
60
+
name=""# For both "master" and "worker" commands
61
+
ip=""# For the "worker" command
62
+
token=""# For the "worker" command
57
63
58
64
# Process options
59
65
while [[ $#-gt 0 ]];do
@@ -64,6 +70,12 @@ while [[ $# -gt 0 ]]; do
64
70
'list')
65
71
help
66
72
;;
73
+
'master')
74
+
master_flag=true
75
+
;;
76
+
'worker')
77
+
worker_flag=true
78
+
;;
67
79
--help | -h)
68
80
help
69
81
;;
@@ -76,10 +88,20 @@ while [[ $# -gt 0 ]]; do
76
88
--permissions | -p)
77
89
permissions=true
78
90
;;
79
-
--master-node | -m)
91
+
--master-token | -m)
92
+
master_token=true
93
+
;;
94
+
--name | -n)
95
+
shift
96
+
name=$1# For both "master" and "worker" commands
97
+
;;
98
+
--ip | -i)
99
+
shift
100
+
ip=$1# For the "worker" command
101
+
;;
102
+
--token | -t)
80
103
shift
81
-
master_node_flag=true
82
-
master_node_name=$1
104
+
token=$1# For the "worker" command
83
105
;;
84
106
*)
85
107
echo -e "\n ${RED_BG} ERROR ${RESET} The option \"$1\" does not exist. \n">&2&&exit 1
@@ -88,27 +110,84 @@ while [[ $# -gt 0 ]]; do
88
110
shift
89
111
done
90
112
91
-
if$master_node_flag;then
92
-
if [ !-z"$master_node_name" ];then
113
+
# Creates a new master node: ./maestro master [-n | --name NAME]
114
+
if$master_flag;then
115
+
if [ !-z"$name" ];then
93
116
if [ !"$UID"-eq 0 ];then
94
117
echo -e "\n ${RED_BG} ERROR ${RESET} You must run this option with sudo.\n">&2;exit 1
95
118
else
96
119
echo -ne "\n ${BLUE_BG} INFO ${RESET} We are creating a node master for you...\r">&2
0 commit comments