From: wrider Date: Wed, 3 Apr 2019 02:10:42 +0000 (-0400) Subject: Initial commit of seed code X-Git-Tag: 0.0.2~110 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=1a8a09deaeded3c6a50fa7c13594e46301375874;p=it%2Fdep.git Initial commit of seed code Change-Id: Ib42ee7294dbfa39bd515380d11aa8e0459748d7e Signed-off-by: wrider --- diff --git a/LICENSES.txt b/LICENSES.txt new file mode 100644 index 00000000..2a3dd5c9 --- /dev/null +++ b/LICENSES.txt @@ -0,0 +1,32 @@ +LICENSES.txt + + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the "Software License"); +you may not use this software except in compliance with the Software +License. You may obtain a copy of the Software License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the Software License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the Software License for the specific language governing permissions +and limitations under the Software License. + + + +Unless otherwise specified, all documentation contained herein is licensed +under the Creative Commons License, Attribution 4.0 Intl. (the +"Documentation License"); you may not use this documentation except in +compliance with the Documentation License. You may obtain a copy of the +Documentation License at + +https://creativecommons.org/licenses/by/4.0/ + +Unless required by applicable law or agreed to in writing, documentation +distributed under the Documentation License is distributed on an "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied. See the Documentation License for the specific language governing +permissions and limitations under the Documentation License. + diff --git a/README.md b/README.md new file mode 100644 index 00000000..13eeaaa0 --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# RIC Integration + +This repo contains RAN Intelligent Controller (RIC) deployments related files. + + +### Directory Structure +- kubernetes: scripts for kubernetes related tasks +- LICENSES.txt: +- localize.sh: a script for inserting localized infrastructure parameters (docker registry host, port, etc) into helm charts and scripts in this repo +- ricplt: RIC Platform Helm charts and related scripts +- runric_env.sh: the env variables for local infrastructure +- xapps: xapps Helm charts and chart templates + +### To Generate Localized Charts and Scripts + +First we will need to edit the ./runric_env.sh and fill values with local infrastructure parameters. + +```sh +$ then run: +$ ./localize.sh +$ cd generated +``` + +Now the localized scripts and charts are ready to use. diff --git a/localize.sh b/localize.sh new file mode 100755 index 00000000..41b783a1 --- /dev/null +++ b/localize.sh @@ -0,0 +1,51 @@ +#!/bin/bash +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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. # +################################################################################ + +source ./runric_env.sh +if [ -z $__RICENV_SET__ ]; then + echo "Edit your ric_env.sh for local infrastyructure values first" + exit +fi + +echo "Copy files to generated fir" +DIRS='kubernetes ricplt xapps' +rm -rf ./generated +mkdir -p generated +for d in $DIRS; do + cp -rf $d ./generated/ +done + +echo "env substitude vars in .yaml and .sh files" +FILELIST=$(find . \( -name "*.sh" -o -name "*.yaml" \)) +for f in $FILELIST; do + echo "$f to ./generated/$f": + envsubst '${__RUNRICENV_GERRIT_HOST__} +${__RUNRICENV_GERRIT_IP__} +${__RUNRICENV_DOCKER_HOST__} +${__RUNRICENV_DOCKER_IP__} +${__RUNRICENV_DOCKER_PORT__} +${__RUNRICENV_DOCKER_USER__} +${__RUNRICENV_DOCKER_PASS__} +${__RUNRICENV_HELMREPO_HOST__} +${__RUNRICENV_HELMREPO_PORT__} +${__RUNRICENV_HELMREPO_IP__} +${__RUNRICENV_HELMREPO_USER__} +${__RUNRICENV_HELMREPO_PASS__} '< $f > "./generated/$f"; +done + + diff --git a/runric_env.sh b/runric_env.sh new file mode 100755 index 00000000..4dca1944 --- /dev/null +++ b/runric_env.sh @@ -0,0 +1,36 @@ +#!/bin/bash +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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. # +################################################################################ + + +# customize the following repo info to local infrastructure +export __RICENV_SET__='' +export __RUNRICENV_GERRIT_HOST__='' +export __RUNRICENV_GERRIT_IP__='' + +export __RUNRICENV_DOCKER_HOST__='' +export __RUNRICENV_DOCKER_IP__='' +export __RUNRICENV_DOCKER_PORT__='' +export __RUNRICENV_DOCKER_USER__='' +export __RUNRICENV_DOCKER_PASS__='' + +export __RUNRICENV_HELMREPO_HOST__='' +export __RUNRICENV_HELMREPO_PORT__='' +export __RUNRICENV_HELMREPO_IP__='' +export __RUNRICENV_HELMREPO_USER__='' +export __RUNRICENV_HELMREPO_PASS__='' + diff --git a/setup-1node-k8s.sh b/setup-1node-k8s.sh new file mode 100755 index 00000000..aa5a8c64 --- /dev/null +++ b/setup-1node-k8s.sh @@ -0,0 +1,319 @@ +#!/bin/bash + +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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. # +################################################################################ + +# The intention for this script is to stand up a dev testing k8s environment +# that is ready for RIC installation for individual developer/team's API and functional +# testing needs. +# The integration team will maintain the synchronization of software infrastructure +# stack (software, versions and configurations) between this iscript and what is +# provided for the E2E validation testing. Due to resource and other differences, this +# environment is not intended for any testing related to performance, resilience, +# robustness, etc. + +# This script installs docker host, a one-node k8s cluster, and Helm for CoDev. +# This script assumes that it will be executed on an Ubuntu 16.04 VM. +# It is best to be run as the cloud-init script at the VM launch time, or from a +# "sudo -i" shell post-launch on a newly launched VM. +# + +set -x + +# for RIC R0 we keep 1.13 +export KUBEV="1.13.3" +export KUBECNIV="0.6.0" +export DOCKERV="18.06.1" + +# for new 1.14 release +#export KUBEVERSION="1.14.0" +#export KUBECNIVERSION="0.7.0" +#export DOCKEFV="18.06.1" + +export HELMV="2.12.3" + +unset FIRSTBOOT +unset DORESET + +while getopts ":r" opt; do + case ${opt} in + r ) + DORESET='YES' + ;; + \? ) + echo "Usage: $0 [-r]" + exit + ;; + esac +done + + +if [ ! -e /var/tmp/firstboot4setupk8s ]; then + echo "First time" + FIRSTBOOT='YES' + touch /var/tmp/firstboot4setupk8s + + modprobe -- ip_vs + modprobe -- ip_vs_rr + modprobe -- ip_vs_wrr + modprobe -- ip_vs_sh + modprobe -- nf_conntrack_ipv4 + + # disable swap + SWAPFILES=$(grep swap /etc/fstab | sed '/^#/ d' |cut -f1 -d' ') + if [ ! -z $SWAPFILES ]; then + for SWAPFILE in $SWAPFILES + do + echo "disabling swap file $SWAPFILE" + if [[ $SWAPFILE == UUID* ]]; then + UUID=$(echo $SWAPFILE | cut -f2 -d'=') + swapoff -U $UUID + else + swapoff $SWAPFILE + fi + # edit /etc/fstab file, remove line with /swapfile + sed -i -e "/$SWAPFILE/d" /etc/fstab + done + fi + # disable swap + #swapoff /swapfile + # edit /etc/fstab file, remove line with /swapfile + #sed -i -e '/swapfile/d' /etc/fstab + + + # add rancodev CI tool hostnames + echo "${__RUNRICENV_GERRIT_IP__} ${__RUNRICENV_GERRIT_HOST__}" >> /etc/hosts + echo "${__RUNRICENV_DOCKER_IP__} ${__RUNRICENV_DOCKER_HOST__}" >> /etc/hosts + echo "${__RUNRICENV_HELMREPO_IP__} ${__RUNRICENV_HELMREPO_HOST__}" >> /etc/hosts + + + # create kubenetes config file + if [[ ${KUBEV} == 1.13.* ]]; then + cat </root/config.yaml +apiVersion: kubeadm.k8s.io/v1alpha3 +kubernetesVersion: v${KUBEV} +kind: ClusterConfiguration +apiServerExtraArgs: + feature-gates: SCTPSupport=true +networking: + dnsDomain: cluster.local + podSubnet: 10.244.0.0/16 + serviceSubnet: 10.96.0.0/12 + +--- +apiVersion: kubeproxy.config.k8s.io/v1alpha1 +kind: KubeProxyConfiguration +mode: ipvs +EOF + elif [[ ${KUBEV} == 1.14.* ]]; then + cat </root/config.yaml +apiVersion: kubeadm.k8s.io/v1beta1 +kubernetesVersion: v${KUBEV} +kind: ClusterConfiguration +apiServerExtraArgs: + feature-gates: SCTPSupport=true +networking: + dnsDomain: cluster.local + podSubnet: 10.244.0.0/16 + serviceSubnet: 10.96.0.0/12 + +--- +apiVersion: kubeproxy.config.k8s.io/v1alpha1 +kind: KubeProxyConfiguration +mode: ipvs +EOF + else + echo "Unsupported Kubernetes version requested. Bail." + exit + fi + + + # create a RBAC file for helm (tiller) + cat < /root/rbac-config.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: tiller + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: tiller +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cluster-admin +subjects: + - kind: ServiceAccount + name: tiller + namespace: kube-system +EOF + + + KUBEVERSION="${KUBEV}-00" + CNIVERSION="${KUBECNIV}-00" + DOCKERVERSION="${DOCKERV}-0ubuntu1.2~16.04.1" + curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - + echo 'deb http://apt.kubernetes.io/ kubernetes-xenial main' > /etc/apt/sources.list.d/kubernetes.list + + # install low latency kernel, docker.io, and kubernetes + apt-get update + apt-get install -y linux-image-4.15.0-45-lowlatency docker.io=${DOCKERVERSION} + apt-get install -y kubernetes-cni=${CNIVERSION} + apt-get install -y --allow-unauthenticated kubeadm=${KUBEVERSION} kubelet=${KUBEVERSION} kubectl=${KUBEVERSION} + apt-mark hold kubernetes-cni kubelet kubeadm kubectl + + # install Helm + HELMVERSION=${HELMV} + cd /root + mkdir Helm + cd Helm + wget https://storage.googleapis.com/kubernetes-helm/helm-v${HELMVERSION}-linux-amd64.tar.gz + tar -xvf helm-v${HELMVERSION}-linux-amd64.tar.gz + mv linux-amd64/helm /usr/local/bin/helm + + + # add cert for accessing docker registry in Azure + mkdir -p /etc/docker/certs.d/${__RUNRICENV_DOCKER_HOST__}:${__RUNRICENV_DOCKER_PORT__} + cat </etc/docker/ca.crt +-----BEGIN CERTIFICATE----- +MIIEPjCCAyagAwIBAgIJAIwtTKgVAnvrMA0GCSqGSIb3DQEBCwUAMIGzMQswCQYD +VQQGEwJVUzELMAkGA1UECAwCTkoxEzARBgNVBAcMCkJlZG1pbnN0ZXIxDTALBgNV +BAoMBEFUJlQxETAPBgNVBAsMCFJlc2VhcmNoMTswOQYDVQQDDDIqLmRvY2tlci5y +YW5jby1kZXYtdG9vbHMuZWFzdHVzLmNsb3VkYXBwLmF6dXJlLmNvbTEjMCEGCSqG +SIb3DQEJARYUcmljQHJlc2VhcmNoLmF0dC5jb20wHhcNMTkwMTI0MjA0MzIzWhcN +MjQwMTIzMjA0MzIzWjCBszELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAk5KMRMwEQYD +VQQHDApCZWRtaW5zdGVyMQ0wCwYDVQQKDARBVCZUMREwDwYDVQQLDAhSZXNlYXJj +aDE7MDkGA1UEAwwyKi5kb2NrZXIucmFuY28tZGV2LXRvb2xzLmVhc3R1cy5jbG91 +ZGFwcC5henVyZS5jb20xIzAhBgkqhkiG9w0BCQEWFHJpY0ByZXNlYXJjaC5hdHQu +Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuAW1O52l9/1L+D7x +Qv+782FjiELP9MWO0RCAL2JzV6Ioeo1IvuZl8jvXQVGlowanCdz1HZlMJjGm6Ybv +60dVECRSMZeOxUQ0JCus6thxOhDiiCFT59m+MpdrRgHqwOzw+8B49ZwULv+lTIWt +ETEQkSYTh4No9jCxnyVLKH9DyTbaW/xFK484u5f4bh7mI5uqDJapOCRvJXv8/J0E +eMrkCVmk5qy0ii8I7O0oCNl61YvC5by9GCeuQhloJJc6gOjzKW8nK9JfUW8G34bC +qnUj79EgwgtW/8F5SYAF5LI0USM0xXjyzlnPMbv5mikrbf0EZkZXdUreICUIzY53 +HRocCQIDAQABo1MwUTAdBgNVHQ4EFgQUm9NbNhZ3Zp1f50DIN4/4fvWQSNswHwYD +VR0jBBgwFoAUm9NbNhZ3Zp1f50DIN4/4fvWQSNswDwYDVR0TAQH/BAUwAwEB/zAN +BgkqhkiG9w0BAQsFAAOCAQEAkbuqbuMACRmzMXFKoSsMTLk/VRQDlKeubdP4lD2t +Z+2dbhfbfiae9oMly7hPCDacoY0cmlBb2zZ8lgA7kVvuw0xwX8mLGYfOaNG9ENe5 +XxFP8MuaCySy1+v5CsNnh/WM3Oznc6MTv/0Nor2DeY0XHQtM5LWrqyKGZaVAKpMW +5nHG8EPIZAOk8vj/ycg3ca3Wv3ne9/8rbrrxDJ3p4L70DOtz/JcQai10Spct4S0Z +7yd4tQL+QSQCvmN7Qm9+i52bY0swYrUAhbNiEX3yJDryKjSCPirePcieGZmBRMxr +7j28jxpa4g32TbWR/ZdxMYEkCVTFViTE23kZdNvahHKfdQ== +-----END CERTIFICATE----- +EOF + cp /etc/docker/ca.crt /etc/docker/certs.d/${__RUNRICENV_DOCKER_HOST__}:${__RUNRICENV_DOCKER_PORT__}/ca.crt + service docker restart + systemctl enable docker.service + docker login -u ${__RUNRICENV_DOCKER_USER__} -p ${__RUNRICENV_DOCKER_PASS__} ${__RUNRICENV_DOCKER_HOST__}:${__RUNRICENV_DOCKER_PORT__} + docker pull ${__RUNRICENV_DOCKER_HOST__}:${__RUNRICENV_DOCKER_PORT__}/whoami:0.0.1 + + + # test access to k8s docker registry + kubeadm config images pull +else + echo "Not first boot" + + kubectl get pods --all-namespaces +fi + + +if [ -n "$DORESET" ]; then + kubeadm reset +fi + +if [ -n ${DORESET+set} ] || [ -n ${FIRSTBOOT+set} ]; then + # start cluster (make sure CIDR is enabled with the flag) + kubeadm init --config /root/config.yaml + + # set up kubectl credential and config + cd /root + rm -rf .kube + mkdir -p .kube + cp -i /etc/kubernetes/admin.conf /root/.kube/config + chown root:root /root/.kube/config + + # at this point we should be able to use kubectl + kubectl get pods --all-namespaces + # you will see the DNS pods stuck in pending state. They are waiting for some networking to be installed. + + # install flannel + # kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml + kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml + + # waiting for all kube-system pods to be in running state + NUMPODS=0 + while [ $NUMPODS -lt 8 ]; do + sleep 5 + OUTPUT=$(kubectl get pods --all-namespaces |grep Running) + NUMPODS=$(echo "$OUTPUT" | wc -l) + echo "Waiting for $NUMPODS / 8 kube-system pods reaching Running state" + done + + # if running a single node cluster, need to enable master node to run pods + kubectl taint nodes --all node-role.kubernetes.io/master- + + cd /root + # install RBAC for Helm + kubectl create -f rbac-config.yaml + + rm -rf .helm + helm init --service-account tiller + + + cat </etc/ca-certificates/update.d/helm.crt +-----BEGIN CERTIFICATE----- +MIIESjCCAzKgAwIBAgIJAIU+AfULkw0PMA0GCSqGSIb3DQEBCwUAMIG5MQswCQYD +VQQGEwJVUzETMBEGA1UECAwKTmV3IEplcnNleTETMBEGA1UEBwwKQmVkbWluc3Rl +cjENMAsGA1UECgwEQVQmVDERMA8GA1UECwwIUmVzZWFyY2gxOTA3BgNVBAMMMCou +aGVsbS5yYW5jby1kZXYtdG9vbHMuZWFzdHVzLmNsb3VkYXBwLmF6dXJlLmNvbTEj +MCEGCSqGSIb3DQEJARYUcmljQHJlc2VhcmNoLmF0dC5jb20wHhcNMTkwMzIxMTU1 +MzAwWhcNMjEwMzIwMTU1MzAwWjCBuTELMAkGA1UEBhMCVVMxEzARBgNVBAgMCk5l +dyBKZXJzZXkxEzARBgNVBAcMCkJlZG1pbnN0ZXIxDTALBgNVBAoMBEFUJlQxETAP +BgNVBAsMCFJlc2VhcmNoMTkwNwYDVQQDDDAqLmhlbG0ucmFuY28tZGV2LXRvb2xz +LmVhc3R1cy5jbG91ZGFwcC5henVyZS5jb20xIzAhBgkqhkiG9w0BCQEWFHJpY0By +ZXNlYXJjaC5hdHQuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA +tguhSQx5Dk2w+qx2AOcFRz7IZBASEehK1Z4f5jz2KrRylGx6jjedCZASdm1b0ZEB +/ZNrKht1zsWDETa7x0DF+q0Z2blff+T+6+YrJWhNxYHgZiYVi9gTuNDzpn8VVn7f ++cQxcMguHo1JBDIotOLubJ4T3/oXMCPv9kRSLHcNjbEE2yTB3AqXu9dvrDXuUdeU +ot6RzxhKXxRCQXPS2/FDjSV9vr9h1dv5fIkFXihpYaag0XqvXcqgncvcOJ1SsLc3 +DK+tyNknqG5SL8y2a7U4F7u+qGO2/3tnCO0ggYwa73hS0pQPY51EpRSckZqlfKEu +Ut0s3wlEFP1VaU0RfU3aIwIDAQABo1MwUTAdBgNVHQ4EFgQUYTpoVXZPXSR/rhjr +pu9PPhL7f9IwHwYDVR0jBBgwFoAUYTpoVXZPXSR/rhjrpu9PPhL7f9IwDwYDVR0T +AQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAUDLbiKVIW6W9qFXLtoyO7S2e +IOUSZ1F70pkfeYUqegsfFZ9njPtPqTzDfJVxYqH2V0vxxoAxXCYCpNyR6vYlYiEL +R+oyxuvauW/yCoiwKBPYa4fD/PBajJnEO1EfIwZvjFLIfw4GjaX59+zDS3Zl0jT/ +w3uhPSsJAYXtDKLZ14btA27cM5mW4kmxVD8CRdUW0jr/cN3Hqe9uLSNWCNiDwma7 +RnpK7NnOgXHyhZD/nVC0nY7OzbK7VHFJatSOjyuMxgWsFGahwYNxf3AWfPwUai0K +ne/fVFGZ6ifR9QdD0SuKIAEuqSyyP4BsQ92uEweU/gWKsnM6iNVmNFX8UOuU9A== +-----END CERTIFICATE----- +EOF + + # waiting for tiller pod to be in running state + NUMPODS=0 + while [ $NUMPODS -lt 1 ]; do + sleep 5 + OUTPUT=$(kubectl get pods --all-namespaces |grep Running) + NUMPODS=$(echo "$OUTPUT" | grep "tiller-deploy" | wc -l) + echo "Waiting for $NUMPODS / 1 tiller-deploy pod reaching Running state" + done + + echo "All up" + + #reboot +fi diff --git a/xapp-admin/Chart.yaml b/xapp-admin/Chart.yaml new file mode 100644 index 00000000..6e2d1bc2 --- /dev/null +++ b/xapp-admin/Chart.yaml @@ -0,0 +1,21 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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 +appVersion: "1.0" +description: Admin Control xApp Helm Chart +name: xapp-admin +version: 0.0.1 diff --git a/xapp-admin/values.yaml b/xapp-admin/values.yaml new file mode 100644 index 00000000..f63a7a75 --- /dev/null +++ b/xapp-admin/values.yaml @@ -0,0 +1,89 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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 is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + # modify this section to point to your local testing settings + repository: "${__RUNRICENV_DOCKER_HOST__}:${__RUNRICENV_DOCKER_PORT__}" + repositoryCred: + user: "${__RUNRICENV_DOCKER_USER__}" + password: "${__RUNRICENV_DOCKER_PASS__}" + image: + pullPolicy: IfNotPresent + +ricplt: + # This section is reserved for values imported from RIC Platform charts + + +ricapp: + # This section is for xapp. Templates to be resolved from xApp descriptor + replicaCount: 1 + xappname: &anchor-xappname xapp-admin + + # # the name of the process that indicates the liveness of the component + livenessprocessname: adm-ctrl-xapp + + image: + name: test/xapp-admin + tag: latest + + nameOverride: "" + fullnameOverride: "" + + service: + enabled: false + + # to be provided as property file + appconfigpath: /opt/etc/xapp + appconfig: + # to be present as appconfigpath/propfile1 + propfile1: | + prop1.v1="propvalue1.1" + prop1.v2="propvalue1.2" + propfile2: "propvalue2" + + # to be provided as env variables + appenv: + NAME: *anchor-xappname + RMR_RTG_SVC: "127.0.0.2" + NAME: "ADM_CTRL_XAPP2" + THREADS: "2" + VERBOSE: "1" + PORT: "tcp:4561" + + # secret + appsecretpath: /opt/etc/kube + appsecret: + username: myusername + password: mypassword + + resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + + nodeSelector: {} + + tolerations: [] + + affinity: {} + diff --git a/xapp-std/.helmignore b/xapp-std/.helmignore new file mode 100644 index 00000000..50af0317 --- /dev/null +++ b/xapp-std/.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/xapp-std/Chart.yaml b/xapp-std/Chart.yaml new file mode 100644 index 00000000..ebf44d4b --- /dev/null +++ b/xapp-std/Chart.yaml @@ -0,0 +1,21 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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 +appVersion: "1.0" +description: Standard xApp Helm Chart +name: xapp-std +version: 0.0.1 diff --git a/xapp-std/templates/_helpers.tpl b/xapp-std/templates/_helpers.tpl new file mode 100644 index 00000000..e3ad5b2c --- /dev/null +++ b/xapp-std/templates/_helpers.tpl @@ -0,0 +1,74 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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. # +################################################################################ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "ricapp.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 "ricapp.fullname" -}} +{{- if .Values.ricapp.fullnameOverride -}} +{{- .Values.ricapp.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.ricapp.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 "ricapp.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{- define "repository" -}} + {{if .Values.repositoryOverride }} + {{- printf "%s" .Values.repositoryOverride -}} + {{else}} + {{- default .Values.repository .Values.global.repository -}} + {{end}} +{{- end -}} + +{{/* + Resolve the image repository secret token. + The value for .Values.global.repositoryCred is used: + repositoryCred: + user: user + password: password + mail: email (optional) +*/}} +{{- define "repository.secret" -}} + {{- $repo := include "repository" . }} + {{- $repo := default "${__RUNRICENV_DOCKER_HOST__}:${__RUNRICENV_DOCKER_PORT__}" $repo }} + {{- $cred := .Values.global.repositoryCred }} + {{- $mail := default "@" $cred.mail }} + {{- $auth := printf "%s:%s" $cred.user $cred.password | b64enc }} + {{- printf "{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"email\":\"%s\",\"auth\":\"%s\"}}" $repo $cred.user $cred.password $mail $auth | b64enc -}} +{{- end -}} + diff --git a/xapp-std/templates/appconfig.yaml b/xapp-std/templates/appconfig.yaml new file mode 100644 index 00000000..ce0dc0a6 --- /dev/null +++ b/xapp-std/templates/appconfig.yaml @@ -0,0 +1,25 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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: {{ .Release.Name }}-appconfig +data: + {{- with .Values.ricapp.appconfig }} + {{- toYaml . | nindent 2 }} + {{- end }} + diff --git a/xapp-std/templates/appenv.yaml b/xapp-std/templates/appenv.yaml new file mode 100644 index 00000000..8f16b036 --- /dev/null +++ b/xapp-std/templates/appenv.yaml @@ -0,0 +1,24 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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: {{ .Release.Name }}-appenv +data: + {{- with .Values.ricapp.appenv }} + {{- toYaml . | nindent 2 }} + {{- end }} diff --git a/xapp-std/templates/appsecret.yaml b/xapp-std/templates/appsecret.yaml new file mode 100644 index 00000000..a0dce0e3 --- /dev/null +++ b/xapp-std/templates/appsecret.yaml @@ -0,0 +1,26 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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: Secret +metadata: + name: {{ .Release.Name }}-appsecret +type: Opaque +stringData: + {{- with .Values.ricapp.appsecret }} + {{- toYaml . | nindent 2 }} + {{- end }} + diff --git a/xapp-std/templates/deployment.yaml b/xapp-std/templates/deployment.yaml new file mode 100644 index 00000000..295747ba --- /dev/null +++ b/xapp-std/templates/deployment.yaml @@ -0,0 +1,99 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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 "ricapp.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "ricapp.name" . }} + helm.sh/chart: {{ include "ricapp.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: {{ .Values.ricapp.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "ricapp.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "ricapp.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + spec: + imagePullSecrets: + - name: {{ .Release.Name }}-docker-registry-key + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.global.repository }}/{{ .Values.ricapp.image.name }}:{{ .Values.ricapp.image.tag }}" + imagePullPolicy: {{ .Values.global.image.pullPolicy }} + # enable the next two elements if wanting to test pod bypassing its own entrypoint + #command: ["sh"] + #args: + # - -c + # - "while sleep 2; do echo thinking; done" + ports: + - name: http + containerPort: 8080 + protocol: TCP + volumeMounts: + - name: config-volume + mountPath: {{ .Values.ricapp.appconfigpath }} + - name: secret-volume + mountPath: {{ .Values.ricapp.appsecretpath }} + envFrom: + - configMapRef: + name: {{ .Release.Name }}-appenv + livenessProbe: + exec: + command: + - /bin/bash + - -c + - ps -ef | grep {{ .Values.ricapp.livenessprocessname }}| grep -v "grep" + initialDelaySeconds: 120 + periodSeconds: 30 + readinessProbe: + httpGet: + path: / + port: http + restartPolicy: Always + resources: + {{- toYaml .Values.resources | nindent 12 }} + securityContext: + # ubuntu + runAsUser: 1000 + allowPrivilegeEscalation: false + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + + volumes: + - name: config-volume + configMap: + name: {{ .Release.Name }}-appconfig + - name: secret-volume + secret: + secretName: {{ .Release.Name }}-appsecret diff --git a/xapp-std/templates/secret.yaml b/xapp-std/templates/secret.yaml new file mode 100644 index 00000000..1a88b2cd --- /dev/null +++ b/xapp-std/templates/secret.yaml @@ -0,0 +1,23 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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: Secret +metadata: + name: {{ .Release.Name }}-docker-registry-key +data: + .dockercfg: {{ include "repository.secret" . }} +type: kubernetes.io/dockercfg diff --git a/xapp-std/templates/service.yaml b/xapp-std/templates/service.yaml new file mode 100644 index 00000000..a76c9749 --- /dev/null +++ b/xapp-std/templates/service.yaml @@ -0,0 +1,38 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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 .Values.ricapp.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "ricapp.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "ricapp.name" . }} + helm.sh/chart: {{ include "ricapp.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + type: {{ .Values.ricapp.service.type }} + ports: + - port: {{ .Values.ricapp.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + app.kubernetes.io/name: {{ include "ricapp.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} +{{ end }} diff --git a/xapp-std/values.yaml b/xapp-std/values.yaml new file mode 100644 index 00000000..59541947 --- /dev/null +++ b/xapp-std/values.yaml @@ -0,0 +1,89 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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 is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + # modify this section to point to your local testing settings + repository: "snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001" + repositoryCred: + user: docker + password: docker + image: + pullPolicy: IfNotPresent + +ricplt: + # This section is reserved for values imported from RIC Platform charts + + +ricapp: + # This section is for xapp. Templates to be resolved from xApp descriptor + replicaCount: 1 + xappname: &anchor-xappname xapp-std + + # the name of the process that indicates the liveness of the component + liveness-process-name: xapp-std + + image: + name: whoami + tag: 0.0.1 + + nameOverride: "" + fullnameOverride: "" + + service: + enabled: false + + + # to be provided as property file + appconfigpath: /opt/etc/xapp + appconfig: + # to be present as file propfile1 under appconfigpath + propfile1: | + prop1.v1="propvalue1.1" + prop1.v2="propvalue1.2" + # to be present as file propfile2 under appconfigpath + propfile2: "prop2" + + # to be provided as env variables + appenv: + NAME: *anchor-xappname + ENV1: "envvalue1" + ENV2: "envvalue2" + + # secret + appsecretpath: /opt/etc/kube + appsecret: + # to be present as files under path appsecretpath + username: myusername + password: mypassword + + + resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + + nodeSelector: {} + + tolerations: [] + + affinity: {} +