Commit 70749df6 authored by cubag's avatar cubag
Browse files

Merge branch 'basic26-basic27' into 'master'

Adds packages for secure helm EE and update helm EE robot tests

See merge request !210
parents bfea4da0 bbdeb1d9
Pipeline #8098 failed with stage
in 1 minute and 33 seconds
nsd:
nsd:
- description: NS with 2 VNFs with cloudinit connected by datanet and mgmtnet VLs
df:
- id: default-df
vnf-profile:
- id: simple
virtual-link-connectivity:
- constituent-cpd-id:
- constituent-base-element-id: simple
constituent-cpd-id: vnf-mgmt-ext
virtual-link-profile-id: mgmtnet
vnfd-id: simple_secure_ee-vnf
id: simple_secure_ee-ns
name: simple_secure_ee-ns
version: 1.0
virtual-link-desc:
- id: mgmtnet
mgmt-network: true
vnfd-id:
- simple_secure_ee-vnf
#cloud-config
password: osm2020
chpasswd: { expire: False }
ssh_pwauth: True
# 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/
apiVersion: v1
appVersion: "1.0"
description: OSM EE helm chart
name: eechart
version: 0.1.0
#!/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
##
# 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))
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 }}
{{/* 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 -}}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "eechart.fullname" . }}
data:
{{ (.Files.Glob "source/*").AsConfig | indent 2 }}
{{- 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 }}
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 }}
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "eechart.serviceAccountName" . }}
labels:
{{ include "eechart.labels" . | indent 4 }}
{{- end -}}
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
- name: grpc-tls
mountPath: /etc/ssl/grpc-tls/
volumes:
- name: osm-ee-source
configMap:
name: {{ include "eechart.fullname" . }}
- name: grpc-tls
secret:
secretName: ee-tls-{{ .Values.global.osm.ns_id }}
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 }}
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
# Default values for eechart.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: gcuba/docker-api-fe
tag: grpc-tls
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: {}
vnfd:
description: A VNF consisting of 1 VDU with cloud-init, and a monitoring ee
df:
- id: default-df
instantiation-level:
- id: default-instantiation-level
vdu-level:
- number-of-instances: 1
vdu-id: mgmtVM
vdu-profile:
- id: mgmtVM
min-number-of-instances: 1
lcm-operations-configuration:
operate-vnf-op-config:
day1-2:
- config-access:
ssh-access:
default-user: ubuntu
required: true
config-primitive:
- execution-environment-primitive: touch
execution-environment-ref: monitor
name: touch
parameter:
- data-type: STRING
default-value: /home/ubuntu/touched
name: file-path
- execution-environment-primitive: sleep
execution-environment-ref: monitor
name: sleep
execution-environment-list:
- external-connection-point-ref: vnf-mgmt-ext
helm-chart: eechart
id: monitor
id: simple_secure_ee-vnf
initial-config-primitive:
- execution-environment-ref: monitor
name: config
parameter:
- name: ssh-hostname
value: <rw_mgmt_ip>
- name: ssh-username
value: ubuntu
- name: ssh-password
value: osm2020
seq: 1
- execution-environment-ref: monitor
name: touch
parameter:
- name: file-path
value: /home/ubuntu/first-touch
seq: 2
ext-cpd:
- id: vnf-mgmt-ext
int-cpd:
cpd: mgmtVM-eth0-int
vdu-id: mgmtVM
id: simple_secure_ee-vnf
mgmt-cp: vnf-mgmt-ext
product-name: simple_secure_ee-vnf
sw-image-desc:
- id: ubuntu18.04
image: ubuntu18.04
name: ubuntu18.04
vdu:
- cloud-init-file: cloud-config.txt
id: mgmtVM
int-cpd:
- id: mgmtVM-eth0-int
virtual-network-interface-requirement:
- name: mgmtVM-eth0
position: 1
virtual-interface:
type: PARAVIRT
name: mgmtVM
sw-image-desc: ubuntu18.04
virtual-compute-desc: mgmtVM-compute
virtual-storage-desc:
- mgmtVM-storage
version: 1.0
virtual-compute-desc:
- id: mgmtVM-compute
virtual-cpu:
num-virtual-cpu: 1
pinning:
policy: static
thread-policy: PREFER
virtual-memory:
mempage-size: LARGE
numa-enabled: true
numa-node-policy:
mem-policy: STRICT
node:
- id: 1
node-cnt: 1
size: 1.0
virtual-storage-desc:
- id: mgmtVM-storage
size-of-storage: 20
#cloud-config
password: osm2020
chpasswd: { expire: False }
ssh_pwauth: True
# 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/
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment