From cf6666b7286ef35d9b8567e036b5db1631f81cd0 Mon Sep 17 00:00:00 2001 From: lloretgalleg <illoret@indra.es> Date: Wed, 29 Jul 2020 10:18:26 +0000 Subject: [PATCH] New version with untarred helm chart Signed-off-by: lloretgalleg <illoret@indra.es> --- simple_ee_vnf/cloud_init/cloud-config.txt | 10 +- simple_ee_vnf/helm-charts/eechart-0.1.0.tgz | Bin 5359 -> 0 bytes simple_ee_vnf/helm-charts/eechart/.helmignore | 22 +++++ simple_ee_vnf/helm-charts/eechart/Chart.yaml | 5 + .../helm-charts/eechart/source/install.sh | 29 ++++++ .../helm-charts/eechart/source/vnf_ee.py | 92 ++++++++++++++++++ .../helm-charts/eechart/templates/NOTES.txt | 21 ++++ .../eechart/templates/_helpers.tpl | 56 +++++++++++ .../eechart/templates/configmap.yaml | 6 ++ .../eechart/templates/ingress.yaml | 41 ++++++++ .../eechart/templates/service.yaml | 16 +++ .../eechart/templates/serviceaccount.yaml | 8 ++ .../eechart/templates/statefulset.yaml | 65 +++++++++++++ .../templates/tests/test-connection.yaml | 15 +++ simple_ee_vnf/helm-charts/eechart/values.yaml | 68 +++++++++++++ simple_ee_vnf/simple_ee_vnfd.yaml | 9 +- 16 files changed, 448 insertions(+), 15 deletions(-) delete mode 100644 simple_ee_vnf/helm-charts/eechart-0.1.0.tgz create mode 100755 simple_ee_vnf/helm-charts/eechart/.helmignore create mode 100755 simple_ee_vnf/helm-charts/eechart/Chart.yaml create mode 100755 simple_ee_vnf/helm-charts/eechart/source/install.sh create mode 100755 simple_ee_vnf/helm-charts/eechart/source/vnf_ee.py create mode 100755 simple_ee_vnf/helm-charts/eechart/templates/NOTES.txt create mode 100755 simple_ee_vnf/helm-charts/eechart/templates/_helpers.tpl create mode 100755 simple_ee_vnf/helm-charts/eechart/templates/configmap.yaml create mode 100755 simple_ee_vnf/helm-charts/eechart/templates/ingress.yaml create mode 100755 simple_ee_vnf/helm-charts/eechart/templates/service.yaml create mode 100755 simple_ee_vnf/helm-charts/eechart/templates/serviceaccount.yaml create mode 100755 simple_ee_vnf/helm-charts/eechart/templates/statefulset.yaml create mode 100755 simple_ee_vnf/helm-charts/eechart/templates/tests/test-connection.yaml create mode 100755 simple_ee_vnf/helm-charts/eechart/values.yaml diff --git a/simple_ee_vnf/cloud_init/cloud-config.txt b/simple_ee_vnf/cloud_init/cloud-config.txt index e22d345c..a9acf627 100755 --- a/simple_ee_vnf/cloud_init/cloud-config.txt +++ b/simple_ee_vnf/cloud_init/cloud-config.txt @@ -1,12 +1,4 @@ #cloud-config -password: osm4u +password: osm2020 chpasswd: { expire: False } ssh_pwauth: True - -write_files: -- content: | - # My new helloworld file - - owner: root:root - permissions: '0644' - path: /root/helloworld.txt diff --git a/simple_ee_vnf/helm-charts/eechart-0.1.0.tgz b/simple_ee_vnf/helm-charts/eechart-0.1.0.tgz deleted file mode 100644 index 98527426330dc335baa22798114771e45df27c6f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 5359 zcmV<L6cFnliwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PH+#Pb0aq`?)3lL!HhX4a|~G0>jMSzT)a|7|tHFGk^#?tJP?P zobF2E#clW6?m%vq``fQ<_d5wNkHhRr_(LA<a=BctmtA%vMpGhn@6db(bCR&{zIy5R z`~BB@d-l8E@3+7EgWbLF2D`6b_jh++z1rRTu0Pm$wX^db^uInS%Oz8q$nW}J+*f;W zf005``W~gCf`>30cqC2Bzy2WT`(BJHk~Gz}>U8)Hj*ei8ECDMw9w!NgkV}y_E86yh zLD2WU_28b$y`|9q8DSZ!|BL~+NB?(T@4ag2|8D>F?vwsMM(MyC9FvS`a1sDxAq#a5 zybfGUsRF8iz^@1I-gd`ACPZtDVN4ksfHxR1A`xapQZizwKnoZlq(mu<fpRTiE;0!k zlavvSD)2msDWefN6dBhc3_On}WP+gwATbq+Y9Z$#P{xEr-J8fXLi7MMnS@|*Xb&LG z7&{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 zB0^<fro5oH<uW3M1&we0m4SEJ2;(Jq+u$EYSZI`>o{G3ysNHQ&+A)9F;AZowWo;9_ z$zdztjTUA_O*yOrwz^2D!p3@b(|<=DU&?I_+qfl?^-i|7o_2Ac%2RnNPvy^7{yzW! N|NjGf*5d$Z003;efdK#j diff --git a/simple_ee_vnf/helm-charts/eechart/.helmignore b/simple_ee_vnf/helm-charts/eechart/.helmignore new file mode 100755 index 00000000..50af0317 --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/.helmignore @@ -0,0 +1,22 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/simple_ee_vnf/helm-charts/eechart/Chart.yaml b/simple_ee_vnf/helm-charts/eechart/Chart.yaml new file mode 100755 index 00000000..414c5f1a --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v1 +appVersion: "1.0" +description: OSM EE helm chart +name: eechart +version: 0.1.0 diff --git a/simple_ee_vnf/helm-charts/eechart/source/install.sh b/simple_ee_vnf/helm-charts/eechart/source/install.sh new file mode 100755 index 00000000..248ec481 --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/source/install.sh @@ -0,0 +1,29 @@ +#!/bin/bash +## +# Copyright 2015 Telefonica Investigacion y Desarrollo, S.A.U. +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +## + +# This script is intended for launching RO from a docker container. +# It waits for mysql server ready, normally running on a separate container, ... +# then it checks if database is present and creates it if needed. +# Finally it launches RO server. + +echo "Sample install.sh from source dir" + +# Install libraries +#apt-get install -y ... + +# Install library to execute command remotely by ssh +python3 -m pip install asyncssh + diff --git a/simple_ee_vnf/helm-charts/eechart/source/vnf_ee.py b/simple_ee_vnf/helm-charts/eechart/source/vnf_ee.py new file mode 100755 index 00000000..3f4a15bb --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/source/vnf_ee.py @@ -0,0 +1,92 @@ +## +# Copyright 2019 Telefonica Investigacion y Desarrollo, S.A.U. +# This file is part of OSM +# 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# For those usages not covered by the Apache License, Version 2.0 please +# contact with: nfvlabs@tid.es +## + +import asyncio +import logging +import asyncssh + + +from osm_ee.exceptions import VnfException + + +class VnfEE: + + def __init__(self, config_params): + self.logger = logging.getLogger('osm_ee.vnf') + self.config_params = config_params + + async def config(self, id, params): + self.logger.debug("Execute action config params: {}".format(params)) + # Config action is special, params are merged with previous config calls + self.config_params.update(params) + required_params = ["ssh-hostname"] + self._check_required_params(self.config_params, required_params) + yield "OK", "Configured" + + async def touch(self, id, params): + self.logger.debug("Execute action touch params: '{}', type: {}".format(params, type(params))) + + try: + self._check_required_params(params, ["file-path"]) + + # Check if filename is a single file or a list + file_list = params["file-path"] if isinstance(params["file-path"], list) else [params["file-path"]] + file_list_length = len(file_list) + + async with asyncssh.connect(self.config_params["ssh-hostname"], + password=self.config_params.get("ssh-password"), + username=self.config_params.get("ssh-username"), + known_hosts=None) as conn: + for index, file_name in enumerate(file_list): + command = "touch {}".format(file_name) + self.logger.debug("Execute remote command: '{}'".format(command)) + result = await conn.run(command) + self.logger.debug("Create command result: {}".format(result)) + + if result.exit_status != 0: + detailed_status = result.stderr + # TODO - ok but with some errors + else: + detailed_status = "Created file {}".format(file_name) + + if index + 1 != file_list_length: + yield "PROCESSING", detailed_status + else: + yield "OK", detailed_status + except Exception as e: + self.logger.error("Error creating remote file: {}".format(repr(e))) + yield "ERROR", str(e) + + async def sleep(self, id, params): + self.logger.debug("Execute action sleep, params: {}".format(params)) + + for i in range(3): + await asyncio.sleep(5) + self.logger.debug("Temporal result return, params: {}".format(params)) + yield "PROCESSING", f"Processing {i} action id {id}" + yield "OK", f"Processed action id {id}" + + @staticmethod + def _check_required_params(params, required_params): + for required_param in required_params: + if required_param not in params: + raise VnfException("Missing required param: {}".format(required_param)) diff --git a/simple_ee_vnf/helm-charts/eechart/templates/NOTES.txt b/simple_ee_vnf/helm-charts/eechart/templates/NOTES.txt new file mode 100755 index 00000000..c52fc2c4 --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "eechart.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "eechart.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "eechart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "eechart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/simple_ee_vnf/helm-charts/eechart/templates/_helpers.tpl b/simple_ee_vnf/helm-charts/eechart/templates/_helpers.tpl new file mode 100755 index 00000000..d3e28e02 --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/templates/_helpers.tpl @@ -0,0 +1,56 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "eechart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "eechart.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "eechart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "eechart.labels" -}} +app.kubernetes.io/name: {{ include "eechart.name" . }} +helm.sh/chart: {{ include "eechart.chart" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "eechart.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "eechart.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/simple_ee_vnf/helm-charts/eechart/templates/configmap.yaml b/simple_ee_vnf/helm-charts/eechart/templates/configmap.yaml new file mode 100755 index 00000000..5b9634c7 --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/templates/configmap.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "eechart.fullname" . }} +data: +{{ (.Files.Glob "source/*").AsConfig | indent 2 }} diff --git a/simple_ee_vnf/helm-charts/eechart/templates/ingress.yaml b/simple_ee_vnf/helm-charts/eechart/templates/ingress.yaml new file mode 100755 index 00000000..264f8909 --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/templates/ingress.yaml @@ -0,0 +1,41 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "eechart.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: +{{ include "eechart.labels" . | indent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + backend: + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} +{{- end }} diff --git a/simple_ee_vnf/helm-charts/eechart/templates/service.yaml b/simple_ee_vnf/helm-charts/eechart/templates/service.yaml new file mode 100755 index 00000000..88d38d66 --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/templates/service.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "eechart.fullname" . }} + labels: +{{ include "eechart.labels" . | indent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: grpc + protocol: TCP + name: grpc + selector: + app.kubernetes.io/name: {{ include "eechart.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} diff --git a/simple_ee_vnf/helm-charts/eechart/templates/serviceaccount.yaml b/simple_ee_vnf/helm-charts/eechart/templates/serviceaccount.yaml new file mode 100755 index 00000000..be615a5f --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/templates/serviceaccount.yaml @@ -0,0 +1,8 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "eechart.serviceAccountName" . }} + labels: +{{ include "eechart.labels" . | indent 4 }} +{{- end -}} diff --git a/simple_ee_vnf/helm-charts/eechart/templates/statefulset.yaml b/simple_ee_vnf/helm-charts/eechart/templates/statefulset.yaml new file mode 100755 index 00000000..3d721fe2 --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/templates/statefulset.yaml @@ -0,0 +1,65 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "eechart.fullname" . }} + labels: +{{ include "eechart.labels" . | indent 4 }} +spec: + serviceName: {{ include "eechart.fullname" . }} + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "eechart.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "eechart.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + imagePullSecrets: + - name: regcred + serviceAccountName: {{ template "eechart.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: grpc + containerPort: 50051 + protocol: TCP + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: osm-ee + mountPath: /app/storage + - name: osm-ee-source + mountPath: /app/EE/osm_ee/vnf + volumes: + - name: osm-ee-source + configMap: + name: {{ include "eechart.fullname" . }} + volumeClaimTemplates: + - metadata: + name: osm-ee + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 1Gi + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/simple_ee_vnf/helm-charts/eechart/templates/tests/test-connection.yaml b/simple_ee_vnf/helm-charts/eechart/templates/tests/test-connection.yaml new file mode 100755 index 00000000..e52b7b8b --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "eechart.fullname" . }}-test-connection" + labels: +{{ include "eechart.labels" . | indent 4 }} + annotations: + "helm.sh/hook": test-success +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "eechart.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/simple_ee_vnf/helm-charts/eechart/values.yaml b/simple_ee_vnf/helm-charts/eechart/values.yaml new file mode 100755 index 00000000..84cb21b7 --- /dev/null +++ b/simple_ee_vnf/helm-charts/eechart/values.yaml @@ -0,0 +1,68 @@ +# Default values for eechart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: illoret/grpcee + tag: latest + pullPolicy: IfNotPresent + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 50050 + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: [] + + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/simple_ee_vnf/simple_ee_vnfd.yaml b/simple_ee_vnf/simple_ee_vnfd.yaml index d1aa5c01..7960bd10 100644 --- a/simple_ee_vnf/simple_ee_vnfd.yaml +++ b/simple_ee_vnf/simple_ee_vnfd.yaml @@ -44,13 +44,10 @@ vnfd-catalog: ssh-access: default-user: ubuntu required: true - #juju: - # charm: simple-proxy execution-environment-list: - id: monitor - helm-chart: eechart-0.1.0.tgz - metric-service: monitor-snmp-exporter - connection-point-ref: vnf-monitor-cp + helm-chart: eechart + connection-point-ref: vnf-mgmt initial-config-primitive: - seq: "1" name: config @@ -61,7 +58,7 @@ vnfd-catalog: - name: ssh-username value: ubuntu - name: ssh-password - value: osm4u + value: osm2020 - seq: "2" name: touch execution-environment-ref: monitor -- GitLab