Commit 5412bd3a authored by Rafael Direito's avatar Rafael Direito
Browse files

Fixed CRs + API Changes

parent e08a6c33
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
apiVersion: org.etsi.osl/v1
kind: DummyOperatorService
metadata:
  name: _to_be_replaced_by_osl
  name: _to_be_replaced_by_osl_
  namespace: default
spec:
  status: "%s"
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
apiVersion: org.etsi.osl/v1
kind: DummyOperatorService
metadata:
  name: _to_be_replaced_by_osl
  name: _to_be_replaced_by_osl_
  namespace: default
spec:
  qodProv:
+60 −0
Original line number Diff line number Diff line

# VARIABLES

# API Docker Image
API_DOCKER_IMAGE_LOCAL_NAME = osl-camaraaas-qod-provisioning-api
API_DOCKER_IMAGE_LOCAL_TAG = latest
API_DOCKER_IMAGE_NAME_ON_REPOSITORY = osl-camaraaas-qod-provisioning-api
API_DOCKER_IMAGE_TAG_ON_REPOSITORY = latest

# Operator Docker Image
OPERATOR_DOCKER_IMAGE_LOCAL_NAME = osl-camaraaas-qod-provisioning-api-op
OPERATOR_DOCKER_IMAGE_LOCAL_TAG = latest
OPERATOR_DOCKER_IMAGE_NAME_ON_REPOSITORY = osl-camaraaas-qod-provisioning-api-op
OPERATOR_DOCKER_IMAGE_TAG_ON_REPOSITORY = latest

# VARIABLES TO UPDATE
REPOSITORY_HOST = atnog-harbor.av.it.pt/camaraaas
OPERATOR_NAMESPACE = osl-camara-controllers

# Dummy Operator Service
create-dummy-operator-crd:
	kubectl apply -f ./DummyOperatorService/crd.yaml
@@ -16,5 +34,47 @@ describe-dummy-operator-cr:
	kubectl describe dos example-dummy-operator-service || true


# CAMARAaaS QoD Provisioning API
build-api-docker-image:
	docker build -t $(API_DOCKER_IMAGE_LOCAL_NAME):$(API_DOCKER_IMAGE_LOCAL_TAG) ./QoDProvisioningAPI/API

tag-api-docker-image:
	docker tag $(API_DOCKER_IMAGE_LOCAL_NAME):$(API_DOCKER_IMAGE_LOCAL_TAG) $(REPOSITORY_HOST)/$(API_DOCKER_IMAGE_NAME_ON_REPOSITORY):$(API_DOCKER_IMAGE_TAG_ON_REPOSITORY)

push-api-docker-image:
	docker push $(REPOSITORY_HOST)/$(API_DOCKER_IMAGE_NAME_ON_REPOSITORY):$(API_DOCKER_IMAGE_TAG_ON_REPOSITORY)

api-docker-image: build-api-docker-image tag-api-docker-image push-api-docker-image


# CAMARAaaS QoD Provisioning API Operator
build-operator-docker-image:
	docker build -t $(OPERATOR_DOCKER_IMAGE_LOCAL_NAME):$(OPERATOR_DOCKER_IMAGE_LOCAL_TAG) ./QoDProvisioningAPI/Operator

tag-operator-docker-image:
	docker tag $(OPERATOR_DOCKER_IMAGE_LOCAL_NAME):$(OPERATOR_DOCKER_IMAGE_LOCAL_TAG) $(REPOSITORY_HOST)/$(OPERATOR_DOCKER_IMAGE_NAME_ON_REPOSITORY):$(OPERATOR_DOCKER_IMAGE_TAG_ON_REPOSITORY)

push-operator-docker-image:
	docker push $(REPOSITORY_HOST)/$(OPERATOR_DOCKER_IMAGE_NAME_ON_REPOSITORY):$(OPERATOR_DOCKER_IMAGE_TAG_ON_REPOSITORY)

operator-docker-image: build-operator-docker-image tag-operator-docker-image push-operator-docker-image


install-operator:
	helm install camaraaas-qod-prov-operator ./QoDProvisioningAPI/Operator/chart --set operator.image="$(REPOSITORY_HOST)/$(OPERATOR_DOCKER_IMAGE_NAME_ON_REPOSITORY):$(OPERATOR_DOCKER_IMAGE_TAG_ON_REPOSITORY)" --set camaraQoDAPI.image="$(REPOSITORY_HOST)/$(API_DOCKER_IMAGE_NAME_ON_REPOSITORY):$(API_DOCKER_IMAGE_TAG_ON_REPOSITORY)"  --namespace $(OPERATOR_NAMESPACE) --create-namespace

get-operator-logs:
	kubectl logs -f $$(kubectl get pods -n $(OPERATOR_NAMESPACE)  -l app=camaraaas-qod-provisioning-api-op -o jsonpath="{.items[0].metadata.name}") -n $(OPERATOR_NAMESPACE) 

uninstall-operator:
	helm uninstall camaraaas-qod-prov-operator -n $(OPERATOR_NAMESPACE) 


create-operator-test-cr:
	kubectl apply -f ./QoDProvisioningAPI/Operator/test-cr.yaml

describe-operator-test-cr:
	kubectl describe camaraaas-qod-provisioning-apis.org.etsi.osl test-qod-provisioning

delete-operator-test-cr:
	kubectl delete -f ./QoDProvisioningAPI/Operator/test-cr.yaml
+31 −0
Original line number Diff line number Diff line
# Use an official Python runtime as a parent image
FROM python:3.9-slim

# Set the working directory to /app
WORKDIR /app

# Install system dependencies and SQLite CLI
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    sqlite3 \
    gcc \
    libsqlite3-dev && \
    rm -rf /var/lib/apt/lists/*

# Copy the requirements file into the container
COPY requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application code into the container
COPY src/ /app/

# Create the data directory for the SQLite database
RUN mkdir -p /data

# Set environment variables
ENV SQLITE_DB_PATH=/data/sqlite.db

# Set the command to run the application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
+37 −0
Original line number Diff line number Diff line

# Variables
DOCKER_REPOSITORY_IMAGE_NAME = camaraaas-qod-provisioning-api
DOCKER_REPOSITORY_TAG = latest
REPOSITORY_HOST = atnog-harbor.av.it.pt/camaraaas

SERVICE_UUID=6b6b2f37-b232-4a6a-b9bf-55f96dbdb773

# API
init:
	python3 -m venv venv && . venv/bin/activate && pip install -r requirements.txt && deactivate

run:
	. venv/bin/activate && SQLITE_DB_PATH=~/sqlite.db  BROKER_ADDRESS=10.255.28.137 BROKER_PORT=61613  BROKER_USERNAME=artemis BROKER_PASSWORD=artemis SERVICE_UUID=$(SERVICE_UUID) PYTHONPATH=src uvicorn src.main:app --host 0.0.0.0 --port 8000 --reload --log-level info  && deactivate

delete-db:
	rm -f ~/sqlite.db


# DOCKER
docker-build:
	docker build -t $(DOCKER_REPOSITORY_IMAGE_NAME):$(DOCKER_REPOSITORY_TAG) .

docker-tag:
	docker tag $(DOCKER_REPOSITORY_IMAGE_NAME):$(DOCKER_REPOSITORY_TAG) $(REPOSITORY_HOST)/$(DOCKER_REPOSITORY_IMAGE_NAME):$(DOCKER_REPOSITORY_TAG)

docker-push:
	docker push $(REPOSITORY_HOST)/$(DOCKER_REPOSITORY_IMAGE_NAME):$(DOCKER_REPOSITORY_TAG)

docker-clean:
	docker image prune -f

docker-remove:
	docker rmi $(LOCAL_IMAGE_NAME):$(LOCAL_TAG)

docker: docker-build docker-tag docker-push
Loading