|
@@ -16,6 +16,8 @@ spec:
|
|
app: sync
|
|
app: sync
|
|
updateStrategy:
|
|
updateStrategy:
|
|
type: RollingUpdate
|
|
type: RollingUpdate
|
|
|
|
+ rollingUpdate:
|
|
|
|
+ maxUnavailable: 50%
|
|
template:
|
|
template:
|
|
metadata:
|
|
metadata:
|
|
labels:
|
|
labels:
|
|
@@ -50,19 +52,10 @@ spec:
|
|
#!/bin/bash
|
|
#!/bin/bash
|
|
set -euo pipefail
|
|
set -euo pipefail
|
|
|
|
|
|
- # loop until BOOTSTRAP_CONFIG_NAME is set
|
|
|
|
- set -o allexport
|
|
|
|
- while true; do
|
|
|
|
- if [[ -f /etc/sysconfig/origin-node ]]; then
|
|
|
|
- source /etc/sysconfig/origin-node
|
|
|
|
- if [[ -z "${BOOTSTRAP_CONFIG_NAME-}" ]]; then
|
|
|
|
- echo "info: Waiting for BOOTSTRAP_CONFIG_NAME to be set" 2>&1
|
|
|
|
- sleep 15
|
|
|
|
- continue
|
|
|
|
- fi
|
|
|
|
- break
|
|
|
|
- fi
|
|
|
|
- done
|
|
|
|
|
|
+ # set by the node image
|
|
|
|
+ unset KUBECONFIG
|
|
|
|
+
|
|
|
|
+ trap 'kill $(jobs -p); exit 0' TERM
|
|
|
|
|
|
# track the current state of the config
|
|
# track the current state of the config
|
|
if [[ -f /etc/origin/node/node-config.yaml ]]; then
|
|
if [[ -f /etc/origin/node/node-config.yaml ]]; then
|
|
@@ -71,12 +64,50 @@ spec:
|
|
touch /tmp/.old
|
|
touch /tmp/.old
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
+ # loop until BOOTSTRAP_CONFIG_NAME is set
|
|
|
|
+ while true; do
|
|
|
|
+ file=/etc/sysconfig/origin-node
|
|
|
|
+ if [[ -f /etc/sysconfig/atomic-openshift-node ]]; then
|
|
|
|
+ file=/etc/sysconfig/atomic-openshift-node
|
|
|
|
+ elif [[ -f /etc/sysconfig/origin-node ]]; then
|
|
|
|
+ file=/etc/sysconfig/origin-node
|
|
|
|
+ else
|
|
|
|
+ echo "info: Waiting for the node sysconfig file to be created" 2>&1
|
|
|
|
+ sleep 15 & wait
|
|
|
|
+ continue
|
|
|
|
+ fi
|
|
|
|
+ name="$(sed -nE 's|^BOOTSTRAP_CONFIG_NAME=([^#].+)|\1|p' "${file}" | head -1)"
|
|
|
|
+ if [[ -z "${name}" ]]; then
|
|
|
|
+ echo "info: Waiting for BOOTSTRAP_CONFIG_NAME to be set" 2>&1
|
|
|
|
+ sleep 15 & wait
|
|
|
|
+ continue
|
|
|
|
+ fi
|
|
|
|
+ # in the background check to see if the value changes and exit if so
|
|
|
|
+ pid=$BASHPID
|
|
|
|
+ (
|
|
|
|
+ while true; do
|
|
|
|
+ if ! updated="$(sed -nE 's|^BOOTSTRAP_CONFIG_NAME=([^#].+)|\1|p' "${file}" | head -1)"; then
|
|
|
|
+ echo "error: Unable to check for bootstrap config, exiting" 2>&1
|
|
|
|
+ kill $pid
|
|
|
|
+ exit 1
|
|
|
|
+ fi
|
|
|
|
+ if [[ "${updated}" != "${name}" ]]; then
|
|
|
|
+ echo "info: Bootstrap configuration profile name changed, exiting" 2>&1
|
|
|
|
+ kill $pid
|
|
|
|
+ exit 0
|
|
|
|
+ fi
|
|
|
|
+ sleep 15
|
|
|
|
+ done
|
|
|
|
+ ) &
|
|
|
|
+ break
|
|
|
|
+ done
|
|
|
|
+
|
|
# periodically refresh both node-config.yaml and relabel the node
|
|
# periodically refresh both node-config.yaml and relabel the node
|
|
while true; do
|
|
while true; do
|
|
- name=${BOOTSTRAP_CONFIG_NAME}
|
|
|
|
- if ! oc extract --config=/etc/origin/node/node.kubeconfig "cm/${BOOTSTRAP_CONFIG_NAME}" -n openshift-node --to=/etc/origin/node --confirm; then
|
|
|
|
|
|
+ if ! oc extract "configmaps/${name}" -n openshift-node --to=/etc/origin/node --confirm --request-timeout=10s --config /etc/origin/node/node.kubeconfig "--token=$( cat /var/run/secrets/kubernetes.io/serviceaccount/token )" > /dev/null; then
|
|
echo "error: Unable to retrieve latest config for node" 2>&1
|
|
echo "error: Unable to retrieve latest config for node" 2>&1
|
|
- sleep 15
|
|
|
|
|
|
+ sleep 15 &
|
|
|
|
+ wait $!
|
|
continue
|
|
continue
|
|
fi
|
|
fi
|
|
# detect whether the node-config.yaml has changed, and if so trigger a restart of the kubelet.
|
|
# detect whether the node-config.yaml has changed, and if so trigger a restart of the kubelet.
|
|
@@ -92,17 +123,22 @@ spec:
|
|
echo "info: Applying node labels $labels" 2>&1
|
|
echo "info: Applying node labels $labels" 2>&1
|
|
if ! oc label --config=/etc/origin/node/node.kubeconfig "node/${NODE_NAME}" ${labels} --overwrite; then
|
|
if ! oc label --config=/etc/origin/node/node.kubeconfig "node/${NODE_NAME}" ${labels} --overwrite; then
|
|
echo "error: Unable to apply labels, will retry in 10" 2>&1
|
|
echo "error: Unable to apply labels, will retry in 10" 2>&1
|
|
- sleep 10
|
|
|
|
|
|
+ sleep 10 &
|
|
|
|
+ wait $!
|
|
continue
|
|
continue
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
+ else
|
|
|
|
+ echo "error: The downloaded node configuration is invalid, exiting" 2>&1
|
|
|
|
+ exit 1
|
|
fi
|
|
fi
|
|
if ! pgrep -U 0 -f 'hyperkube kubelet ' | xargs kill; then
|
|
if ! pgrep -U 0 -f 'hyperkube kubelet ' | xargs kill; then
|
|
echo "error: Unable to restart Kubelet" 2>&1
|
|
echo "error: Unable to restart Kubelet" 2>&1
|
|
fi
|
|
fi
|
|
fi
|
|
fi
|
|
cp -f /tmp/.new /tmp/.old
|
|
cp -f /tmp/.new /tmp/.old
|
|
- sleep 180
|
|
|
|
|
|
+ sleep 180 &
|
|
|
|
+ wait $!
|
|
done
|
|
done
|
|
|
|
|
|
env:
|
|
env:
|
|
@@ -117,7 +153,7 @@ spec:
|
|
# Directory which contains the host configuration. We read from this directory
|
|
# Directory which contains the host configuration. We read from this directory
|
|
- mountPath: /etc/origin/node/
|
|
- mountPath: /etc/origin/node/
|
|
name: host-config
|
|
name: host-config
|
|
- - mountPath: /etc/sysconfig/origin-node
|
|
|
|
|
|
+ - mountPath: /etc/sysconfig
|
|
name: host-sysconfig-node
|
|
name: host-sysconfig-node
|
|
readOnly: true
|
|
readOnly: true
|
|
|
|
|
|
@@ -129,7 +165,4 @@ spec:
|
|
path: /etc/origin/node
|
|
path: /etc/origin/node
|
|
- name: host-sysconfig-node
|
|
- name: host-sysconfig-node
|
|
hostPath:
|
|
hostPath:
|
|
- path: /etc/sysconfig/origin-node
|
|
|
|
- - name: host-modules
|
|
|
|
- hostPath:
|
|
|
|
- path: /lib/modules
|
|
|
|
|
|
+ path: /etc/sysconfig
|