function _compile_src {
echo "Compiling source code"
- ls
pushd $k8s_path/src/k8splugin/
pwd
# mount directory and build in container (thus not relying on the state of the runner)
# See the License for the specific language governing permissions and
# limitations under the License.
-version: '3'
-
+# network_mode: host is necessary because
+# the multicloud-k8s needs to be able to access the
+# kubernetes cluster that is running on the host (in the pipeline)
services:
+ mongo-service:
+ container_name: mongo-service
+ image: nexus3.onap.org:10001/mongo:5.0.28
+ healthcheck:
+ test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
+ interval: 10s
+ timeout: 3s
+ retries: 3
+ start_period: 10s
+ network_mode: host
+ # ports:
+ # - 27017:27017
+ restart: always
+ etcd-service:
+ container_name: etcd-service
+ image: nexus3.onap.org:10001/bitnami/etcd:3
+ environment:
+ - ALLOW_NONE_AUTHENTICATION=yes
+ volumes:
+ - etcd_data:/bitnami/etcd
+ network_mode: host
+ # ports:
+ # - 2379:2379
+ # - 2380:2380
multicloud-k8s:
image: ${IMAGE_NAME}
build:
context: ./
- args:
- - HTTP_PROXY=${HTTP_PROXY}
- - HTTPS_PROXY=${HTTPS_PROXY}
- - NO_PROXY=${NO_PROXY}
- environment:
- - HTTP_PROXY=${HTTP_PROXY}
- - HTTPS_PROXY=${HTTPS_PROXY}
- - NO_PROXY=${NO_PROXY},mongo
depends_on:
- mongo:
+ mongo-service:
condition: service_healthy
+ # ports:
+ # - 9015:9015
network_mode: host
- ports:
- - 9015:9015
volumes:
- /opt/csar:/opt/csar
- ${PWD}/k8sconfig.json:/opt/multicloud/k8splugin/k8sconfig.json:ro
restart: always
healthcheck:
test: ["CMD", "curl", "http://localhost:9015/v1"]
- mongo:
- image: nexus3.onap.org:10001/mongo:5.0.28
- environment:
- - HTTP_PROXY=${HTTP_PROXY}
- - HTTPS_PROXY=${HTTPS_PROXY}
- - NO_PROXY=${NO_PROXY}
- healthcheck:
- test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
- ports:
- - 27017:27017
- restart: always
- etcd:
- image: nexus3.onap.org:10001/bitnami/etcd:3
- environment:
- - ALLOW_NONE_AUTHENTICATION=yes
- - HTTP_PROXY=${HTTP_PROXY}
- - HTTPS_PROXY=${HTTPS_PROXY}
- - NO_PROXY=${NO_PROXY}
- volumes:
- - etcd_data:/bitnami/etcd
- ports:
- - 2379:2379
- - 2380:2380
+ interval: 10s
+ timeout: 3s
+ retries: 3
+ start_period: 5s
volumes:
etcd_data:
--- /dev/null
+{
+ "database-address": "localhost",
+ "database-ip": "localhost",
+ "etcd-ip": "localhost",
+ "database-type": "mongo",
+ "plugin-dir": "plugins",
+ "service-port": "9015"
+
+}
# Start k8splugin from containers. build.sh should be run prior this script.
#
stop_all
-start_mongo
-generate_k8sconfig
start_all
wait_for_service
return 2
else
echo "[INFO] Server replied with status: ${status}" >&2
- cat "${curl_response_file}"
- rm "${curl_response_file}"
if [[ "${status:0:1}" =~ [45] ]]; then
+ echo $(cat "${curl_response_file}") >&2
+ echo $(docker compose logs -f $WORKSPACE/deployments/docker-compose.yml --tail=30 multicloud-k8s) >&2
+ # `cat` determines the return value on stdout for the caller here
+ cat "${curl_response_file}"
+ rm "${curl_response_file}"
return 1
else
+ cat "${curl_response_file}"
+ rm "${curl_response_file}"
return 0
fi
fi
call_api --data-binary "@${CSAR_DIR}/${csar_id}/vault-consul-dev-0.0.0.tgz" "${base_url}/rb/definition/$rb_name/$rb_version/content"
print_msg "Listing Resource Bundle Definitions"
+sleep 2
rb_list=$(call_api "${base_url}/rb/definition/$rb_name")
if [[ "$rb_list" != *"${rb_name}"* ]]; then
echo $rb_list
echo "Resource Bundle Definition not stored"
+ echo "Last container logs: "
+ echo $(docker compose -f $WORKSPACE/deployments/docker-compose.yml logs --tail=30 multicloud-k8s) >&2
exit 1
fi
func readConfigFile(file string) (*Configuration, error) {
f, err := os.Open(file)
if err != nil {
+ log.Printf("Error loading config file: %v. Using defaults.", err)
return defaultConfiguration(), err
}
defer f.Close()
if gConfig == nil {
conf, err := readConfigFile("k8sconfig.json")
if err != nil {
- log.Println("Error loading config file. Using defaults.")
+ log.Printf("Error loading config file: %v", err)
}
gConfig = conf
}