|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2015 The Kubernetes Authors All rights reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# Deploy the addon services after the cluster is available |
| 18 | +# TODO: integrate with or use /cluster/saltbase/salt/kube-addons/kube-addons.sh |
| 19 | +# Requires: |
| 20 | +# ENABLE_CLUSTER_DNS (Optional) - 'Y' to deploy kube-dns |
| 21 | +# KUBE_SERVER (Optional) - url to the api server for configuring kube-dns |
| 22 | + |
| 23 | +set -o errexit |
| 24 | +set -o nounset |
| 25 | +set -o pipefail |
| 26 | + |
| 27 | +KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE}")/../../.." && pwd) |
| 28 | +source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/${KUBE_CONFIG_FILE-"config-default.sh"}" |
| 29 | +source "${KUBE_ROOT}/cluster/${KUBERNETES_PROVIDER}/util-temp-dir.sh" |
| 30 | +kubectl="${KUBE_ROOT}/cluster/kubectl.sh" |
| 31 | + |
| 32 | + |
| 33 | +function deploy_dns { |
| 34 | + echo "Deploying DNS Addon" 1>&2 |
| 35 | + local workspace=$(pwd) |
| 36 | + |
| 37 | + # Process salt pillar templates manually |
| 38 | + sed -e "s/{{ pillar\['dns_replicas'\] }}/${DNS_REPLICAS}/g;s/{{ pillar\['dns_domain'\] }}/${DNS_DOMAIN}/g" "${KUBE_ROOT}/cluster/addons/dns/skydns-rc.yaml.in" > "${workspace}/skydns-rc.yaml" |
| 39 | + sed -e "s/{{ pillar\['dns_server'\] }}/${DNS_SERVER_IP}/g" "${KUBE_ROOT}/cluster/addons/dns/skydns-svc.yaml.in" > "${workspace}/skydns-svc.yaml" |
| 40 | + |
| 41 | + # Use kubectl to create skydns rc and service |
| 42 | + "${kubectl}" create -f "${workspace}/skydns-rc.yaml" |
| 43 | + "${kubectl}" create -f "${workspace}/skydns-svc.yaml" |
| 44 | +} |
| 45 | + |
| 46 | +function deploy_ui { |
| 47 | + echo "Deploying UI Addon" 1>&2 |
| 48 | + |
| 49 | + # Use kubectl to create ui rc and service |
| 50 | + "${kubectl}" create -f "${KUBE_ROOT}/cluster/addons/kube-ui/kube-ui-rc.yaml" |
| 51 | + "${kubectl}" create -f "${KUBE_ROOT}/cluster/addons/kube-ui/kube-ui-svc.yaml" |
| 52 | +} |
| 53 | + |
| 54 | +# create the kube-system namespace |
| 55 | +"${kubectl}" create -f "${KUBE_ROOT}/cluster/mesos/docker/kube-system-ns.yaml" |
| 56 | + |
| 57 | +if [ "${ENABLE_CLUSTER_DNS}" == true ]; then |
| 58 | + cluster::mesos::docker::run_in_temp_dir 'k8sm-dns' 'deploy_dns' |
| 59 | +fi |
| 60 | + |
| 61 | +if [ "${ENABLE_CLUSTER_UI}" == true ]; then |
| 62 | + deploy_ui |
| 63 | +fi |
0 commit comments