From 2446f49ba93061e1ca7e53f3341210fb30d7d243 Mon Sep 17 00:00:00 2001 From: Jack Lucas Date: Wed, 9 Jun 2021 15:35:45 -0400 Subject: Move healthcheck to a non-python container Use an alpine-based node image as the base for the healthcheck container. This image has no python installations, and so eliminates the issue with python2 in the previous version of the container. Also moves to the most recent LTS release of node (14.17.0). Issue-ID: DCAEGEN2-2737 Signed-off-by: Jack Lucas Change-Id: I0ce96af11adc35632ef8ac7ddddd57db1734fe2c --- healthcheck-container/Dockerfile | 5 +++-- healthcheck-container/README.md | 6 +++--- healthcheck-container/pom.xml | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/healthcheck-container/Dockerfile b/healthcheck-container/Dockerfile index 9b884a7..6a546c6 100644 --- a/healthcheck-container/Dockerfile +++ b/healthcheck-container/Dockerfile @@ -2,6 +2,7 @@ # org.onap.dcae # ================================================================================ # Copyright (c) 2018-2020 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2021 J. F. Lucas. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,9 +17,9 @@ # limitations under the License. # ============LICENSE_END========================================================= # -FROM node:12.15.0 +FROM node:14.17.0-alpine3.13 RUN mkdir -p /opt/app \ - && useradd -d /opt/app health + && adduser -D -h /opt/app health COPY *.js /opt/app/ COPY package.json /opt/app/ RUN chown -R health:health /opt/app diff --git a/healthcheck-container/README.md b/healthcheck-container/README.md index f4185bd..878ef42 100644 --- a/healthcheck-container/README.md +++ b/healthcheck-container/README.md @@ -2,16 +2,16 @@ The Healthcheck service provides a simple HTTP API to check the status of DCAE or DCAE MOD components running in the Kubernetes environment. When it receives any incoming HTTP request, the service makes queries to the Kubernetes API to determine the current status of the DCAE or DCAE MOD components, as seen by Kubernetes. Most components have defined a "readiness probe" (an HTTP healthcheck endpoint or a healthcheck script) that Kubernetes uses to determine readiness. -Two instances of the Healthcheck service are deployed in ONAP: one for DCAE and one for DCAE MOD. +Three instances of the Healthcheck service are deployed in ONAP: one for DCAE (dcaegen2), one for DCAE Helm-deployed microservices (dcaegen2-services), and one for DCAE MOD (dcaemod). The Healthcheck service has two sources for identifying components that should be running: 1. A list of components that are expected to be deployed by Helm as part of the ONAP installation, specified in a JSON array stored in a file at `/opt/app/expected-components.json`. - DCAE and DCAE MOD have configurable deployments. By setting flags in the `values.yaml` file or in an override file, a user can select which components are deployed. The`/opt/app/expected-components.json` file is generated at deployment time based on which components have been selected for deployment. The file is stored in a Kubernetes ConfigMap that is mounted on the healthcheck container at `/opt/app/expected-components.json`. See the Helm charts for DCAE and DCAEMOD in the OOM repository for details on how the ConfigMap is created. + dcaegen2, dcaegen2-services, and dcaemod have configurable deployments. By setting flags in the `values.yaml` file or in an override file, a user can select which components are deployed. The`/opt/app/expected-components.json` file is generated at deployment time based on which components have been selected for deployment. The file is stored in a Kubernetes ConfigMap that is mounted on the healthcheck container at `/opt/app/expected-components.json`. See the Helm charts for DCAE and DCAEMOD in the OOM repository for details on how the ConfigMap is created. 2. Components whose Kubernetes deployments have been marked with the labeled specified by the environment variable `DEPLOY_LABEL`. These are identified by a query to the Kubernetes API requesting a list of all the deployments with the label. The query is made each time an incoming HTTP request is made, so that as new deployments are created, they will be detected and included in the health check. - For the DCAE instance of the Healthcheck service, the `DEPLOY_LABEL` variable is set to `cfydeployment`. This is the label that the DCAE k8s Cloudify plugin uses to mark every deployment that it creates. The DCAE Healthcheck instance therefore includes all components deployed by the DCAE k8s plugin in its health check. For the DCAE MOD instance of the Healthcheck service, the `DEPLOY_LABEL` is not set, so the DCAE MOD health check does not make any checks based on a label. + For the dcaegen2 instance of the Healthcheck service, the `DEPLOY_LABEL` variable is set to `cfydeployment`. This is the label that the DCAE k8s Cloudify plugin uses to mark every deployment that it creates. The dcaegen2 Healthcheck instance therefore includes all components deployed by the DCAE k8s plugin in its health check. For the dcaemod and dcaegen2-services instances of the Healthcheck service, the `DEPLOY_LABEL` is not set, so the dcaemod and dcaegen2-services health checks do not make any checks based on a label. The Healthcheck service returns an HTTP status code of 200 if Kubernetes reports that all of the components that should be running are in a ready state. It returns a status code of 500 if some of the components are not ready. It returns a status code of 503 if some kind of error prevented it from completing a query. diff --git a/healthcheck-container/pom.xml b/healthcheck-container/pom.xml index c2c325f..b4fab76 100644 --- a/healthcheck-container/pom.xml +++ b/healthcheck-container/pom.xml @@ -3,6 +3,7 @@ ================================================================================ Copyright (c) 2018-2020 AT&T Intellectual Property. All rights reserved. Copyright (c) 2020 NOKIA Intellectual Property. All rights reserved. +Copyright (c) 2021 J. F. Lucas. All rights reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -28,7 +29,7 @@ limitations under the License. org.onap.dcaegen2.deployments healthcheck-container dcaegen2-deployments-healthcheck-container - 2.1.0 + 2.2.0 http://maven.apache.org UTF-8 -- cgit 1.2.3-korg