Skip to content

Commit

Permalink
Merge pull request kubernetes#1832 from doublerr/rackspace_switch_to_…
Browse files Browse the repository at this point in the history
…coreos

Rackspace - Switch to CoreOS for standard cluster
  • Loading branch information
jbeda committed Oct 22, 2014
2 parents 155b56d + d513854 commit 25b1eea
Show file tree
Hide file tree
Showing 14 changed files with 524 additions and 270 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
152 changes: 152 additions & 0 deletions cluster/rackspace/cloud-config/master-cloud-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#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: 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/server/bin/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 --portal_net=PORTAL_NET --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/server/bin/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/server/bin/scheduler /opt/bin/scheduler
ExecStart=/opt/bin/scheduler --master=127.0.0.1:8080 --logtostderr=true
Restart=always
RestartSec=10
#Running nginx service with --net="host" is a necessary evil until running all k8s services in docker.
- 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
224 changes: 224 additions & 0 deletions cluster/rackspace/cloud-config/minion-cloud-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
#cloud-config

write_files:
- path: /opt/bin/kube-net-update.sh
permissions: 0755
content: |
#!/bin/sh
set -x -e
nh=${ETCD_WATCH_KEY##*/}
net=$ETCD_WATCH_VALUE
case $ETCD_WATCH_ACTION in
set) ip route replace $net via $nh dev eth2 metric 900 ;;
expire) ip route del $net via $nh metric 900 ;;
esac
- 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-manifests/cadvisor.manifest
permissions: 0755
content: |
version: v1beta2
id: cadvisor-agent
containers:
- name: cadvisor
image: google/cadvisor:latest
ports:
- name: http
containerPort: 8080
hostPort: 4194
volumeMounts:
- name: varrun
mountPath: /var/run
readOnly: false
- name: varlibdocker
mountPath: /var/lib/docker
readOnly: true
- name: cgroups
mountPath: /sys/fs/cgroup
readOnly: true
volumes:
- name: varrun
source:
hostDir:
path: /var/run
- name: varlibdocker
source:
hostDir:
path: /var/lib/docker
- name: cgroups
source:
hostDir:
path: /sys/fs/cgroup
coreos:
etcd:
name: kubernetes-minion-INDEX
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=minion

update:
reboot-strategy: etcd-lock

units:
- 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: minion-kubelet.service
command: start
content: |
[Unit]
Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network-online.target
Requires=network-online.target
After=docker.service
Requires=docker.service
After=download-release.service
Requires=download-release.service
[Service]
ExecStartPre=/usr/bin/ln -sf /opt/kubernetes/server/bin/kubelet /opt/bin/kubelet
ExecStart=/opt/bin/kubelet --address=$private_ipv4 --hostname_override=$private_ipv4 --etcd_servers=http://127.0.0.1:4001 --logtostderr=true --config=/opt/kubernetes-manifests
Restart=always
RestartSec=2
- name: minion-proxy.service
command: start
content: |
[Unit]
Description=Kubernetes Proxy
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network-online.target
Requires=network-online.target
After=docker.service
Requires=docker.service
After=download-release.service
Requires=download-release.service
[Service]
ExecStartPre=/usr/bin/ln -sf /opt/kubernetes/server/bin/proxy /opt/bin/proxy
ExecStart=/opt/bin/proxy --bind_address=$private_ipv4 --etcd_servers=http://127.0.0.1:4001 --logtostderr=true
Restart=always
RestartSec=2
- name: minion-advertiser.service
command: start
content: |
[Unit]
Description=Kubernetes Minion Advertiser
After=etcd.service
Requires=etcd.service
After=minion-kubelet.service
[Service]
ExecStart=/bin/sh -c 'while :; do etcdctl set /corekube/minions/$private_ipv4 $private_ipv4 --ttl 300; sleep 120; done'
Restart=always
RestartSec=120
- name: net-advertiser.service
command: start
content: |
[Unit]
Description=Kubernetes Network Advertiser
After=etcd.service
Requires=etcd.service
After=minion-kubelet.service
[Service]
ExecStart=/bin/sh -c 'eth2_ip=$$(ip -o -f inet a show dev eth2 | sed "s/.* inet \([0-9.]\+\).*/\1/"); while :; do etcdctl set /corekube/net/$$eth2_ip 10.240.INDEX.0/24 --ttl 300; sleep 120; done'
Restart=always
RestartSec=120
- name: net-router.service
command: start
content: |
[Unit]
Description=Kubernetes Network Router
After=etcd.service
Requires=etcd.service
After=minion-kubelet.service
[Service]
ExecStart=/usr/bin/etcdctl exec-watch --recursive /corekube/net -- /opt/bin/kube-net-update.sh
Restart=always
RestartSec=120
- name: cbr0.netdev
command: start
content: |
[NetDev]
Kind=bridge
Name=cbr0
- name: cbr0.network
command: start
content: |
[Match]
Name=cbr0
[Network]
Address=10.240.INDEX.1/24
- name: nat.service
command: start
content: |
[Unit]
Description=NAT container->outside traffic
[Service]
ExecStart=/usr/sbin/iptables -t nat -A POSTROUTING -o eth0 -s 10.240.INDEX.0/24 -j MASQUERADE
ExecStart=/usr/sbin/iptables -t nat -A POSTROUTING -o eth1 -s 10.240.INDEX.0/24 -j MASQUERADE
RemainAfterExit=yes
Type=oneshot
- name: docker.service
command: start
content: |
[Unit]
After=network.target
Description=Docker Application Container Engine
Documentation=http://docs.docker.io
[Service]
ExecStartPre=/bin/mount --make-rprivate /
ExecStart=/usr/bin/docker -d -s=btrfs -H fd:// -b cbr0 --iptables=false
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
- name: format-data.service
command: start
content: |
[Unit]
Description=Formats data drive
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/wipefs -f /dev/xvde1
ExecStart=/usr/sbin/mkfs.btrfs -f /dev/xvde1
- name: var-lib-docker-volumes.mount
command: start
content: |
[Unit]
Description=Mount data drive to /var/lib/docker/volumes
Requires=format-data.service
After=format-data.service
Before=docker.service
[Mount]
What=/dev/xvde1
Where=/var/lib/docker/volumes
Type=btrfs
Loading

0 comments on commit 25b1eea

Please sign in to comment.