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
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
......@@ -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
......@@ -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
......
......@@ -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
......@@ -7,3 +7,4 @@ Jinja2==3.1.3
MarkupSafe==2.1.5
werkzeug==3.0.2
zipp==3.18.1
PyYAML==6.0.2
......@@ -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
......@@ -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"
......
......@@ -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
......@@ -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
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