Run the installation script with -c k8s to deploy osm on K8s.
To Uninstall OSM deployed on Kubernetes run script with --uninstall -c k8s.
Each yaml file in osm_pods directory contains yaml definitions for pods and services.
Added license to yaml files in osm_pods.
Changed volume mounts to OSM_NAMESPACE_VOL from docker volumes.
Removes all pods and services while uninstalling.
Added namespace to deploy osm services. Deleting namespace
for uninstalling osm services.
Resolved Merge conflict with Change-7931. Changed Mongo, Kafka,
zookeeper, mysql and prometheus to statefulset.
-s <namespace> users can define namespace for k8s to deploy
osm services.
Added cluster configuration file which will be used to install k8s control plane
Addressed nodeport range issue and resolved merge conflict.
Added two yaml files to create a job for systest and robot test.
Change-Id: Iabe70fa7aed9cd638011bb92e2f300e32cff5772
Signed-off-by: vijaynag.bs <vijaynag.bs@tataelxsi.co.in>
+# Copyright 2019 ETSI
+#
+# 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.
+
*.pyc
.cache
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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
+# Author: Vijay Nag B S (vijaynag.bs@tataelxsi.co.in)
+
+apiVersion: kubeadm.k8s.io/v1beta1
+kind: ClusterConfiguration
+networking:
+ podSubnet: 10.244.0.0/16
+apiServer:
+ extraArgs:
+ service-node-port-range: "80-32767"
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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
+# Author: Vijay Nag B S (vijaynag.bs@tataelxsi.co.in)
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: kafka
+spec:
+ clusterIP: None
+ ports:
+ - port: 9092
+ protocol: TCP
+ targetPort: 9092
+ selector:
+ app: kafka
+ type: ClusterIP
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+ name: kafka
+ labels:
+ app: kafka
+spec:
+ replicas: 1
+ serviceName: kafka
+ selector:
+ matchLabels:
+ app: kafka
+ template:
+ metadata:
+ labels:
+ app: kafka
+ spec:
+ initContainers:
+ - name: zookeeper-test
+ image: alpine:latest
+ command: ["sh", "-c", "until nc -zvw1 zookeeper 2181; do sleep3; done; exit 0"]
+ containers:
+ - name: kafka
+ image: wurstmeister/kafka:2.11-1.0.2
+ ports:
+ - containerPort: 9092
+ protocol: TCP
+ env:
+ - name: KAFKA_ADVERTISED_HOST_NAME
+ value: kafka
+ - name: KAFKA_ADVERTISED_PORT
+ value: "9092"
+ - name: KAFKA_ZOOKEEPER_CONNECT
+ value: zookeeper:2181
+ - name: KAFKA_LOG_RETENTION_HOURS
+ value: "24"
+ volumeMounts:
+ - name: socket
+ mountPath: /var/run/docker.sock
+ volumes:
+ - name: socket
+ hostPath:
+ path: /var/run/docker.sock
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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
+# Author: Vijay Nag B S (vijaynag.bs@tataelxsi.co.in)
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: keystone
+spec:
+ ports:
+ - port: 5000
+ protocol: TCP
+ targetPort: 5000
+ selector:
+ app: keystone
+ type: ClusterIP
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: keystone
+ labels:
+ app: keystone
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: keystone
+ template:
+ metadata:
+ labels:
+ app: keystone
+ spec:
+ containers:
+ - name: keystone
+ image: opensourcemano/keystone:latest
+ ports:
+ - containerPort: 5000
+ protocol: TCP
+ env:
+ - name: DB_HOST
+ value: mysql
+ envFrom:
+ - secretRef:
+ name: keystone-secret
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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
+# Author: Vijay Nag B S (vijaynag.bs@tataelxsi.co.in)
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: lcm
+ labels:
+ app: lcm
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: lcm
+ template:
+ metadata:
+ labels:
+ app: lcm
+ spec:
+ initContainers:
+ - name: kafka-ro-mongo-test
+ image: alpine:latest
+ command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 ro 9090 && nc -zvw1 mongo 27017 ); do sleep 3; done; exit 0"]
+ containers:
+ - name: lcm
+ image: opensourcemano/lcm:latest
+ env:
+ - name: OSMLCM_RO_HOST
+ value: ro
+ - name: OSMLCM_DATABASE_HOST
+ value: mongo
+ - name: OSMLCM_MESSAGE_HOST
+ value: kafka
+ envFrom:
+ - secretRef:
+ name: lcm-secret
+ volumeMounts:
+ - name: osm-packages
+ mountPath: /app/storage
+ volumes:
+ - name: osm-packages
+ hostPath:
+ path: /var/lib/osm/osm_osm_packages/_data
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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
+# Author: Vijay Nag B S (vijaynag.bs@tataelxsi.co.in)
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: light-ui
+spec:
+ ports:
+ - nodePort: 80
+ port: 80
+ protocol: TCP
+ targetPort: 80
+ selector:
+ app: light-ui
+ type: NodePort
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: light-ui
+ labels:
+ app: light-ui
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: light-ui
+ template:
+ metadata:
+ labels:
+ app: light-ui
+ spec:
+ containers:
+ - name: light-ui
+ image: opensourcemano/light-ui:latest
+ envFrom:
+ - secretRef:
+ name: lwui-secret
+ ports:
+ - containerPort: 80
+ protocol: TCP
+ env:
+ - name: OSM_SERVER
+ value: nbi
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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
+# Author: Vijay Nag B S (vijaynag.bs@tataelxsi.co.in)
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: mon
+spec:
+ clusterIP: None
+ ports:
+ - port: 8662
+ protocol: TCP
+ targetPort: 8662
+ selector:
+ app: mon
+ type: ClusterIP
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: mon
+ labels:
+ app: mon
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: mon
+ template:
+ metadata:
+ labels:
+ app: mon
+ spec:
+ initContainers:
+ - name: kafka-mongo-test
+ image: alpine:latest
+ command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongo 27017); do sleep 3; done; exit 0"]
+ containers:
+ - name: mon
+ image: opensourcemano/mon:latest
+ ports:
+ - containerPort: 8662
+ protocol: TCP
+ env:
+ - name: OSMMON_MESSAGE_HOST
+ value: kafka
+ - name: OSMMON_MESSAGE_PORT
+ value: "9092"
+ envFrom:
+ - secretRef:
+ name: mon-secret
+ volumeMounts:
+ - name: mon-storage
+ mountPath: /app/database
+ volumes:
+ - name: mon-storage
+ hostPath:
+ path: /var/lib/osm/osm_mon_db/_data
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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
+# Author: Vijay Nag B S (vijaynag.bs@tataelxsi.co.in)
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: mongo
+spec:
+ clusterIP: None
+ ports:
+ - port: 27017
+ protocol: TCP
+ targetPort: 27017
+ selector:
+ app: mongo
+ type: ClusterIP
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+ name: mongo
+ labels:
+ app: mongo
+spec:
+ replicas: 1
+ serviceName: mongo
+ selector:
+ matchLabels:
+ app: mongo
+ template:
+ metadata:
+ labels:
+ app: mongo
+ spec:
+ containers:
+ - name: mongo
+ image: mongo:latest
+ ports:
+ - containerPort: 27017
+ protocol: TCP
+ volumeMounts:
+ - name: mongo-db
+ mountPath: /data/db
+ volumes:
+ - name: mongo-db
+ hostPath:
+ path: /var/lib/osm/osm_mongo_db/_data
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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
+# Author: Vijay Nag B S (vijaynag.bs@tataelxsi.co.in)
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: mysql
+spec:
+ clusterIP: None
+ ports:
+ - port: 3306
+ protocol: TCP
+ targetPort: 3306
+ selector:
+ app: mysql
+ type: ClusterIP
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+ name: mysql
+ labels:
+ app: mysql
+spec:
+ replicas: 1
+ serviceName: mysql
+ selector:
+ matchLabels:
+ app: mysql
+ template:
+ metadata:
+ labels:
+ app: mysql
+ spec:
+ containers:
+ - image: mysql:5
+ name: mysql
+ envFrom:
+ - secretRef:
+ name: ro-db-secret
+ ports:
+ - containerPort: 3306
+ name: mysql
+ volumeMounts:
+ - name: mysql-db
+ mountPath: /var/lib/mysql
+ volumes:
+ - name: mysql-db
+ hostPath:
+ path: /var/lib/osm/osm_ro_db/_data
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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
+# Author: Vijay Nag B S (vijaynag.bs@tataelxsi.co.in)
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: nbi
+spec:
+ ports:
+ - nodePort: 9999
+ port: 9999
+ protocol: TCP
+ targetPort: 9999
+ selector:
+ app: nbi
+ type: NodePort
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: nbi
+ labels:
+ app: nbi
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: nbi
+ template:
+ metadata:
+ labels:
+ app: nbi
+ spec:
+ initContainers:
+ - name: kafka-mongo-test
+ image: alpine:latest
+ command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongo 27017); do sleep 3; done; exit 0"]
+ containers:
+ - name: nbi
+ image: opensourcemano/nbi:latest
+ ports:
+ - containerPort: 9999
+ protocol: TCP
+ env:
+ - name: OSMNBI_DATABASE_HOST
+ value: mongo
+ - name: OSMNBI_MESSAGE_HOST
+ value: kafka
+ envFrom:
+ - secretRef:
+ name: nbi-secret
+ volumeMounts:
+ - name: osm-packages
+ mountPath: /app/storage
+ volumes:
+ - name: osm-packages
+ hostPath:
+ path: /var/lib/osm/osm_osm_packages/_data
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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
+# Author: Vijay Nag B S (vijaynag.bs@tataelxsi.co.in)
+
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: pol
+ labels:
+ app: pol
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: pol
+ template:
+ metadata:
+ labels:
+ app: pol
+ spec:
+ initContainers:
+ - name: kafka-mongo-test
+ image: alpine:latest
+ command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 mongo 27017); do sleep 3; done; exit 0"]
+ containers:
+ - name: pol
+ image: opensourcemano/pol:latest
+ env:
+ - name: OSMPOL_MESSAGE_HOST
+ value: kafka
+ - name: OSMPOL_MESSAGE_PORT
+ value: "9092"
+ envFrom:
+ - secretRef:
+ name: pol-secret
+ volumeMounts:
+ - name: db
+ mountPath: /app/database
+ volumes:
+ - name: db
+ hostPath:
+ path: /var/lib/osm/osm_pol_db/_data
--- /dev/null
+apiVersion: v1
+kind: Service
+metadata:
+ name: prometheus
+spec:
+ ports:
+ - nodePort: 9091
+ port: 9090
+ protocol: TCP
+ targetPort: 9090
+ selector:
+ app: prometheus
+ type: NodePort
+---
+apiVersion: v1
+data:
+ prometheus.yml: |
+ # Copyright 2018 The Prometheus Authors
+ # Copyright 2018 Whitestack
+ # Copyright 2018 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.
+
+ # my global config
+ global:
+ scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
+ evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
+ # scrape_timeout is set to the global default (10s).
+
+ # Alertmanager configuration
+ alerting:
+ alertmanagers:
+ - static_configs:
+ - targets:
+ # - alertmanager:9093
+
+ # Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
+ rule_files:
+ # - "first_rules.yml"
+ # - "second_rules.yml"
+
+ # A scrape configuration containing exactly one endpoint to scrape:
+ # Here it's Prometheus itself.
+ scrape_configs:
+ # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
+ - job_name: 'prometheus'
+
+ # metrics_path defaults to '/metrics'
+ # scheme defaults to 'http'.
+
+ static_configs:
+ - targets: ['mon:8000']
+kind: ConfigMap
+metadata:
+ name: prom
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+ name: prometheus
+ labels:
+ app: prometheus
+spec:
+ replicas: 1
+ serviceName: prometheus
+ selector:
+ matchLabels:
+ app: prometheus
+ template:
+ metadata:
+ labels:
+ app: prometheus
+ spec:
+ containers:
+ - name: prometheus
+ image: prom/prometheus:v2.4.3
+ ports:
+ - containerPort: 9090
+ protocol: TCP
+ volumeMounts:
+ - name: prom-config
+ mountPath: /etc/prometheus/
+ - name: prom-db
+ mountPath: /prometheus
+ volumes:
+ - configMap:
+ defaultMode: 420
+ name: prom
+ name: prom-config
+ - emptyDir: {}
+ name: prom-db
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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
+# Author: Vijay Nag B S (vijaynag.bs@tataelxsi.co.in)
+
+apiVersion: v1
+kind: Service
+metadata:
+ name: ro
+spec:
+ clusterIP: None
+ ports:
+ - port: 9090
+ protocol: TCP
+ targetPort: 9090
+ selector:
+ app: ro
+ type: ClusterIP
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: ro
+ labels:
+ app: ro
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: ro
+ template:
+ metadata:
+ labels:
+ app: ro
+ spec:
+ initContainers:
+ - name: ro-db-test
+ image: alpine:latest
+ command: ["sh", "-c", "until nc -zvw1 mysql 3306; do sleep 3 ; done; exit 0"]
+ containers:
+ - name: ro
+ image: opensourcemano/ro:latest
+ ports:
+ - containerPort: 9090
+ protocol: TCP
+ env:
+ - name: RO_DB_HOST
+ value: mysql
+ envFrom:
+ - secretRef:
+ name: ro-secret
+ volumeMounts:
+ - name: ro
+ mountPath: /var/log/osm
+ volumes:
+ - name: ro
+ hostPath:
+ path: /var/lib/osm/osm_ro/_data
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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: zookeeper
+spec:
+ clusterIP: None
+ ports:
+ - port: 2181
+ protocol: TCP
+ targetPort: 2181
+ selector:
+ app: zookeeper
+ type: ClusterIP
+---
+apiVersion: apps/v1
+kind: StatefulSet
+metadata:
+ name: zookeeper
+ labels:
+ app: zookeeper
+spec:
+ replicas: 1
+ serviceName: zookeeper
+ selector:
+ matchLabels:
+ app: zookeeper
+ template:
+ metadata:
+ labels:
+ app: zookeeper
+ spec:
+ containers:
+ - name: zookeeper
+ image: wurstmeister/zookeeper:latest
+ ports:
+ - containerPort: 2181
+ protocol: TCP
echo -e " -b v2.0 (v2.0 branch)"
echo -e " -b tags/v1.1.0 (a specific tag)"
echo -e " ..."
- echo -e " -s <stack name> user defined stack name, default is osm"
+ echo -e " -c <orchestrator> deploy osm services using container <orchestrator>. Valid values are <k8s> or <swarm>. If -c is not used then osm will be deployed using default orchestrator. When used with --uninstall, osm services deployed by the orchestrator will be uninstalled"
+ echo -e " -s <stack name> or <namespace> user defined stack name when installed using swarm or namespace when installed using k8s, default is osm"
echo -e " -H <VCA host> use specific juju host controller IP"
echo -e " -S <VCA secret> use VCA/juju secret key"
echo -e " -P <VCA pubkey> use VCA/juju public key file"
}
function remove_volumes() {
- stack=$1
- volumes="mongo_db mon_db osm_packages ro_db"
- for volume in $volumes; do
- sg docker -c "docker volume rm ${stack}_${volume}"
- done
+ if [ -n "$KUBERNETES" ]; then
+ k8_volume=$1
+ echo "Removing ${k8_volume}"
+ $WORKDIR_SUDO rm -rf ${k8_volume}
+ else
+ stack=$1
+ volumes="mongo_db mon_db osm_packages ro_db"
+ for volume in $volumes; do
+ sg docker -c "docker volume rm ${stack}_${volume}"
+ done
+ fi
}
function remove_network() {
fi
}
+#removes osm deployments and services
+function remove_k8s_namespace() {
+ kubectl delete ns $1
+}
+
#Uninstall lightweight OSM: remove dockers
function uninstall_lightweight() {
if [ -n "$INSTALL_ONLY" ]; then
fi
else
echo -e "\nUninstalling OSM"
- remove_stack $OSM_STACK_NAME
- remove_stack osm_elk
- remove_stack osm_metrics
+ if [ -n "$KUBERNETES" ]; then
+ remove_k8s_namespace $OSM_STACK_NAME
+ else
+ remove_stack $OSM_STACK_NAME
+ remove_stack osm_elk
+ remove_stack osm_metrics
+ fi
echo "Now osm docker images and volumes will be deleted"
newgrp docker << EONG
docker image rm ${DOCKER_USER}/ro:${OSM_DOCKER_TAG}
docker image rm ${DOCKER_USER}/pol:${OSM_DOCKER_TAG}
docker image rm ${DOCKER_USER}/osmclient:${OSM_DOCKER_TAG}
EONG
- remove_volumes $OSM_STACK_NAME
- remove_network $OSM_STACK_NAME
+
+ if [ -n "$KUBERNETES" ]; then
+ OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}"
+ remove_volumes $OSM_NAMESPACE_VOL
+ else
+ remove_volumes $OSM_STACK_NAME
+ remove_network $OSM_STACK_NAME
+ fi
echo "Removing $OSM_DOCKER_WORK_DIR"
$WORKDIR_SUDO rm -rf $OSM_DOCKER_WORK_DIR
sg lxd -c "juju destroy-controller --destroy-all-models --yes $OSM_STACK_NAME"
fi
}
-
function generate_docker_env_files() {
echo "Doing a backup of existing env files"
$WORKDIR_SUDO cp $OSM_DOCKER_WORK_DIR/keystone-db.env{,~}
$WORKDIR_SUDO cp $OSM_DOCKER_WORK_DIR/ro.env{,~}
echo "Generating docker env files"
- # Docker-compose
- $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/docker-compose.yaml $OSM_DOCKER_WORK_DIR/docker-compose.yaml
+ if [ -n "$KUBERNETES" ]; then
+ #Kubernetes resources
+ $WORKDIR_SUDO cp -bR ${OSM_DEVOPS}/installers/docker/osm_pods $OSM_DOCKER_WORK_DIR
+ else
+ # Docker-compose
+ $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/docker-compose.yaml $OSM_DOCKER_WORK_DIR/docker-compose.yaml
- # Prometheus
- $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/prometheus.yml $OSM_DOCKER_WORK_DIR/prometheus.yml
+ # Prometheus
+ $WORKDIR_SUDO cp -b ${OSM_DEVOPS}/installers/docker/prometheus.yml $OSM_DOCKER_WORK_DIR/prometheus.yml
+ fi
# LCM
if [ ! -f $OSM_DOCKER_WORK_DIR/lcm.env ]; then
echo "osmclient sidecar container can be found at: $OSM_DOCKER_WORK_DIR/osm"
}
+#installs kubernetes packages
+function install_kube() {
+ sudo apt-get update && sudo apt-get install -y apt-transport-https
+ curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
+ sudo add-apt-repository "deb https://apt.kubernetes.io/ kubernetes-xenial main"
+ sudo apt-get update
+ echo "Installing Kubernetes Packages ..."
+ sudo apt-get install -y kubelet=1.15.0-00 kubeadm=1.15.0-00 kubectl=1.15.0-00
+}
+
+#initializes kubernetes control plane
+function init_kubeadm() {
+ sudo swapoff -a
+ sudo kubeadm init --config $1
+ sleep 5
+}
+
+function kube_config_dir() {
+ [ ! -d $K8S_MANIFEST_DIR ] && FATAL "Cannot Install Kubernetes"
+ mkdir -p $HOME/.kube
+ sudo cp /etc/kubernetes/admin.conf $HOME/.kube/config
+ sudo chown $(id -u):$(id -g) $HOME/.kube/config
+}
+
+#deploys flannel as daemonsets
+function deploy_cni_provider() {
+ CNI_DIR="$(mktemp -d -q --tmpdir "flannel.XXXXXX")"
+ trap 'rm -rf "${CNI_DIR}"' EXIT
+ wget -q https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml -P $CNI_DIR
+ kubectl apply -f $CNI_DIR
+ [ $? -ne 0 ] && FATAL "Cannot Install Flannel"
+}
+
+#creates secrets from env files which will be used by containers
+function kube_secrets(){
+ kubectl create ns $OSM_STACK_NAME
+ kubectl create secret generic lcm-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/lcm.env
+ kubectl create secret generic mon-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/mon.env
+ kubectl create secret generic nbi-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/nbi.env
+ kubectl create secret generic ro-db-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/ro-db.env
+ kubectl create secret generic ro-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/ro.env
+ kubectl create secret generic keystone-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/keystone.env
+ kubectl create secret generic lwui-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/lwui.env
+ kubectl create secret generic pol-secret -n $OSM_STACK_NAME --from-env-file=$OSM_DOCKER_WORK_DIR/pol.env
+}
+
+#deploys osm pods and services
+function deploy_osm_services() {
+ K8S_MASTER=$(kubectl get nodes | awk '$3~/master/'| awk '{print $1}')
+ kubectl taint node $K8S_MASTER node-role.kubernetes.io/master:NoSchedule-
+ sleep 5
+ kubectl apply -n $OSM_STACK_NAME -f $OSM_K8S_WORK_DIR
+}
+
+function parse_yaml() {
+ osm_services="nbi lcm ro pol mon light-ui keystone"
+ TAG=$1
+ for osm in $osm_services; do
+ $WORKDIR_SUDO sed -i "s/opensourcemano\/$osm:.*/opensourcemano\/$osm:$TAG/g" $OSM_K8S_WORK_DIR/$osm.yaml
+ done
+}
+
+function namespace_vol() {
+ osm_services="nbi lcm ro pol mon kafka mongo mysql"
+ for osm in $osm_services; do
+ $WORKDIR_SUDO sed -i "s#path: /var/lib/osm#path: $OSM_NAMESPACE_VOL#g" $OSM_K8S_WORK_DIR/$osm.yaml
+ done
+}
+
function init_docker_swarm() {
if [ "${DEFAULT_MTU}" != "1500" ]; then
DOCKER_NETS=`sg docker -c "docker network list" | awk '{print $2}' | egrep -v "^ID$" | paste -d " " -s`
function install_lightweight() {
[ "${OSM_STACK_NAME}" == "osm" ] || OSM_DOCKER_WORK_DIR="$OSM_WORK_DIR/stack/$OSM_STACK_NAME"
+ [ -n "$KUBERNETES" ] && OSM_K8S_WORK_DIR="$OSM_DOCKER_WORK_DIR/osm_pods" && OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}"
[ ! -d "$OSM_DOCKER_WORK_DIR" ] && $WORKDIR_SUDO mkdir -p $OSM_DOCKER_WORK_DIR
+ [ -n "$KUBERNETES" ] && $WORKDIR_SUDO cp -b $OSM_DEVOPS/installers/docker/cluster-config.yaml $OSM_DOCKER_WORK_DIR/cluster-config.yaml
track checkingroot
[ "$USER" == "root" ] && FATAL "You are running the installer as root. The installer is prepared to be executed as a normal user with sudo privileges."
track noroot
- [ -z "$ASSUME_YES" ] && ! ask_user "The installation will configure LXD, install juju, install docker CE and init a docker swarm, as pre-requirements. Do you want to proceed (Y/n)? " y && echo "Cancelled!" && exit 1
+
+ if [ -n "$KUBERNETES" ]; then
+ [ -z "$ASSUME_YES" ] && ! ask_user "The installation will do the following
+ 1. Install and configure LXD
+ 2. Install juju
+ 3. Install docker CE
+ 4. Disable swap space
+ 5. Install and initialize Kubernetes
+ as pre-requirements.
+ Do you want to proceed (Y/n)? " y && echo "Cancelled!" && exit 1
+
+ else
+ [ -z "$ASSUME_YES" ] && ! ask_user "The installation will configure LXD, install juju, install docker CE and init a docker swarm, as pre-requirements. Do you want to proceed (Y/n)? " y && echo "Cancelled!" && exit 1
+ fi
track proceed
+
echo "Installing lightweight build of OSM"
LWTEMPDIR="$(mktemp -d -q --tmpdir "installosmlight.XXXXXX")"
trap 'rm -rf "${LWTEMPDIR}"' EXIT
|| FATAL "failed to install $need_packages_lw"
fi
track prereqok
- [ -z "$INSTALL_NOJUJU" ] && install_juju
+ [ -z "$INSTALL_NOJUJU" ] && install_juju
track juju_install
+
if [ -z "$OSM_VCA_HOST" ]; then
juju_createcontroller
OSM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_STACK_NAME"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
[ -z "$OSM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address"
fi
track juju_controller
+
if [ -z "$OSM_VCA_SECRET" ]; then
OSM_VCA_SECRET=$(parse_juju_password $OSM_STACK_NAME)
[ -z "$OSM_VCA_SECRET" ] && FATAL "Cannot obtain juju secret"
OSM_DATABASE_COMMONKEY=$(generate_secret)
[ -z "OSM_DATABASE_COMMONKEY" ] && FATAL "Cannot generate common db secret"
fi
-
track juju
+
[ -n "$INSTALL_NODOCKER" ] || install_docker_ce
track docker_ce
- #install_docker_compose
- [ -n "$INSTALL_NODOCKER" ] || init_docker_swarm
- track docker_swarm
+
+ #Installs Kubernetes and deploys osm services
+ if [ -n "$KUBERNETES" ]; then
+ install_kube
+ track install_k8s
+ init_kubeadm $OSM_DOCKER_WORK_DIR/cluster-config.yaml
+ kube_config_dir
+ track init_k8s
+ else
+ #install_docker_compose
+ [ -n "$INSTALL_NODOCKER" ] || init_docker_swarm
+ track docker_swarm
+ fi
+
[ -z "$DOCKER_NOBUILD" ] && generate_docker_images
track docker_build
+
generate_docker_env_files
- # remove old stack
- remove_stack $OSM_STACK_NAME
- create_docker_network
- deploy_lightweight
- generate_osmclient_script
- track docker_deploy
- [ -n "$INSTALL_VIMEMU" ] && install_vimemu && track vimemu
- [ -n "$INSTALL_ELK" ] && deploy_elk && track elk
- [ -n "$INSTALL_PERFMON" ] && deploy_perfmon && track perfmon
+ if [ -n "$KUBERNETES" ]; then
+ #remove old namespace
+ remove_k8s_namespace $OSM_STACK_NAME
+ deploy_cni_provider
+ kube_secrets
+ [ ! $OSM_DOCKER_TAG == "latest" ] && parse_yaml $OSM_DOCKER_TAG
+ namespace_vol
+ deploy_osm_services
+ track deploy_osm_services_k8s
+ else
+ # remove old stack
+ remove_stack $OSM_STACK_NAME
+ create_docker_network
+ deploy_lightweight
+ generate_osmclient_script
+ track docker_deploy
+ [ -n "$INSTALL_VIMEMU" ] && install_vimemu && track vimemu
+ [ -n "$INSTALL_ELK" ] && deploy_elk && track elk
+ [ -n "$INSTALL_PERFMON" ] && deploy_perfmon && track perfmon
+ fi
+
[ -z "$INSTALL_NOHOSTCLIENT" ] && install_osmclient
track osmclient
+
wget -q -O- https://osm-download.etsi.org/ftp/osm-6.0-six/README2.txt &> /dev/null
track end
return 0
echo "DOCKER_USER=$DOCKER_USER"
echo "OSM_STACK_NAME=$OSM_STACK_NAME"
echo "PULL_IMAGES=$PULL_IMAGES"
+ echo "KUBERNETES=$KUBERNETES"
echo "SHOWOPTS=$SHOWOPTS"
echo "Install from specific refspec (-b): $COMMIT_ID"
}
INSTALL_NOLXD=""
INSTALL_NODOCKER=""
INSTALL_NOJUJU=""
+KUBERNETES=""
INSTALL_NOHOSTCLIENT=""
NOCONFIGURE=""
RELEASE_DAILY=""
WORKDIR_SUDO=sudo
OSM_WORK_DIR="/etc/osm"
OSM_DOCKER_WORK_DIR="/etc/osm/docker"
+OSM_K8S_WORK_DIR="${OSM_DOCKER_WORK_DIR}/osm_pods"
+OSM_HOST_VOL="/var/lib/osm"
+OSM_NAMESPACE_VOL="${OSM_HOST_VOL}/${OSM_STACK_NAME}"
OSM_DOCKER_TAG=latest
DOCKER_USER=opensourcemano
PULL_IMAGES="y"
OSM_DATABASE_COMMONKEY=
ELASTIC_VERSION=6.4.2
ELASTIC_CURATOR_VERSION=5.5.4
+POD_NETWORK_CIDR=10.244.0.0/16
+K8S_MANIFEST_DIR="/etc/kubernetes/manifests"
+RE_CHECK='^[a-z0-9]([-a-z0-9]*[a-z0-9])?$'
-while getopts ":hy-:b:r:k:u:R:l:p:D:o:m:H:S:s:w:t:U:P:A:" o; do
+while getopts ":hy-:b:r:c:k:u:R:l:p:D:o:m:H:S:s:w:t:U:P:A:" o; do
case "${o}" in
h)
usage && exit 0
REPOSITORY="${OPTARG}"
REPO_ARGS+=(-r "$REPOSITORY")
;;
+ c)
+ [ "${OPTARG}" == "swarm" ] && continue
+ [ "${OPTARG}" == "k8s" ] && KUBERNETES="y" && continue
+ echo -e "Invalid argument for -i : ' $OPTARG'\n" >&2
+ usage && exit 1
+ ;;
R)
RELEASE="${OPTARG}"
REPO_ARGS+=(-R "$RELEASE")
OSM_DEVOPS="${OPTARG}"
;;
s)
- OSM_STACK_NAME="${OPTARG}"
+ OSM_STACK_NAME="${OPTARG}" && [ -n "$KUBERNETES" ] && [[ ! "${OPTARG}" =~ $RE_CHECK ]] && echo "Namespace $OPTARG is invalid. Regex used for validation is $RE_CHECK" && exit 0
;;
H)
OSM_VCA_HOST="${OPTARG}"
#!/bin/sh
+# Copyright 2019 ETSI
+#
+# 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.
+
WAIT_TIME=340 # LCM healthcheck needs 2x(30+140) senconds
SERVICES_WITH_HEALTH="nbi ro zookeeper lcm mon light-ui pol"
NUM_SERVICES_WITH_HEALTH=$(echo $SERVICES_WITH_HEALTH | wc -w)
WAIT_FINAL=30
+OSM_DEPLOYMENT="light-ui nbi lcm ro mon pol keystone"
+OSM_STATEFULSET="zookeeper kafka mongo mysql prometheus"
+NUM_K8S_PODS=$(echo $OSM_DEPLOYMENT $OSM_STATEFULSET | wc -w)
-while getopts "w:s:n:c:" o; do
+while getopts "w:s:n:c:k" o; do
case "${o}" in
w)
WAIT_TIME=${OPTARG}
c)
SERVICES_WITH_HEALTH="${OPTARG}"
;;
+ k)
+ KUBERNETES="y"
+ ;;
esac
done
time=0
step=2
while [ $time -le "$WAIT_TIME" ]; do
- if [ "$(docker ps | grep " ${STACK_NAME}_" | grep -i healthy | wc -l)" -ge "$NUM_SERVICES_WITH_HEALTH" ]; then
- # all dockers are healthy now.
- # final sleep is needed until more health checks are added to validate system is ready to handle requests
- sleep $WAIT_FINAL
- exit 0
+ if [ -n "$KUBERNETES" ]; then
+ if [ "$(kubectl get pods -n "${STACK_NAME}" | grep -i running | wc -l)" -ge "$NUM_K8S_PODS" ]; then
+ #all pods are running now.
+ sleep $WAIT_FINAL
+ exit 0
+ fi
+ else
+ if [ "$(docker ps | grep " ${STACK_NAME}_" | grep -i healthy | wc -l)" -ge "$NUM_SERVICES_WITH_HEALTH" ]; then
+ # all dockers are healthy now.
+ # final sleep is needed until more health checks are added to validate system is ready to handle requests
+ sleep $WAIT_FINAL
+ exit 0
+ fi
fi
sleep $step
time=$((time+step))
done
-echo "Not all Docker services are healthy"
-docker ps | grep " ${STACK_NAME}_"
-
-for S_WITH_HEALTH in $SERVICES_WITH_HEALTH ; do
- docker ps | grep " ${STACK_NAME}_" | grep -i healthy | grep -q "_${S_WITH_HEALTH}." && continue
- echo
- echo BEGIN LOGS of container ${S_WITH_HEALTH} not healthy
- docker service logs ${STACK_NAME}_${S_WITH_HEALTH} 2>&1 | tail -n 100
- echo END LOGS of container ${S_WITH_HEALTH} not healthy
- echo
-done
+if [ -n "$KUBERNETES" ]; then
+ echo "Not all pods are running"
+ kubectl get pods -n "${STACK_NAME}"
+ for POD in $OSM_DEPLOYMENT $OSM_STATEFULSET; do
+ kubectl get pods -n "${STACK_NAME}" | grep -i running | grep -q ^"${POD}-" && continue
+ echo
+ echo BEGIN LOGS of pods ${POD} not running
+ LOG_POD=$(kubectl get pods -n "${STACK_NAME}" | grep -e ^"${POD}-" | awk '{print $1}' )
+ [ -z "$LOG_POD" ] && echo "${POD} Failed to deploy" || kubectl logs ${LOG_POD} -n $STACK_NAME 2>&1 | tail -n 100
+ echo END LOGS of services $POD not running
+ done
+else
+ echo "Not all Docker services are healthy"
+ docker ps | grep " ${STACK_NAME}_"
+ for S_WITH_HEALTH in $SERVICES_WITH_HEALTH ; do
+ docker ps | grep " ${STACK_NAME}_" | grep -i healthy | grep -q "_${S_WITH_HEALTH}." && continue
+ echo
+ echo BEGIN LOGS of container ${S_WITH_HEALTH} not healthy
+ docker service logs ${STACK_NAME}_${S_WITH_HEALTH} 2>&1 | tail -n 100
+ echo END LOGS of container ${S_WITH_HEALTH} not healthy
+ echo
+ done
+fi
exit 1
-
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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.
+# Author: VIJAY NAG B S (vijaynag.bs@tataelxsi.co.in)
+
+################################################################
+# Please execute this command prior to deploying this yaml file.
+# __tag__ , __testName__ and __tempdir__ are placeholders for osm rel, testname and tempdir respectively.
+#
+# $ sed "s|__tag__|$TAG|; s|__testName__|$TEST|; s|__tempdir__|$tempdir|" osmclient-robot.yaml
+#
+############################################################
+
+apiVersion: batch/v1
+kind: Job
+metadata:
+ name: osmclient-robot
+ labels:
+ ciStage: stage3
+spec:
+ containers:
+ - name: osm-client
+ image: opensourcemano/osmclient:__tag__
+ envFrom:
+ - secretRef:
+ name: robot-secret
+ command: [ "bash", "-C", "/usr/share/osm-devops/robot-systest/run_test.sh", "--do_install", "-t", "__testName__" ]
+ volumeMounts:
+ - name: temp-dir
+ mountPath: /usr/share/osm-devops/systest/reports
+ restartPolicy: OnFailure
+ volumes:
+ - name: temp-dir
+ hostPath:
+ path: __tempdir__
--- /dev/null
+# Copyright 2019 TATA ELXSI
+#
+# 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.
+# Author: VIJAY NAG B S (vijaynag.bs@tataelxsi.co.in)
+
+################################################################
+# Please execute this command prior to deploying this yaml file.
+# __tag__ , __testName__ and __tempdir__ are placeholders for osm rel, testname and tempdir respectively.
+#
+# $ sed "s|__tag__|$TAG|; s|__testName__|$TEST|; s|__tempdir__|$tempdir|" osmclient-systest.yaml
+#
+############################################################
+
+apiVersion: batch/v1
+kind: Job
+metadata:
+ name: systest-client
+ labels:
+ ciStage: stage3
+spec:
+ containers:
+ - name: osm-client
+ image: opensourcemano/osmclient:__tag__
+ envFrom:
+ - secretRef:
+ name: systest-secret
+ command: [ "make", "-C", "/usr/share/osm-devops/systest", "__testName__" ]
+ volumeMounts:
+ - name: temp-dir
+ mountPath: /usr/share/osm-devops/systest/reports
+ restartPolicy: OnFailure
+ volumes:
+ - name: temp-dir
+ hostPath:
+ path: __tempdir__