11#! /bin/bash
22# Install a single node deployment of Stackable
33
4- HOSTNAME=` /usr/bin/hostname -f`
4+ # This is a dirty hack to get two K8s nodes running on a single machine.
5+ # Use the shortname if hostname returns the FQDN or vice versa.
6+ if [ " $( hostname) " = " $( hostname -f) " ]; then
7+ K8S_HOSTNAME=` /usr/bin/hostname -s`
8+ else
9+ K8S_HOSTNAME=` /usr/bin/hostname -f`
10+ fi
11+
512GPG_KEY_URL=" https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xce45c7a0a3e41385acd4358916dd12f5c7a6d76a"
613
714# This is the list of currently supported operators for Stackable Quickstart
@@ -23,12 +30,14 @@ function install_prereqs {
2330 if [ " $VERSION " = " 8" ] || [ " $VERSION " = " 7" ]; then
2431 echo " $ID $VERSION found"
2532 REPO_URL=" https://repo.stackable.tech/repository/rpm-${REPO_TYPE} /el${VERSION} "
33+ INSTALLER=/usr/bin/yum
2634 install_prereqs_redhat
2735 else
2836 echo " Only Redhat/CentOS 7 & 8 are supported. This host is running $VERSION ."
2937 fi
3038 elif [ " $ID " = " ubuntu" ] || [ " $ID " = " debian" ]; then
3139 REPO_URL=" https://repo.stackable.tech/repository/deb-${REPO_TYPE} "
40+ INSTALLER=apt
3241 install_prereqs_debian
3342 fi
3443}
@@ -48,7 +57,11 @@ function install_prereqs_redhat {
4857
4958 # Create YUM repo configuration file
5059 # TODO: Enable GPG checking on Stackable repo
51- /usr/bin/yum-config-manager --add-repo=$REPO_URL
60+ echo " [stackable]
61+ name=Stackable ${REPO_TYPE} repo
62+ baseurl=${REPO_URL}
63+ enabled=1
64+ gpgcheck=0" > /etc/yum.repos.d/stackable.repo
5265 /usr/bin/yum clean all
5366}
5467
@@ -116,54 +129,36 @@ function check_operator_list {
116129}
117130
118131function install_operator {
119- operator=$1
132+ OPERATOR=$1
133+ PKG_NAME=stackable-${OPERATOR} -operator-server
134+ echo " Installing Stackable operator for ${OPERATOR} "
120135
121- if [ " $ID " == " redhat" ] || [ " $ID " == " centos" ]; then
122- /usr/bin/yum -y install stackable
123- fi
136+ $INSTALLER -y install ${PKG_NAME}
137+
138+ /usr/bin/systemctl enable ${PKG_NAME}
139+ /usr/bin/systemctl start ${PKG_NAME}
124140}
125141
126142function install_stackable_operators {
127143 echo " Installing Stackable operators"
128- # for OPERATOR in ${OPERATORS[@]}; do
129- # install_operator($OPERATOR)
130- # done
131-
132- apt install -y stackable-spark-operator-server stackable-zookeeper-operator-server stackable-kafka-operator-server stackable-nifi-operator-server
133- systemctl enable stackable-spark-operator-server
134- systemctl enable stackable-kafka-operator-server
135- systemctl enable stackable-zookeeper-operator-server
136- systemctl enable stackable-nifi-operator-server
137- systemctl start stackable-spark-operator-server
138- systemctl start stackable-kafka-operator-server
139- systemctl start stackable-zookeeper-operator-server
140- systemctl start stackable-nifi-operator-server
144+ for OPERATOR in ${OPERATORS[@]} ; do
145+ install_operator $OPERATOR
146+ done
141147}
142148
143- # MAIN
144- # Check the list of operators to deploy against the allowed list
145- check_operator_list
146-
147- # Install the prerequisite OS-dependant repos and packages
148- install_prereqs
149-
150- # Install the K3s Kubernetes distribution
151- install_k8s
152- exit
153-
154- install_stackable_k8s_repo
155- install_stackable_operators
156-
157- echo Installing Stackable agent
158- apt install -y stackable-agent
159- echo " --hostname=$HOSTNAME " > /etc/stackable/stackable-agent/agent.conf
160- systemctl enable stackable-agent
161- systemctl start stackable-agent
162- kubectl certificate approve ${HOSTNAME} -tls
163- kubectl get nodes
149+ function install_stackable_agent {
150+ echo " Installing Stackable agent"
151+ ${INSTALLER} -y install stackable-agent
152+ echo " --hostname=$K8S_HOSTNAME " > /etc/stackable/stackable-agent/agent.conf
153+ systemctl enable stackable-agent
154+ systemctl start stackable-agent
155+ kubectl certificate approve ${K8S_HOSTNAME} -tls
156+ kubectl get nodes
157+ }
164158
165- echo Deploying Apache Zookeeper
166- kubectl apply -f - << EOF
159+ function deploy_zookeeper {
160+ echo " Deploying Apache Zookeeper"
161+ kubectl apply -f - << EOF
167162apiVersion: zookeeper.stackable.tech/v1
168163kind: ZookeeperCluster
169164metadata:
@@ -175,13 +170,15 @@ spec:
175170 default:
176171 selector:
177172 matchLabels:
178- kubernetes.io/hostname: ${HOSTNAME }
173+ kubernetes.io/hostname: ${K8S_HOSTNAME }
179174 instances: 1
180175 instancesPerNode: 1
181176EOF
177+ }
182178
183- echo Deploying Apache Kafka
184- kubectl apply -f - << EOF
179+ function deploy_kafka {
180+ echo Deploying Apache Kafka
181+ kubectl apply -f - << EOF
185182apiVersion: kafka.stackable.tech/v1
186183kind: KafkaCluster
187184metadata:
@@ -200,13 +197,15 @@ spec:
200197 default:
201198 selector:
202199 matchLabels:
203- kubernetes.io/hostname: ${HOSTNAME }
200+ kubernetes.io/hostname: ${K8S_HOSTNAME }
204201 instances: 1
205202 instancesPerNode: 1
206203EOF
204+ }
207205
208- echo Deploying Apache Spark
209- kubectl apply -f - << EOF
206+ function deploy_spark {
207+ echo Deploying Apache Spark
208+ kubectl apply -f - << EOF
210209apiVersion: spark.stackable.tech/v1
211210kind: SparkCluster
212211metadata:
@@ -218,7 +217,7 @@ spec:
218217 default:
219218 selector:
220219 matchLabels:
221- kubernetes.io/hostname: ${HOSTNAME }
220+ kubernetes.io/hostname: ${K8S_HOSTNAME }
222221 instances: 1
223222 instancesPerNode: 1
224223 config:
@@ -229,7 +228,7 @@ spec:
229228 2core2g:
230229 selector:
231230 matchLabels:
232- kubernetes.io/hostname: ${HOSTNAME }
231+ kubernetes.io/hostname: ${K8S_HOSTNAME }
233232 instances: 1
234233 instancesPerNode: 1
235234 config:
@@ -242,13 +241,15 @@ spec:
242241 default:
243242 selector:
244243 matchLabels:
245- kubernetes.io/hostname: ${HOSTNAME }
244+ kubernetes.io/hostname: ${K8S_HOSTNAME }
246245 instances: 1
247246 instancesPerNode: 1
248247 config:
249248 historyWebUiPort: 18081
250249EOF
250+ }
251251
252+ function deploy_nifi {
252253echo Deploying Apache Nifi
253254kubectl apply -f - << EOF
254255apiVersion: nifi.stackable.tech/v1
@@ -266,14 +267,45 @@ spec:
266267 default:
267268 selector:
268269 matchLabels:
269- kubernetes.io/hostname: ${HOSTNAME }
270+ kubernetes.io/hostname: ${K8S_HOSTNAME }
270271 instances: 1
271272 instancesPerNode: 1
272273 config:
273274 httpPort: 10000
274275 nodeProtocolPort: 10443
275276 nodeLoadBalancingPort: 6342
276277EOF
278+ }
279+
280+
281+
282+ # MAIN
283+ # Check the list of operators to deploy against the allowed list
284+ check_operator_list
285+
286+ # Install the prerequisite OS-dependant repos and packages
287+ install_prereqs
288+
289+ # Install the K3s Kubernetes distribution
290+ install_k8s
291+
292+ # Install the Stackable Kubernetes repo
293+ install_stackable_k8s_repo
294+
295+ # Install the Stackable operators for the chosen components
296+ install_stackable_operators
297+
298+ # Install the Stackable CRDs
299+ install_crds
300+
301+ # Install the Stackable agent
302+ install_stackable_agent
303+
304+ # Deploy Stackable Components
305+ for OPERATOR in ${OPERATORS[@]} ; do
306+ echo " Deploying ${OPERATOR} "
307+ deploy_${OPERATOR}
308+ done
277309
278310# TODO: Create TLS certificate
279311# TODO: Create Spark client configuration
0 commit comments