summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryuryn <Yury.Novitsky@Amdocs.com>2017-11-09 20:07:02 +0200
committeryuryn <Yury.Novitsky@Amdocs.com>2018-01-17 23:31:42 +0200
commitd9f6ecd1c5b5296d8bb198b13430d437a6f7a54a (patch)
tree62e22c5462dd8d26e724d302d72620a755636d56
parent58a0c10a49c79962adfd43d179ad8043c5aa1e81 (diff)
Refresh /etc/hosts in VNC - reviewed
Change-Id: Ie2c9648e067867d00c035dd9f35560be2ecd6724 Issue-ID: OOM-413 Signed-off-by: yuryn <Yury.Novitsky@Amdocs.com>
-rw-r--r--kubernetes/portal/docker/init/ubuntu/Dockerfile11
-rw-r--r--kubernetes/portal/resources/scripts/update_hosts.sh17
-rw-r--r--kubernetes/portal/templates/portal-vnc-dep.yaml29
-rw-r--r--kubernetes/portal/values.yaml1
4 files changed, 33 insertions, 25 deletions
diff --git a/kubernetes/portal/docker/init/ubuntu/Dockerfile b/kubernetes/portal/docker/init/ubuntu/Dockerfile
deleted file mode 100644
index 779a7fa921..0000000000
--- a/kubernetes/portal/docker/init/ubuntu/Dockerfile
+++ /dev/null
@@ -1,11 +0,0 @@
-FROM ubuntu:16.04
-
-ENV no_proxy "localhost,127.0.0.1,.cluster.local,$KUBERNETES_SERVICE_HOST"
-# Setup Corporate proxy
-ENV https_proxy ${HTTPS_PROXY}
-ENV http_proxy ${HTTP_PROXY}
-
-RUN apt-get update
-RUN apt-get install -y host dnsutils
-
-VOLUME /ubuntu-init
diff --git a/kubernetes/portal/resources/scripts/update_hosts.sh b/kubernetes/portal/resources/scripts/update_hosts.sh
new file mode 100644
index 0000000000..cd38fafb40
--- /dev/null
+++ b/kubernetes/portal/resources/scripts/update_hosts.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+_SRC_HOST=$1
+_DST_HOST=$2
+_IP=`getent hosts ${_SRC_HOST}|cut -d' ' -f1`
+if [ -z ${_IP} ]; then
+ echo "Cannot retreive IP for host mapping ${_SRC_HOST} -> ${_DST_HOST}"
+ exit 1
+fi
+_REGEX=".*[[:blank:]]${_DST_HOST}$"
+if grep -c -e "${_REGEX}" /etc/hosts > /dev/null 2>&1 ; then
+ cp /etc/hosts /tmp/hosts
+ sed -i "s/${_REGEX}/${_IP} ${_DST_HOST}/g" /tmp/hosts
+ cp /tmp/hosts /etc/hosts
+else
+ echo "${_IP} ${_DST_HOST}" >> /etc/hosts
+fi
diff --git a/kubernetes/portal/templates/portal-vnc-dep.yaml b/kubernetes/portal/templates/portal-vnc-dep.yaml
index 536ac37396..b200d8fc15 100644
--- a/kubernetes/portal/templates/portal-vnc-dep.yaml
+++ b/kubernetes/portal/templates/portal-vnc-dep.yaml
@@ -6,6 +6,14 @@ metadata:
data:
{{ (.Files.Glob "resources/vnc/init_profile/profiles.ini").AsConfig | indent 2 }}
---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: vnc-update-hosts
+ namespace: "{{ .Values.nsPrefix }}-portal"
+data:
+{{ (.Files.Glob "resources/scripts/update_hosts.sh").AsConfig | indent 2 }}
+---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
@@ -71,21 +79,13 @@ spec:
image: {{ .Values.image.readiness }}
imagePullPolicy: {{ .Values.pullPolicy }}
name: vnc-vid-readiness
- - command: ["/bin/sh","-c"]
- args: ["echo `host sdc-be.{{ .Values.nsPrefix }}-sdc | awk ''{print$4}''` sdc.api.be.simpledemo.onap.org >> /ubuntu-init/hosts; echo `host portalapps.{{ .Values.nsPrefix }}-portal | awk ''{print$4}''` portal.api.simpledemo.onap.org >> /ubuntu-init/hosts; echo `host pap.{{ .Values.nsPrefix }}-policy | awk ''{print$4}''` policy.api.simpledemo.onap.org >> /ubuntu-init/hosts; echo `host sdc-fe.{{ .Values.nsPrefix }}-sdc | awk ''{print$4}''` sdc.api.simpledemo.onap.org >> /ubuntu-init/hosts; echo `host vid-server.{{ .Values.nsPrefix }}-vid | awk ''{print$4}''` vid.api.simpledemo.onap.org >> /ubuntu-init/hosts; echo `host sparky-be.{{ .Values.nsPrefix }}-aai | awk ''{print$4}''` aai.api.simpledemo.onap.org >> /ubuntu-init/hosts"]
- image: {{ .Values.image.ubuntuInit }}
- imagePullPolicy: {{ .Values.pullPolicy }}
- name: vnc-init-hosts
- volumeMounts:
- - name: ubuntu-init
- mountPath: /ubuntu-init/
containers:
- image: {{ .Values.image.ubuntuDesktop }}
imagePullPolicy: {{ .Values.pullPolicy }}
lifecycle:
postStart:
exec:
- command: ["/bin/sh", "-c", "mkdir -p /root/.mozilla/firefox/onap.default; cp /root/.init_profile/profiles.ini /root/.mozilla/firefox/; echo 'user_pref(\"browser.tabs.remote.autostart.2\", false);' > /root/.mozilla/firefox/onap.default/prefs.js; cat /ubuntu-init/hosts >> /etc/hosts"]
+ command: ["/bin/sh", "-c", "mkdir -p /root/.mozilla/firefox/onap.default; cp /root/.init_profile/profiles.ini /root/.mozilla/firefox/; echo 'user_pref(\"browser.tabs.remote.autostart.2\", false);' > /root/.mozilla/firefox/onap.default/prefs.js; (while true; do /tmp/update_hosts.sh sdc-be.{{ .Values.nsPrefix }}-sdc sdc.api.be.simpledemo.onap.org; /tmp/update_hosts.sh portalapps.{{ .Values.nsPrefix }}-portal portal.api.simpledemo.onap.org; /tmp/update_hosts.sh pap.{{ .Values.nsPrefix }}-policy policy.api.simpledemo.onap.org; /tmp/update_hosts.sh sdc-fe.{{ .Values.nsPrefix }}-sdc sdc.api.simpledemo.onap.org; /tmp/update_hosts.sh vid-server.{{ .Values.nsPrefix }}-vid vid.api.simpledemo.onap.org; /tmp/update_hosts.sh sparky-be.{{ .Values.nsPrefix }}-aai aai.api.simpledemo.onap.org; sleep 10; done) > update_hosts.log 2>&1 &"]
env:
- name: VNC_PASSWORD
value: password
@@ -94,11 +94,12 @@ spec:
- mountPath: /etc/localtime
name: localtime
readOnly: true
- - mountPath: /ubuntu-init/
- name: ubuntu-init
- mountPath: /root/.init_profile/profiles.ini
name: vnc-profiles-ini
subPath: profiles.ini
+ - mountPath: /tmp/update_hosts.sh
+ name: vnc-update-hosts
+ subPath: update_hosts.sh
securityContext:
privileged: true
securityContext: {}
@@ -106,11 +107,13 @@ spec:
- name: localtime
hostPath:
path: /etc/localtime
- - name: ubuntu-init
- emptyDir: {}
- name: vnc-profiles-ini
configMap:
name: vnc-profiles-ini
+ - name: vnc-update-hosts
+ configMap:
+ name: vnc-update-hosts
+ defaultMode: 0755
imagePullSecrets:
- name: "{{ .Values.nsPrefix }}-docker-registry-key"
#{{ end }}
diff --git a/kubernetes/portal/values.yaml b/kubernetes/portal/values.yaml
index aaa781995a..6e2e83d215 100644
--- a/kubernetes/portal/values.yaml
+++ b/kubernetes/portal/values.yaml
@@ -7,7 +7,6 @@ image:
portaldb: nexus3.onap.org:10001/onap/portal-db:v1.3.0
mariadbClient: oomk8s/mariadb-client-init:1.0.0
portalwms: nexus3.onap.org:10001/onap/portal-wms:v1.3.0
- ubuntuInit: oomk8s/ubuntu-init:1.0.0
ubuntuDesktop: dorowu/ubuntu-desktop-lxde-vnc
filebeat: docker.elastic.co/beats/filebeat:5.5.0
onapPortal: