Add npd_enabled label

Change-Id: Id3c5fdda6424d1a51f2e60ae26ca3069d93e00ee
Story: 2004782
Task: 34192
Signed-off-by: Diogo Guerra <dy090.guerra@gmail.com>
This commit is contained in:
Diogo Guerra 2019-06-20 17:18:08 +02:00
parent 77d4408fc4
commit 530372b140
8 changed files with 54 additions and 15 deletions

View File

@ -414,6 +414,9 @@ the table are linked to more details elsewhere in the user guide.
+---------------------------------------+--------------------+---------------+
| `max_node_count`_ | see below | see below |
+---------------------------------------+--------------------+---------------+
| `npd_enabled`_ | - true | true |
| | - false | |
+---------------------------------------+--------------------+---------------+
Cluster
-------
@ -1318,6 +1321,9 @@ _`max_node_count`
The maxmium node count of the cluster when doing auto scaling or auto
healing.
_`npd_enabled`
Set Node Problem Detector service enabled or disabled. Default enabled.
External load balancer for services
-----------------------------------

View File

@ -7,13 +7,15 @@ printf "Starting to run ${step}\n"
_gcr_prefix=${CONTAINER_INFRA_PREFIX:-k8s.gcr.io/}
# Generate Node Problem Detector manifest file
NPD_DEPLOY=/srv/magnum/kubernetes/manifests/npd.yaml
# Either auto scaling or auto healing we need CA to be deployed
if [ "$(echo $AUTO_HEALING_ENABLED | tr '[:upper:]' '[:lower:]')" = "true" || "$(echo $NPD_ENABLED | tr '[:upper:]' '[:lower:]')" = "true"]; then
# Generate Node Problem Detector manifest file
NPD_DEPLOY=/srv/magnum/kubernetes/manifests/npd.yaml
[ -f ${NPD_DEPLOY} ] || {
echo "Writing File: $NPD_DEPLOY"
mkdir -p $(dirname ${NPD_DEPLOY})
cat << EOF > ${NPD_DEPLOY}
[ -f ${NPD_DEPLOY} ] || {
echo "Writing File: $NPD_DEPLOY"
mkdir -p $(dirname ${NPD_DEPLOY})
cat << EOF > ${NPD_DEPLOY}
apiVersion: v1
kind: ServiceAccount
metadata:
@ -104,17 +106,19 @@ spec:
- key: "CriticalAddonsOnly"
operator: "Exists"
EOF
}
}
echo "Waiting for Kubernetes API..."
until [ "ok" = "$(curl --silent http://127.0.0.1:8080/healthz)" ]
do
sleep 5
done
echo "Waiting for Kubernetes API..."
until [ "ok" = "$(curl --silent http://127.0.0.1:8080/healthz)" ]
do
sleep 5
done
kubectl apply -f ${NPD_DEPLOY}
kubectl apply -f ${NPD_DEPLOY}
printf "Finished running ${step}\n"
fi
printf "Finished running ${step}\n"
_docker_draino_prefix=${CONTAINER_INFRA_PREFIX:-docker.io/planetlabs/}
step="enable-auto-healing"

View File

@ -100,6 +100,7 @@ HEAT_PARAMS=/etc/sysconfig/heat-params
AUTOSCALER_TAG="$AUTOSCALER_TAG"
MIN_NODE_COUNT="$MIN_NODE_COUNT"
MAX_NODE_COUNT="$MAX_NODE_COUNT"
NPD_ENABLED="$NPD_ENABLED"
EOF
}

View File

@ -140,7 +140,7 @@ class K8sFedoraTemplateDefinition(k8s_template_def.K8sTemplateDefinition):
'nginx_ingress_controller_tag',
'auto_healing_enabled', 'auto_scaling_enabled',
'draino_tag', 'autoscaler_tag',
'min_node_count', 'max_node_count']
'min_node_count', 'max_node_count', 'npd_enabled']
for label in label_list:
label_value = cluster.labels.get(label)

View File

@ -648,6 +648,12 @@ parameters:
max batch size when doing rolling upgrade
default: 1
npd_enabled:
type: boolean
description: >
true if the npd service should be launched
default:
true
resources:
@ -941,6 +947,7 @@ resources:
autoscaler_tag: {get_param: autoscaler_tag}
min_node_count: {get_param: min_node_count}
max_node_count: {get_param: max_node_count}
npd_enabled: {get_param: npd_enabled}
kube_cluster_config:
type: OS::Heat::SoftwareConfig
@ -1075,6 +1082,7 @@ resources:
octavia_enabled: {get_param: octavia_enabled}
heat_container_agent_tag: {get_param: heat_container_agent_tag}
auto_healing_enabled: {get_param: auto_healing_enabled}
npd_enabled: {get_param: npd_enabled}
outputs:

View File

@ -483,6 +483,13 @@ parameters:
description: >
maximum node count of cluster workers when doing scale up
npd_enabled:
type: boolean
description: >
true if the npd service should be launched
default:
true
resources:
######################################################################
#
@ -626,6 +633,7 @@ resources:
"$AUTOSCALER_TAG": {get_param: autoscaler_tag}
"$MIN_NODE_COUNT": {get_param: min_node_count}
"$MAX_NODE_COUNT": {get_param: max_node_count}
"$NPD_ENABLED": {get_param: npd_enabled}
- get_file: ../../common/templates/kubernetes/fragments/make-cert.sh
- get_file: ../../common/templates/kubernetes/fragments/configure-etcd.sh
- get_file: ../../common/templates/kubernetes/fragments/write-kube-os-config.sh

View File

@ -281,6 +281,13 @@ parameters:
description: >
true if the auto healing feature should be enabled
npd_enabled:
type: boolean
description: >
true if the npd service should be launched
default:
true
resources:
agent_config:
@ -366,6 +373,7 @@ resources:
$OCTAVIA_ENABLED: {get_param: octavia_enabled}
$HEAT_CONTAINER_AGENT_TAG: {get_param: heat_container_agent_tag}
$AUTO_HEALING_ENABLED: {get_param: auto_healing_enabled}
$NPD_ENABLED: {get_param: npd_enabled}
- get_file: ../../common/templates/kubernetes/fragments/write-kube-os-config.sh
- get_file: ../../common/templates/kubernetes/fragments/make-cert-client.sh
- get_file: ../../common/templates/fragments/configure-docker-registry.sh

View File

@ -528,6 +528,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
autoscaler_tag = mock_cluster.labels.get('autoscaler_tag')
min_node_count = mock_cluster.labels.get('min_node_count')
max_node_count = mock_cluster.labels.get('max_node_count')
npd_enabled = mock_cluster.labels.get('npd_enabled')
master_image = mock_cluster_template.image_id
minion_image = mock_cluster_template.image_id
@ -604,6 +605,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
'traefik_ingress_controller_tag': traefik_ingress_controller_tag,
'master_image': master_image,
'minion_image': minion_image,
'npd_enabled': npd_enabled,
'kube_version': kube_tag,
}}
mock_get_params.assert_called_once_with(mock_context,
@ -931,6 +933,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
autoscaler_tag = mock_cluster.labels.get('autoscaler_tag')
min_node_count = mock_cluster.labels.get('min_node_count')
max_node_count = mock_cluster.labels.get('max_node_count')
npd_enabled = mock_cluster.labels.get('npd_enabled')
master_image = mock_cluster_template.image_id
minion_image = mock_cluster_template.image_id
@ -1009,6 +1012,7 @@ class AtomicK8sTemplateDefinitionTestCase(BaseK8sTemplateDefinitionTestCase):
'traefik_ingress_controller_tag': traefik_ingress_controller_tag,
'master_image': master_image,
'minion_image': minion_image,
'npd_enabled': npd_enabled,
'kube_version': kube_tag,
}}
mock_get_params.assert_called_once_with(mock_context,