Activate gce minion list.

pull/6/head
Brendan Burns 2014-06-29 21:00:22 -07:00
parent d75bd790d3
commit d5516e4cdc
7 changed files with 38 additions and 5 deletions

View File

@ -1,3 +1,4 @@
base:
'*':
- mine
- common

View File

@ -1,5 +1,5 @@
{%- set ips = salt['mine.get']('roles:kubernetes-master', 'network.ip_addrs', 'grain').values() %}
DAEMON_ARGS="$DAEMON_ARGS -etcd_servers=http://{{ ips[0][0] }}:4001"
DAEMON_ARGS="$DAEMON_ARGS -etcd_servers=http://{{ ips[0][0] }}:4001 -minion_regexp '{{ pillar['instance_prefix'] }}.*'"
MACHINES="{{ ','.join(salt['mine.get']('roles:kubernetes-pool', 'network.ip_addrs', expr_form='grain').keys()) }}"
DAEMON_ARGS="$DAEMON_ARGS --machines $MACHINES"

View File

@ -17,7 +17,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="The Kubernetes API server"
NAME=apiserver
DAEMON=/usr/local/bin/apiserver
DAEMON_ARGS="-cloud_provider gce "
DAEMON_ARGS="-cloud_provider gce"
DAEMON_LOG_FILE=/var/log/$NAME.log
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

View File

@ -38,6 +38,6 @@ type TCPLoadBalancer interface {
type Instances interface {
IPAddress(name string) (net.IP, error)
// Lists instances that match 'filter' which is a regular expression which must match the entire instance name
// Lists instances that match 'filter' which is a regular expression which must match the entire instance name (fqdn)
List(filter string) ([]string, error)
}

View File

@ -21,6 +21,7 @@ import (
"io/ioutil"
"net"
"net/http"
"os/exec"
"strconv"
"strings"
"time"
@ -181,7 +182,31 @@ func (gce *GCECloud) IPAddress(instance string) (net.IP, error) {
return ip, nil
}
// This is hacky, compute the delta between hostame and hostname -f
func fqdnSuffix() (string, error) {
fullHostname, err := exec.Command("hostname", "-f").Output()
if err != nil {
return "", err
}
hostname, err := exec.Command("hostname").Output()
if err != nil {
return "", err
}
return strings.TrimSpace(string(fullHostname)[len(string(hostname)):]), nil
}
func (gce *GCECloud) List(filter string) ([]string, error) {
// GCE gives names without their fqdn suffix, so get that here for appending.
// This is needed because the kubelet looks for its jobs in /registry/hosts/<fqdn>/pods
// We should really just replace this convention, with a negotiated naming protocol for kubelet's
// to register with the master.
suffix, err := fqdnSuffix()
if err != nil {
return []string{}, err
}
if len(suffix) > 0 {
suffix = "." + suffix
}
listCall := gce.service.Instances.List(gce.projectID, gce.zone)
if len(filter) > 0 {
listCall = listCall.Filter("name eq " + filter)
@ -192,7 +217,7 @@ func (gce *GCECloud) List(filter string) ([]string, error) {
}
var instances []string
for _, instance := range res.Items {
instances = append(instances, instance.Name)
instances = append(instances, instance.Name+suffix)
}
return instances, nil
}

View File

@ -74,7 +74,7 @@ func (p *PodCache) updateContainerInfo(host, id string) error {
func (p *PodCache) UpdateAllContainers() {
pods, err := p.pods.ListPods(labels.Everything())
if err != nil {
glog.Errorf("Error synchronizing container: %#v", err)
glog.Errorf("Error synchronizing container list: %#v", err)
return
}
for _, pod := range pods {

View File

@ -25,6 +25,8 @@ set -e
source $(dirname $0)/config.sh
source $(dirname ${BASH_SOURCE})/../cluster/${KUBE_CONFIG_FILE-"config-default.sh"}
cd $(dirname $0)/..
# First build the release tar. This gets copied on to the master and installed
@ -40,6 +42,11 @@ mkdir -p $MASTER_RELEASE_DIR/third_party/go
echo "Building release tree"
cp release/master-release-install.sh $MASTER_RELEASE_DIR/src/scripts/master-release-install.sh
cp -r cluster/saltbase $MASTER_RELEASE_DIR/src/saltbase
cat << EOF > $MASTER_RELEASE_DIR/src/saltbase/pillar/common.sls
instance_prefix: $INSTANCE_PREFIX-minion
EOF
cp -r third_party/src $MASTER_RELEASE_DIR/third_party/go/src
function find_go_files() {