Skip to content
Snippets Groups Projects
Commit 8035a343 authored by Panagiotis Karamolegkos's avatar Panagiotis Karamolegkos :v_tone2:
Browse files

Merge branch '11022025_MDM_FIX' into 'main'

11022025 mdm fix

See merge request !13
parents 4a009420 046c3ba8
No related branches found
No related tags found
1 merge request!1311022025 mdm fix
Pipeline #65131 passed
...@@ -26,4 +26,4 @@ docker push hecodeco/acm-controller:2.3.1-hotfix ...@@ -26,4 +26,4 @@ docker push hecodeco/acm-controller:2.3.1-hotfix
docker buildx build \ docker buildx build \
--push \ --push \
--platform linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8 \ --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 --tag hecodeco/acm-controller:2.0.0 . # Next one will be 2.1.0
\ No newline at end of file \ No newline at end of file
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
# The commands below must be executed from this directory # The commands below must be executed from this directory
docker build \ 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 # The commands below must be executed from this directory
docker buildx build \ docker buildx build \
--push \ --push \
--platform linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8 \ --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 --tag hecodeco/mdm-controller:2.0.0 . # Next one will be 2.1.0
\ No newline at end of file \ No newline at end of file
...@@ -35,7 +35,7 @@ spec: ...@@ -35,7 +35,7 @@ spec:
serviceAccountName: default serviceAccountName: default
containers: containers:
- name: mdm-controller - name: mdm-controller
image: docker.io/hecodeco/mdm-controller:2.0.0 image: docker.io/hecodeco/mdm-controller:2.0.2
imagePullPolicy: Always imagePullPolicy: Always
ports: ports:
- containerPort: 5000 - containerPort: 5000
......
...@@ -19,35 +19,84 @@ ...@@ -19,35 +19,84 @@
from flask import Flask, request from flask import Flask, request
import random import random
import yaml
app = Flask(__name__) app = Flask(__name__)
# Define the CRD properties # Define possible values for properties
properties = { properties = {
"pod_name": None, "freshness": ["0.1", "0.3", "0.4", "n/a"],
"freshness": ["healthy", "stale", "unknown"], "compliance": ["0.8", "0.9", "1.0", "n/a"],
"compliance": ["compliant", "non-compliant", "unknown"], "portability": ["0.5", "0.7", "1.0", "n/a"]
"portability": ["high", "medium", "low", "unknown"]
} }
# 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 # Define the endpoint
@app.route('/pdlc', methods=['GET']) @app.route('/mdm/api/v1/pdlc', methods=['GET'])
def pdlc(): def pdlc():
# Extract parameters from the request # Extract parameters from the request
cluster = request.args.get('cluster') cluster = request.args.get('cluster')
namespace = request.args.get('namespace') namespace = request.args.get('namespace')
pod = request.args.get('pod') pod_name = request.args.get('pod')
# Generate random values for CRD properties # Generate random values for CRD properties
freshness = random.choice(properties["freshness"]) freshness = random.choice(properties["freshness"])
compliance = random.choice(properties["compliance"]) compliance = random.choice(properties["compliance"])
portability = random.choice(properties["portability"]) portability = random.choice(properties["portability"])
# Construct CR string # Parse the YAML template
cr_string = f"Cluster: {cluster}\nNamespace: {namespace}\nPod: {pod}\n" yaml_data = yaml.safe_load(yaml_template)
cr_string += f"Freshness: {freshness}\nCompliance: {compliance}\nPortability: {portability}"
# 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__': if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True) app.run(host='0.0.0.0', port=5000, debug=True)
\ No newline at end of file
...@@ -7,3 +7,4 @@ Jinja2==3.1.3 ...@@ -7,3 +7,4 @@ Jinja2==3.1.3
MarkupSafe==2.1.5 MarkupSafe==2.1.5
werkzeug==3.0.2 werkzeug==3.0.2
zipp==3.18.1 zipp==3.18.1
PyYAML==6.0.2
...@@ -19,6 +19,6 @@ ...@@ -19,6 +19,6 @@
# The commands below must be executed from this directory # The commands below must be executed from this directory
docker build \ docker build \
--tag hecodeco/mdm-tester:v2.0.1 . --tag hecodeco/mdm-tester:2.0.2 .
docker push hecodeco/mdm-tester:v2.0.1 docker push hecodeco/mdm-tester:2.0.2
\ No newline at end of file \ No newline at end of file
...@@ -35,7 +35,7 @@ spec: ...@@ -35,7 +35,7 @@ spec:
serviceAccountName: default serviceAccountName: default
containers: containers:
- name: mdm-tester - name: mdm-tester
image: docker.io/hecodeco/mdm-tester:2.0.0 image: docker.io/hecodeco/mdm-tester:2.0.2
env: env:
- name: MDM_CONTROLLER_SERVICE_URL - name: MDM_CONTROLLER_SERVICE_URL
# value: "http://mdm-controller-service.he-codeco-mdm.svc.cluster.local:5000" # value: "http://mdm-controller-service.he-codeco-mdm.svc.cluster.local:5000"
......
...@@ -25,6 +25,6 @@ import os ...@@ -25,6 +25,6 @@ import os
url = os.getenv('MDM_CONTROLLER_SERVICE_URL', "http://mdm-controller-service.he-codeco-mdm.svc.cluster.local:5000") url = os.getenv('MDM_CONTROLLER_SERVICE_URL', "http://mdm-controller-service.he-codeco-mdm.svc.cluster.local:5000")
while True: 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) print(response.text)
time.sleep(1) time.sleep(1)
\ No newline at end of file
...@@ -26,4 +26,4 @@ docker push hecodeco/netma-controller:2.3.0-update ...@@ -26,4 +26,4 @@ docker push hecodeco/netma-controller:2.3.0-update
docker buildx build \ docker buildx build \
--push \ --push \
--platform linux/amd64,linux/arm/v5,linux/arm/v7,linux/arm64/v8 \ --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 --tag hecodeco/netma-controller:2.0.0 . # Next one will be 2.1.0
\ No newline at end of file \ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment