mirror of https://github.com/k3s-io/k3s
adding local registry to libvirt_coreos
parent
0d80ee0b8d
commit
3e1b88800e
|
@ -58,9 +58,16 @@ ENABLE_CLUSTER_DNS="${KUBE_ENABLE_CLUSTER_DNS:-true}"
|
|||
DNS_SERVER_IP="${SERVICE_CLUSTER_IP_RANGE%.*}.254"
|
||||
DNS_DOMAIN="cluster.local"
|
||||
|
||||
# Optional: Install cluster registry
|
||||
ENABLE_CLUSTER_REGISTRY="${KUBE_ENABLE_CLUSTER_REGISTRY:-true}"
|
||||
|
||||
# Optional: Enable DNS horizontal autoscaler
|
||||
ENABLE_DNS_HORIZONTAL_AUTOSCALER="${KUBE_ENABLE_DNS_HORIZONTAL_AUTOSCALER:-false}"
|
||||
|
||||
#Generate dns files
|
||||
sed -f "${KUBE_ROOT}/cluster/addons/dns/transforms2sed.sed" < "${KUBE_ROOT}/cluster/addons/dns/kubedns-controller.yaml.base" | sed -f "${KUBE_ROOT}/cluster/libvirt-coreos/forShellEval.sed" > "${KUBE_ROOT}/cluster/libvirt-coreos/kubedns-controller.yaml"
|
||||
sed -f "${KUBE_ROOT}/cluster/addons/dns/transforms2sed.sed" < "${KUBE_ROOT}/cluster/addons/dns/kubedns-svc.yaml.base" | sed -f "${KUBE_ROOT}/cluster/libvirt-coreos/forShellEval.sed" > "${KUBE_ROOT}/cluster/libvirt-coreos/kubedns-svc.yaml"
|
||||
|
||||
|
||||
#Generate registry files
|
||||
sed -f "${KUBE_ROOT}/cluster/libvirt-coreos/forEmptyDirRegistry.sed" < "${KUBE_ROOT}/cluster/addons/registry/registry-rc.yaml" > "${KUBE_ROOT}/cluster/libvirt-coreos/registry-rc.yaml"
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
s/persistentVolumeClaim:/emptyDir: {}/g
|
||||
s/claimName: kube-registry-pvc//g
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
[ ! -z ${UTIL_SH_DEBUG+x} ] && set -x
|
||||
|
||||
command -v kubectl >/dev/null 2>&1 || { echo >&2 "kubectl not found in path. Aborting."; exit 1; }
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/../..
|
||||
readonly ROOT=$(dirname "${BASH_SOURCE}")
|
||||
source "$ROOT/${KUBE_CONFIG_FILE:-"config-default.sh"}"
|
||||
|
@ -90,6 +92,12 @@ function generate_certs {
|
|||
echo "TLS assets generated..."
|
||||
}
|
||||
|
||||
#Setup registry proxy
|
||||
function setup_registry_proxy {
|
||||
if [[ "$ENABLE_CLUSTER_REGISTRY" == "true" ]]; then
|
||||
cp "./cluster/saltbase/salt/kube-registry-proxy/kube-registry-proxy.yaml" "$POOL_PATH/kubernetes/manifests"
|
||||
fi
|
||||
}
|
||||
|
||||
# Verify prereqs on host machine
|
||||
function verify-prereqs {
|
||||
|
@ -202,14 +210,13 @@ function render-template {
|
|||
|
||||
function wait-cluster-readiness {
|
||||
echo "Wait for cluster readiness"
|
||||
local kubectl="${KUBE_ROOT}/cluster/kubectl.sh"
|
||||
|
||||
local timeout=120
|
||||
while [[ $timeout -ne 0 ]]; do
|
||||
nb_ready_nodes=$("${kubectl}" get nodes -o go-template="{{range.items}}{{range.status.conditions}}{{.type}}{{end}}:{{end}}" --api-version=v1 2>/dev/null | tr ':' '\n' | grep -c Ready || true)
|
||||
nb_ready_nodes=$(kubectl get nodes -o go-template="{{range.items}}{{range.status.conditions}}{{.type}}{{end}}:{{end}}" --api-version=v1 2>/dev/null | tr ':' '\n' | grep -c Ready || true)
|
||||
echo "Nb ready nodes: $nb_ready_nodes / $NUM_NODES"
|
||||
if [[ "$nb_ready_nodes" -eq "$NUM_NODES" ]]; then
|
||||
return 0
|
||||
return 0
|
||||
fi
|
||||
|
||||
timeout=$(($timeout-1))
|
||||
|
@ -225,9 +232,9 @@ function kube-up {
|
|||
detect-nodes
|
||||
initialize-pool keep_base_image
|
||||
generate_certs "${NODE_NAMES[@]}"
|
||||
setup_registry_proxy
|
||||
initialize-network
|
||||
|
||||
|
||||
readonly ssh_keys="$(cat ~/.ssh/*.pub | sed 's/^/ - /')"
|
||||
readonly kubernetes_dir="$POOL_PATH/kubernetes"
|
||||
|
||||
|
@ -277,8 +284,50 @@ function kube-up {
|
|||
echo
|
||||
echo " http://${KUBE_MASTER_IP}:8080"
|
||||
echo
|
||||
echo "You can control the Kubernetes cluster with: 'cluster/kubectl.sh'"
|
||||
echo "You can control the Kubernetes cluster with: 'kubectl'"
|
||||
echo "You can connect on the master with: 'ssh core@${KUBE_MASTER_IP}'"
|
||||
|
||||
wait-registry-readiness
|
||||
|
||||
}
|
||||
|
||||
function create_registry_rc() {
|
||||
echo " Create registry replication controller"
|
||||
kubectl create -f $ROOT/registry-rc.yaml
|
||||
local timeout=120
|
||||
while [[ $timeout -ne 0 ]]; do
|
||||
phase=$(kubectl get pods -n kube-system -lk8s-app=kube-registry --output='jsonpath={.items..status.phase}')
|
||||
if [ "$phase" = "Running" ]; then
|
||||
return 0
|
||||
fi
|
||||
timeout=$(($timeout-1))
|
||||
sleep .5
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
function create_registry_svc() {
|
||||
echo " Create registry service"
|
||||
kubectl create -f "${KUBE_ROOT}/cluster/addons/registry/registry-svc.yaml"
|
||||
}
|
||||
|
||||
function wait-registry-readiness() {
|
||||
if [[ "$ENABLE_CLUSTER_REGISTRY" != "true" ]]; then
|
||||
return 0
|
||||
fi
|
||||
echo "Wait for registry readiness..."
|
||||
local timeout=120
|
||||
while [[ $timeout -ne 0 ]]; do
|
||||
phase=$(kubectl get namespaces --output=jsonpath='{.items[?(@.metadata.name=="kube-system")].status.phase}')
|
||||
if [ "$phase" = "Active" ]; then
|
||||
create_registry_rc
|
||||
create_registry_svc
|
||||
return 0
|
||||
fi
|
||||
echo "waiting for namespace kube-system"
|
||||
timeout=$(($timeout-1))
|
||||
sleep .5
|
||||
done
|
||||
}
|
||||
|
||||
# Delete a kubernetes cluster
|
||||
|
|
Loading…
Reference in New Issue