apiVersion: v1 kind: ConfigMap metadata: name: hadoop-configmap labels: app: {{ template "hadoop.name" . }} chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} release: {{ .Release.Name }} heritage: {{ .Release.Service }} data: bootstrap.sh: | #!/bin/bash : ${HADOOP_PREFIX:=/usr/local/hadoop} . $HADOOP_PREFIX/etc/hadoop/hadoop-env.sh # Directory to find config artifacts CONFIG_DIR="/tmp/hadoop-config" # Copy config files from volume mount for f in slaves core-site.xml hdfs-site.xml mapred-site.xml yarn-site.xml; do if [[ -e ${CONFIG_DIR}/$f ]]; then cp ${CONFIG_DIR}/$f $HADOOP_PREFIX/etc/hadoop/$f else echo "ERROR: Could not find $f in $CONFIG_DIR" exit 1 fi done # installing libraries if any - (resource urls added comma separated to the ACP system variable) cd $HADOOP_PREFIX/share/hadoop/common ; for cp in ${ACP//,/ }; do echo == $cp; curl -LO $cp ; done; cd - if [[ "${HOSTNAME}" =~ "hdfs-nn" ]]; then mkdir -p /root/hdfs/namenode $HADOOP_PREFIX/bin/hdfs namenode -format -force -nonInteractive sed -i s/{{ template "hbase.name" . }}-hdfs-nn/0.0.0.0/ /usr/local/hadoop/etc/hadoop/core-site.xml $HADOOP_PREFIX/sbin/hadoop-daemon.sh start namenode fi if [[ "${HOSTNAME}" =~ "hdfs-dn" ]]; then mkdir -p /root/hdfs/datanode # wait up to 30 seconds for namenode (while [[ $count -lt 15 && -z `curl -sf http://{{ template "hbase.name" . }}-hdfs-nn:50070` ]]; do ((count=count+1)) ; echo "Waiting for {{ template "hbase.name" . }}-hdfs-nn" ; sleep 2; done && [[ $count -lt 15 ]]) [[ $? -ne 0 ]] && echo "Timeout waiting for hdfs-nn, exiting." && exit 1 $HADOOP_PREFIX/sbin/hadoop-daemon.sh start datanode fi if [[ "${HOSTNAME}" =~ "yarn-rm" ]]; then sed -i s/{{ template "hbase.name" . }}-yarn-rm/0.0.0.0/ $HADOOP_PREFIX/etc/hadoop/yarn-site.xml cp ${CONFIG_DIR}/start-yarn-rm.sh $HADOOP_PREFIX/sbin/ cd $HADOOP_PREFIX/sbin chmod +x start-yarn-rm.sh ./start-yarn-rm.sh fi if [[ "${HOSTNAME}" =~ "yarn-nm" ]]; then sed -i '/<\/configuration>/d' $HADOOP_PREFIX/etc/hadoop/yarn-site.xml cat >> $HADOOP_PREFIX/etc/hadoop/yarn-site.xml <<- EOM yarn.nodemanager.resource.memory-mb ${MY_MEM_LIMIT:-2048} yarn.nodemanager.resource.cpu-vcores ${MY_CPU_LIMIT:-2} EOM echo '' >> $HADOOP_PREFIX/etc/hadoop/yarn-site.xml cp ${CONFIG_DIR}/start-yarn-nm.sh $HADOOP_PREFIX/sbin/ cd $HADOOP_PREFIX/sbin chmod +x start-yarn-nm.sh # wait up to 30 seconds for resourcemanager (while [[ $count -lt 15 && -z `curl -sf http://{{ template "hbase.name" . }}-yarn-rm:8088/ws/v1/cluster/info` ]]; do ((count=count+1)) ; echo "Waiting for {{ template "hbase.name" . }}-yarn-rm" ; sleep 2; done && [[ $count -lt 15 ]]) [[ $? -ne 0 ]] && echo "Timeout waiting for yarn-rm, exiting." && exit 1 ./start-yarn-nm.sh fi if [[ $1 == "-d" ]]; then until find ${HADOOP_PREFIX}/logs -mmin -1 | egrep -q '.*'; echo "`date`: Waiting for logs..." ; do sleep 2 ; done tail -F ${HADOOP_PREFIX}/logs/* & while true; do sleep 1000; done fi if [[ $1 == "-bash" ]]; then /bin/bash fi core-site.xml: | fs.defaultFS hdfs://{{ template "hbase.name" . }}-hdfs-nn:9000/ NameNode URI hdfs-site.xml: | dfs.datanode.use.datanode.hostname false dfs.client.use.datanode.hostname false dfs.replication 3 dfs.datanode.data.dir file:///root/hdfs/datanode DataNode directory dfs.namenode.name.dir file:///root/hdfs/namenode NameNode directory for namespace and transaction logs storage. dfs.namenode.datanode.registration.ip-hostname-check false mapred-site.xml: | mapreduce.framework.name yarn mapreduce.jobhistory.address {{ template "hbase.name" . }}-yarn-rm-0.{{ template "hbase.name" . }}-yarn-rm.{{ .Release.Namespace }}.svc.cluster.local:10020 mapreduce.jobhistory.webapp.address {{ template "hbase.name" . }}-yarn-rm-0.{{ template "hbase.name" . }}-yarn-rm.{{ .Release.Namespace }}.svc.cluster.local:19888 slaves: | localhost start-yarn-nm.sh: | #!/usr/bin/env bash # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Start all yarn daemons. Run this on master node. echo "starting yarn daemons" bin=`dirname "${BASH_SOURCE-$0}"` bin=`cd "$bin"; pwd` DEFAULT_LIBEXEC_DIR="$bin"/../libexec HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR} . $HADOOP_LIBEXEC_DIR/yarn-config.sh # start resourceManager # "$bin"/yarn-daemon.sh --config $YARN_CONF_DIR start resourcemanager # start nodeManager "$bin"/yarn-daemon.sh --config $YARN_CONF_DIR start nodemanager # start proxyserver #"$bin"/yarn-daemon.sh --config $YARN_CONF_DIR start proxyserver start-yarn-rm.sh: | #!/usr/bin/env bash # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Start all yarn daemons. Run this on master node. echo "starting yarn daemons" bin=`dirname "${BASH_SOURCE-$0}"` bin=`cd "$bin"; pwd` DEFAULT_LIBEXEC_DIR="$bin"/../libexec HADOOP_LIBEXEC_DIR=${HADOOP_LIBEXEC_DIR:-$DEFAULT_LIBEXEC_DIR} . $HADOOP_LIBEXEC_DIR/yarn-config.sh # start resourceManager "$bin"/yarn-daemon.sh --config $YARN_CONF_DIR start resourcemanager # start nodeManager # "$bin"/yarn-daemons.sh --config $YARN_CONF_DIR start nodemanager # start proxyserver "$bin"/yarn-daemon.sh --config $YARN_CONF_DIR start proxyserver yarn-site.xml: | yarn.resourcemanager.hostname {{ template "hbase.name" . }}-yarn-rm yarn.nodemanager.vmem-check-enabled false yarn.nodemanager.aux-services mapreduce_shuffle yarn.nodemanager.aux-services.mapreduce_shuffle.class org.apache.hadoop.mapred.ShuffleHandler List of directories to store localized files in. yarn.nodemanager.local-dirs /var/lib/hadoop-yarn/cache/${user.name}/nm-local-dir Where to store container logs. yarn.nodemanager.log-dirs /var/log/hadoop-yarn/containers Where to aggregate logs to. yarn.nodemanager.remote-app-log-dir /var/log/hadoop-yarn/apps yarn.application.classpath /usr/local/hadoop/etc/hadoop, /usr/local/hadoop/share/hadoop/common/*, /usr/local/hadoop/share/hadoop/common/lib/*, /usr/local/hadoop/share/hadoop/hdfs/*, /usr/local/hadoop/share/hadoop/hdfs/lib/*, /usr/local/hadoop/share/hadoop/mapreduce/*, /usr/local/hadoop/share/hadoop/mapreduce/lib/*, /usr/local/hadoop/share/hadoop/yarn/*, /usr/local/hadoop/share/hadoop/yarn/lib/*