diff --git a/cluster/libvirt-coreos/config-default.sh b/cluster/libvirt-coreos/config-default.sh index 90efad88d3354..0e37aeb7343b8 100644 --- a/cluster/libvirt-coreos/config-default.sh +++ b/cluster/libvirt-coreos/config-default.sh @@ -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 diff --git a/cluster/libvirt-coreos/skydns-rc.yaml b/cluster/libvirt-coreos/skydns-rc.yaml new file mode 100644 index 0000000000000..f2e033af540af --- /dev/null +++ b/cluster/libvirt-coreos/skydns-rc.yaml @@ -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 diff --git a/cluster/libvirt-coreos/skydns-svc.yaml b/cluster/libvirt-coreos/skydns-svc.yaml new file mode 100644 index 0000000000000..d765f3f3fa937 --- /dev/null +++ b/cluster/libvirt-coreos/skydns-svc.yaml @@ -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 diff --git a/cluster/libvirt-coreos/user_data_master.yml b/cluster/libvirt-coreos/user_data_master.yml index 0efc5e7a5d435..7fbf6e52354bc 100644 --- a/cluster/libvirt-coreos/user_data_master.yml +++ b/cluster/libvirt-coreos/user_data_master.yml @@ -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 diff --git a/cluster/libvirt-coreos/user_data_minion.yml b/cluster/libvirt-coreos/user_data_minion.yml index 3c75b16dd59b3..e0205eaaa70c2 100644 --- a/cluster/libvirt-coreos/user_data_minion.yml +++ b/cluster/libvirt-coreos/user_data_minion.yml @@ -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 diff --git a/cluster/libvirt-coreos/util.sh b/cluster/libvirt-coreos/util.sh index 2598f49ee6919..7bcee77043c0f 100644 --- a/cluster/libvirt-coreos/util.sh +++ b/cluster/libvirt-coreos/util.sh @@ -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 }