summaryrefslogtreecommitdiffstats
path: root/kubernetes/robot/templates
diff options
context:
space:
mode:
authorSylvain Desbureaux <sylvain.desbureaux@orange.com>2020-12-07 10:28:24 +0100
committerSylvain Desbureaux <sylvain.desbureaux@orange.com>2020-12-07 10:31:27 +0100
commit16bdf241133bc2b448b89b445e489cbab76fcf25 (patch)
tree22ece7a4873d3c87ecfa27cd90071e5d475aaf8d /kubernetes/robot/templates
parent2dce7527bc6a7c88934eb07f16e2b1b568fb29a6 (diff)
[ROBOT] Reintegrate robot in main repository
Robot chart is currently in its own directory. As a lot will be done in the charts with tight coordination between "common" part and components parts, it's a lot easier to have everything in a same place for now. we're using commit 85b5af5058bbda19b557add185d917f60c2188ee from robot Issue-ID: OOM-2645 Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com> Change-Id: I7c187b616d3436ed2eab7bf7e95cb6a1a90edf31
Diffstat (limited to 'kubernetes/robot/templates')
-rw-r--r--kubernetes/robot/templates/NOTES.txt25
-rw-r--r--kubernetes/robot/templates/_ingress_svc_hostname.tpl157
-rw-r--r--kubernetes/robot/templates/configmap.yaml52
-rw-r--r--kubernetes/robot/templates/deployment.yaml117
-rw-r--r--kubernetes/robot/templates/ingress.yaml1
-rw-r--r--kubernetes/robot/templates/pv.yaml40
-rw-r--r--kubernetes/robot/templates/pvc.yaml39
-rw-r--r--kubernetes/robot/templates/service.yaml39
8 files changed, 470 insertions, 0 deletions
diff --git a/kubernetes/robot/templates/NOTES.txt b/kubernetes/robot/templates/NOTES.txt
new file mode 100644
index 0000000000..fe7c9313df
--- /dev/null
+++ b/kubernetes/robot/templates/NOTES.txt
@@ -0,0 +1,25 @@
+# Copyright © 2018 Amdocs, Bell Canada
+#
+# This file is licensed under the CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE
+#
+# Full license text at https://creativecommons.org/licenses/by/4.0/legalcode
+
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range .Values.ingress.hosts }}
+ http://{{ . }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ include "common.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.name" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ include "common.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 svc -w {{ include "common.name" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.namespace" . }} {{ include "common.name" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
+ echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ include "common.namespace" . }} -l "app={{ template "common.name" . }},release={{ .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:{{ .Values.service.internalPort }}
+{{- end }}
diff --git a/kubernetes/robot/templates/_ingress_svc_hostname.tpl b/kubernetes/robot/templates/_ingress_svc_hostname.tpl
new file mode 100644
index 0000000000..160bfbf868
--- /dev/null
+++ b/kubernetes/robot/templates/_ingress_svc_hostname.tpl
@@ -0,0 +1,157 @@
+{{/*
+# Copyright © 2020 Samsung Electronics
+#
+# 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 internal use only!
+
+ Return true value if robot via ingress test is enabled
+
+ The template takes two arguments:
+ - .parent: environment (.)
+ - .key: robot test component name
+*/}}
+
+{{- define "robot.ingress.svchost._isen" -}}
+ {{- $key := .key -}}
+ {{- $master := .parent.Values.config.useIngressHost -}}
+ {{- if hasKey $master "enabled" -}}
+ {{- if (index $master "enabled") -}}
+ {{- if hasKey $master $key -}}
+ {{- $en_parent := (index $master $key) -}}
+ {{- if hasKey $en_parent "enabled" -}}
+ {{- default "" (index $en_parent "enabled") -}}
+ {{- else -}}
+ {{- "" -}}
+ {{- end -}}
+ {{- else -}}
+ {{- "" -}}
+ {{- end -}}
+ {{- else -}}
+ {{- "" -}}
+ {{- end -}}
+ {{- else -}}
+ {{- "" -}}
+ {{- end -}}
+{{- end -}}
+
+{{/*
+ For internal use only!
+
+ Return ingress alternative hotname if present
+
+ The template takes two arguments:
+ - .parent: environment (.)
+ - .key: robot test component name
+*/}}
+
+{{- define "robot.ingress.svchost._inghost" -}}
+ {{- $key := .key -}}
+ {{- $master := .parent.Values.config.useIngressHost -}}
+ {{- if hasKey $master $key -}}
+ {{- $h_parent := (index $master $key) -}}
+ {{- if hasKey $h_parent "hostname" -}}
+ {{- default "" (index $h_parent "hostname") -}}
+ {{- else -}}
+ {{- "" -}}
+ {{- end -}}
+ {{- else -}}
+ {{- "" -}}
+ {{- end -}}
+{{- end -}}
+
+{{/*
+ For internal use only!
+
+ Return robot target port depending on the robot test configuration
+ or default value if config is not available
+
+ The template takes two arguments:
+ - .parent: environment (.)
+ - .key: robot test component name
+*/}}
+{{- define "robot.ingress.svchost._port" -}}
+ {{- $key := .key -}}
+ {{- $master := .parent.Values.config.useIngressHost -}}
+ {{- if hasKey $master $key -}}
+ {{- $https_parent := (index $master $key) -}}
+ {{- if hasKey $https_parent "https" -}}
+ {{- $ishttps := (index $https_parent "https") -}}
+ {{- ternary 443 80 $ishttps -}}
+ {{- else -}}
+ {{- 80 -}}
+ {{- end -}}
+ {{- else -}}
+ {{- 80 -}}
+ {{- end -}}
+{{- end -}}
+
+{{/*
+ Return the hostname for tested compoment by robot
+ if the ingress is enabled it return cluster ingress
+ controller hostname. If the ingress controller in robot
+ test is disabled it returns the internal cluster hostname
+
+ The template takes two arguments:
+ - .root: root environment (.)
+ - .hostname: basename of host
+
+ Return string target hostname for robot test on particular component
+*/}}
+{{- define "robot.ingress.svchost" -}}
+ {{- $hostname := required "service hostname" .hostname -}}
+ {{- $tplhname := $hostname | replace "-" "_" -}}
+ {{- $ingress_enabled := include "robot.ingress.svchost._isen" (dict "parent" .root "key" $tplhname) -}}
+ {{- if $ingress_enabled -}}
+ {{- if .root.Values.global.ingress -}}
+ {{- if .root.Values.global.ingress.virtualhost -}}
+ {{- $domain := .root.Values.global.ingress.virtualhost.baseurl -}}
+ {{- $ihostname := default $hostname (include "robot.ingress.svchost._inghost" (dict "parent" .root "key" $tplhname)) -}}
+ {{- printf "%s.%s" $ihostname $domain -}}
+ {{- end -}}
+ {{- end -}}
+ {{- else -}}
+ {{- $domain := include "common.namespace" .root -}}
+ {{- printf "%s.%s" $hostname $domain -}}
+ {{- end -}}
+{{- end -}}
+
+
+{{/*
+ Return the target port for the robot testing purpose
+ if the ingress is enabled it return cluster ingress
+ controller port. If the target port doesn't exists
+ it return default port
+
+ The template takes three arguments:
+ - .root: root environment (.)
+ - .hostname: basename of host
+ - .port Default target port
+
+ Return target port for tested components
+*/}}
+{{- define "robot.ingress.port" -}}
+ {{- $hostname := required "service hostname" .hostname -}}
+ {{- $port := required "service port" .port -}}
+ {{- $tplhname := $hostname | replace "-" "_" -}}
+ {{- $ingress_enabled := include "robot.ingress.svchost._isen" (dict "parent" .root "key" $tplhname) -}}
+ {{- if $ingress_enabled -}}
+ {{- include "robot.ingress.svchost._port" (dict "parent" .root "key" $tplhname) -}}
+ {{- else -}}
+ {{- printf "%d" $port -}}
+ {{- end -}}
+{{- end -}}
+
diff --git a/kubernetes/robot/templates/configmap.yaml b/kubernetes/robot/templates/configmap.yaml
new file mode 100644
index 0000000000..5b41aa4176
--- /dev/null
+++ b/kubernetes/robot/templates/configmap.yaml
@@ -0,0 +1,52 @@
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# 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.
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ include "common.fullname" . }}-eteshare-configmap
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ include "common.release" . }}
+ heritage: {{ .Release.Service }}
+data:
+{{ tpl (.Files.Glob "resources/config/eteshare/config/*").AsConfig . | indent 2 }}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ include "common.fullname" . }}-lighttpd-configmap
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ include "common.release" . }}
+ heritage: {{ .Release.Service }}
+data:
+{{ tpl (.Files.Glob "resources/config/lighttpd/*").AsConfig . | indent 2 }}
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ include "common.fullname" . }}-lighttpd-ssl-configmap
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ .Release.Name }}
+ heritage: {{ .Release.Service }}
+data:
+{{ tpl (.Files.Glob "resources/config/lighttpd/ssl/*").AsConfig . | indent 2 }}
diff --git a/kubernetes/robot/templates/deployment.yaml b/kubernetes/robot/templates/deployment.yaml
new file mode 100644
index 0000000000..a466189c22
--- /dev/null
+++ b/kubernetes/robot/templates/deployment.yaml
@@ -0,0 +1,117 @@
+# Copyright © 2018 Amdocs, Bell Canada, AT&T
+#
+# 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.
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "common.fullname" . }}
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ include "common.release" . }}
+ heritage: {{ .Release.Service }}
+spec:
+ selector:
+ matchLabels:
+ app: {{ include "common.name" . }}
+ replicas: {{ .Values.replicaCount }}
+ template:
+ metadata:
+ labels:
+ app: {{ include "common.name" . }}
+ release: {{ include "common.release" . }}
+ spec:
+ hostAliases:
+ - ip: {{ .Values.kubernetesExternalIp }}
+ hostnames:
+ - "portal.api.simpledemo.onap.org"
+ - "vid.api.simpledemo.onap.org"
+ - "sdc.api.fe.simpledemo.onap.org"
+ - "portal-sdk.simpledemo.onap.org"
+ - "policy.api.simpledemo.onap.org"
+ - "aai.api.sparky.simpledemo.onap.org"
+ - "aai.ui.simpledemo.onap.org"
+ - "cli.api.simpledemo.onap.org"
+ - "so-monitoring"
+ containers:
+ - name: {{ include "common.name" . }}
+ image: "{{ include "common.repository" . }}/{{ .Values.image }}"
+ imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+ ports:
+ - containerPort: {{ .Values.service.internalPort }}
+ {{ if .Values.liveness.enabled }}
+ livenessProbe:
+ tcpSocket:
+ port: {{ .Values.service.internalPort }}
+ initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
+ periodSeconds: {{ .Values.liveness.periodSeconds }}
+ {{ end }}
+ readinessProbe:
+ tcpSocket:
+ port: {{ .Values.service.internalPort }}
+ initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
+ periodSeconds: {{ .Values.readiness.periodSeconds }}
+ volumeMounts:
+ - name: dshm
+ mountPath: /dev/shm
+ - name: localtime
+ mountPath: /etc/localtime
+ readOnly: true
+ - name: robot-eteshare
+ mountPath: /share/config
+ - name: robot-lighttpd
+ mountPath: /etc/lighttpd
+ - name: robot-lighttpd-ssl
+ mountPath: /etc/lighttpd/ssl
+ - name: robot-logs
+ mountPath: /share/logs
+ resources:
+{{ include "common.resources" . }}
+ {{- if .Values.nodeSelector }}
+ nodeSelector:
+{{ toYaml .Values.nodeSelector | indent 8 }}
+ {{- end -}}
+ {{- if .Values.affinity }}
+ affinity:
+{{ toYaml .Values.affinity | indent 8 }}
+ {{- end }}
+ volumes:
+ {{- if .Values.persistence.enabled }}
+ - name: robot-logs
+ persistentVolumeClaim:
+ claimName: {{ include "common.fullname" . }}
+ {{- else }}
+ emptyDir: {}
+ {{- end }}
+ - name: dshm
+ emptyDir:
+ medium: Memory
+ - name: localtime
+ hostPath:
+ path: /etc/localtime
+ - name: robot-eteshare
+ configMap:
+ name: {{ include "common.fullname" . }}-eteshare-configmap
+ defaultMode: 0755
+ - name: robot-lighttpd
+ configMap:
+ name: {{ include "common.fullname" . }}-lighttpd-configmap
+ defaultMode: 0755
+ - name: robot-lighttpd-ssl
+ configMap:
+ name: {{ include "common.fullname" . }}-lighttpd-ssl-configmap
+ defaultMode: 0600
+ imagePullSecrets:
+ - name: "{{ include "common.namespace" . }}-docker-registry-key"
diff --git a/kubernetes/robot/templates/ingress.yaml b/kubernetes/robot/templates/ingress.yaml
new file mode 100644
index 0000000000..8f87c68f1e
--- /dev/null
+++ b/kubernetes/robot/templates/ingress.yaml
@@ -0,0 +1 @@
+{{ include "common.ingress" . }}
diff --git a/kubernetes/robot/templates/pv.yaml b/kubernetes/robot/templates/pv.yaml
new file mode 100644
index 0000000000..1226402372
--- /dev/null
+++ b/kubernetes/robot/templates/pv.yaml
@@ -0,0 +1,40 @@
+{{/*
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# 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.
+*/}}
+
+{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
+{{- if eq "True" (include "common.needPV" .) -}}
+kind: PersistentVolume
+apiVersion: v1
+metadata:
+ name: {{ include "common.fullname" . }}
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
+ release: {{ include "common.release" . }}
+ heritage: "{{ .Release.Service }}"
+ name: {{ include "common.fullname" . }}
+spec:
+ capacity:
+ storage: {{ .Values.persistence.size}}
+ accessModes:
+ - {{ .Values.persistence.accessMode }}
+ storageClassName: "{{ include "common.fullname" . }}-data"
+ persistentVolumeReclaimPolicy: {{ .Values.persistence.volumeReclaimPolicy }}
+ hostPath:
+ path: {{ .Values.global.persistence.mountPath | default .Values.persistence.mountPath }}/{{ include "common.release" . }}/{{ .Values.persistence.mountSubPath }}
+{{- end -}}
+{{- end -}}
diff --git a/kubernetes/robot/templates/pvc.yaml b/kubernetes/robot/templates/pvc.yaml
new file mode 100644
index 0000000000..6c18ca0628
--- /dev/null
+++ b/kubernetes/robot/templates/pvc.yaml
@@ -0,0 +1,39 @@
+{{/*
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# 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.
+*/}}
+
+{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) -}}
+kind: PersistentVolumeClaim
+apiVersion: v1
+metadata:
+ name: {{ include "common.fullname" . }}
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
+ release: {{ include "common.release" . }}
+ heritage: "{{ .Release.Service }}"
+{{- if .Values.persistence.annotations }}
+ annotations:
+{{ toYaml .Values.persistence.annotations | indent 4 }}
+{{- end }}
+spec:
+ accessModes:
+ - {{ .Values.persistence.accessMode }}
+ storageClassName: {{ include "common.storageClass" . }}
+ resources:
+ requests:
+ storage: {{ .Values.persistence.size }}
+{{- end -}}
diff --git a/kubernetes/robot/templates/service.yaml b/kubernetes/robot/templates/service.yaml
new file mode 100644
index 0000000000..d1e3bec6b3
--- /dev/null
+++ b/kubernetes/robot/templates/service.yaml
@@ -0,0 +1,39 @@
+# Copyright © 2017 Amdocs, Bell Canada
+#
+# 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.
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "common.servicename" . }}
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ include "common.release" . }}
+ heritage: {{ .Release.Service }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ {{if eq .Values.service.type "NodePort" -}}
+ - port: {{ .Values.service.externalPort }}
+ nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.nodePort }}
+ name: {{ .Values.service.portName | default "http" }}
+ {{- else -}}
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ name: {{ .Values.service.portName | default "http" }}
+ {{- end}}
+ selector:
+ app: {{ include "common.name" . }}
+ release: {{ include "common.release" . }}