Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

upgrade k8s without deleting etcd data #1038

Merged
merged 10 commits into from
Aug 6, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

kubectl create configmap host-configuration --from-file=host-configuration/
kubectl create configmap docker-credentials --from-file=docker-credentials/
kubectl create configmap gpu-configuration --from-file=gpu-configuration/
kubectl create configmap host-configuration --from-file=host-configuration/ --dry-run -o yaml | kubectl apply --overwrite=true -f -
Copy link
Contributor

@ydye ydye Aug 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What‘s effect of --dry-run here? And what's effect of --overwrite here?
If I remove --overwrite, what will happen? I know when we label the node with overwrite, if the key already exists, it will be overwritten.
But when applying some object, without the --overwrite, it still works. So I wanna know what's the purpose of --overwrite here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --dry-run here is to let create command generate the configuration without executing it. Since we need to read config from host-configuration file, the apply command cannot support reading config from a file. So I leverage the create dry run to generate the config and then apply it to the object.

The --overwrite flag is to resolve the conflict when applying new configuration by overwriting the old config with the new one. If we don't enable overwrite here, when merge the new config with the live config, if conflicts occur, the apply will fail and kubectl will report an error. Here I enable --overwrite is to make sure the new config can be successfully applied to the live object in case the object has been restored by k8s.

kubectl create configmap docker-credentials --from-file=docker-credentials/ --dry-run -o yaml | kubectl apply --overwrite=true -f -
kubectl create configmap gpu-configuration --from-file=gpu-configuration/ --dry-run -o yaml | kubectl apply --overwrite=true -f -
4 changes: 2 additions & 2 deletions pai-management/bootstrap/cluster-configuration/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ pushd $(dirname "$0") > /dev/null
#chmod u+x configmap-create.sh
/bin/bash configmap-create.sh

kubectl create -f secret.yaml
kubectl apply --overwrite=true -f secret.yaml

popd > /dev/null
popd > /dev/null
4 changes: 2 additions & 2 deletions pai-management/bootstrap/drivers/node-label.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

{% for host in machinelist %}
{% if 'gpu' in machineinfo[ machinelist[ host ][ 'machinetype' ] ] %}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} machinetype=gpu
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} machinetype=gpu
{% endif %}
{% endfor %}
{% endfor %}
4 changes: 2 additions & 2 deletions pai-management/bootstrap/drivers/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pushd $(dirname "$0") > /dev/null
#chmod u+x node-label.sh
/bin/bash node-label.sh

kubectl create -f drivers.yaml
kubectl apply --overwrite=true -f drivers.yaml

PYTHONPATH="../.." python -m k8sPaiLibrary.monitorTool.check_node_label_exist -k machinetype -v gpu
ret=$?
Expand All @@ -34,4 +34,4 @@ else
PYTHONPATH="../.." python -m k8sPaiLibrary.monitorTool.check_pod_ready_status -w -k app -v drivers-one-shot
fi

popd > /dev/null
popd > /dev/null
2 changes: 1 addition & 1 deletion pai-management/bootstrap/end-to-end-test/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

pushd $(dirname "$0") > /dev/null

kubectl create -f end-to-end-test.yaml
kubectl apply --overwrite=true -f end-to-end-test.yaml

popd > /dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

kubectl create configmap frameworklauncher-configmap --from-file=frameworklauncher-configuration/
kubectl create configmap frameworklauncher-configmap --from-file=frameworklauncher-configuration/ --dry-run -o yaml | kubectl apply --overwrite=true -f -

kubectl create configmap frameworklauncher-delete --from-file=frameworklauncher-delete/
kubectl create configmap frameworklauncher-delete --from-file=frameworklauncher-delete/ --dry-run -o yaml | kubectl apply --overwrite=true -f -
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

{% for host in machinelist %}
{% if 'launcher' in machinelist[ host ] and machinelist[ host ][ 'launcher' ] == 'true' %}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} launcher=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} launcher=true
{% endif %}
{% endfor %}
{% endfor %}
4 changes: 2 additions & 2 deletions pai-management/bootstrap/frameworklauncher/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ pushd $(dirname "$0") > /dev/null

/bin/bash configmap-create.sh

kubectl create -f frameworklauncher.yaml
kubectl apply --overwrite=true -f frameworklauncher.yaml

popd > /dev/null
popd > /dev/null
2 changes: 1 addition & 1 deletion pai-management/bootstrap/grafana/configmap-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

kubectl create configmap grafana-configuration --from-file=grafana-configuration/
kubectl create configmap grafana-configuration --from-file=grafana-configuration/ --dry-run -o yaml | kubectl apply --overwrite=true -f -
4 changes: 2 additions & 2 deletions pai-management/bootstrap/grafana/node-label.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

{% for host in machinelist %}
{% if 'grafana' in machinelist[ host ] and machinelist[ host ][ 'grafana' ] == 'true' %}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} grafana=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} grafana=true
{% endif %}
{% endfor %}
{% endfor %}
4 changes: 2 additions & 2 deletions pai-management/bootstrap/grafana/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ do
fi
done

kubectl create -f grafana.yaml
kubectl apply --overwrite=true -f grafana.yaml

popd > /dev/null
popd > /dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

kubectl create configmap hadoop-configuration --from-file=hadoop-configuration/
kubectl create configmap hadoop-configuration --from-file=hadoop-configuration/ --dry-run -o yaml | kubectl apply --overwrite=true -f -
2 changes: 1 addition & 1 deletion pai-management/bootstrap/hadoop-batch-job/refresh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ kubectl delete job batch-job-hadoop

kubectl create -f one-time-job-hadoop.yaml

popd > /dev/null
popd > /dev/null
4 changes: 2 additions & 2 deletions pai-management/bootstrap/hadoop-batch-job/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ pushd $(dirname "$0") > /dev/null

/bin/bash configmap-create.sh

kubectl create -f one-time-job-hadoop.yaml
kubectl apply --overwrite=true -f one-time-job-hadoop.yaml

popd > /dev/null
popd > /dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

kubectl create configmap hadoop-data-node-configuration --from-file=hadoop-data-node-configuration/
kubectl create configmap hadoop-data-node-configuration --from-file=hadoop-data-node-configuration/ --dry-run -o yaml | kubectl apply --overwrite=true -f -
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

{% for host in machinelist %}
{% if 'hadoop-data-node' in machinelist[ host ] and machinelist[ host ][ 'hadoop-data-node' ] == 'true' -%}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} hadoop-data-node=true
kubectl label --overwrite nodes {{ machinelist[ host ][ 'nodename' ] }} hadoop-data-node=true
{% endif %}
{% endfor %}
{% endfor %}
4 changes: 2 additions & 2 deletions pai-management/bootstrap/hadoop-data-node/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pushd $(dirname "$0") > /dev/null


# Hadoop data node
kubectl create -f hadoop-data-node.yaml
kubectl apply --overwrite=true -f hadoop-data-node.yaml

PYTHONPATH="../.." python -m k8sPaiLibrary.monitorTool.check_node_label_exist -k hadoop-data-node -v "true"
ret=$?
Expand All @@ -42,4 +42,4 @@ else
fi


popd > /dev/null
popd > /dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

kubectl create configmap hadoop-jobhistory-configuration --from-file=hadoop-jobhistory-configuration/
kubectl create configmap hadoop-jobhistory-configuration --from-file=hadoop-jobhistory-configuration/ --dry-run -o yaml | kubectl apply --overwrite=true -f -
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

{% for host in machinelist %}
{% if 'jobhistory' in machinelist[ host ] and machinelist[ host ][ 'jobhistory' ] == 'true' -%}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} jobhistory=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} jobhistory=true
{% endif %}
{% endfor %}
{% endfor %}
4 changes: 2 additions & 2 deletions pai-management/bootstrap/hadoop-jobhistory/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pushd $(dirname "$0") > /dev/null


# Hadoop jobhistory
kubectl create -f hadoop-jobhistory.yaml
kubectl apply --overwrite=true -f hadoop-jobhistory.yaml

PYTHONPATH="../.." python -m k8sPaiLibrary.monitorTool.check_node_label_exist -k jobhistory -v "true"
ret=$?
Expand All @@ -41,4 +41,4 @@ else
PYTHONPATH="../.." python -m k8sPaiLibrary.monitorTool.check_pod_ready_status -w -k app -v hadoop-jobhistory-service
fi

popd > /dev/null
popd > /dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

kubectl create configmap hadoop-name-node-configuration --from-file=hadoop-name-node-configuration/
kubectl create configmap hadoop-name-node-configuration --from-file=hadoop-name-node-configuration/ --dry-run -o yaml | kubectl apply --overwrite=true -f -
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

{% for host in machinelist %}
{% if 'hadoop-name-node' in machinelist[ host ] and machinelist[ host ][ 'hadoop-name-node' ] == 'true' -%}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} hadoop-name-node=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} hadoop-name-node=true
{% endif %}
{% endfor %}
{% endfor %}
4 changes: 2 additions & 2 deletions pai-management/bootstrap/hadoop-name-node/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pushd $(dirname "$0") > /dev/null


# Hadoop name node
kubectl create -f hadoop-name-node.yaml
kubectl apply --overwrite=true -f hadoop-name-node.yaml

PYTHONPATH="../.." python -m k8sPaiLibrary.monitorTool.check_node_label_exist -k hadoop-name-node -v "true"
ret=$?
Expand All @@ -42,4 +42,4 @@ else
fi


popd > /dev/null
popd > /dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

kubectl create configmap hadoop-node-manager-configuration --from-file=hadoop-node-manager-configuration/
kubectl create configmap hadoop-node-manager-configuration --from-file=hadoop-node-manager-configuration/ --dry-run -o yaml | kubectl apply --overwrite=true -f -
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

{% for host in machinelist %}
{% if 'hadoop-node-manager' in machinelist[ host ] and machinelist[ host ][ 'hadoop-node-manager' ] == 'true' -%}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} hadoop-node-manager=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} hadoop-node-manager=true
{% endif %}
{% endfor %}
{% endfor %}
4 changes: 2 additions & 2 deletions pai-management/bootstrap/hadoop-node-manager/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pushd $(dirname "$0") > /dev/null


# Hadoop node manager
kubectl create -f hadoop-node-manager.yaml
kubectl apply --overwrite=true -f hadoop-node-manager.yaml

PYTHONPATH="../.." python -m k8sPaiLibrary.monitorTool.check_node_label_exist -k hadoop-node-manager -v "true"
ret=$?
Expand All @@ -42,4 +42,4 @@ else
fi


popd > /dev/null
popd > /dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

kubectl create configmap hadoop-resource-manager-configuration --from-file=hadoop-resource-manager-configuration/
kubectl create configmap hadoop-resource-manager-configuration --from-file=hadoop-resource-manager-configuration/ --dry-run -o yaml| kubectl apply --overwrite=true -f -
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

{% for host in machinelist %}
{% if 'hadoop-resource-manager' in machinelist[ host ] and machinelist[ host ][ 'hadoop-resource-manager' ] == 'true' -%}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} hadoop-resource-manager=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} hadoop-resource-manager=true
{% endif %}
{% endfor %}
{% endfor %}
4 changes: 2 additions & 2 deletions pai-management/bootstrap/hadoop-resource-manager/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pushd $(dirname "$0") > /dev/null


# Hadoop resource manager
kubectl create -f hadoop-resource-manager.yaml
kubectl apply --overwrite=true -f hadoop-resource-manager.yaml

PYTHONPATH="../.." python -m k8sPaiLibrary.monitorTool.check_node_label_exist -k hadoop-resource-manager -v "true"
ret=$?
Expand All @@ -42,4 +42,4 @@ else
fi


popd > /dev/null
popd > /dev/null
8 changes: 4 additions & 4 deletions pai-management/bootstrap/prometheus/node-label.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

{% for host in machinelist %}
{% if 'prometheus' in machinelist[ host ] and machinelist[ host ][ 'prometheus' ] == 'true' %}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} prometheus=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} prometheus=true
{% endif %}
{% if 'node-exporter' in machinelist[ host ] and machinelist[ host ][ 'node-exporter' ] == 'true' %}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} node-exporter=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} node-exporter=true
{% endif %}
{% if 'watchdog' in machinelist[ host ] and machinelist[ host ][ 'watchdog' ] == 'true' %}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} watchdog=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} watchdog=true
{% endif %}
{% if 'alert-manager' in machinelist[ host ] and machinelist[ host ][ 'alert-manager' ] == 'true' %}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} alertmanager=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} alertmanager=true
{% endif %}
{% endfor %}
17 changes: 9 additions & 8 deletions pai-management/bootstrap/prometheus/start.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ pushd $(dirname "$0") > /dev/null

/bin/bash node-label.sh

kubectl create -f prometheus-configmap.yaml
kubectl create configmap prometheus-alert --from-file=../../../prometheus/prometheus-alert
kubectl create -f node-exporter-ds.yaml
kubectl create -f prometheus-deployment.yaml
kubectl create -f watchdog-configmap.yaml
kubectl create -f watchdog-ds.yaml
kubectl apply --overwrite=true -f prometheus-configmap.yaml
kubectl create configmap prometheus-alert --from-file=../../../prometheus/prometheus-alert --dry-run -o yaml | kubectl apply --overwrite=true -f -
kubectl apply --overwrite=true -f node-exporter-ds.yaml
kubectl apply --overwrite=true -f prometheus-deployment.yaml
kubectl apply --overwrite=true -f watchdog-configmap.yaml
kubectl apply --overwrite=true -f watchdog-ds.yaml

{% if clusterinfo['prometheusinfo']['alerting'] %}
kubectl create -f alert-configmap.yaml
kubectl create -f alert-deployment.yaml
kubectl apply --overwrite=true -f alert-configmap.yaml
kubectl apply --overwrite=true -f alert-deployment.yaml
{% endif %}

popd > /dev/null
4 changes: 2 additions & 2 deletions pai-management/bootstrap/pylon/node-label.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

{% for host in machinelist %}
{% if 'pylon' in machinelist[ host ] and machinelist[ host ][ 'pylon' ] == 'true' %}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} pylon=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} pylon=true
{% endif %}
{% endfor %}
{% endfor %}
4 changes: 2 additions & 2 deletions pai-management/bootstrap/pylon/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ pushd $(dirname "$0") > /dev/null

/bin/bash node-label.sh

kubectl create -f pylon.yaml
kubectl apply --overwrite=true -f pylon.yaml

popd > /dev/null
popd > /dev/null
4 changes: 2 additions & 2 deletions pai-management/bootstrap/rest-server/node-label.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

{% for host in machinelist %}
{% if 'restserver' in machinelist[ host ] and machinelist[ host ][ 'restserver' ] == 'true' %}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} restserver=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} restserver=true
{% endif %}
{% endfor %}
{% endfor %}
4 changes: 2 additions & 2 deletions pai-management/bootstrap/rest-server/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ pushd $(dirname "$0") > /dev/null

/bin/bash node-label.sh

kubectl create -f rest-server.yaml
kubectl apply --overwrite=true -f rest-server.yaml

popd > /dev/null
popd > /dev/null
4 changes: 2 additions & 2 deletions pai-management/bootstrap/webportal/node-label.sh.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

{% for host in machinelist %}
{% if 'webportal' in machinelist[ host ] and machinelist[ host ][ 'webportal' ] == 'true' %}
kubectl label nodes {{ machinelist[ host ][ 'nodename' ] }} webportal=true
kubectl label --overwrite=true nodes {{ machinelist[ host ][ 'nodename' ] }} webportal=true
{% endif %}
{% endfor %}
{% endfor %}
4 changes: 2 additions & 2 deletions pai-management/bootstrap/webportal/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ pushd $(dirname "$0") > /dev/null

/bin/bash node-label.sh

kubectl create -f webportal.yaml
kubectl apply --overwrite=true -f webportal.yaml

popd > /dev/null
popd > /dev/null
Loading