mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
The `systemctl enable` command ordinarily prints the `ln` command used
to enable the unit to stderr, but that's not ideal in the vagrant setup
because it gets printed in red, which should be reserved for errors, but
it's not a real error.
Set an environment variable to raise the log level to prevent `info`
messages from being printed to stderr (as they are not actually errors.)
I looked into the `systemctl` calls happening from the Salt setup script
to understand why they were not going to stderr, and it turns out the
Salt script will redirect all messages to stdout so they will all be
green regardless...
Tested:
- Started a fresh Vagrant cluster, confirmed no red messages in output
when creating the cluster successfully. Successfully started nginx
through Kubernetes using cluster/kubecfg.sh.
- Confirmed that the salt-api service was up after `vagrant up`:
$ vagrant ssh master -c 'systemctl status salt-api.service'
salt-api.service - The Salt API
Loaded: loaded (/usr/lib/systemd/system/salt-api.service; enabled)
Active: active (running) since Fri 2014-08-29 23:19:47 UTC; 11min ago
Main PID: 2090 (salt-api)
CGroup: /system.slice/salt-api.service
+-2090 /usr/bin/python /usr/bin/salt-api
+-2110 /usr/bin/python /usr/bin/salt-api
Signed-off-by: Filipe Brandenburger <filbranden@google.com>
110 lines
3.0 KiB
Bash
Executable File
110 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Copyright 2014 Google Inc. All rights reserved.
|
|
#
|
|
# Licensed 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.
|
|
|
|
# exit on any error
|
|
set -e
|
|
source $(dirname $0)/provision-config.sh
|
|
|
|
# Update salt configuration
|
|
mkdir -p /etc/salt/minion.d
|
|
echo "master: $MASTER_NAME" > /etc/salt/minion.d/master.conf
|
|
|
|
cat <<EOF >/etc/salt/minion.d/grains.conf
|
|
grains:
|
|
master_ip: $MASTER_IP
|
|
etcd_servers: $MASTER_IP
|
|
cloud_provider: vagrant
|
|
roles:
|
|
- kubernetes-master
|
|
EOF
|
|
|
|
# Configure the salt-master
|
|
# Auto accept all keys from minions that try to join
|
|
mkdir -p /etc/salt/master.d
|
|
cat <<EOF >/etc/salt/master.d/auto-accept.conf
|
|
open_mode: True
|
|
auto_accept: True
|
|
EOF
|
|
|
|
cat <<EOF >/etc/salt/master.d/reactor.conf
|
|
# React to new minions starting by running highstate on them.
|
|
reactor:
|
|
- 'salt/minion/*/start':
|
|
- /srv/reactor/start.sls
|
|
EOF
|
|
|
|
cat <<EOF >/etc/salt/master.d/salt-output.conf
|
|
# Minimize the amount of output to terminal
|
|
state_verbose: False
|
|
state_output: mixed
|
|
EOF
|
|
|
|
# Configure nginx authorization
|
|
mkdir -p $KUBE_TEMP
|
|
mkdir -p /srv/salt/nginx
|
|
echo "Using password: $MASTER_USER:$MASTER_PASSWD"
|
|
python $(dirname $0)/../../third_party/htpasswd/htpasswd.py -b -c ${KUBE_TEMP}/htpasswd $MASTER_USER $MASTER_PASSWD
|
|
MASTER_HTPASSWD=$(cat ${KUBE_TEMP}/htpasswd)
|
|
echo $MASTER_HTPASSWD > /srv/salt/nginx/htpasswd
|
|
|
|
# we will run provision to update code each time we test, so we do not want to do salt install each time
|
|
if ! which salt-master >/dev/null 2>&1; then
|
|
|
|
# Configure the salt-api
|
|
cat <<EOF >/etc/salt/master.d/salt-api.conf
|
|
# Set vagrant user as REST API user
|
|
external_auth:
|
|
pam:
|
|
vagrant:
|
|
- .*
|
|
rest_cherrypy:
|
|
port: 8000
|
|
host: 127.0.0.1
|
|
disable_ssl: True
|
|
webhook_disable_auth: True
|
|
EOF
|
|
|
|
# Install Salt
|
|
#
|
|
# -M installs the master
|
|
curl -sS -L --connect-timeout 20 --retry 6 --retry-delay 10 https://bootstrap.saltstack.com | sh -s -- -M
|
|
|
|
# Install salt-api
|
|
#
|
|
# This is used to inform the cloud provider used in the vagrant cluster
|
|
yum install -y salt-api
|
|
# Set log level to a level higher than "info" to prevent the message about
|
|
# enabling the service (which is not an error) from being printed to stderr.
|
|
SYSTEMD_LOG_LEVEL=notice systemctl enable salt-api
|
|
systemctl start salt-api
|
|
|
|
fi
|
|
|
|
# Build release
|
|
echo "Building release"
|
|
pushd /vagrant
|
|
./release/build-release.sh kubernetes
|
|
popd
|
|
|
|
echo "Running release install script"
|
|
pushd /vagrant/_output/release/master-release/src/scripts
|
|
./master-release-install.sh
|
|
popd
|
|
|
|
echo "Executing configuration"
|
|
salt '*' mine.update
|
|
salt --force-color '*' state.highstate
|