Skip to content

Commit

Permalink
Integrate SkyDNS in libvirt-coreos
Browse files Browse the repository at this point in the history
  • Loading branch information
L3n41c committed Mar 2, 2015
1 parent 7ce6f22 commit c763fbf
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cluster/libvirt-coreos/config-default.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ ENABLE_NODE_MONITORING=true
# Optional: Enable node logging.
ENABLE_NODE_LOGGING=false
LOGGING_DESTINATION=elasticsearch

# Optional: Install cluster DNS.
ENABLE_CLUSTER_DNS=true
DNS_SERVER_IP="10.11.0.254"
DNS_DOMAIN="kubernetes.local"
DNS_REPLICAS=1
44 changes: 44 additions & 0 deletions cluster/libvirt-coreos/skydns-rc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
kind: ReplicationController
apiVersion: v1beta1
id: skydns
namespace: default
labels:
k8s-app: skydns
desiredState:
replicas: ${DNS_REPLICAS}
replicaSelector:
k8s-app: skydns
podTemplate:
labels:
k8s-app: skydns
desiredState:
manifest:
version: v1beta2
id: skydns
dnsPolicy: "Default" # Don't use cluster DNS.
containers:
- name: etcd
image: quay.io/coreos/etcd:latest
command: [
\"/etcd\",
\"-bind-addr=127.0.0.1\",
\"-peer-bind-addr=127.0.0.1\",
]
- name: kube2sky
image: kubernetes/kube2sky:1.0
command: [
# entrypoint = \"/kube2sky\",
\"-domain=${DNS_DOMAIN}\",
]
- name: skydns
image: kubernetes/skydns:2014-12-23-001
command: [
# entrypoint = \"/skydns\",
\"-machines=http://localhost:4001\",
\"-addr=0.0.0.0:53\",
\"-domain=${DNS_DOMAIN}.\",
]
ports:
- name: dns
containerPort: 53
protocol: UDP
12 changes: 12 additions & 0 deletions cluster/libvirt-coreos/skydns-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: Service
apiVersion: v1beta1
id: skydns
namespace: default
protocol: UDP
port: 53
portalIP: ${DNS_SERVER_IP}
containerPort: 53
labels:
k8s-app: skydns
selector:
k8s-app: skydns
20 changes: 20 additions & 0 deletions cluster/libvirt-coreos/user_data_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,25 @@ coreos:
Restart=always
RestartSec=2
[Install]
WantedBy=multi-user.target
- name: kube-addons.service
command: start
content: |
[Unit]
After=opt-kubernetes.mount kube-apiserver.service
ConditionPathIsDirectory=/opt/kubernetes/addons
Description=Kubernetes addons
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
Requires=opt-kubernetes.mount kube-apiserver.service
[Service]
Type=oneshot
ExecStartPre=/bin/bash -c 'while [[ \"\$(curl -s http://127.0.0.1:8080/healthz)\" != \"ok\" ]]; do sleep 1; done'
ExecStartPre=/bin/sleep 10
ExecStart=/opt/kubernetes/bin/kubectl create -f /opt/kubernetes/addons
ExecStop=/opt/kubernetes/bin/kubectl stop -f /opt/kubernetes/addons
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
3 changes: 3 additions & 0 deletions cluster/libvirt-coreos/user_data_minion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ coreos:
--address=0.0.0.0 \
--hostname_override=${MINION_IPS[$i]} \
--etcd_servers=http://127.0.0.1:4001 \
--api_servers=http://${MASTER_IP}:8080 \
$( [[ "$ENABLE_CLUSTER_DNS" == "true" ]] && echo "--cluster_dns=${DNS_SERVER_IP}" ) \
$( [[ "$ENABLE_CLUSTER_DNS" == "true" ]] && echo "--cluster_domain=${DNS_DOMAIN}" ) \
--config=/opt/kubernetes/manifests
Restart=always
RestartSec=2
Expand Down
6 changes: 6 additions & 0 deletions cluster/libvirt-coreos/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ function initialize-pool {
fi
fi

mkdir -p "$POOL_PATH/kubernetes/addons"
if [[ "$ENABLE_CLUSTER_DNS" == "true" ]]; then
render-template "$ROOT/skydns-svc.yaml" > "$POOL_PATH/kubernetes/addons/skydns-svc.yaml"
render-template "$ROOT/skydns-rc.yaml" > "$POOL_PATH/kubernetes/addons/skydns-rc.yaml"
fi

virsh pool-refresh $POOL
}

Expand Down

0 comments on commit c763fbf

Please sign in to comment.