diff --git a/acm-controller/for-dockerhub.txt b/acm-controller/for-dockerhub.txt index 370e7ce056a2ad29be231821269ad4642dcee009..5b7fdbd840e096072b532bf3b6b621b17ac42b56 100644 --- a/acm-controller/for-dockerhub.txt +++ b/acm-controller/for-dockerhub.txt @@ -26,4 +26,4 @@ docker push hecodeco/acm-controller:2.3.1-hotfix docker buildx build \ --push \ --platform linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8 \ ---tag hecodeco/acm-controller:v2.0.0 . # Next one will be v2.1.0 \ No newline at end of file +--tag hecodeco/acm-controller:2.0.0 . # Next one will be 2.1.0 \ No newline at end of file diff --git a/mdm-controller/for-dockerhub.txt b/mdm-controller/for-dockerhub.txt index 66db167c166e8b3f88563ad20a73effea61ddc57..8c6ecc49754b16d8161eef00b9a04267023fd77b 100644 --- a/mdm-controller/for-dockerhub.txt +++ b/mdm-controller/for-dockerhub.txt @@ -19,12 +19,12 @@ # The commands below must be executed from this directory docker build \ ---tag hecodeco/mdm-controller:v2.0.1 . +--tag hecodeco/mdm-controller:2.0.2 . -docker push hecodeco/mdm-controller:v2.0.1 +docker push hecodeco/mdm-controller:2.0.2 # The commands below must be executed from this directory docker buildx build \ --push \ --platform linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8 \ ---tag hecodeco/mdm-controller:v2.0.0 . # Next one will be v2.1.0 \ No newline at end of file +--tag hecodeco/mdm-controller:2.0.0 . # Next one will be 2.1.0 \ No newline at end of file diff --git a/mdm-controller/mdm-controller-deployment.yaml b/mdm-controller/mdm-controller-deployment.yaml index 5cd6b37b67459d79d95857fd79d850cc19e257bc..247a232229e4d6f071ebf29b0a8578ca1377e1e8 100644 --- a/mdm-controller/mdm-controller-deployment.yaml +++ b/mdm-controller/mdm-controller-deployment.yaml @@ -35,7 +35,7 @@ spec: serviceAccountName: default containers: - name: mdm-controller - image: docker.io/hecodeco/mdm-controller:2.0.0 + image: docker.io/hecodeco/mdm-controller:2.0.2 imagePullPolicy: Always ports: - containerPort: 5000 diff --git a/mdm-controller/mdm-controller.py b/mdm-controller/mdm-controller.py index fdaf481922621f8749f8f05e232c9b4720690a6c..165a7762004c23f24923ff4194acb80d8c394a14 100644 --- a/mdm-controller/mdm-controller.py +++ b/mdm-controller/mdm-controller.py @@ -19,35 +19,84 @@ from flask import Flask, request import random +import yaml app = Flask(__name__) -# Define the CRD properties +# Define possible values for properties properties = { - "pod_name": None, - "freshness": ["healthy", "stale", "unknown"], - "compliance": ["compliant", "non-compliant", "unknown"], - "portability": ["high", "medium", "low", "unknown"] + "freshness": ["0.1", "0.3", "0.4", "n/a"], + "compliance": ["0.8", "0.9", "1.0", "n/a"], + "portability": ["0.5", "0.7", "1.0", "n/a"] } +# Base YAML template +yaml_template = """ +spec: + groups: codeco.com + versions: + - name: v1 + served: 'true' + storage: 'true' + schema: + openAPIV3Schema: + type: object + properties: + spec: + type: object + properties: + pod_name: + description: identifier of the node + type: string + value: n/a + freshness: + description: healthiness of the node based on data freshness + type: string + value: n/a + compliance: + description: compliance to application requirements + type: string + value: n/a + portability: + description: portability level for a specific application + type: string + value: n/a + scope: Namespaced + names: + plural: mdm-mons + singular: mdm-mon + kind: MDM + shortNames: + - mdm-m +""" + # Define the endpoint -@app.route('/pdlc', methods=['GET']) +@app.route('/mdm/api/v1/pdlc', methods=['GET']) def pdlc(): # Extract parameters from the request cluster = request.args.get('cluster') namespace = request.args.get('namespace') - pod = request.args.get('pod') + pod_name = request.args.get('pod') # Generate random values for CRD properties freshness = random.choice(properties["freshness"]) compliance = random.choice(properties["compliance"]) portability = random.choice(properties["portability"]) - # Construct CR string - cr_string = f"Cluster: {cluster}\nNamespace: {namespace}\nPod: {pod}\n" - cr_string += f"Freshness: {freshness}\nCompliance: {compliance}\nPortability: {portability}" + # Parse the YAML template + yaml_data = yaml.safe_load(yaml_template) + + # Update YAML with extracted and random values + properties_section = yaml_data["spec"]["versions"][0]["schema"]["openAPIV3Schema"]["properties"]["spec"]["properties"] + properties_section["pod_name"]["value"] = pod_name + properties_section["freshness"]["value"] = freshness + properties_section["compliance"]["value"] = compliance + properties_section["portability"]["value"] = portability + + # Convert back to YAML format + updated_yaml = yaml.dump(yaml_data, default_flow_style=False) - return cr_string, 200, {'Content-Type': 'text/plain'} + return updated_yaml, 200, {'Content-Type': 'text/plain'} if __name__ == '__main__': app.run(host='0.0.0.0', port=5000, debug=True) \ No newline at end of file diff --git a/mdm-controller/requirements.txt b/mdm-controller/requirements.txt index 571fb67faf4e0e5079780a240a64d301e95032db..e68a7bff184c7e5a4e3bf53f4134c37d06154d28 100644 --- a/mdm-controller/requirements.txt +++ b/mdm-controller/requirements.txt @@ -7,3 +7,4 @@ Jinja2==3.1.3 MarkupSafe==2.1.5 werkzeug==3.0.2 zipp==3.18.1 +PyYAML==6.0.2 diff --git a/mdm-tester/for-dockerhub.txt b/mdm-tester/for-dockerhub.txt index 18c5a5f1512c6fa1df45f404f196acdbfa6b6a37..73cf1854331f641cea03636335eea9169a508b4e 100644 --- a/mdm-tester/for-dockerhub.txt +++ b/mdm-tester/for-dockerhub.txt @@ -19,6 +19,6 @@ # The commands below must be executed from this directory docker build \ ---tag hecodeco/mdm-tester:v2.0.1 . +--tag hecodeco/mdm-tester:2.0.2 . -docker push hecodeco/mdm-tester:v2.0.1 \ No newline at end of file +docker push hecodeco/mdm-tester:2.0.2 \ No newline at end of file diff --git a/mdm-tester/mdm-tester-deployment.yaml b/mdm-tester/mdm-tester-deployment.yaml index 79081c461a2001ad68777d33b2b84705e663b447..0de491435f64285327f4181730bb839d19eddd41 100644 --- a/mdm-tester/mdm-tester-deployment.yaml +++ b/mdm-tester/mdm-tester-deployment.yaml @@ -35,7 +35,7 @@ spec: serviceAccountName: default containers: - name: mdm-tester - image: docker.io/hecodeco/mdm-tester:2.0.0 + image: docker.io/hecodeco/mdm-tester:2.0.2 env: - name: MDM_CONTROLLER_SERVICE_URL # value: "http://mdm-controller-service.he-codeco-mdm.svc.cluster.local:5000" diff --git a/mdm-tester/mdm-tester.py b/mdm-tester/mdm-tester.py index 8ba4774d8cae89a6feba870d5bd49ef8c6d5329a..c1358d008e9f034365cfa92473aefd2e77cad4d5 100644 --- a/mdm-tester/mdm-tester.py +++ b/mdm-tester/mdm-tester.py @@ -25,6 +25,6 @@ import os url = os.getenv('MDM_CONTROLLER_SERVICE_URL', "http://mdm-controller-service.he-codeco-mdm.svc.cluster.local:5000") while True: - response = requests.get(url+"/pdlc?cluster=test-cluster&namespace=my-namespace&pod=test-pod") + response = requests.get(url+"/mdm/api/v1/pdlc?cluster=test-cluster&namespace=my-namespace&pod=test-pod") print(response.text) time.sleep(1) \ No newline at end of file diff --git a/netma-controller/for-dockerhub.txt b/netma-controller/for-dockerhub.txt index d1c3748b5f04853bfba04a43aca925f770491597..3210b422d165f83c1d36c0e056913e4dc5e57945 100644 --- a/netma-controller/for-dockerhub.txt +++ b/netma-controller/for-dockerhub.txt @@ -26,4 +26,4 @@ docker push hecodeco/netma-controller:2.3.0-update docker buildx build \ --push \ --platform linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8 \ ---tag hecodeco/netma-controller:v2.0.0 . # Next one will be v2.1.0 \ No newline at end of file +--tag hecodeco/netma-controller:2.0.0 . # Next one will be 2.1.0 \ No newline at end of file