1. kubelet can automatically register nodes, so we don't need to register nodes. 2. When we remove a node from the cluster, the nova instance is terminated. So the instance has no stop process to run unregister script. Heat has a spec [1] to add stop deletion policy now. After this function is merged, I will add unregister script back. [1] https://review.openstack.org/#/c/243012/ Change-Id: I9b1ea0eda74f9bfba8b87c67c2bd063c62460336 Partial-Bug: #1511570changes/83/241183/6
parent
1078891c24
commit
c075bc7ce0
@ -1,52 +0,0 @@
|
||||
#cloud-config
|
||||
merge_how: dict(recurse_array)+list(append)
|
||||
write_files:
|
||||
- path: /usr/local/bin/kube-register
|
||||
permissions: "0755"
|
||||
owner: root
|
||||
content: |
|
||||
#!/bin/sh
|
||||
|
||||
. /etc/sysconfig/heat-params
|
||||
KUBE_PROTOCOL="https"
|
||||
KUBE_CONFIG=""
|
||||
CURL_OPTIONS=""
|
||||
if [ "$TLS_DISABLED" == "True" ]; then
|
||||
KUBE_PROTOCOL="http"
|
||||
else
|
||||
KUBE_CONFIG="--kubeconfig=/srv/kubernetes/kubeconfig.yaml"
|
||||
CURL_OPTIONS="--cacert /srv/kubernetes/ca.crt"
|
||||
CURL_OPTIONS="$CURL_OPTIONS --key /srv/kubernetes/client.key"
|
||||
CURL_OPTIONS="$CURL_OPTIONS --cert /srv/kubernetes/client.crt"
|
||||
fi
|
||||
master_url="$KUBE_PROTOCOL://$KUBE_MASTER_IP:$KUBE_API_PORT"
|
||||
nova_instance_name=$(hostname -s)
|
||||
|
||||
# wait for master api
|
||||
until curl -o /dev/null ${CURL_OPTIONS} -sf "${master_url}/healthz"; do
|
||||
echo "waiting for kubernetes master"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
if [ "$1" = "-u" ]; then
|
||||
echo "unregistering minion $nova_instance_name"
|
||||
kubectl -s ${master_url} ${KUBE_CONFIG} delete node/$nova_instance_name
|
||||
else
|
||||
echo "registering minion $nova_instance_name"
|
||||
cpu=$(($(nproc) * 1000))
|
||||
memory=$(awk '/MemTotal: /{print $2 * 1024}' /proc/meminfo)
|
||||
|
||||
cat <<EOF | kubectl create -s ${master_url} ${KUBE_CONFIG} -f-
|
||||
apiVersion: v1
|
||||
id: $nova_instance_name
|
||||
kind: Node
|
||||
resources:
|
||||
capacity:
|
||||
cpu: $cpu
|
||||
memory: $memory
|
||||
metadata:
|
||||
name: $nova_instance_name
|
||||
spec:
|
||||
externalID: $nova_instance_name
|
||||
EOF
|
||||
fi
|
Loading…
Reference in new issue