diff options
Diffstat (limited to 'VNFs/DPPD-PROX/helper-scripts/rapid')
11 files changed, 131 insertions, 4 deletions
diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/Dockerfile b/VNFs/DPPD-PROX/helper-scripts/rapid/Dockerfile index a62c5dc4..2c25f097 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/Dockerfile +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/Dockerfile @@ -48,6 +48,11 @@ EXPOSE 22 8474 COPY ./rapid_rsa_key.pub /home/centos/.ssh/authorized_keys COPY ./rapid_rsa_key.pub /root/.ssh/authorized_keys +RUN chown centos:centos /home/centos/.ssh/authorized_keys \ + && chmod 600 /home/centos/.ssh/authorized_keys \ + && chown root:root /root/.ssh/authorized_keys \ + && chmod 600 /root/.ssh/authorized_keys + # Copy startup script COPY ./start.sh /start.sh RUN chmod +x /start.sh diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/deploycentostools.sh b/VNFs/DPPD-PROX/helper-scripts/rapid/deploycentostools.sh index c50d7968..a0fe7cb2 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/deploycentostools.sh +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/deploycentostools.sh @@ -44,7 +44,8 @@ function os_pkgs_install() numactl-devel vim tuna openssl-devel wireshark \ make driverctl - ${SUDO} wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/linux/nasm-2.14.02-0.fc27.x86_64.rpm + ${SUDO} wget --no-check-certificate \ + https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/linux/nasm-2.14.02-0.fc27.x86_64.rpm ${SUDO} rpm -ivh nasm-2.14.02-0.fc27.x86_64.rpm } @@ -55,6 +56,12 @@ function k8s_os_pkgs_runtime_install() # Install required dynamically linked libraries + required packages ${SUDO} yum install -y numactl-libs libpcap openssh openssh-server \ openssh-clients sudo + + # Install additional packets for universal image + ${SUDO} yum install -y epel-release python3 kubernetes-client + ${SUDO} yum install -y python3-paramiko python3-future + ${SUDO} python3 -m pip install --upgrade pip + ${SUDO} pip3 install scp kubernetes } function os_cfg() diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/dockerimage.sh b/VNFs/DPPD-PROX/helper-scripts/rapid/dockerimage.sh index e0f38ade..e2266e58 100755 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/dockerimage.sh +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/dockerimage.sh @@ -16,7 +16,7 @@ ## PROX_DEPLOY_DIR="." -PROX_IMAGE_NAME="prox_slim" +PROX_IMAGE_NAME="rapid" RSA_KEY_FILE_NAME="rapid_rsa_key" DOCKERFILE="Dockerfile" diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py b/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py index fc6749da..c1aade6b 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/prox_ctrl.py @@ -86,6 +86,7 @@ class prox_ctrl(object): def run_cmd(self, command): self._sshclient.run_cmd(command) + return self._sshclient.get_output() def prox_sock(self, port=8474): """Connect to the PROX instance on remote system. diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid.pods b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid.pods index f5681397..cd54d507 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid.pods +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid.pods @@ -16,6 +16,7 @@ [DEFAULT] total_number_of_pods=2 +namespace=rapid-testing [POD1] nodeSelector_hostname=k8s-node1 diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/.helmignore b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/Chart.yaml b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/Chart.yaml new file mode 100644 index 00000000..4d210409 --- /dev/null +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: rapid +description: A Helm chart for deploying RAPID test scripts and environment +type: application +version: 0.0.1 +appVersion: "1.0.0" diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/templates/deployment.yaml b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/templates/deployment.yaml new file mode 100644 index 00000000..74fc6297 --- /dev/null +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/templates/deployment.yaml @@ -0,0 +1,26 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: rapid-testing + namespace: {{ .Values.namespace }} + labels: + app: rapid-testing +spec: + replicas: 1 + selector: + matchLabels: + app: rapid-testing + template: + metadata: + labels: + app: rapid-testing + spec: + serviceAccountName: rapid-testing-sa + containers: + - name: rapid-mgmt + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/templates/serviceaccount.yaml b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/templates/serviceaccount.yaml new file mode 100644 index 00000000..7886ade3 --- /dev/null +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/templates/serviceaccount.yaml @@ -0,0 +1,36 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + name: {{ .Values.namespace }} + +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: rapid-testing-sa + namespace: {{ .Values.namespace }} + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: rapid-testing-cr +rules: +- apiGroups: [""] + resources: ["pods", "pods/exec", "pods/status"] + verbs: ["get", "list", "watch", "create", "update", "patch", "delete"] + +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: rapid-testing-crb +subjects: +- kind: ServiceAccount + name: rapid-testing-sa + namespace: {{ .Values.namespace }} +roleRef: + kind: ClusterRole + name: rapid-testing-cr + apiGroup: rbac.authorization.k8s.io diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/values.yaml b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/values.yaml new file mode 100644 index 00000000..76b8037a --- /dev/null +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_helm_chart/values.yaml @@ -0,0 +1,8 @@ +namespace: rapid-testing + +image: + repository: opnfv/rapid + tag: "latest" + pullPolicy: IfNotPresent + +nodeSelector: {} diff --git a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_deployment.py b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_deployment.py index 2d88cd96..bfb81611 100644 --- a/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_deployment.py +++ b/VNFs/DPPD-PROX/helper-scripts/rapid/rapid_k8s_deployment.py @@ -40,6 +40,7 @@ class K8sDeployment: _create_config = None _runtime_config = None _total_number_of_pods = 0 + _namespace = "rapid-testing" _pods = [] def __init__(self): @@ -64,7 +65,11 @@ class K8sDeployment: self._log.addHandler(console_handler) # Initialize k8s plugin - config.load_kube_config() + try: + config.load_kube_config() + except: + config.load_incluster_config() + Pod.k8s_CoreV1Api = client.CoreV1Api() def load_create_config(self, config_file_name): @@ -89,6 +94,15 @@ class K8sDeployment: self._log.debug("Total number of pods %d" % self._total_number_of_pods) + if self._create_config.has_option("DEFAULT", "namespace"): + self._namespace = self._create_config.get( + "DEFAULT", "namespace") + else: + self._log.error("No option namespace in DEFAULT section") + return -1 + + self._log.debug("Using namespace %s" % self._total_number_of_pods) + # Parse [PODx] sections for i in range(1, int(self._total_number_of_pods) + 1): # Search for POD name @@ -123,7 +137,7 @@ class K8sDeployment: else: pod_dp_subnet = "24" - pod = Pod(pod_name) + pod = Pod(pod_name, self._namespace) pod.set_nodeselector(pod_nodeselector_hostname) pod.set_dp_ip(pod_dp_ip) pod.set_dp_subnet(pod_dp_subnet) |