Skip to content

Commit

Permalink
Move vagrant to flannel
Browse files Browse the repository at this point in the history
  • Loading branch information
derekwaynecarr committed Sep 15, 2015
1 parent 83fc0b7 commit 360e762
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 116 deletions.
48 changes: 28 additions & 20 deletions cluster/saltbase/salt/etcd/init.sls
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Early configurations of Kubernetes ran etcd on the host and as part of a migration step, we began to delete the host etcd
# It's possible though that the host has configured a separate etcd to configure other services like Flannel
# In that case, we do not want Salt to remove or stop the host service
# Note: its imperative that the host installed etcd not conflict with the Kubernetes managed etcd
{% if grains['keep_host_etcd'] is not defined %}

delete_etc_etcd_dir:
file.absent:
- name: /etc/etcd
Expand All @@ -6,20 +12,6 @@ delete_etcd_conf:
file.absent:
- name: /etc/etcd/etcd.conf

touch /var/log/etcd.log:
cmd.run:
- creates: /var/log/etcd.log

/var/etcd:
file.directory:
- user: root
- group: root
- dir_mode: 700
- recurse:
- user
- group
- mode

delete_etcd_default:
file.absent:
- name: /etc/default/etcd
Expand All @@ -34,6 +26,28 @@ delete_etcd_initd:
file.absent:
- name: /etc/init.d/etcd

#stop legacy etcd_service
stop_etcd-service:
service.dead:
- name: etcd
- enable: None

{% endif %}

touch /var/log/etcd.log:
cmd.run:
- creates: /var/log/etcd.log

/var/etcd:
file.directory:
- user: root
- group: root
- dir_mode: 700
- recurse:
- user
- group
- mode

/etc/kubernetes/manifests/etcd.manifest:
file.managed:
- source: salt://etcd/etcd.manifest
Expand All @@ -43,9 +57,3 @@ delete_etcd_initd:
- mode: 644
- makedirs: true
- dir_mode: 755

#stop legacy etcd_service
stop_etcd-service:
service.dead:
- name: etcd
- enable: None
2 changes: 1 addition & 1 deletion cluster/vagrant/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ENABLE_CLUSTER_MONITORING="${KUBE_ENABLE_CLUSTER_MONITORING:-influxdb}"
# TODO Enable selinux when Fedora 21 repositories get an updated docker package
# see https://bugzilla.redhat.com/show_bug.cgi?id=1216151
#EXTRA_DOCKER_OPTS="-b=cbr0 --selinux-enabled --insecure-registry 10.0.0.0/8"
EXTRA_DOCKER_OPTS="-b=cbr0 --insecure-registry 10.0.0.0/8"
EXTRA_DOCKER_OPTS="--insecure-registry 10.0.0.0/8"

# Flag to tell the kubelet to enable CFS quota support
ENABLE_CPU_CFS_QUOTA="${KUBE_ENABLE_CPU_CFS_QUOTA:-true}"
Expand Down
5 changes: 3 additions & 2 deletions cluster/vagrant/provision-master.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ done
echo "127.0.0.1 localhost" >> /etc/hosts # enables cmds like 'kubectl get pods' on master.
echo "$MASTER_IP $MASTER_NAME" >> /etc/hosts

# Configure the openvswitch network
provision-network
# Configure the master network
provision-network-master

# Update salt configuration
mkdir -p /etc/salt/minion.d
Expand Down Expand Up @@ -108,6 +108,7 @@ grains:
runtime_config: '$(echo "$RUNTIME_CONFIG" | sed -e "s/'/''/g")'
docker_opts: '$(echo "$DOCKER_OPTS" | sed -e "s/'/''/g")'
master_extra_sans: '$(echo "$MASTER_EXTRA_SANS" | sed -e "s/'/''/g")'
keep_host_etcd: true
EOF

mkdir -p /srv/salt-overlay/pillar
Expand Down
2 changes: 1 addition & 1 deletion cluster/vagrant/provision-minion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ for (( i=0; i<${#MINION_NAMES[@]}; i++)); do
done

# Configure network
provision-network
provision-network-minion

# Placeholder for any other manifests that may be per-node.
mkdir -p /etc/kubernetes/manifests
Expand Down
80 changes: 80 additions & 0 deletions cluster/vagrant/provision-network-master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

# Copyright 2015 The Kubernetes Authors 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.

# provision-network-master configures flannel on the master
function provision-network-master {

echo "Provisioning network on master"

FLANNEL_ETCD_URL="http://${MASTER_IP}:4379"

# Install etcd for flannel data
if ! which etcd >/dev/null 2>&1; then

yum install -y etcd

# Modify etcd configuration for flannel data
cat <<EOF >/etc/etcd/etcd.conf
ETCD_NAME=flannel
ETCD_DATA_DIR="/var/lib/etcd/flannel.etcd"
ETCD_LISTEN_PEER_URLS="http://${MASTER_IP}:4380"
ETCD_LISTEN_CLIENT_URLS="http://${MASTER_IP}:4379"
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://${MASTER_IP}:4380"
ETCD_INITIAL_CLUSTER="flannel=http://${MASTER_IP}:4380"
ETCD_ADVERTISE_CLIENT_URLS="${FLANNEL_ETCD_URL}"
EOF
# Enable and start etcd
systemctl enable etcd
systemctl start etcd

fi

# Install flannel for overlay
if ! which flanneld >/dev/null 2>&1; then

yum install -y flannel

cat <<EOF >/etc/flannel-config.json
{
"Network": "${CONTAINER_SUBNET}",
"SubnetLen": 24,
"Backend": {
"Type": "udp",
"Port": 8285
}
}
EOF

# Import default configuration into etcd for master setup
etcdctl -C ${FLANNEL_ETCD_URL} set /coreos.com/network/config < /etc/flannel-config.json

# Configure local daemon to speak to master
NETWORK_CONF_PATH=/etc/sysconfig/network-scripts/
if_to_edit=$( find ${NETWORK_CONF_PATH}ifcfg-* | xargs grep -l VAGRANT-BEGIN )
NETWORK_IF_NAME=`echo ${if_to_edit} | awk -F- '{ print $3 }'`
cat <<EOF >/etc/sysconfig/flanneld
FLANNEL_ETCD="${FLANNEL_ETCD_URL}"
FLANNEL_ETCD_KEY="/coreos.com/network"
FLANNEL_OPTIONS="-iface=${NETWORK_IF_NAME}"
EOF

# Start flannel
systemctl enable flanneld
systemctl start flanneld
fi

echo "Network configuration verified"
}
45 changes: 45 additions & 0 deletions cluster/vagrant/provision-network-minion.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

# Copyright 2015 The Kubernetes Authors 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.

# provision-network-minion configures flannel on the minion
function provision-network-minion {

echo "Provisioning network on minion"

FLANNEL_ETCD_URL="http://${MASTER_IP}:4379"

# Install flannel for overlay
if ! which flanneld >/dev/null 2>&1; then

yum install -y flannel

# Configure local daemon to speak to master
NETWORK_CONF_PATH=/etc/sysconfig/network-scripts/
if_to_edit=$( find ${NETWORK_CONF_PATH}ifcfg-* | xargs grep -l VAGRANT-BEGIN )
NETWORK_IF_NAME=`echo ${if_to_edit} | awk -F- '{ print $3 }'`
cat <<EOF >/etc/sysconfig/flanneld
FLANNEL_ETCD="${FLANNEL_ETCD_URL}"
FLANNEL_ETCD_KEY="/coreos.com/network"
FLANNEL_OPTIONS="-iface=${NETWORK_IF_NAME}"
EOF

# Start flannel
systemctl enable flanneld
systemctl start flanneld
fi

echo "Network configuration verified"
}
89 changes: 0 additions & 89 deletions cluster/vagrant/provision-network.sh

This file was deleted.

4 changes: 2 additions & 2 deletions cluster/vagrant/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function create-provision-scripts {
echo "KUBE_PROXY_TOKEN='${KUBE_PROXY_TOKEN:-}'"
echo "MASTER_EXTRA_SANS='${MASTER_EXTRA_SANS:-}'"
echo "ENABLE_CPU_CFS_QUOTA='${ENABLE_CPU_CFS_QUOTA}'"
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-network.sh"
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-network-master.sh"
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-master.sh"
) > "${KUBE_TEMP}/master-start.sh"

Expand All @@ -179,7 +179,7 @@ function create-provision-scripts {
echo "KUBELET_TOKEN='${KUBELET_TOKEN:-}'"
echo "KUBE_PROXY_TOKEN='${KUBE_PROXY_TOKEN:-}'"
echo "MASTER_EXTRA_SANS='${MASTER_EXTRA_SANS:-}'"
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-network.sh"
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-network-minion.sh"
awk '!/^#/' "${KUBE_ROOT}/cluster/vagrant/provision-minion.sh"
) > "${KUBE_TEMP}/minion-start-${i}.sh"
done
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started-guides/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Here are all the solutions mentioned above in table form.
IaaS Provider | Config. Mgmt | OS | Networking | Docs | Conforms | Support Level
-------------------- | ------------ | ------ | ---------- | --------------------------------------------- | ---------| ----------------------------
GKE | | | GCE | [docs](https://cloud.google.com/container-engine) | [][3] | Commercial
Vagrant | Saltstack | Fedora | OVS | [docs](vagrant.md) | [][2] | Project
Vagrant | Saltstack | Fedora | flannel | [docs](vagrant.md) | [][2] | Project
GCE | Saltstack | Debian | GCE | [docs](gce.md) | [][1] | Project
Azure | CoreOS | CoreOS | Weave | [docs](coreos/azure/README.md) | | Community ([@errordeveloper](https://github.com/errordeveloper), [@squillace](https://github.com/squillace), [@chanezon](https://github.com/chanezon), [@crossorigin](https://github.com/crossorigin))
Docker Single Node | custom | N/A | local | [docs](docker.md) | | Project ([@brendandburns](https://github.com/brendandburns))
Expand Down

0 comments on commit 360e762

Please sign in to comment.