Merge pull request #7227 from lhuard1A/libvirt-coreos_etcd2

Make the libvirt-coreos cluster use the etcd2 shipped within CoreOS
This commit is contained in:
Brendan Burns 2015-08-13 11:19:54 -07:00
commit 35c22714d1
7 changed files with 40 additions and 61 deletions

View File

@ -1,3 +1,2 @@
/libvirt_storage_pool/ /libvirt_storage_pool/
/coreos_production_qemu_image.img.bz2 /coreos_production_qemu_image.img.bz2
/etcd-v2.0.9-linux-amd64.tar.gz

View File

@ -35,11 +35,6 @@
<target dir='kubernetes'/> <target dir='kubernetes'/>
<readonly/> <readonly/>
</filesystem> </filesystem>
<filesystem type='mount' accessmode='squash'>
<source dir='${etcd_dir}'/>
<target dir='etcd'/>
<readonly/>
</filesystem>
<interface type='network'> <interface type='network'>
<mac address='52:54:00:00:00:${i}'/> <mac address='52:54:00:00:00:${i}'/>
<source network='kubernetes_global'/> <source network='kubernetes_global'/>

View File

@ -14,25 +14,13 @@ write_files:
RuntimeMaxUse=50M RuntimeMaxUse=50M
coreos: coreos:
etcd: etcd2:
name: ${name}
addr: ${public_ip}:4001
# bind-addr: 0.0.0.0
peer-addr: ${public_ip}:7001
# peers: {etcd_peers}
discovery: ${discovery} discovery: ${discovery}
advertise-client-urls: http://${public_ip}:2379
initial-advertise-peer-urls: http://${public_ip}:2380
listen-client-urls: http://0.0.0.0:2379
listen-peer-urls: http://${public_ip}:2380
units: units:
- name: etcd.service
drop-ins:
- name: opt-etcd2.conf
content: |
[Unit]
After=opt-etcd.mount
Requires=opt-etcd.mount
[Service]
ExecStart=
ExecStart=/opt/etcd/bin/etcd
- name: static.network - name: static.network
command: start command: start
content: | content: |
@ -80,7 +68,7 @@ coreos:
ExecStart=/usr/sbin/iptables -w -t nat -A POSTROUTING -o eth0 -j MASQUERADE ! -d ${CONTAINER_SUBNET} ExecStart=/usr/sbin/iptables -w -t nat -A POSTROUTING -o eth0 -j MASQUERADE ! -d ${CONTAINER_SUBNET}
RemainAfterExit=yes RemainAfterExit=yes
Type=oneshot Type=oneshot
- name: etcd.service - name: etcd2.service
command: start command: start
- name: docker.service - name: docker.service
command: start command: start
@ -114,17 +102,6 @@ coreos:
Where=/opt/kubernetes Where=/opt/kubernetes
Options=ro,trans=virtio,version=9p2000.L Options=ro,trans=virtio,version=9p2000.L
Type=9p Type=9p
- name: opt-etcd.mount
command: start
content: |
[Unit]
ConditionVirtualization=|vm
[Mount]
What=etcd
Where=/opt/etcd
Options=ro,trans=virtio,version=9p2000.L
Type=9p
update: update:
group: ${COREOS_CHANNEL:-alpha} group: ${COREOS_CHANNEL:-alpha}
reboot-strategy: off reboot-strategy: off

View File

@ -6,17 +6,17 @@ coreos:
command: start command: start
content: | content: |
[Unit] [Unit]
After=opt-kubernetes.mount etcd.service After=opt-kubernetes.mount etcd2.service
ConditionFileIsExecutable=/opt/kubernetes/bin/kube-apiserver ConditionFileIsExecutable=/opt/kubernetes/bin/kube-apiserver
Description=Kubernetes API Server Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=opt-kubernetes.mount etcd.service Requires=opt-kubernetes.mount etcd2.service
[Service] [Service]
ExecStart=/opt/kubernetes/bin/kube-apiserver \ ExecStart=/opt/kubernetes/bin/kube-apiserver \
--address=0.0.0.0 \ --address=0.0.0.0 \
--port=8080 \ --port=8080 \
--etcd-servers=http://127.0.0.1:4001 \ --etcd-servers=http://127.0.0.1:2379 \
--kubelet-port=10250 \ --kubelet-port=10250 \
--service-cluster-ip-range=${SERVICE_CLUSTER_IP_RANGE} --service-cluster-ip-range=${SERVICE_CLUSTER_IP_RANGE}
Restart=always Restart=always

View File

@ -6,11 +6,11 @@ coreos:
command: start command: start
content: | content: |
[Unit] [Unit]
After=opt-kubernetes.mount etcd.service docker.socket After=opt-kubernetes.mount docker.socket
ConditionFileIsExecutable=/opt/kubernetes/bin/kubelet ConditionFileIsExecutable=/opt/kubernetes/bin/kubelet
Description=Kubernetes Kubelet Description=Kubernetes Kubelet
Documentation=https://github.com/GoogleCloudPlatform/kubernetes Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=opt-kubernetes.mount etcd.service docker.socket Requires=opt-kubernetes.mount docker.socket
[Service] [Service]
ExecStart=/opt/kubernetes/bin/kubelet \ ExecStart=/opt/kubernetes/bin/kubelet \
@ -29,11 +29,11 @@ coreos:
command: start command: start
content: | content: |
[Unit] [Unit]
After=opt-kubernetes.mount etcd.service After=opt-kubernetes.mount
ConditionFileIsExecutable=/opt/kubernetes/bin/kube-proxy ConditionFileIsExecutable=/opt/kubernetes/bin/kube-proxy
Description=Kubernetes Proxy Description=Kubernetes Proxy
Documentation=https://github.com/GoogleCloudPlatform/kubernetes Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=opt-kubernetes.mount etcd.service Requires=opt-kubernetes.mount
[Service] [Service]
ExecStart=/opt/kubernetes/bin/kube-proxy \ ExecStart=/opt/kubernetes/bin/kube-proxy \

View File

@ -26,8 +26,6 @@ export LIBVIRT_DEFAULT_URI=qemu:///system
readonly POOL=kubernetes readonly POOL=kubernetes
readonly POOL_PATH="$(cd $ROOT && pwd)/libvirt_storage_pool" readonly POOL_PATH="$(cd $ROOT && pwd)/libvirt_storage_pool"
ETCD_VERSION=${ETCD_VERSION:-v2.0.9}
# join <delim> <list...> # join <delim> <list...>
# Concatenates the list elements with the delimiter passed as first parameter # Concatenates the list elements with the delimiter passed as first parameter
# #
@ -96,9 +94,6 @@ function destroy-pool {
virsh vol-delete $vol --pool $POOL virsh vol-delete $vol --pool $POOL
done done
rm -rf "$POOL_PATH"/etcd/*
virsh vol-delete etcd --pool $POOL || true
[[ "$1" == 'keep_base_image' ]] && return [[ "$1" == 'keep_base_image' ]] && return
set +e set +e
@ -146,18 +141,6 @@ function initialize-pool {
render-template "$ROOT/skydns-rc.yaml" > "$POOL_PATH/kubernetes/addons/skydns-rc.yaml" render-template "$ROOT/skydns-rc.yaml" > "$POOL_PATH/kubernetes/addons/skydns-rc.yaml"
fi fi
mkdir -p "$POOL_PATH/etcd"
if [[ ! -f "$ROOT/etcd-${ETCD_VERSION}-linux-amd64.tar.gz" ]]; then
wget -P "$ROOT" https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-amd64.tar.gz
fi
if [[ "$ROOT/etcd-${ETCD_VERSION}-linux-amd64.tar.gz" -nt "$POOL_PATH/etcd/etcd" ]]; then
tar -x -C "$POOL_PATH/etcd" -f "$ROOT/etcd-${ETCD_VERSION}-linux-amd64.tar.gz" etcd-${ETCD_VERSION}-linux-amd64
rm -rf "$POOL_PATH/etcd/bin/*"
mkdir -p "$POOL_PATH/etcd/bin"
mv "$POOL_PATH"/etcd/etcd-${ETCD_VERSION}-linux-amd64/{etcd,etcdctl} "$POOL_PATH/etcd/bin"
rm -rf "$POOL_PATH/etcd/etcd-${ETCD_VERSION}-linux-amd64"
fi
virsh pool-refresh $POOL virsh pool-refresh $POOL
} }
@ -200,13 +183,13 @@ function wait-cluster-readiness {
function kube-up { function kube-up {
detect-master detect-master
detect-minions detect-minions
get-kubeconfig-bearertoken
initialize-pool keep_base_image initialize-pool keep_base_image
initialize-network initialize-network
readonly ssh_keys="$(cat ~/.ssh/id_*.pub | sed 's/^/ - /')" readonly ssh_keys="$(cat ~/.ssh/id_*.pub | sed 's/^/ - /')"
readonly kubernetes_dir="$POOL_PATH/kubernetes" readonly kubernetes_dir="$POOL_PATH/kubernetes"
readonly etcd_dir="$POOL_PATH/etcd" readonly discovery=$(curl -s https://discovery.etcd.io/new?size=$(($NUM_MINIONS+1)))
readonly discovery=$(curl -s https://discovery.etcd.io/new)
readonly machines=$(join , "${KUBE_MINION_IP_ADDRESSES[@]}") readonly machines=$(join , "${KUBE_MINION_IP_ADDRESSES[@]}")

View File

@ -36,6 +36,7 @@ Getting started with libvirt CoreOS
**Table of Contents** **Table of Contents**
- [Highlights](#highlights) - [Highlights](#highlights)
- [Warnings about `libvirt-coreos` use case](#warnings-about-libvirt-coreos-use-case)
- [Prerequisites](#prerequisites) - [Prerequisites](#prerequisites)
- [Setup](#setup) - [Setup](#setup)
- [Interacting with your Kubernetes cluster with the `kube-*` scripts.](#interacting-with-your-kubernetes-cluster-with-the-kube--scripts) - [Interacting with your Kubernetes cluster with the `kube-*` scripts.](#interacting-with-your-kubernetes-cluster-with-the-kube--scripts)
@ -52,6 +53,30 @@ Getting started with libvirt CoreOS
* Reduced disk usage thanks to [COW](https://en.wikibooks.org/wiki/QEMU/Images#Copy_on_write) * Reduced disk usage thanks to [COW](https://en.wikibooks.org/wiki/QEMU/Images#Copy_on_write)
* Reduced memory footprint thanks to [KSM](https://www.kernel.org/doc/Documentation/vm/ksm.txt) * Reduced memory footprint thanks to [KSM](https://www.kernel.org/doc/Documentation/vm/ksm.txt)
### Warnings about `libvirt-coreos` use case
The primary goal of the `libvirt-coreos` cluster provider is to deploy a multi-node Kubernetes cluster on local VMs as fast as possible and to be as light as possible in term of resources used.
In order to achieve that goal, its deployment is very different from the “standard production deployment” method used on other providers. This was done on purpose in order to implement some optimizations made possible by the fact that we know that all VMs will be running on the same physical machine.
The `libvirt-coreos` cluster provider doesnt aim at being production look-alike.
Another difference is that no security is enforced on `libvirt-coreos` at all. For example,
* Kube API server is reachable via a clear-text connection (no SSL);
* Kube API server requires no credentials;
* etcd access is not protected;
* Kubernetes secrets are not protected as securely as they are on production environments;
* etc.
So, an k8s application developer should not validate its interaction with Kubernetes on `libvirt-coreos` because he might technically succeed in doing things that are prohibited on a production environment like:
* un-authenticated access to Kube API server;
* Access to Kubernetes private data structures inside etcd;
* etc.
On the other hand, `libvirt-coreos` might be useful for people investigating low level implementation of Kubernetes because debugging techniques like sniffing the network traffic or introspecting the etcd content are easier on `libvirt-coreos` than on a production deployment.
### Prerequisites ### Prerequisites
1. Install [dnsmasq](http://www.thekelleys.org.uk/dnsmasq/doc.html) 1. Install [dnsmasq](http://www.thekelleys.org.uk/dnsmasq/doc.html)