Skip to content

Commit

Permalink
Rackspace - Switch to CoreOS for standard cluster
Browse files Browse the repository at this point in the history
The Rackspace setup for Kubernetes now leverages CoreOS instead of Ubuntu. We've dropped Salt completely for our cluster.
  • Loading branch information
doublerr committed Oct 20, 2014
1 parent 6c434e6 commit a8bae68
Show file tree
Hide file tree
Showing 15 changed files with 529 additions and 215 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ While the concepts and architecture in Kubernetes represent years of experience
* [CoreOS](docs/getting-started-guides/coreos.md)
* [OpenStack](https://developer.rackspace.com/blog/running-coreos-and-kubernetes/)
* [CloudStack](docs/getting-started-guides/cloudstack.md)
* [Rackspace](docs/getting-started-guides/rackspace.md)

* The following clouds are currently broken at Kubernetes head. Please sync your client to `v0.3` (`git checkout v0.3`) to use these:
* [Locally](docs/getting-started-guides/locally.md)
* [vSphere](docs/getting-started-guides/vsphere.md)
* [Microsoft Azure](docs/getting-started-guides/azure.md)
* [Rackspace](docs/getting-started-guides/rackspace.md)
* [Kubernetes 101](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/examples/walkthrough)
* [kubecfg command line tool](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/cli.md)
* [Kubernetes API Documentation](http://cdn.rawgit.com/GoogleCloudPlatform/kubernetes/31a0daae3627c91bc96e1f02a6344cd76e294791/api/kubernetes.html)
Expand Down
65 changes: 65 additions & 0 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -663,3 +663,68 @@ function kube::release::gcs::copy_release_tarballs() {

gsutil ls -lh "${gcs_destination}"
}

# ---------------------------------------------------------------------------
# Rackspace Release

function kube::release::rackspace::release() {

[[ ${KUBE_RACKSPACE_UPLOAD_RELEASE-y} =~ ^[yY]$ ]] || return 0

CLOUDFILES_CONTAINER="kubernetes-releases-${OS_USERNAME}"

kube::release::rackspace::verify_prereqs
kube::release::rackspace::ensure_release_container
kube::release::rackspace::copy_release_tarballs
}

# Verify things are set up for uploading to GCS
function kube::release::rackspace::verify_prereqs() {

# Make sure swiftly is installed and available
if [[ -z "$(which gsutil)" ]]; then
echo "build/common.sh: Couldn't find swiftly in PATH. Please install swiftly:"
echo -e "\tpip install swiftly"
return 1
fi

if [[ -z "${OS_AUTH_URL-}" ]]; then
echo "build/common.sh: OS_AUTH_URL not set."
echo -e "\texport OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0/"
return 1
fi

if [[ -z "${OS_USERNAME-}" ]]; then
echo "build/common.sh: OS_USERNAME not set."
echo -e "\texport OS_USERNAME=myusername"
return 1
fi

if [[ -z "${OS_PASSWORD-}" ]]; then
echo "build/common.sh: OS_PASSWORD not set."
echo -e "\texport OS_PASSWORD=myapikey"
return 1
fi
}

function kube::release::rackspace::ensure_release_container() {

KUBE_RACKSPACE_RELEASE_BUCKET=${KUBE_RACKSPACE_RELEASE_BUCKET-kubernetes-releases-${OS_USERNAME}}
KUBE_RACKSPACE_RELEASE_PREFIX=${KUBE_RACKSPACE_RELEASE_PREFIX-devel/}

SWIFTLY_CMD="swiftly -A ${OS_AUTH_URL} -U ${OS_USERNAME} -K ${OS_PASSWORD}"

if ! ${SWIFTLY_CMD} get ${CLOUDFILES_CONTAINER} > /dev/null 2>&1 ; then
echo "build/common.sh: Container doesn't exist. Creating container ${CLOUDFILES_CONTAINER}"
${SWIFTLY_CMD} put ${CLOUDFILES_CONTAINER} > /dev/null 2>&1
fi
}

function kube::release::rackspace::copy_release_tarballs() {

# Copy release tar.gz to cloud files object store
echo "build/common.sh: Uploading to Cloud Files"
${SWIFTLY_CMD} put -i ${RELEASE_DIR}/kubernetes-server-linux-amd64.tar.gz ${CLOUDFILES_CONTAINER}/devel/kubernetes-server-linux-amd64.tar.gz > /dev/null 2>&1

echo "Release pushed."
}
3 changes: 2 additions & 1 deletion build/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ fi
kube::build::copy_output
kube::build::run_image
kube::release::package_tarballs
kube::release::gcs::release

kube::release::${KUBERNETES_PROVIDER}::release
153 changes: 153 additions & 0 deletions cluster/rackspace/cloud-config/master-cloud-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#cloud-config

write_files:
- path: /opt/bin/regen-minion-list.sh
permissions: 0755
content: |
#!/bin/sh
m=$(echo $(etcdctl ls --recursive /corekube/minions | cut -d/ -f4 | sort) | tr ' ' ,)
echo "Found $m"
mkdir -p /run/apiserver
echo "MINIONS=$m" > /run/apiserver/minions.env
- path: /opt/bin/git-kubernetes-nginx.sh
permissions: 0755
content: |
#!/bin/bash
git clone https://github.com/doublerr/kubernetes_nginx /opt/kubernetes_nginx
/usr/bin/cp /opt/.kubernetes_auth /opt/kubernetes_nginx/.kubernetes_auth
docker build -t kubernetes_nginx:latest /opt/kubernetes_nginx
- path: /opt/bin/download-release.sh
permissions: 0755
content: |
#!/bin/bash
OBJECT_URL="CLOUD_FILES_URL"
echo "Downloading release ($OBJECT_URL)"
wget $OBJECT_URL -O /opt/kubernetes.tar.gz
echo "Unpacking release"
rm -rf /opt/kubernetes || false
tar xzf /opt/kubernetes.tar.gz -C /opt/
- path: /opt/.kubernetes_auth
permissions: 0600
content: |
KUBE_USER:KUBE_PASSWORD
coreos:
etcd:
name: kubernetes-master
discovery: https://discovery.etcd.io/DISCOVERY_ID
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
peer-bind-addr: $private_ipv4:7001

fleet:
public-ip: $private_ipv4
metadata: kubernetes_role=master

update:
reboot-strategy: etcd-lock

units:
#- name: nova-agent-watcher.service
# command: try-restart
- name: etcd.service
command: start
- name: fleet.service
command: start
- name: download-release.service
command: start
content: |
[Unit]
Description=Downloads Kubernetes Release
After=network-online.target
Requires=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/bash /opt/bin/download-release.sh
- name: master-apiserver.service
command: start
content: |
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network-online.target
Requires=network-online.target
After=minion-finder.service
Requires=minion-finder.service
After=download-release.service
Requires=download-release.service
[Service]
EnvironmentFile=-/run/apiserver/minions.env
ExecStartPre=/usr/bin/ln -sf /opt/kubernetes/platforms/linux/amd64/apiserver /opt/bin/apiserver
ExecStart=/opt/bin/apiserver --address=127.0.0.1 --port=8080 --machines=${MINIONS} --etcd_servers=http://127.0.0.1:4001 --logtostderr=true
Restart=always
RestartSec=2
- name: master-apiserver-sighup.path
command: start
content: |
[Path]
PathChanged=/run/apiserver/minions.env
- name: master-apiserver-sighup.service
command: start
content: |
[Service]
ExecStart=/usr/bin/pkill -SIGHUP -f apiserver
- name: minion-finder.service
command: start
content: |
[Unit]
Description=Kubernetes Minion finder
After=network-online.target
Requires=network-online.target
After=etcd.service
Requires=etcd.service
[Service]
ExecStartPre=/opt/bin/regen-minion-list.sh
ExecStart=/usr/bin/etcdctl exec-watch --recursive /corekube/minions -- /opt/bin/regen-minion-list.sh
Restart=always
RestartSec=30
- name: master-controller-manager.service
command: start
content: |
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network-online.target
Requires=network-online.target
After=master-apiserver.service
Requires=master-apiserver.service
[Service]
ExecStartPre=/usr/bin/ln -sf /opt/kubernetes/platforms/linux/amd64/controller-manager /opt/bin/controller-manager
ExecStart=/opt/bin/controller-manager --master=127.0.0.1:8080 --logtostderr=true
Restart=always
RestartSec=2
- name: master-scheduler.service
command: start
content: |
[Unit]
Description=Kubernetes Scheduler
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network-online.target
Requires=network-online.target
After=master-apiserver.service
Requires=master-apiserver.service
[Service]
ExecStartPre=/usr/bin/ln -sf /opt/kubernetes/platforms/linux/amd64/scheduler /opt/bin/scheduler
ExecStart=/opt/bin/scheduler --master=127.0.0.1:8080 --logtostderr=true
Restart=always
RestartSec=10
- name: kubernetes-nginx.service
command: start
content: |
[Unit]
Description=Kubernetes Nginx Service
After=network-online.target
Requires=network-online.target
After=docker.service
Requires=docker.service
[Service]
ExecStartPre=/opt/bin/git-kubernetes-nginx.sh
ExecStart=/usr/bin/docker run --rm --net="host" -p "443:443" -t --name "kubernetes_nginx" kubernetes_nginx
ExecStop=/usr/bin/docker stop kubernetes_nginx
Restart=always
RestartSec=15
Loading

0 comments on commit a8bae68

Please sign in to comment.